Repository navigation
Add an instance-weighted (micro) suite aggregation strategy - #385
Conversation
038c574 to
68186f1
Compare
08506b4 to
b14272a
Compare
b14272a to
6e67bbb
Compare
gregorybchris
left a comment
There was a problem hiding this comment.
This review was generated by an agent following
REVIEW_GUIDE.md. It is not from a human reviewer. Reply in the PR thread and a maintainer will follow up.
Looks good overall! The weighted math is right and well tested, and the rebase left the MMLU-Pro suites consistent with the task module. One thing should be fixed before merge: the new "instance counts are required" storage check breaks persistence for external evals, which never carried a count.
I found one blocking issue and four non-blocking ones. The blocking one is a persistence regression introduced by the last commit. The others are documentation drift from that same commit and two test gaps.
Blocking
-
src/olmo_eval/storage/base.py:181
The external runner builds each task with"num_instances": result.metadata.get("num_tasks")(src/olmo_eval/runners/external/runner.py:303). Only some external benchmarks setnum_tasks:terminal_benchanddeepscholaralways do,tau2andastaonly inside a success branch, andscicodenever does. For those resultsnum_instancesisNone, soconvert_runner_resultsnow raises.save_resultscatches that atsrc/olmo_eval/runners/io/storage.py:265, logs an error, andcontinues. The whole experiment is skipped from every storage backend and the run still exits normally. The external runner's failure path (runner.py:119) goes through the same_save_results, so a failed external eval's error record is dropped from storage too. That is the "error information dropped on persistence" case from section 3.4.I reproduced this by calling
convert_runner_resultson a result dict shaped exactly like the external runner's forscicodewithnum_instances=None: it raisesValueError: num_instances is required for task 'scicode'. Onorigin/mainthe same input converts and storesnum_instances=None.Please make the external runner always supply an integer count before this check lands.
len(result.predictions)when predictions exist, elsenum_tasks, else0would match what_write_metrics_jsonalready does withtask_data.get("num_instances") or 0atrunner.py:360. Please also add a regression test that runs an external-shaped result withoutnum_tasksthroughconvert_runner_results, and a direct test intests/storage/test_base.py:265(TestConvertRunnerResults) asserting that a missingnum_instancesraises.The silence here is a pre-existing framework fault, not this PR's:
save_resultsswallows converter errors and the run exits 0 with nothing stored. Could you file a follow-up issue asking whether a converter failure should fail the run, or at least be reported alongside the hard-failure gate?
Non-blocking
-
src/olmo_eval/evals/suites/registry.py:35
TheWEIGHTED_AVERAGEdocstring still says "Falls back to the unweighted average when any contributing task has no instance count." The last commit removed that fallback. Since this docstring is whathelp(AggregationStrategy)and the next contributor will read, please change it to say the aggregate is omitted (runner) orNone(viewer) when a count is missing, matchingREADME.md:185. -
src/olmo_eval/runners/processing/aggregation.py:363(and:159for a nested child)
When a weighted suite is omitted, the only trace is alogger.warning. The suite key is absent fromresults["suites"]inmetrics.json, and the summary table has no row, so a reader ofmetrics.jsoncannot tell "omitted for missing counts" from "suite not requested". Today this branch is unreachable from the async runner, which always sets an integer count (src/olmo_eval/runners/asynq/results.py:451), so I am not asking for a change now. Should the omitted suite get an entry with an"error"field and nometrics, the way failed tasks do, so the omission is visible in the persisted file? A follow-up issue would be fine. -
tests/test_runner.py:977
test_suite_aggregation_weighted_average_without_countscovers the flat case. The nested case (aWEIGHTED_AVERAGEchild underAVERAGE_OF_AVERAGESwhere one leaf lacks a count, so_compute_child_averagereturnsNoneand the parent averages the remaining children) is tested forcompute_scope_scoreattests/analysis/test_scope_scores.py:117but not for the runner. Please add the runner counterpart so the two implementations cannot drift. -
PR description
Several paragraphs describe behavior the last commit removed: "the aggregate falls back to the unweighted mean", "That fallback is decided once per scope", "scope_scores.weights_are_completeanswers that question", "the viewer's aggregate tooltip says so", and the Testing section listsweights_are_completeand "the per-scope fallback". The PR body is the record of what merged, so please bring it in line with the code before merge.
Nits
- Nit:
src/olmo_eval/cli/results/viewer_server.py:570relies on operator precedence:int(num_instances) or None if num_instances is not None else Noneparses as(int(x) or None) if x is not None else None. It is correct, but parentheses would save the next reader a trip to the grammar. - Nit:
_task_weightexists in bothrunners/processing/aggregation.py:66(returns0.0for missing) andanalysis/scope_scores.py:24(returnsNonefor missing). Same name, different contract. Consider naming one to reflect the difference.
What I verified
uv run ruff check src/ tests/clean.uv run ruff format --checkclean (535 files).uv run ty check src/ alembic/reports only the pre-existing unusedtype: ignoreinharness/sandbox/executor.py:788.uv run pytest tests/ --ignore=tests/integration: 2402 passed, 23 skipped. All match the PR description.- Rebase consistency: expanded all three MMLU-Pro suites (14 tasks each) and resolved every spec through
task_exists. None missing, no task name collides with a suite name. Primary metrics areLogprobMCAccuracyMetric(mmlu_pro),BPBMetricInstanceAvg(mmlu_pro:bpb), andAccuracyMetricoverMMLUProCoTExactMatchScorer(mmlu_pro:cot), so the "weighting an instance-averaged BPB reproduces the pooled BPB" claim holds. - Weighted math:
_weighted_meanuseszip(strict=True)over lists that are appended in lockstep, and_tasks_missing_instance_countsrejects<= 0before any division, so denominators are positive. Recomputed the PR body's table: 12,032 instances, macro 33.02, micro 30.77. - Task identity and persisted formats:
aggregationis aSuiteattribute, not aTaskConfigfield, so no task hash changes.convert_runner_resultsdoes not persist suites, so Postgres rows are unchanged.metrics.jsonsuites[*].aggregationcan now be"weighted_average"; the only consumer that switches on it (log_summary) was updated.PairwiseResult.model_task_instance_countsis built per request and not persisted.TaskResult.num_instancesstays nullable and unchanged, so no Alembic migration is needed. - Hash-variant collapse in
compute_scope_score:_group_model_task_scores_by_nameand_group_model_task_instance_counts_by_nameiterate the samecolumnslist, and the pairwise payload's two_group_by_task_namecalls iterate the sametask_entries, so scores and counts align by position.zip_longesttreats a length mismatch as a missing count. The "mean of variant counts" choice is documented in the docstring and tested. - Viewer query:
func.greatest/coalesceis Postgres-only, and the repo has no SQLite path. The pairwise path already recovers counts from predictions in_update_task_rows_num_instances, so the two surfaces agree. - Runner:
asynq/results.py:451always writes an integernum_instances, including for failed tasks, so the "omit the aggregate" branch is reachable only from hand-built or imported result dicts.
Before merge
Fix Blocking 1 (external runner supplies a count; regression tests for the converter) and update the registry.py docstring and the PR description. Please file the two follow-up issues named above (converter failures surfacing; omitted weighted suites leaving a trace in metrics.json). After that you may merge once CI is green.
oe-eval suite configs support "primary_metric": "micro", an instance-count weighted mean across a suite's tasks, and several benchmarks are reported that way. MMLU-Pro is the first port where it matters: its 14 category tasks range from 381 to 1,351 questions, so the unweighted suite average sits about two points above the micro average oe-eval publishes. AggregationStrategy.WEIGHTED_AVERAGE weights each leaf task by its instance count. Instance counts now travel alongside task scores from results storage into the viewer results table and the pairwise payload so the displayed aggregate matches what the runner writes. When any contributing task has no usable count the aggregate falls back to the unweighted mean rather than mixing weighted and unweighted terms. mmlu_pro, mmlu_pro:bpb and mmlu_pro:cot now use the new strategy. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The viewer and the pairwise payload decided the unweighted fallback once per model, so one comparison column could hold a micro average for a run with instance counts beside a macro average for a run without them. The decision is now made once per scope: if any compared run is missing a count, none of them are weighted, and the viewer's aggregate tooltip says so. scope_scores.weights_are_complete answers that question for a scope. A WEIGHTED_AVERAGE suite nested inside an AVERAGE_OF_AVERAGES parent was collapsed with an unweighted mean of its leaves in both the runner and the viewer, and the runner's summary table did not collapse its task rows at all. All three now recognize the strategy. mmlu_pro:cot ports oe-eval's mmlu_pro:0shot_cot::tulu3, which macro-averages; the micro CoT suites there are 5-shot and are not what we ported. Its description now names that divergence instead of claiming a parity that does not hold. mmlu_pro:bpb says why instance weighting is exact for an instance-averaged metric. Also documents WEIGHTED_AVERAGE in the README, and zips the unfiltered weight list in _weighted_mean so a length mismatch cannot silently pair values with the wrong weights. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The fallback let one suite name mean two different statistics depending on what happened to be stored, and nothing downstream could tell which one it was looking at. A weighted suite now reports its instance-weighted mean or no score at all: the runner omits the aggregate and logs the tasks that lacked a count, and compute_scope_score returns None. Counts are now guaranteed rather than hoped for. build_eval_result rejects a task result with no num_instances, the way it already rejects one with no task_hash, and the viewer's results-table query recovers a missing count from the saved predictions the way the pairwise query already does. This removes weights_are_complete and the per-scope use_instance_weights plumbing from both viewer surfaces. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The external runner now always stores an integer instance count, so the storage check that requires one no longer drops external results that lack `num_tasks`. The viewer's two task-grouping helpers are merged into one, and the WEIGHTED_AVERAGE docstring describes the current behavior when a count is missing. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
6e67bbb to
402b0ab
Compare
|
@mgmorgan23 could I please request your re-review when you get a chance? |
Closes #384.
What changed
AggregationStrategy.WEIGHTED_AVERAGEweights each of a suite's leaf tasks by its instance count, matching oe-eval's"primary_metric": "micro"—sum(metric * num_instances) / sum(num_instances), as computed inoe_eval/tasks/aggregate_tasks.py.mmlu_pro,mmlu_pro:bpbandmmlu_pro:cotnow use it. The 14 category tasks range from 381 to 1,351 questions, so per issue #384 the MC suite roll-up on OLMo-2-1124-7B moves from 33.02 to 30.77, against a model card figure of 31.0.Instance counts had to reach every place a suite score is computed:
compute_suite_aggregationsreadsnum_instancesfrom the task results it already receives.compute_scope_scoretakes a newtask_instance_counts_by_nameargument, keyed and ordered to matchtask_scores_by_nameso task-hash variants collapse the same way.TaskResult.num_instancesand publishes atask_instance_countsmap per model.PairwiseResultcarriesmodel_task_instance_countsalongsidemodel_task_scores.A weighted suite reports its weighted mean or no score at all. When any contributing task lacks a positive instance count, the runner omits the suite aggregate and logs which tasks were missing, and the viewer and pairwise payload return
Nonefor that model's scope score. Publishing an unweighted mean under a weighted suite's name would put a different statistic behind the same label.To keep that case rare,
convert_runner_resultsnow requiresnum_instanceson every task it stores. The external runner always supplies an integer count for this: the number of predictions when there are any, else the benchmark'snum_tasks, else 0.TaskResult.num_instancesstays nullable, so results stored before this change can still lack a count.A
WEIGHTED_AVERAGEsuite nested inside anAVERAGE_OF_AVERAGESparent is collapsed with its own weighting, in the runner (_compute_child_average), in the viewer (_child_scope_score), and in the runner's summary table, whose collapse check previously testedaggregation == "average"by string. No registered suite nests a weighted child today; this keeps the next one from being silently wrong.The CLI already prints
suite.aggregation.valuein botholmo-eval suitesandolmo-eval suite inspect, so the new strategy shows up there without further changes.README.mddocuments it.Parity notes
mmlu_pro(5-shot MC) matches oe-eval'smmlu_pro:mc::none, which is micro. Unambiguous.mmlu_pro:bpbhas no oe-eval counterpart suite. Instance weighting is exactly right here anyway: the task's metric isBPBMetricInstanceAvg, so weighting each category's BPB by its instance count reproduces the bits per byte of the pooled question set.mmlu_pro:cotports the prompt of oe-eval'smmlu_pro:0shot_cot::tulu3, which macro-averages (its sampling and answer extraction follow the MMLU and GPQA CoT ports, per Add MMLU-Pro tasks (5-shot MC, 5-shot cloze, 0-shot CoT) #383's review). oe-eval's two micro CoT suites (mmlu_pro:cot::none,mmlu_pro:cot::llama3.1) are 5-shot and are not what we ported. Per Suite aggregation: add an instance-weighted (micro) average strategy #384 this suite is still weighted, so that all three MMLU-Pro suites here roll up the same way as the benchmark's own pooled reporting, but its description now names the divergence rather than claiming a parity that does not hold.Audit of other ported suites
I enumerated oe-eval's
TASK_SUITE_CONFIGSprogrammatically. Nineteen suites are micro:bbh:*(nine variants),bfcl_live_ast_micro::std,bfcl_live_micro::std,deepmind_math::tulu,deepmind_math::olmo3:heldout,minerva_math::llama3.1,mmlu::olmo1, and the fourmmlu_pro:mc/cotsuites.MMLU-Pro is the only one that needs this strategy. We have no bbh or deepmind_math suites. Our
mmlufollowsmmlu:*::olmes(macro), notmmlu::olmo1. Ourminerva_mathfollowsminerva_math::olmes(macro), not::llama3.1. BFCL (#387, merged since this PR opened) reproducesbfcl_live_ast_micro::stdandbfcl_live_micro::stdwith the pooled tasksbfcl_live_astandbfcl_live, which give the same number, so its suites stay as they are.I had earlier flagged
multipl_e_humaneval:olmo3base:v2as a possible micro counterpart. That was wrong: oe-eval'smultipl_e_humaneval:6lang::olmo3:n32:v2has noprimary_metrickey at all, andTASK_GROUPS_RAWonly admits suites that have one, so oe-eval computes no aggregate for it. Nothing to reconcile.Testing
uv run pytest tests/ --ignore=tests/integration— 2528 passed, 30 skipped after rebasing onto currentmain. Lint, format, andty checkare clean apart from one pre-existing diagnostic inharness/sandbox/executor.py.New coverage: weighted runner aggregation and the omitted aggregate when a count is missing, both flat and as a nested child under
AVERAGE_OF_AVERAGES; the summary-table collapse;compute_scope_scoreweighting, including hash-variant collapsing and every missing-count path; the viewer results table exposing instance counts; the viewer and pairwise scope scores;convert_runner_resultsrejecting a task with no count; and the external runner storing results that carry nonum_tasks.Validation on a real run
Launched
olmo-2-7b(allenai/OLMo-2-1124-7B) on themmlu_prosuite at commitb14272a: beaker.org/ex/01M2RG6VM9N6PA4D3JGY0J9XEN. All 14 tasks succeeded, 12,032 instances scored, exit code 0.Computed from those per-task rows:
The runner's published suite aggregate was 0.3077 (
mmlu_pro | Success | primary_score:average | 0.3077), so it published the weighted mean, not the unweighted one. Both figures reproduce #384 exactly: 33.02 unweighted, 30.77 micro, against a model card figure of 31.0. The 2.26-point gap is the whole point of the change, and it falls out of the spread in task sizes — 381 questions for history against 1,351 for math, with the large tasks scoring well below average.This run covers the runner's weighted aggregation end to end. It does not cover the storage-boundary check or the viewer/pairwise read paths: it ran with
--no-storebecause the launching machine had no AWS credentials, and--storefetches the Postgres password from AWS Secrets Manager inside the job. Those paths are covered by unit tests only.🤖 Generated with Claude Code