-
Notifications
You must be signed in to change notification settings - Fork 93
feat(accuracy): AIME 2025 lighteval-backed benchmark (AIP-876) #926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
FrankD412
merged 1 commit into
main
from
dbermudez/aip-876-implement-aime25-benchmark-loader
May 29, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,84 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """AIME 2025 benchmark loader, aligned with the trt-llm lighteval reference. | ||
|
|
||
| Mirrors ``acc_bench_lighteval.py:aime25``: same ``aime_prompt_fn``, | ||
| same zero-shot config, ``generation_size=32768``, | ||
| ``hf_repo="yentinglin/aime_2025"``. See the AIME24 module for a fuller | ||
| explanation of the design. | ||
|
|
||
| Reference: | ||
| trt-llm-benchmark-recipe/src/accuracy/acc_bench_lighteval.py:142 | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING | ||
| import asyncio | ||
| from typing import TYPE_CHECKING, Any | ||
|
|
||
| from aiperf.accuracy.models import BenchmarkProblem | ||
| from datasets import Dataset, load_dataset | ||
|
|
||
| from aiperf.accuracy.models import AccuracyChatMessage, BenchmarkProblem | ||
| from aiperf.common.mixins import AIPerfLoggerMixin | ||
|
|
||
| if TYPE_CHECKING: | ||
| from aiperf.config.resolution.plan import BenchmarkRun | ||
|
|
||
| DATASET_NAME = "yentinglin/aime_2025" | ||
| TASK_NAME = "aime25" | ||
|
|
||
| # lighteval's aime25 task config: ``generation_size=32768``. | ||
| DEFAULT_GENERATION_SIZE = 32768 | ||
|
|
||
| # Schema field names in yentinglin/aime_2025 (same lowercase shape as | ||
| # AIME24's HuggingFaceH4 mirror). | ||
| PROBLEM_FIELD = "problem" | ||
| ANSWER_FIELD = "answer" | ||
|
|
||
|
|
||
| class AIME25Benchmark(AIPerfLoggerMixin): | ||
| """Registered placeholder for a future AIME 2025 loader. | ||
| """AIME 2025 lighteval-aligned benchmark loader. | ||
|
|
||
| `load_problems()` intentionally raises NotImplementedError in this release; | ||
| use the MMLU benchmark when a working accuracy loader is required. | ||
| Loads ``yentinglin/aime_2025`` (train split) and emits one user | ||
| message per problem containing the bare problem text — matching | ||
| lighteval's zero-shot ``aime_prompt_fn`` rendering. Pair with | ||
| ``LightevalExprGrader`` for grading parity with the recipe. | ||
| """ | ||
|
|
||
| def __init__(self, run: BenchmarkRun, **kwargs) -> None: | ||
| def __init__(self, run: BenchmarkRun, **kwargs: Any) -> None: | ||
| super().__init__(**kwargs) | ||
| self.run = run | ||
|
|
||
| async def load_problems( | ||
| self, tasks: list[str] | None, n_shots: int, enable_cot: bool | ||
| ) -> list[BenchmarkProblem]: | ||
| raise NotImplementedError( | ||
| "aime25 benchmark is not yet implemented; only 'mmlu' is available in this release." | ||
| ) | ||
| """Load AIME25 problems and format them lighteval-style. | ||
|
|
||
| Args: | ||
| tasks: Ignored — AIME25 has no subtasks. | ||
| n_shots: Ignored — the lighteval reference is zero-shot. | ||
| enable_cot: Ignored — lighteval's ``aime_prompt_fn`` does | ||
| not add a CoT trigger. | ||
|
|
||
| Returns: | ||
| One ``BenchmarkProblem`` per dataset row, in dataset order. | ||
| """ | ||
| ds: Dataset = await asyncio.to_thread(load_dataset, DATASET_NAME, split="train") | ||
| return await asyncio.to_thread(self._build_problems, ds) | ||
|
|
||
| def _build_problems(self, ds: Dataset) -> list[BenchmarkProblem]: | ||
| problems: list[BenchmarkProblem] = [] | ||
| for row in ds: | ||
| problem = row[PROBLEM_FIELD] | ||
| messages: list[AccuracyChatMessage] = [{"role": "user", "content": problem}] | ||
| problems.append( | ||
| BenchmarkProblem( | ||
| prompt=problem, | ||
| ground_truth=str(row[ANSWER_FIELD]), | ||
| task=TASK_NAME, | ||
| metadata={"generation_size": DEFAULT_GENERATION_SIZE}, | ||
| raw_messages=messages, | ||
| ) | ||
| ) | ||
| return problems |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,207 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| """Unit tests for ``AIME25Benchmark`` after lighteval alignment. | ||
|
|
||
| Same shape as ``test_aime24_benchmark.py`` — the lighteval reference | ||
| config is identical except for the dataset URL. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| import pytest | ||
|
|
||
| from aiperf.accuracy.benchmarks.aime25 import ( | ||
| DEFAULT_GENERATION_SIZE, | ||
| TASK_NAME, | ||
| AIME25Benchmark, | ||
| ) | ||
| from aiperf.accuracy.models import BenchmarkProblem | ||
| from aiperf.plugin.enums import AccuracyBenchmarkType, EndpointType | ||
| from tests.unit.conftest import make_benchmark_run | ||
|
|
||
|
|
||
| def _make_run(): | ||
| return make_benchmark_run( | ||
| model_names=["test-model"], | ||
| endpoint_type=EndpointType.COMPLETIONS, | ||
| streaming=False, | ||
| accuracy={"benchmark": AccuracyBenchmarkType.AIME25}, | ||
| ) | ||
|
|
||
|
|
||
| def _make_row(problem: str = "What is 1+1?", answer: int = 2) -> dict[str, Any]: | ||
| return {"problem": problem, "answer": answer} | ||
|
|
||
|
|
||
| def _make_fake_dataset(rows: list[dict[str, Any]]) -> MagicMock: | ||
| ds = MagicMock() | ||
| ds.__iter__ = MagicMock(side_effect=lambda: iter(rows)) | ||
| ds.__len__ = MagicMock(return_value=len(rows)) | ||
| ds.__getitem__ = MagicMock(side_effect=lambda i: rows[i]) | ||
| return ds | ||
|
|
||
|
|
||
| class TestPromptIsBareProblemText: | ||
| @pytest.mark.asyncio | ||
| async def test_flat_prompt_is_problem_text(self) -> None: | ||
| rows = [_make_row("Compute the answer.", 42)] | ||
| with patch( | ||
| "aiperf.accuracy.benchmarks.aime25.load_dataset", | ||
| return_value=_make_fake_dataset(rows), | ||
| ): | ||
| bench = AIME25Benchmark(run=_make_run()) | ||
| problems = await bench.load_problems( | ||
| tasks=None, n_shots=0, enable_cot=False | ||
| ) | ||
| assert problems[0].prompt == "Compute the answer." | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_no_instruction_prefix(self) -> None: | ||
| rows = [_make_row("Q?", 1)] | ||
| with patch( | ||
| "aiperf.accuracy.benchmarks.aime25.load_dataset", | ||
| return_value=_make_fake_dataset(rows), | ||
| ): | ||
| bench = AIME25Benchmark(run=_make_run()) | ||
| problems = await bench.load_problems( | ||
| tasks=None, n_shots=0, enable_cot=False | ||
| ) | ||
| prompt = problems[0].prompt | ||
| assert "**Problem**" not in prompt | ||
| assert "competition math" not in prompt | ||
| assert "Let's think" not in prompt | ||
| assert "boxed" not in prompt | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_chat_message_is_single_user_message(self) -> None: | ||
| rows = [_make_row("Q?", 1)] | ||
| with patch( | ||
| "aiperf.accuracy.benchmarks.aime25.load_dataset", | ||
| return_value=_make_fake_dataset(rows), | ||
| ): | ||
| bench = AIME25Benchmark(run=_make_run()) | ||
| problems = await bench.load_problems( | ||
| tasks=None, n_shots=0, enable_cot=False | ||
| ) | ||
| msgs = problems[0].raw_messages | ||
| assert msgs is not None | ||
| assert len(msgs) == 1 | ||
| assert msgs[0]["role"] == "user" | ||
| assert msgs[0]["content"] == "Q?" | ||
|
|
||
|
|
||
| class TestNShotsAndCoTAreIgnored: | ||
| @pytest.mark.asyncio | ||
| async def test_n_shots_argument_does_not_affect_prompt(self) -> None: | ||
| rows = [_make_row(f"q{i}", i) for i in range(3)] | ||
| with patch( | ||
| "aiperf.accuracy.benchmarks.aime25.load_dataset", | ||
| return_value=_make_fake_dataset(rows), | ||
| ): | ||
| bench = AIME25Benchmark(run=_make_run()) | ||
| zero_shot = await bench.load_problems( | ||
| tasks=None, n_shots=0, enable_cot=False | ||
| ) | ||
| five_shot = await bench.load_problems( | ||
| tasks=None, n_shots=5, enable_cot=False | ||
| ) | ||
| assert [p.prompt for p in zero_shot] == [p.prompt for p in five_shot] | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_enable_cot_does_not_affect_prompt(self) -> None: | ||
| rows = [_make_row("Q?", 1)] | ||
| with patch( | ||
| "aiperf.accuracy.benchmarks.aime25.load_dataset", | ||
| return_value=_make_fake_dataset(rows), | ||
| ): | ||
| bench = AIME25Benchmark(run=_make_run()) | ||
| no_cot = await bench.load_problems(tasks=None, n_shots=0, enable_cot=False) | ||
| with_cot = await bench.load_problems(tasks=None, n_shots=0, enable_cot=True) | ||
| assert no_cot[0].prompt == with_cot[0].prompt | ||
|
|
||
|
|
||
| class TestLoadProblemsCore: | ||
| @pytest.mark.asyncio | ||
| async def test_returns_one_problem_per_row(self) -> None: | ||
| rows = [_make_row(f"q{i}", i) for i in range(5)] | ||
| with patch( | ||
| "aiperf.accuracy.benchmarks.aime25.load_dataset", | ||
| return_value=_make_fake_dataset(rows), | ||
| ): | ||
| bench = AIME25Benchmark(run=_make_run()) | ||
| problems = await bench.load_problems( | ||
| tasks=None, n_shots=0, enable_cot=False | ||
| ) | ||
| assert len(problems) == 5 | ||
| assert all(isinstance(p, BenchmarkProblem) for p in problems) | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_ground_truth_is_string_form_of_answer(self) -> None: | ||
| rows = [_make_row("q", 42)] | ||
| with patch( | ||
| "aiperf.accuracy.benchmarks.aime25.load_dataset", | ||
| return_value=_make_fake_dataset(rows), | ||
| ): | ||
| bench = AIME25Benchmark(run=_make_run()) | ||
| problems = await bench.load_problems( | ||
| tasks=None, n_shots=0, enable_cot=False | ||
| ) | ||
| assert problems[0].ground_truth == "42" | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_task_name_is_aime25(self) -> None: | ||
| rows = [_make_row("q", 1)] | ||
| with patch( | ||
| "aiperf.accuracy.benchmarks.aime25.load_dataset", | ||
| return_value=_make_fake_dataset(rows), | ||
| ): | ||
| bench = AIME25Benchmark(run=_make_run()) | ||
| problems = await bench.load_problems( | ||
| tasks=None, n_shots=0, enable_cot=False | ||
| ) | ||
| assert problems[0].task == TASK_NAME | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_generation_size_is_32k(self) -> None: | ||
| rows = [_make_row("q", 1)] | ||
| with patch( | ||
| "aiperf.accuracy.benchmarks.aime25.load_dataset", | ||
| return_value=_make_fake_dataset(rows), | ||
| ): | ||
| bench = AIME25Benchmark(run=_make_run()) | ||
| problems = await bench.load_problems( | ||
| tasks=None, n_shots=0, enable_cot=False | ||
| ) | ||
| assert problems[0].metadata["generation_size"] == DEFAULT_GENERATION_SIZE | ||
| assert DEFAULT_GENERATION_SIZE == 32768 | ||
|
|
||
|
|
||
| class TestPathologicalDatasetRows: | ||
| @pytest.mark.asyncio | ||
| async def test_empty_dataset_returns_empty_list(self) -> None: | ||
| with patch( | ||
| "aiperf.accuracy.benchmarks.aime25.load_dataset", | ||
| return_value=_make_fake_dataset([]), | ||
| ): | ||
| bench = AIME25Benchmark(run=_make_run()) | ||
| problems = await bench.load_problems( | ||
| tasks=None, n_shots=0, enable_cot=False | ||
| ) | ||
| assert problems == [] | ||
|
|
||
| @pytest.mark.asyncio | ||
| async def test_unicode_problem_text_preserved(self) -> None: | ||
| rows = [_make_row("Solve ∑₁ⁿ k² for n=10. ✓", 385)] | ||
| with patch( | ||
| "aiperf.accuracy.benchmarks.aime25.load_dataset", | ||
| return_value=_make_fake_dataset(rows), | ||
| ): | ||
| bench = AIME25Benchmark(run=_make_run()) | ||
| problems = await bench.load_problems( | ||
| tasks=None, n_shots=0, enable_cot=False | ||
| ) | ||
| assert "∑₁ⁿ" in problems[0].prompt |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.