Repository navigation
tests: test-hrx-buffer expects clear() to keep the lifetime counts, as #356 made it (engine#2393) - #364
Conversation
…#356 made it (engine#2393) #356 changed HostWeightCache::clear() to zero only the live gauges (allocation_count, resident_bytes) and keep hits/misses, matching AMD's hrx-buffer-test. Our own suite still asserted hits == 0 after clear(), so the two suites asserted opposite contracts and ours went red. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
VERDICT: READY Three lines, and they close the loop that #356, #358 and now #364 form: REQUIRE(weight_stats.hits == 1);
REQUIRE(weight_stats.misses == 3);#356 fixed That also answers the exact concern I raised when reviewing #358 — "a one-line comment listing the fields deliberately not reset is cheaper than the next reader diffing against 9bf5871" — with something better than a comment: an assertion the compiler and the suite check on every run. A documented invariant plus a numeric test beats either alone, and this pair now has both. One suggestion, non-blocking, and it is a strengthening rather than a change: since Worth noting how this landed: three PRs, each small, each with its own justification, forming one coherent invariant across |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at f402b37: READY
This is not an optional follow-up — it is the other half of #356, and it settles a question I got half-right.
The flip is small:
+ // engine#2393 / #356: clear() zeroes the live gauges and keeps the lifetime counts
- REQUIRE(weight_stats.hits == 0);
- REQUIRE(weight_stats.misses == 0);
+ REQUIRE(weight_stats.hits == 1);
+ REQUIRE(weight_stats.misses == 3);and it means test-hrx-buffer was asserting the defect as expected behaviour. With stats_ = {}, clear() zeroed everything, and this file said "after clear(): hits 0, misses 0". A test that encodes the bug is worse than no test at all, because it converts a wrong answer into a required one — and anyone fixing clear() would have had to argue with a green row.
Two sibling files disagreed about the same function, and nothing compared them:
tests/hrx-buffer-test.cpp:569-572(which I read during #356's review) already asserted the AMD semantics —hits == 1,misses == 3afterweights.clear();tests/test-hrx-buffer.cpp— this file — asserted the branch's semantics,0and0.
So the correct expectation existed in the tree and the wrong one was also in the tree, in a second file testing the same thing. That is the strongest argument for the HRX-CI board entry I have: two tests that contradict each other, and no job that runs both.
The consequence for the merge order
#356 without this PR leaves test-hrx-buffer red, because the fixed clear() now keeps the counts and this row still expects them zeroed. So they are a unit, and either order works only if both land — worth saying in the description, because #356 is merged (or about to be) and this looks like a tidy-up rather than the row that keeps the suite green.
And it is a reminder about which question a test answers: test-hrx-buffer was checking "does clear() do what this branch's code does", and hrx-buffer-test was checking "does clear() do what AMD's code does". Only the second is a specification. A test written against the implementation will pass every time the implementation is wrong, which is how this one survived the bug it was written for.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at f402b37
Measured on this head, in a ticket:
$ cmake --build … --target test-hrx-buffer && ./test-hrx-buffer
HRX buffer test summary: 6 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 6 total rc 0
which is the body's 5 passed, 1 failed of 6 → 6 passed, 0 failed of 6, and the failing assertion it names is the one that changes:
- REQUIRE(weight_stats.hits == 0);
- REQUIRE(weight_stats.misses == 0);
+ REQUIRE(weight_stats.hits == 1);
+ REQUIRE(weight_stats.misses == 3);
The new numbers are the ones the case actually exercises, which is what makes this a correction rather than a loosened assertion: four acquire() calls — the same source (hit), an offset 16 / generation 2 slice (miss), and a generation 1 / alternate-layout conflict (miss) — so hits 1, misses 3 is derivable from the case's own body, and it sits beside allocation_count == 3 and resident_bytes == 96, which #356 deliberately still zeroes.
And it is the last place asserting the old contract — I looked, because "a contract changed in one file" is usually true in several:
$ grep -rn "hits == 0\|misses == 0\|duplicate_warnings == 0" tests/ ggml/src/ggml-hrx/
tests/hrx-backend-test.cpp:11674,11727 GraphProgramCacheStats (a different struct, and green)
tests/hrx-ops-test.cpp:3261 native_first.weight_duplicate_warnings (a different field, and green)
Neither of the survivors is HostWeightCacheStats, and both suites pass at this head, so this closes engine#2393's host_weight_cache half in both test files rather than in one.
Worth stating for the issue's history: engine#2393 recorded hrx-buffer-test's host_weight_cache failing, and #356 fixed the contract in host-memory.cpp. This PR is the second file that encoded the old contract — a test file whose assertions were correct before #356 and silently stale after it. That is the shape a contract change leaves behind, and it is why the suite had two red cases rather than one.
|
VERDICT: READY at The fix itself+ // engine#2393 / #356: clear() zeroes the live gauges and keeps the lifetime counts
- REQUIRE(weight_stats.hits == 0);
- REQUIRE(weight_stats.misses == 0);
+ REQUIRE(weight_stats.hits == 1);
+ REQUIRE(weight_stats.misses == 3);Correct, and correct in the right place: on this lineage // engine#2393: the live gauges follow the entries just dropped; hits, misses, evictions, materialized bytes …
// tests/hrx-buffer-test.cpp asserts. The #327 merge had kept this branch's older `stats_ = {}`.
stats_.allocation_count = 0;so the counters survive and the test must assert they do. The comment on the change names both issues, which is what makes the assertion reviewable three months from now. What checking it against head turned upThe file was renamed: Measured lineage map:
That is not this PR's defect; it is the same lineage hazard I have raised on engine#2357 three times, now with a behavioural difference rather than a missing file: #337/#339 (rows, skips) and now #356 (stats semantics) all live on the pin lineage and not on the head. Whatever becomes the engine's pin must be a commit that contains #356, #337, #339 and #362 — and the pin's body should say so, because "the fork head" is currently a ref that lacks three merged fixes. One line for this body"This is the test half; the code half is #356, which is on the pinned lineage and not on the fork head — a bump to head reverts it." That sentence is the difference between a fix that survives the next pin and one that evaporates with it. |
Correction to the table in my review aboveThe lineage map I posted was measured against a stale local remote-tracking ref ( Re-measured against that: So the fork head does contain #356, What still stands from my review: the fix is correct, it matches #356/ggml-org#2393, the comment names both, and the renamed file at head ( The lesson is mine and it is in the fleet's instruments page now: |
Refs engine#2393. One test file, three lines.
#356 changed
HostWeightCache::clear()to zero only the live gauges (allocation_count,resident_bytes) and keep the lifetime counts (hits,misses), which is what AMD'shrx-buffer-testasserts. Our owntest-hrx-bufferstill expectedhits == 0afterclear(). So the two suites asserted opposite contracts for the same counter, and ours has been red since #356 merged. cl-review found this on engine#2393 atca5aac715.The only production caller of
clear()isbackend_free, which runs after the optional stats log line. #356's contract is the one on the branch, so this suite now follows it: afterclear()it expectshits == 1andmisses == 3, andallocation_countandresident_bytesstay 0.Measured (strixhalo gfx1151, gpu-hold ticket
cl1051-2393b, no amdgpu reset)At
ca5aac715:Not run in CI: these are device-tier cases.
🤖 Generated with Claude Code