Repository navigation
fix(repo): first_useful_rate leaves out a cell whose steps is past the measure bound (#922) - #1018
Conversation
…e measure bound (intel#922) first_useful_rate counted a cell whose first_useful.steps is no measure (past the 1e150 bound, NaN, inf) as a non-hit, in the rate and in its n, so steps 5 and 1e200 gave 0.5 with n 2. Every other measure leaves such a value out as absent, and the compare header counted the same cell as measured. A new helper, _rated, keeps the cells with a verdict less those whose steps is set but is no measure; a cell with steps None (never) stays a miss. useful_task_values, useful_task_counts and useful_counts all read it, so the rate, its n and the header's observed-of-measured count agree: steps 5 and 1e200 now give 1.0 with n 1, and the header shows the cell as unmeasured. The contract's "The measure bound" and the compare module docstring say so. The old expectation of test_first_useful_rate_keeps_a_cell_with_steps_past_the_bound_as_a_non_hit (rate 0.5, n 2) and the rate and count lines of test_a_stored_non_finite_or_huge_number_is_no_measure (rate 0.0, measured 1) are reversed because intel#922 asks for it. Test-narrowed: test_first_useful_rate_keeps_a_cell_with_steps_past_the_bound_as_a_non_hit is renamed test_first_useful_rate_leaves_out_a_cell_with_steps_past_the_bound and its assertion reversed to the behaviour intel#922 asks for; no check is dropped. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 3 selected item(s). CI at Review details
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1018 +/- ##
========================================
Coverage 95.89% 95.90%
========================================
Files 448 448
Lines 59289 59390 +101
Branches 10224 10238 +14
========================================
+ Hits 56857 56957 +100
+ Misses 1511 1509 -2
- Partials 921 924 +3
🚀 New features to boost your workflow:
|
Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
vchamarthi
left a comment
There was a problem hiding this comment.
🟡 Not approved yet · reviewed 2fe7e2e
Next: @antonwolfy: settle 1 open question (below).
Blocking
- Open question for @antonwolfy:
repo report's row counts a cell whosestepsis past the bound innbut not inobserved: steps 5 and steps 1e200 give1 of 2 observedwith no reason on the head, while the compare header now shows that cell as unmeasured. State in therepo reportparagraph ofdokimi/docs/repo-evaluation-contract.mdwhether a past-bound cell is counted inn, or leave it out ofninuseful_summaryas the compare side now does.
Verified on 2fe7e2e: ✅ changed tests: 162 passed, fail on main · ✅ full suite with main merged in: 23936 passed · ✅ merges onto main · ✅ 2 broken variants of the changed code: 2 caught by the tests · 2 mutations tried · 6 edge inputs tried
12 checks behind it, each with its evidence
| Area | What holds | How |
|---|---|---|
| Changed tests | The 162 tests in the two changed test files pass on the head, including the new past-bound, never, at-bound and header-count cases | tests on the head |
| Tests pin the change | Seven changed tests fail on main: the past-bound rate tests for 1e200, NaN and inf, the never-beside-past-bound case, the header count, and the rewritten lone-cell test | same tests on main |
make ci-local |
make ci-local passes on the head merged with main: 23936 passed, 0 failed, no new failures |
full suite, main merged in |
| Merge | The PR merges onto main with no conflict | merge onto main |
| Rate past the bound | Steps 5 and steps 1e200 give first_useful_rate [1.0] with n 1, and the header counts the cell as unmeasured |
ran it, edge input (numbers) |
| Never beside past bound | Steps 5, steps 1e200 and a never cell give a rate of 0.5 with n 2: the never cell stays a miss |
ran it, edge input (numbers) |
| Steps at the bound | Steps 1e150 (SCORE_BOUND) is still a hit: steps 5 and steps 1e150 give a rate of 1.0 with n 2 |
ran it, edge input (numbers) |
| Steps that are no measure | NaN, inf, -inf, the float maximum, 10400 and True as steps are left out of the rate and n |
ran it, edge input (numbers) |
| No records | An empty record list gives a rate of [None], a count of 0, and no header line |
ran it, edge input (numbers) |
| Steps zero and negative | Steps 0 and -1 count as hits in the rate, since as_measure takes any finite number within the bound; first_useful() never stores them (enumerate(known, 1), useful.py:72) |
ran it, edge input (numbers) |
| Rate tests | Removing the steps is None clause from _rated (useful.py:112) fails the changed tests |
broke the code, tests caught it |
| Header count | Counting unmeasured from _measured in useful_counts (useful.py:205) fails the changed tests |
broke the code, tests caught it |
…s is past the bound (intel#922) Settles the review question on `repo report`: a cell whose `first_useful.steps` is past the measure bound stays in the row's total (`n`) and is not counted as observed, with no reason, so steps 5 and steps 1e200 give `1 of 2 observed`. The `repo report` paragraph of the repo evaluation contract now says so; `repo compare` leaves such a cell out of the rate, as documented beside it. Signed-off-by: Anton Volkov <antonwolfy@gmail.com>
@vchamarthi (#1018 (review)): A past-bound cell is counted in |
|
Ready for another look at codecov has not reported on this head yet. |
…or never Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
Signed-off-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
🟢 LGTM · checked a682950 · nothing required from @antonwolfy
🔀 Merge: safe now · merges cleanly into current main, 12 commits behind, and main has not touched its files · no open PR conflicts with it
✅ make ci-local --offline: 23,914 passed · schema_compat fails from the base (removed v1 schemas on main), not from this PR · ✅ 7 of the changed tests fail on the base · ✅ the new steps-None test fails with the fix reverted
A broken steps is now neither a hit nor a miss in first_useful_rate, its n and the header, and the docs match.
Fixed in this branch, up to a682950:
Summary
repo compare'sfirst_useful_ratecounted a cell whosefirst_useful.stepsis no measure (past the 1e150 bound, NaN, inf) as a non-hit, in the rate and in itsn. Every other measure leaves a past-bound value out of the mean and ofn, as a value that is absent.kindedit,reasonnull unless noted)first_useful_rateonmainsteps5, 1e200[0.5],n2[1.0],n1steps5, 1e200, and anevercell (stepsnull)[0.333...],n3[0.5],n2The compare header's "first useful observed: arm X of Y (Z unmeasured)" counted the same cell as measured:
useful_countsgave{'observed': 1, 'measured': 2, 'unmeasured': 0}for steps 5 and 1e200, so the header said "1 of 2" while the rate was 0.5 of 2. It now gives{'observed': 1, 'measured': 1, 'unmeasured': 1}.Of the issue's three options (count it as a non-hit, drop it, count it as a hit) this takes dropping: the contract's "The measure bound" already leaves every other past-bound value out as absent. Counting it as a hit is not taken:
first_useful()stores anenumerateint, so astepsof 1e200 is a corrupt record, and the repo's rule for a corrupt measure is "no measurement", not a trusted verdict. A cell whosestepsis null (never) is still a miss.Closes #922
Changes
dokimi/dokimi/repos/useful.py: a new_ratedkeeps the cells with a verdict less those whosestepsis set but is no measure.useful_task_values,useful_task_countsanduseful_countsread it, so the rate, itsnand the header's observed-of-measured count agree. Their docstrings, and_rated's, say such a cell is neither a hit nor a miss.first_useful(),useful_summary(repo report's row) and the medians are unchanged: the row's total counts every declared cell, so a past-bound cell is in the total and not observed (steps 5 and steps 1e200 give1 of 2 observed), and the contract'srepo reportparagraph now says so.dokimi/docs/repo-evaluation-contract.md("The measure bound" and the twofirst_useful_rateparagraphs) and thedokimi/dokimi/repos/compare.pymodule docstring say a cell whosestepsis past the bound is left out of the rate and itsn, and shows as unmeasured in the header.tests/test_repo_compare_overflow.py:test_first_useful_rate_keeps_a_cell_with_steps_past_the_bound_as_a_non_hitis renamedtest_first_useful_rate_leaves_out_a_cell_with_steps_past_the_bound, its expectation reversed (rate[1.0],n1) and parametrized over 1e200, NaN and inf. New tests: anevercell beside a past-bound one stays a miss (rate[0.5],n2);stepsof 1e150 (SCORE_BOUND) is still a hit;useful_countsshows the cell as unmeasured.tests/test_repo_useful.py::test_a_stored_non_finite_or_huge_number_is_no_measurepinned a lone past-bound cell as rate 0.0 andmeasured1; it now expects rateNone,n0,measured0 andunmeasured1.Risk
repo compareoutput changes for a batch whoseresult.jsonholds afirst_useful.stepspast 1e150, NaN or inf, which the writer does not produce: the task'sfirst_useful_raterises (or is absent when that was its only cell) and itsndrops, and the header counts the cell as unmeasured. No other input changes: cells withstepsnull,unobservedortimeoutare handled as before.Open PRs on the same files: #779 changes
useful.pytoo, but onlyfirst_useful(), the module docstring and the import block, none of which this PR touches, so the two merge apart. #779, #781, #787, #898, #952, #953, #956, #958, #977 and #1003 editrepo-evaluation-contract.mdin other sections than "The measure bound" and thefirst_useful_rateparagraph near §4.1, and #781'scompare.pychange is not in its module docstring'sfirst_useful_rateitem.Testing
On a Linux review host, at
5da94f70(onmain52160e9c):make ci-local: 0 failed, 36 passed, 14 skipped (skipped: jobs for other platforms, matrix legs, docker, and tools not on the PATH). The pytest step had 23964 passed, 19 skipped.main's code the new and rewritten tests oftests/test_repo_compare_overflow.pyfail (5 failed, 40 passed), e.g.assert [0.5] == [1.0]for steps 5 and 1e200._ratedreturning_measured(have)fails the past-bound rate tests, thenevertest and theuseful_countstest (5 failed);_rateddropping thesteps is Nonepart fails thenevertest;_ratedwith a< 1e150bound fails the at-the-bound test;useful_countsreading_measuredfails theuseful_countstest andtest_a_stored_non_finite_or_huge_number_is_no_measure.Open questions
None.
Revert
A plain revert restores counting a past-bound
stepscell as a non-hit. Nothing is stored.Checklist
pytestpassesruff,mypy, and schema checks passAGENTS.mdraise/exit and test names the doc, contract or issue it traces to.github/.licenserc.yaml)