Skip to content

fix(arms): the Summary prints each arm's mean over the pairs its delta is over - #1594

Merged
antonwolfy merged 2 commits into
intel:mainfrom
antonwolfy:fix/arms-summary-paired-means
Dec 3, 2026
Merged

antonwolfy merged 2 commits into
intel:mainfrom
antonwolfy:fix/arms-summary-paired-means

Conversation

@antonwolfy

@antonwolfy antonwolfy commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#1584: the arms run Summary (the Summary (avg aggregate): lines of the console and the ## Summary (avg aggregate score, 0–100) table of --out-md) printed each arm's avg_aggregate, a mean over every question the arm scored, beside delta_vs_baseline, a mean over the questions both arms scored. When a question is scored in one arm only, the printed delta is not the difference of the two printed means. On main, with four questions, a fake model and one empty baseline reply (the issue's arms_summary.py), the table reads:

Arm Avg Δ vs baseline n
baseline 40.0 (baseline) 3
docs 87.5 +50.0 4

87.5 − 40.0 = 47.5, not 50.0, and report model-compare prints 90.0 for the same file. Option taken: the artifact keeps its means and gains the pair means, and both printers show the pair means beside the delta (the issue's other option, a line saying the means cover different questions, would leave the two commands printing different numbers for one run). Now the table has docs 90.0, delta +50.0, n 3, and the console prints docs 90.0 (delta +50.0).

Closes #1584

Changes

  • ArmRunner._summarize (eval/arm_runner.py, with paired_mean_fields in eval/arm_summary.py) writes paired_avg_aggregate and paired_n for a treatment arm that has a delta_vs_baseline: the arm's mean (one place, mean_in_range) and count over the pairs of stats.paired_vectors, the same ones the delta uses. A baseline, an arm with no pair and an arm whose delta is refused (delta_error) get neither field. avg_aggregate, n, errors, delta_vs_baseline and significance keep their values.
  • report/arms_pairs.py (new) holds the shared choice: shown_mean gives a treatment arm's paired_* when present and avg_aggregate/n otherwise (the baseline row always keeps its own), and pairs_note gives the one-line italic note printed under the summary when a treatment arm's paired_n differs from the baseline's n; it says a treatment arm with a delta shows the pair Avg and n, and the baseline row and an arm with no delta show every question each scored. cmd_arms_run (commands/arms.py) and render_arms_report (report/arms_report.py) each change two reads and add the note call. The console prints no n, so the console line shows the mean only.
  • schemas/arms.v1.json: the two optional per_arm properties, edited in place (a widening; older artifacts still validate).
  • docs/benchmarking-and-comparison.md and docs/methodology.md: one sentence each on which questions avg_aggregate/n and paired_avg_aggregate/paired_n cover.
  • New tests/test_arms_summary_paired_means.py; no existing test changed.
  • Changelog fragment (Fixed).

Risk

An arms run Summary whose arms scored different questions prints different numbers than before: treatment rows show the pair mean and pair count, and a note line appears when a treatment arm's pair count differs from the baseline row's n. A run in which every treatment arm has the same questions as the baseline prints exactly as before. An artifact written before this change has no paired_* fields and renders as before. Readers of avg_aggregate and n (subjects/evidence.py, plugin_delta, the matrix rollups, knowledge-runs) see no change.

Open PRs that touch the same printers: #1560 moves the console summary loop into _print_summary and #1568 moves the table into _section_summary, so whichever merges second has a textual conflict in the lines that read avg_aggregate/n (a two-line edit, the logic is in arms_pairs.py); #1573 wraps arm names in fmt.cell(...) in the same table rows, a conflict on the row line is possible.

Testing

On Linux, at cfe7641b (on main badfd39):

  • make ci-local: 38 passed, 0 failed, 16 skipped. 34482 tests passed, 28 skipped; changed-line coverage 100%.
  • The issue's script as a test (test_arms_run_prints_the_pair_means_in_the_console_and_the_report): on main's code the console prints docs 87.5 (delta +50.0) and the table | docs | 87.5 | +50.0 | 4 | 0 |; here 90.0 and n 3. On main's code 7 of the 9 new tests fail (the two that pass are the ones pinning output that does not change).
  • Mutants: each of 11 breaks (pair selection over all scored questions, the fallback always reading paired_*, two breaks of the note condition, the baseline row read as a treatment row, the wrong baseline key in the note, paired fields written without a delta, the console and the table printing the unpaired mean and n, and each printer dropping the note) fails the new tests. A twelfth, the note without its clause about an arm with no delta, fails test_the_note_says_an_arm_with_no_pair_shows_its_own_questions and test_the_note_names_the_rows_when_a_pair_count_differs_from_the_baseline_n; the first renders q1 baseline 40 and docs 90, q2 baseline 60, q3 other 80, where other prints Avg 80.0 and n 1 from its own question.
  • Not run: the other Python versions (3.11, 3.12, 3.14).

Open questions

None.

Revert

A plain revert restores the old summary (the unpaired mean beside the paired delta). Artifacts already written keep their paired_avg_aggregate and paired_n, which the older reader ignores; the schema (v1, edited in place) loses the two optional properties, so a stored artifact with them still validates because additionalProperties is not restricted.

Checklist

  • Tests added/updated and pytest passes
  • ruff, mypy, and schema checks pass
  • Docs updated (or N/A) — see the docs-drift checklist in CONTRIBUTING.md
  • Self-reviewed per "Before opening a PR" in AGENTS.md
  • Each new raise/exit and test names the doc, contract or issue it traces to
  • No ad-hoc run artifacts committed
  • New files carry the SPDX license header (or are exempt in .github/.licenserc.yaml)

…a is over (intel#1584)

The `arms run` Summary (console and `--out-md` table) printed each arm's `avg_aggregate`, a mean over every question the arm scored, beside `delta_vs_baseline`, a mean over the questions both arms scored. With one baseline reply empty the issue's run printed docs 87.5 and baseline 40.0 beside a delta of +50.0.

`_summarize` now also writes `paired_avg_aggregate` and `paired_n` for a treatment arm that has a delta, taken from `stats.paired_vectors` and `mean_in_range`, so they never exist without the delta they agree with. `avg_aggregate`, `n` and `errors` keep their meaning in the artifact. The new `report/arms_pairs.py` chooses the Avg and n a row shows (the pair values when present, else the old ones) and the one-line note printed when a treatment arm's pair count differs from the baseline row's n; both printers call it. The run of the issue now prints docs 90.0 over 3 pairs, baseline 40.0, delta +50.0, as `report model-compare` does. The schema gains the two optional fields and the two docs that describe the summary say what they cover.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@antonwolfy
antonwolfy requested a review from a team as a code owner December 3, 2026 12:19
Copilot AI balanced review requested due to automatic review settings December 3, 2026 12:19
@antonwolfy antonwolfy self-assigned this Dec 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The report note describes displayed means as based on baseline pairs, but treatments with no complete pairs or with delta_error can show fallback averages and counts from unpaired questions. This misstates the sample basis for those rows in both printers.

1 open issue
What changed in this PR

1 finding. This PR addresses #1584 by aligning Dokimi’s treatment-arm summary means with the paired questions used for their deltas.

Changes:

  • Adds optional paired means and counts while preserving existing artifact fields.
  • Updates console and Markdown summaries, retaining fallback behavior for older artifacts.
  • Adds regression tests, schema properties, documentation, and a changelog entry.
File Description
dokimi/​tests/​test_arms_summary_paired_means.py Tests paired summaries, fallbacks, and notes.
dokimi/​dokimi/​schemas/​arms.v1.json Defines optional paired fields.
dokimi/​dokimi/​report/​arms_report.py Displays paired means and counts.
dokimi/​dokimi/​report/​arms_pairs.py Shares display selection and explanatory notes.
dokimi/​dokimi/​eval/​arm_summary.py Computes paired mean fields.
dokimi/​dokimi/​eval/​arm_runner.py Adds paired fields to summaries.
dokimi/​dokimi/​commands/​arms.py Updates console summary output.
dokimi/​docs/​methodology.md Explains paired versus per-arm measures.
dokimi/​docs/​benchmarking-and-comparison.md Documents fields and fallback behavior.
dokimi/​changelog.d/​20261203_140000_arms-summary-paired-means.md Records the summary correction.

Review effort: Balanced

Comment thread dokimi/dokimi/report/arms_pairs.py Resolved
@exai-bot

exai-bot commented Dec 3, 2026 •

Copy link
Copy Markdown

✅ OpenCodeReview: Review complete: 0 finding(s) across 10 selected item(s).

CI at cfe7641: 21 passing, 4 skipped.

Review details
  • Commit reviewed: cfe7641 against merge base badfd39
  • Coverage: 10 files in 1 groups
  • Engine: OpenCodeReview v1.13.5-exai.4.8f73eada, us.openai.gpt-6.1-sol
  • Usage: 163k tokens (95k from cache), 30s
  • Tool calls: 15 (9 file_read, 3 code_search, 1 ci_status, 1 local_check_results, 1 pr_threads)
  • Paired means in arms summaries, reports, schema, and documentation: 10 files

@codecov-commenter

codecov-commenter commented Dec 3, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.50%. Comparing base (badfd39) to head (cfe7641).
⚠️ Report is 2 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1594      +/-   ##
==========================================
- Coverage   96.50%   96.50%   -0.01%     
==========================================
  Files         539      541       +2     
  Lines       72177    72265      +88     
  Branches    12445    12456      +11     
==========================================
+ Hits        69655    69738      +83     
- Misses       1545     1547       +2     
- Partials      977      980       +3     
Files with missing lines Coverage Δ
dokimi/dokimi/commands/arms.py 97.79% <100.00%> (+0.01%) ⬆️
dokimi/dokimi/eval/arm_runner.py 96.96% <100.00%> (+<0.01%) ⬆️
dokimi/dokimi/eval/arm_summary.py 100.00% <100.00%> (ø)
dokimi/dokimi/report/arms_pairs.py 100.00% <100.00%> (ø)
dokimi/dokimi/report/arms_report.py 100.00% <100.00%> (ø)

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Mutation of changed lines

⚠️ Tests miss 7 of 38 small breaks of the lines this PR changes

At cfe7641: 31 caught · 7 missed

Each row is a small deliberate break (a mutant) of a line this PR changes that every test reaching that line still passes. Add a test that fails on it or, if it cannot change behaviour, put # mutation-ok[<operator>]: <reason> at the end of the line or alone on the line above.

Where Operator Change no test notices Tests reaching the line
dokimi/dokimi/report/arms_pairs.py:23 drop-clause arm != baseline and stats.get("paired_avg_aggregate") is not None and stats.get( → (arm != baseline and stats.get('paired_avg_aggregate') is not None) 44
dokimi/dokimi/report/arms_pairs.py:30 bump-int 0 → 1 43
dokimi/dokimi/eval/arm_summary.py:403 drop-clause stats.get("delta_vs_baseline") is None or not arm_values → (stats.get("delta_vs_baseline") is None) 81
dokimi/dokimi/eval/arm_summary.py:405 bump-int 1 → 2 60
dokimi/dokimi/report/arms_pairs.py:23 drop-clause arm != baseline and stats.get("paired_avg_aggregate") is not None and stats.get( → (arm != baseline and stats.get('paired_n')) 44
dokimi/dokimi/report/arms_pairs.py:25 bump-int 0 → 1 44
dokimi/dokimi/report/arms_pairs.py:32 drop-clause arm != baseline and stats.get("paired_n") and stats["paired_n"] != base_n → (stats.get('paired_n') and stats['paired_n'] != base_n) 43

Not checked:

  • 1 changed line was not mutated

Warning only: a missed break does not fail the job. Updated on every push; the full report is in the ci run summary.

…ion it scored

Settles the Copilot review point on arms_pairs.py: the note said each treatment arm's Avg and n cover the questions it and the baseline both scored, but a treatment arm with no complete pair (no delta) prints its own mean and n.

The note now says a treatment arm with a delta shows the pair mean and count, and the baseline row and an arm with no delta show every question each scored. A test renders the reviewer's case (q1 baseline 40 and docs 90, q2 baseline 60, q3 other 80) and checks the `other` row and the note.

Signed-off-by: Anton Volkov <antonwolfy@gmail.com>

@napetrov napetrov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change class: CONTRACT (head cfe7641)

  • Contract: changed. schema dokimi/dokimi/schemas/arms.v1.json
  • Responsibility: none
  • Dependency: none
  • Review depth: check the changed surface: callers, docs, tests pin new behaviour
  • Coverage gaps: none

No merge-blocking findings.

Checked complete and partial pairs, legacy artifact fields and both summaries. Ran 88 focused tests with current main. Required CI passed.

@antonwolfy
antonwolfy merged commit 1ce19bb into intel:main Dec 3, 2026
30 of 31 checks passed
@antonwolfy
antonwolfy deleted the fix/arms-summary-paired-means branch December 3, 2026 16:05
@antonwolfy antonwolfy added the testing-strategy Part of #1595: checks for the bug classes behind our fix series, their sweeps and research label Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing-strategy Part of #1595: checks for the bug classes behind our fix series, their sweeps and research

Projects

None yet

Development

Successfully merging this pull request may close these issues.

arms run: the Summary prints each arm's mean over its own questions beside a delta over the pairs

5 participants