Skip to content

[Setup] Fix white space - #5

Merged
jiarong0907 merged 8 commits into
mainfrom
setup/fix-whitespace
Oct 30, 2025
Merged

[Setup] Fix white space#5
jiarong0907 merged 8 commits into
mainfrom
setup/fix-whitespace

Conversation

@jiarong0907

Copy link
Copy Markdown
Contributor

No description provided.

@gemini-code-assist

Copy link
Copy Markdown

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@jiarong0907

jiarong0907 commented Oct 27, 2025

Copy link
Copy Markdown
Contributor Author

@yl231 Could you help fix these errors?

This can be reproduced by running the following commands on branch setup/fix-whitespace.

pip install mypy==1.11.1 types-cachetools types-setuptools types-PyYAML types-requests pydantic
tools/mypy.sh 1 3.10

The import errors can be ignored locally. After fixing the problem, pushing to the same branch and check whether it passes the actions.

(.venv) jiarong@ds05:~/RouterArena$ pip install mypy==1.11.1 types-cachetools types-setuptools types-PyYAML types-requests pydantic^C
(.venv) jiarong@ds05:~/RouterArena$ tools/mypy.sh 1 3.10
Running mypy on llm_evaluation
llm_evaluation/enhanced_extractor.py:82: error: Incompatible default for argument "dataset" (default has type "None", argument has type "str")  [assignment]
llm_evaluation/enhanced_extractor.py:82: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
llm_evaluation/enhanced_extractor.py:82: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
llm_evaluation/enhanced_extractor.py:224: error: Incompatible default for argument "dataset" (default has type "None", argument has type "str")  [assignment]
llm_evaluation/enhanced_extractor.py:224: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
llm_evaluation/enhanced_extractor.py:224: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
llm_evaluation/enhanced_extractor.py:433: error: Incompatible default for argument "dataset" (default has type "None", argument has type "str")  [assignment]
llm_evaluation/enhanced_extractor.py:433: note: PEP 484 prohibits implicit Optional. Accordingly, mypy has changed its default to no_implicit_optional=True
llm_evaluation/enhanced_extractor.py:433: note: Use https://github.com/hauntsaninja/no_implicit_optional to automatically upgrade your codebase
llm_evaluation/metric_utils.py:5: error: Library stubs not installed for "regex"  [import-untyped]
llm_evaluation/metric_utils.py:5: note: Hint: "python3 -m pip install types-regex"
llm_evaluation/metric_utils.py:8: error: Cannot find implementation or library stub for module named "latex2sympy2"  [import-not-found]
llm_evaluation/metric_utils.py:9: error: Cannot find implementation or library stub for module named "sympy"  [import-not-found]
llm_evaluation/metric_utils.py:10: error: Cannot find implementation or library stub for module named "sympy.parsing.latex"  [import-not-found]
llm_evaluation/metric_utils.py:11: error: Cannot find implementation or library stub for module named "sympy.parsing.sympy_parser"  [import-not-found]
llm_evaluation/metric_utils.py:20: error: Incompatible types in assignment (expression has type "list[Any]", variable has type "str")  [assignment]
llm_evaluation/metric_utils.py:22: error: Incompatible types in assignment (expression has type "list[str]", variable has type "str")  [assignment]
llm_evaluation/utils.py:5: error: Library stubs not installed for "pandas"  [import-untyped]
llm_evaluation/utils.py:6: error: Cannot find implementation or library stub for module named "datasets"  [import-not-found]
llm_evaluation/livecodebench_util.py:482: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | int | None], Never]")  [assignment]
llm_evaluation/livecodebench_util.py:483: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | int | None], Never]")  [assignment]
llm_evaluation/livecodebench_util.py:489: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[int, int], None]")  [assignment]
llm_evaluation/livecodebench_util.py:490: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | bytes | PathLike[str] | PathLike[bytes]], int]")  [assignment]
llm_evaluation/livecodebench_util.py:491: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | bytes | PathLike[str] | PathLike[bytes], str | bytes | PathLike[str] | PathLike[bytes]], None]")  [assignment]
llm_evaluation/livecodebench_util.py:492: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | bytes | PathLike[str] | PathLike[bytes], DefaultNamedArg(int | None, 'dir_fd')], None]")  [assignment]
llm_evaluation/livecodebench_util.py:493: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | bytes | PathLike[str] | PathLike[bytes]], None]")  [assignment]
llm_evaluation/livecodebench_util.py:494: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | bytes | PathLike[str] | PathLike[bytes], DefaultNamedArg(int | None, 'dir_fd')], None]")  [assignment]
llm_evaluation/livecodebench_util.py:495: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[int | HasFileno], None]")  [assignment]
llm_evaluation/livecodebench_util.py:496: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[int], None]")  [assignment]
llm_evaluation/livecodebench_util.py:497: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[], int]")  [assignment]
llm_evaluation/livecodebench_util.py:498: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[], tuple[int, int]]")  [assignment]
llm_evaluation/livecodebench_util.py:499: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[int, int], None]")  [assignment]
llm_evaluation/livecodebench_util.py:500: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | bytes | PathLike[str] | PathLike[bytes], str | bytes | PathLike[str] | PathLike[bytes], DefaultNamedArg(int | None, 'src_dir_fd'), DefaultNamedArg(int | None, 'dst_dir_fd')], None]")  [assignment]
llm_evaluation/livecodebench_util.py:501: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | bytes | PathLike[str] | PathLike[bytes], str | bytes | PathLike[str] | PathLike[bytes]], None]")  [assignment]
llm_evaluation/livecodebench_util.py:502: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[int | str | bytes | PathLike[str] | PathLike[bytes], int], None]")  [assignment]
llm_evaluation/livecodebench_util.py:503: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | bytes | PathLike[str] | PathLike[bytes], str | bytes | PathLike[str] | PathLike[bytes], DefaultNamedArg(int | None, 'src_dir_fd'), DefaultNamedArg(int | None, 'dst_dir_fd')], None]")  [assignment]
llm_evaluation/livecodebench_util.py:504: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | bytes | PathLike[str] | PathLike[bytes], DefaultNamedArg(int | None, 'dir_fd')], None]")  [assignment]
llm_evaluation/livecodebench_util.py:505: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[int, int], None]")  [assignment]
llm_evaluation/livecodebench_util.py:506: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[int, int, int], None]")  [assignment]
llm_evaluation/livecodebench_util.py:507: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[int | str | bytes | PathLike[str] | PathLike[bytes], int, DefaultNamedArg(int | None, 'dir_fd'), DefaultNamedArg(bool, 'follow_symlinks')], None]")  [assignment]
llm_evaluation/livecodebench_util.py:508: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[int | str | bytes | PathLike[str] | PathLike[bytes], int, int, DefaultNamedArg(int | None, 'dir_fd'), DefaultNamedArg(bool, 'follow_symlinks')], None]")  [assignment]
llm_evaluation/livecodebench_util.py:509: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | bytes | PathLike[str] | PathLike[bytes]], None]")  [assignment]
llm_evaluation/livecodebench_util.py:510: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[int | HasFileno], None]")  [assignment]
llm_evaluation/livecodebench_util.py:511: error: Module has no attribute "lchflags"  [attr-defined]
llm_evaluation/livecodebench_util.py:512: error: Module has no attribute "lchmod"; maybe "chmod" or "fchmod"?  [attr-defined]
llm_evaluation/livecodebench_util.py:513: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | bytes | PathLike[str] | PathLike[bytes], int, int], None]")  [assignment]
llm_evaluation/livecodebench_util.py:514: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[], str]")  [assignment]
llm_evaluation/livecodebench_util.py:515: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[int | str | bytes | PathLike[str] | PathLike[bytes]], None]")  [assignment]
llm_evaluation/livecodebench_util.py:519: error: Incompatible types in assignment (expression has type "None", variable has type "_RmtreeType")  [assignment]
llm_evaluation/livecodebench_util.py:520: error: Incompatible types in assignment (expression has type "None", variable has type "Callable[[str | PathLike[str], str | PathLike[str], Callable[[str, str], object] | Callable[[str | PathLike[str], str | PathLike[str]], object]], Any]")  [assignment]
llm_evaluation/livecodebench_util.py:521: error: Incompatible types in assignment (expression has type "None", variable has type overloaded function)  [assignment]
llm_evaluation/livecodebench_util.py:531: error: Incompatible types in assignment (expression has type "None", target has type Module)  [assignment]
llm_evaluation/livecodebench_util.py:532: error: Incompatible types in assignment (expression has type "None", target has type Module)  [assignment]
llm_evaluation/livecodebench_util.py:533: error: Incompatible types in assignment (expression has type "None", target has type Module)  [assignment]
llm_evaluation/livecodebench_util.py:534: error: Incompatible types in assignment (expression has type "None", target has type Module)  [assignment]
llm_evaluation/livecodebench_util.py:535: error: Incompatible types in assignment (expression has type "None", target has type Module)  [assignment]
llm_evaluation/metrics.py:9: error: Cannot find implementation or library stub for module named "jieba"  [import-not-found]
llm_evaluation/metrics.py:10: error: Cannot find implementation or library stub for module named "fuzzywuzzy"  [import-not-found]
llm_evaluation/metrics.py:14: error: Cannot find implementation or library stub for module named "rouge"  [import-not-found]
llm_evaluation/metrics.py:15: error: Library stubs not installed for "regex"  [import-untyped]
llm_evaluation/eval_reasoning.py:17: error: Cannot find implementation or library stub for module named "datasets"  [import-not-found]
llm_evaluation/eval_reasoning.py:17: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
llm_evaluation/evaluate_models.py:21: error: Library stubs not installed for "tqdm"  [import-untyped]
llm_evaluation/evaluate_models.py:21: note: Hint: "python3 -m pip install types-tqdm"
llm_evaluation/evaluate_models.py:21: note: (or run "mypy --install-types" to install all missing stub packages)
llm_evaluation/evaluate_models.py:37: error: Incompatible types in assignment (expression has type "None", variable has type "ModelNameManager")  [assignment]
llm_evaluation/evaluate_models.py:83: error: Need type annotation for "dataset_configs" (hint: "dataset_configs: dict[<type>, <type>] = ...")  [var-annotated]
llm_evaluation/evaluate_models.py:84: error: Need type annotation for "existing_results" (hint: "existing_results: dict[<type>, <type>] = ...")  [var-annotated]
llm_evaluation/evaluate_models.py:85: error: Need type annotation for "cost_config" (hint: "cost_config: dict[<type>, <type>] = ...")  [var-annotated]
llm_evaluation/evaluate_models.py:98: error: Cannot find implementation or library stub for module named "datasets"  [import-not-found]
llm_evaluation/evaluate_models.py:99: error: Library stubs not installed for "pandas"  [import-untyped]
llm_evaluation/evaluate_models.py:99: note: Hint: "python3 -m pip install pandas-stubs"
llm_evaluation/evaluate_models.py:241: error: Need type annotation for "dataset_groups" (hint: "dataset_groups: dict[<type>, <type>] = ...")  [var-annotated]
llm_evaluation/evaluate_models.py:442: error: "None" has no attribute "__iter__" (not iterable)  [attr-defined]
llm_evaluation/evaluate_models.py:499: error: Need type annotation for "dataset_results" (hint: "dataset_results: dict[<type>, <type>] = ...")  [var-annotated]
Found 64 errors in 7 files (checked 8 source files)

@jiarong0907

Copy link
Copy Markdown
Contributor Author

@yl231 Any updates on the errors?

@jiarong0907
jiarong0907 requested a review from yl231 October 30, 2025 07:50
@jiarong0907
jiarong0907 merged commit aa09708 into main Oct 30, 2025
10 checks passed
@jiarong0907
jiarong0907 deleted the setup/fix-whitespace branch October 30, 2025 18:10
yl231 added a commit that referenced this pull request Jun 12, 2026
* Fix cost accounting for reasoning tokens and zero-usage generations (#135)

Issue #135 reported two distinct cost-accounting gaps in the evaluator:

1. Reasoning tokens were never billed. calculate_inference_cost charged
   only input+output tokens, ignoring reasoning/"thinking" tokens, which
   providers bill at the completion rate but report only via the gap
   total_tokens - (input + output). They are now billed at the model's
   output rate (or an explicit reasoning_token_price_per_million when
   configured). Affected routers: Azure (8.6M tokens), Nadir (6.4M),
   vLLM-SR (2.0M).

2. Successful generations with no usable token usage were free. Rows with
   success=True and a non-empty answer but empty token_usage ({}) or
   output_tokens=0 passed the success-only validity gate from #118 and
   were scored as correct at $0 cost. The validity gate now also requires
   output_tokens > 0; such rows are treated as failed inference (scored as
   wrong, excluded from cost) consistently across the RouterArena score
   and the optimality pool. This extends the #118 empty-response fix
   rather than duplicating it.

Also adds:
- check_config_prediction_files.py: submission-time validation rejecting
  successful non-empty generations without usable output_tokens, so future
  submissions are caught up front.
- tools/audit_token_accounting.py: audit script reporting per-router
  reasoning-token magnitude and failed-inference counts to forward to the
  router authors.
- scripts/rescore_affected.sh: reproducible driver to re-score affected
  routers through the patched pipeline.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Leaderboard: re-score reasoning-token routers under the #135 fix

Re-evaluated, at current model_cost.json prices, the routers whose models
emit reasoning tokens or zero-usage rows. Routers with neither are
unchanged.

- vLLM-SR: arena 75.38->72.15, acc 75.97->73.19, cost $0.11->$0.23/1k
  (reasoning tokens now billed; 279 zero-usage rows now scored as wrong)
- Nadir:   arena 73.33->72.29, acc 74.87->75.01, cost $0.29->$0.68/1k
- Azure:   arena 71.87->70.42, acc 72.82->72.94, cost $0.22->$0.73/1k

New top of leaderboard: Sqwish #1, AgentForge #2, Weave #3, Nadir #4,
vLLM-SR #5.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* Apply pre-commit fixes (ruff-format, codespell)

- ruff-format reflows the reasoning-cost expression and audit-script lines
  to match the repo's pinned formatter (ruff 0.11.7).
- Rename token shorthands it/ot/tt -> n_in/n_out/n_total in the audit
  script so codespell no longer flags "ot" as a misspelling.

No behavior change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Louie Lu <yl231@datalab2.cs.rice.edu>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
xufan866 pushed a commit to xufan866/RouterArena that referenced this pull request Aug 5, 2026
…s#172)

xAI retired `grok-4-1-fast-reasoning` on 2026-05-15 and silently redirects it
to grok-4.3 (low reasoning), which is stronger and ~5-6x pricier. Submissions
that selected the retired slug via xAI/OpenRouter were served grok-4.3 but
billed at the retired slug's $0.20/$0.50 price, inflating their cost-aware
Arena scores. Reported and audited by @loswald (thanks!).

Fix (prices the model that actually answered, not the requested alias):
- model_cost.json: add `grok-4.3` and `x-ai/grok-4.3` at $1.25/$2.50.
- evaluate_models.py: add `has_price()`; factor the cost lookup into
  `_lookup_cost_info()`.
- run.py: bill by `generated_result.model_used` when it is present and priced,
  else the router's selected model. Redirected slugs are now billed correctly.
- check_config_prediction_files.py: preflight warning for retired/redirected
  slugs (guardrail RouteWorks#1 from the issue).

Precision (only provably-redirected rows change; Azure-hosted Grok 4.1 is left
alone):
- cross-router  217 rows (openrouter, model_used=x-ai/grok-4.3) -> repriced
- vllm-sr       257 rows (openrouter, model_used=x-ai/grok-4.3) -> repriced
- nadir-tumbler 3571 rows (xAI, model_used absent): backfilled
  model_used=x-ai/grok-4.3 (retired slug + 2026-07-04 generation date) so the
  same mechanism reprices it. Team to be notified.
- azure-model-router (4803) and nadir-cascade-v2 (3101): provider=azure, NOT
  subject to the xAI redirect -> unchanged.

Leaderboard (accuracy held fixed, affected calls billed at grok-4.3):
- Cross-Router   76.12 -> 75.75  ($0.30 -> $0.40/1K)  stays RouteWorks#1
- vLLM-SR        75.30 -> 74.86  ($0.30 -> $0.42/1K)  RouteWorks#2 -> RouteWorks#3
- Nadir-Tumbler  75.17 -> 73.44  ($0.08 -> $0.37/1K)  RouteWorks#4 -> RouteWorks#5

Co-authored-by: Louie Lu <yl231@datalab2.cs.rice.edu>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants