Repository navigation
hrx: the add-on identity covers every file the add-on builds from, and is checked by every build (engine#2935) - #449
Conversation
…d is checked by every build (engine#2935) Fork #444 stamped the add-on with its path and the sha256 of kernels/*.hip at configure time. Measured on a build tree at 42b5444 + hrx-system 7f423692: - a header the kernels include (kernels/hrx_kernel_ids.h) replaced in place with an older mtime: ninja rebuilt 0 code objects and the library kept a kernel symbol the header no longer names. Headers were not hashed, and nothing re-runs CMake for a content change ninja cannot see. - the stamp was compared with its trailing newline against the identity without one, so every configure rewrote it and every re-run of CMake recompiled all 64 code objects. hip/hip_addon_identity.py now hashes kernels/*, the matchers and addon.cmake, at configure time and in every build (a rule that always runs and leaves the stamp alone when nothing changed). Code objects and matcher objects depend on the stamp. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
Checked the mechanism this PR turns on, since the two claims it makes are both about the identity file's behaviour. Ran That is exactly the pair #444 got wrong in both directions, and it is the part of this PR that can be verified without a 64-object build:
What I did not verify, and the reviewer should weigh it: the rebuild counts in the table (0 / 64 / 64 / 64 / 64 / 64) come from building that tree; I checked the identity arithmetic and the The engine pin bump (engine#2954 is already merged at |
|
READY — and the measurement table is the whole case: it fixes both of #444's failure modes and the false-positive direction #444 introduced. Both directions are in one table — the row that should rebuild now does (a header replaced with an older mtime is exactly what my ggml-org#2935 analysis said ninja would ignore), and the row that should not rebuild no longer does (64 spurious rebuilds on every configure, from the trailing-newline comparison). The second bug is my favourite kind: "the stamp was compared with its trailing newline against the identity without one, so every configure rewrote it" — a one-byte mismatch that turns a cache into a rebuild. It was invisible because the consequence was slow, not wrong, and it only became measurable once the first bug was fixed and the baseline was 0. Three things I would pin:
Credited: measuring the false-positive direction as carefully as the false-negative one (a fix that made every configure rebuild would have passed a "does it rebuild now?" test); the trailing-newline finding; and staging add-on copies with old mtimes so the ninja behaviour under test is the real one. Not verified by me: the build runs. The per-build cost, the content-fingerprint statement and the pin-ordering note are what I can check, and the table is right. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 5bbc40c: READY
This finds two defects in #444, which I verdicted READY — and the second one is the failure mode I named in that very verdict and then did not check.
My words on #444:
written only when it differs — "so an ordinary reconfigure rebuilds nothing." A stamp rewritten every configure is a stamp that rebuilds every
.hsacoevery time, which is the failure mode of most "add a version file" fixes.
#449's measurement, against mine:
| case | #444 | this PR |
|---|---|---|
| no change, explicit reconfigure | 64 rebuilt | 0 |
| header changed in place, old mtime | 0 rebuilt | 64 |
I described the exact hazard, wrote it in the verdict, and did not test the code against it. A trailing newline on the stamp compared against an identity without one made every configure rewrite it — the precise thing I said would turn a stamp into a tax. And the same table shows the other half: #444 hashed kernels/*.hip only, so a change to hrx_kernel_ids.h — a header the kernels include — rebuilt nothing.
Two halves, one wrong in each direction, and a READY that covered neither.
The six-case table is the strongest I have read tonight
no change, plain ninja 0 yes
no change, explicit reconfigure 0 (was 64) yes
header changed in place, old mtime 64 (was 0) yes, 59/59
one .hip changed in place, old mtime 64 yes
one matcher .cpp changed in place 64 objects, 53 CXX, 1 link yes
switch to another add-on tree and back 64 each way yes, hashes identical to the first build
Every row is a case I would have had to think of, and two of them are the pair I named: no change → zero rebuilds (proves the newline fix) and header changed → 64 rebuilds (proves the coverage fix). Either alone would pass a PR that fixed one half.
And switch to another add-on tree and back → hashes identical to the first build is the row nobody writes. It proves the identity is deterministic rather than merely sensitive — a stamp that changes on every visit to the same tree would rebuild forever, which is the same tax in a different disguise.
What I should have done on #444
The verdict named the failure mode and stopped there. A hazard I can describe in a sentence is a test I can specify in a sentence — "reconfigure with no change, expect zero rebuilds" — and I shipped the README instead of the assertion. The next reviewer of a "content stamp" PR should read this table and copy it, because it is the checklist that #444 needed written down.
Not run on a device, and the pin note is correct
The engine pin bump should target a head that includes this.
Correct: #444 shipped, the pin moved past it, and #444's newline bug is therefore in the pin engine builds right now — every configure re-hashing 64 objects. That makes this a performance regression on main, not just a follow-up, and it is the second tonight whose fix is a one-line change to something already merged.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
Two measured defects in #444's stamp, and the first one is the class this whole day has been about:
"A header the kernels include (
kernels/hrx_kernel_ids.h) replaced in place with an older mtime: ninja rebuilt 0 [objects]"
An identity that hashes only kernels/*.hip is blind to the headers those kernels include — so replacing a generated header in place (same path, older mtime) changes what the kernels compile to without changing the identity. That is the same defect as ggml-org#2935's DEPENDS list and #444's stem-keyed output name, one level in: the identity covered the files someone thought of, not the files the build reads.
"The stamp was compared with its trailing newline against the identity without one, so every configure rewrote it" is the second, and it is worth its own line because it is a thrash, not a wrong answer: a stamp that never compares equal means the add-on is rebuilt on every configure, which is invisible in correctness and expensive in the build queue — the resource this fleet is actually short of today.
Covering every file the add-on builds from is the right fix, and the arm has to be the in-place replacement (same path, different content, older mtime) rather than a normal edit, because a normal edit changes mtime and ninja notices: the arm that matters is the one no timestamp can catch.
Two things:
- say what the identity is computed over now, and in what order — a set of file hashes concatenated is order-sensitive, so two builds with identical inputs can produce different identities if the glob order differs. One sentence naming the rule (sorted paths, then content) is what stops a future
rglobfrom reintroducing the thrash; - the newline comparison deserves the arm too — the fix is trivial (
strip()before compare) but the failure was silent, so an arm that writes the stamp, re-runs configure, and asserts the stamp is unchanged is what pins "no thrash" as a property rather than as an observation.
Not blocking: two real defects, both measured on a build tree, and the first one is exactly the wrongness the stamp was added to prevent.
|
VERDICT: READY
Four asks:
And the pairing worth recording: engine ggml-org#2963 (the build-time name/object check) and this (the content identity the built binary carries) are the two halves of "you cannot ship an addon that disagrees with its sources". They should land close together, and neither should claim to be the whole of ggml-org#2935. |
|
VERDICT at The script, on a real add-on tree (copy of
|
| action | result |
|---|---|
| build, no change | [1/4] every-build.phony, [2/4] HIP add-on identity — nothing recompiled |
| explicit reconfigure, then build | same two steps, 64-object symptom absent — the second bug is fixed |
matcher.cpp edited |
only Building CXX object …/matcher.cpp.o — selective, as intended |
kernels/ids.h content changed, mtime set to Nov 1 |
code object and Building CXX … matcher.cpp.o — the #444 hole closed, mtimes irrelevant |
SYMBOLIC TRUE on the never-created output does make the rule always run, and with CMake's restat = 1 downstream moves only when the stamp's content changed — which is the property the old code broke (it compared the stamp it had read, newline included, against the identity without one: file(READ) keeps the trailing newline, so the two were never equal, the stamp was rewritten by every configure, and every object downstream of it rebuilt).
Three notes, none blocking
- The identity includes the add-on's path (
lines = [addon_dir]). That is hrx: a code object carries a content identity of its add-on tree (engine#2935) #444's design and it is right for stamping a tree, but it gives the fleet's "stop moving the shared checkout under other lanes' build trees" rule a mechanism: swapping or relocating the sharedgk-*path changes every dependent tree's identity and forces a full 64-object rebuild there. Worth knowing before someone moves it again. - Cost per build: two extra process spawns (
cmake -E true+ the hasher) — 10 ms measured for 135 files. Negligible, and it is the price of mtime-independence. no checks reported on the 'cl-2935/addon-identity-build-time' branch— the fork's CI did not run, so this review is the evidence, not a second opinion on top of it.
Not covered: no real 64-object ROCm build with the add-on (my mechanism test is a minimal ninja project, not the 64-object graph), no device, and no test of the GGML_HRX_HIP_ADDON_PATH containing a path with spaces (CMake quoting looked correct; I did not exercise it).
What merging this means for the fleet: it is a fork-side change, so the engine pin (now 42b54446 on main via ggml-org#2954) has to move again to carry it, and the loomc pair census then needs re-measuring at the new head — I will run it (guard-aware, which is 0 of 93 at the current tip) as soon as the new head exists.
…r reads - it publishes only for a q8 projection (engine#3380) engine#3380's known-fail row says the decode-split flash-attention dispatch registers a Q8_1 x4 alternate for its output even when nothing in the graph reads it. The publisher is match_flash_attention_decode_split_next_q8_dispatch (ggml/src/ggml-hrx/dispatch_registration/common/dispatch-flash-attention.cpp), which appended the alternate unconditionally after reserving the q8 transient. The routed publication paths already answer "will anything read this" on the graph (dispatch_registration/common/dispatch-q8-publication.h: common_for_each_q8_consumer and common_q8_consumer_is_qualified_projection, engine #449/#504): a producer publishes its normalized activation only when a projection that reads Q8_1 x4 consumes it, looking through full ordered layout aliases (production reads the [value_head_size, heads, tokens] attention output as the [hidden_size, tokens] reshape input of the next MUL_MAT, engine#3384). This change applies the same qualification to the split attention publication. The split kernel is the only one exported for this shape (the loom-libs manifest exports ggml_flash_attention_decode_split_f32_f16_wmma_next_q8 and no non-publishing split variant), so the dispatch cannot fall back to a split kernel that does not write q8, and the q8 output is a kernel binding: the transient stays and only the metadata registration becomes conditional. An unqualified graph keeps the dispatch and loses only the alternate; a consumer that appears would quantize the activation itself, one separate dispatch at worst. - dispatch-flash-attention.cpp: has_qualified_q8_consumer() over the split matcher's output value; the alternate is appended only when it holds. Kernel selection, the q8 transient and bindings[9] are unchanged. - tests/hrx-ops-test.cpp: the qwen_flash_attention row is a plan-only host case now (it built a graph, read the plan back, then ran one device compute that the ten common_flash_attention.decode rows already run) and its known_fail label is gone. - tests/test-hrx-ops.cpp: the seven fa_decode_split rows end at the attention output, so under consumer-driven publication their plan registers no alternate; they assert that and keep asserting the q8 transient binding (bindings[9] == plan.transients[3].value). Publication with a consumer stays pinned by hrx-ops-test's qwen_decode_split_flash_attention.*.masked.head96.value64 and qwen_decode_attention_output_next_q8.* rows. Evidence (host tier on ryzen, no device; the plans are for gfx1151 and execute nothing). Control at d2369fe with the source fix reverted and the new row kept: $ build-hrx/bin/hrx-ops-test --hrx-test-filter '^qwen_flash_attention$' --hrx-test-jobs 1 --hrx-test-output all [FAIL] qwen_flash_attention ggml_hrx dispatch: common.flash_attention_decode_split_next_q8 (single) tests/hrx-ops-test.cpp:5143: requirement failed: scheduler.plan().metadata.find_alternate_value( output_value->id, GGML_TYPE_Q8_1, ...) == nullptr $ HRX_OPS_TEST_FILTER='^fa_decode_split\.' (device rows registered host for this control run only) [FAIL] fa_decode_split.1.512 / .4.513 / .1.512.true / .1.65 tests/test-hrx-ops.cpp:2625: requirement failed: plan.metadata.find_alternate_value(output_value->id, GGML_TYPE_Q8_1, q8_output_bytes) == nullptr With this change: $ GGML_HRX_LOG_DISPATCH=1 build-hrx/bin/hrx-ops-test --hrx-test-filter '^(qwen_flash_attention|qwen_decode_split_flash_attention\.|qwen_decode_attention_output_next_q8\.)$' --hrx-test-jobs 1 [PASS] qwen_flash_attention ggml_hrx dispatch: common.flash_attention_decode_split_next_q8 (single) <- kernel still selected, no alternate [PASS] qwen_decode_split_flash_attention.query1.kv512.masked.head96.value64 <- alternate still published [PASS] qwen_decode_split_flash_attention.query4.kv513.masked.head96.value64 [PASS] qwen_decode_attention_output_next_q8.no_selectors [PASS] qwen_decode_attention_output_next_q8.selectors HRX test summary: 5 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 5 total $ build-hrx/bin/hrx-ops-test HRX test summary: 18 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 18 total $ HRX_OPS_TEST_OUTPUT=all build-hrx/bin/test-hrx-ops test-hrx-ops summary: 2 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 2 total $ python3 ggml/src/ggml-hrx/tools/check_stale_expectations.py --check stale-expectations: 488 expectation literal(s), every one selectable by a registration Device tier, strixhalo gfx1151, add-on build (GGML_HRX=ON, HIP add-on gpu-kernels 87bdf514, text corpus, gfx1151), package runtime libs, one box-hold both ticket as root, every command timeout-bounded (/data/dev/cl-hrxtest/runs/lane3380b.status): stage /data/dev/cl-hrxtest/tests-3380b hrx-ops-test d83361d2ec77c4b330585a5da55fc886 test-hrx-ops 6f1ca1d066291f227b5f32346d80ef03 libggml-hrx.so.0 6b79744c130ecebaca66bf264edff7c3 libhrx.so.0 10757295697998877566d0db0b5acc4e (package) libloomc.so.0 b485ddd8ea03569a8dc66aa23ba6817e (package) env HRX_ALLOW_NO_SVM=1 HSA_USERPTR_FOR_PAGED_MEM=0 HSA_USE_SVM=0 IREE_HAL_AMDGPU_LIBHSA_PATH=/opt/rocm-therock/lib/libhsa-runtime64.so.1, ulimit -l unlimited 0-caselist rc=0, 411 cases, first line the engine#680 HRX0 guardrail (GTT 120.0 GiB, pool 103.7 GiB, host MemAvailable 121.5 GiB) 1-row [PASS] 1/1 qwen_flash_attention HRX test summary: 1 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 1 total, 110 ms 2-addon full HRX test summary: 411 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 411 total, 106897 ms 3-addon test-hrx-ops test-hrx-ops summary: 295 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 295 total, 407025 ms 4-publish-rows HRX test summary: 7 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 7 total, 176 ms window 2026-11-24T12:58:38Z - 13:07:13Z: no amdgpu reset / wedged / page fault / ring timeout line in dmesg during the run (the only such lines are uptime 2737 s, ~11:03Z, from an earlier job). Before (merged pin d2369fe, add-on full suite): 410 passed, 0 failed, 1 known-fail, 411 total; the known-fail was qwen_flash_attention "engine#3380: decode-split FA always publishes a Q8_1 alternate that no consumer reads" at tests/hrx-ops-test.cpp:5143. After: 411 passed, 0 failed, 0 known-fail. Not verified here: no no-add-on device run of hrx-ops-test (it has five pre-existing failures at this pin that this change does not touch); no decode tok/s change measured (the change removes a metadata registration, not kernel work, so no throughput claim). Assisted-by: DeepSeek Harness (deepseek-flash) Co-authored-by: bong-water-water-bong <[email protected]>
…r reads - it publishes only for a q8 projection (engine#3380) (#511) engine#3380's known-fail row says the decode-split flash-attention dispatch registers a Q8_1 x4 alternate for its output even when nothing in the graph reads it. The publisher is match_flash_attention_decode_split_next_q8_dispatch (ggml/src/ggml-hrx/dispatch_registration/common/dispatch-flash-attention.cpp), which appended the alternate unconditionally after reserving the q8 transient. The routed publication paths already answer "will anything read this" on the graph (dispatch_registration/common/dispatch-q8-publication.h: common_for_each_q8_consumer and common_q8_consumer_is_qualified_projection, engine #449/#504): a producer publishes its normalized activation only when a projection that reads Q8_1 x4 consumes it, looking through full ordered layout aliases (production reads the [value_head_size, heads, tokens] attention output as the [hidden_size, tokens] reshape input of the next MUL_MAT, engine#3384). This change applies the same qualification to the split attention publication. The split kernel is the only one exported for this shape (the loom-libs manifest exports ggml_flash_attention_decode_split_f32_f16_wmma_next_q8 and no non-publishing split variant), so the dispatch cannot fall back to a split kernel that does not write q8, and the q8 output is a kernel binding: the transient stays and only the metadata registration becomes conditional. An unqualified graph keeps the dispatch and loses only the alternate; a consumer that appears would quantize the activation itself, one separate dispatch at worst. - dispatch-flash-attention.cpp: has_qualified_q8_consumer() over the split matcher's output value; the alternate is appended only when it holds. Kernel selection, the q8 transient and bindings[9] are unchanged. - tests/hrx-ops-test.cpp: the qwen_flash_attention row is a plan-only host case now (it built a graph, read the plan back, then ran one device compute that the ten common_flash_attention.decode rows already run) and its known_fail label is gone. - tests/test-hrx-ops.cpp: the seven fa_decode_split rows end at the attention output, so under consumer-driven publication their plan registers no alternate; they assert that and keep asserting the q8 transient binding (bindings[9] == plan.transients[3].value). Publication with a consumer stays pinned by hrx-ops-test's qwen_decode_split_flash_attention.*.masked.head96.value64 and qwen_decode_attention_output_next_q8.* rows. Evidence (host tier on ryzen, no device; the plans are for gfx1151 and execute nothing). Control at d2369fe with the source fix reverted and the new row kept: $ build-hrx/bin/hrx-ops-test --hrx-test-filter '^qwen_flash_attention$' --hrx-test-jobs 1 --hrx-test-output all [FAIL] qwen_flash_attention ggml_hrx dispatch: common.flash_attention_decode_split_next_q8 (single) tests/hrx-ops-test.cpp:5143: requirement failed: scheduler.plan().metadata.find_alternate_value( output_value->id, GGML_TYPE_Q8_1, ...) == nullptr $ HRX_OPS_TEST_FILTER='^fa_decode_split\.' (device rows registered host for this control run only) [FAIL] fa_decode_split.1.512 / .4.513 / .1.512.true / .1.65 tests/test-hrx-ops.cpp:2625: requirement failed: plan.metadata.find_alternate_value(output_value->id, GGML_TYPE_Q8_1, q8_output_bytes) == nullptr With this change: $ GGML_HRX_LOG_DISPATCH=1 build-hrx/bin/hrx-ops-test --hrx-test-filter '^(qwen_flash_attention|qwen_decode_split_flash_attention\.|qwen_decode_attention_output_next_q8\.)$' --hrx-test-jobs 1 [PASS] qwen_flash_attention ggml_hrx dispatch: common.flash_attention_decode_split_next_q8 (single) <- kernel still selected, no alternate [PASS] qwen_decode_split_flash_attention.query1.kv512.masked.head96.value64 <- alternate still published [PASS] qwen_decode_split_flash_attention.query4.kv513.masked.head96.value64 [PASS] qwen_decode_attention_output_next_q8.no_selectors [PASS] qwen_decode_attention_output_next_q8.selectors HRX test summary: 5 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 5 total $ build-hrx/bin/hrx-ops-test HRX test summary: 18 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 18 total $ HRX_OPS_TEST_OUTPUT=all build-hrx/bin/test-hrx-ops test-hrx-ops summary: 2 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 2 total $ python3 ggml/src/ggml-hrx/tools/check_stale_expectations.py --check stale-expectations: 488 expectation literal(s), every one selectable by a registration Device tier, strixhalo gfx1151, add-on build (GGML_HRX=ON, HIP add-on gpu-kernels 87bdf514, text corpus, gfx1151), package runtime libs, one box-hold both ticket as root, every command timeout-bounded (/data/dev/cl-hrxtest/runs/lane3380b.status): stage /data/dev/cl-hrxtest/tests-3380b hrx-ops-test d83361d2ec77c4b330585a5da55fc886 test-hrx-ops 6f1ca1d066291f227b5f32346d80ef03 libggml-hrx.so.0 6b79744c130ecebaca66bf264edff7c3 libhrx.so.0 10757295697998877566d0db0b5acc4e (package) libloomc.so.0 b485ddd8ea03569a8dc66aa23ba6817e (package) env HRX_ALLOW_NO_SVM=1 HSA_USERPTR_FOR_PAGED_MEM=0 HSA_USE_SVM=0 IREE_HAL_AMDGPU_LIBHSA_PATH=/opt/rocm-therock/lib/libhsa-runtime64.so.1, ulimit -l unlimited 0-caselist rc=0, 411 cases, first line the engine#680 HRX0 guardrail (GTT 120.0 GiB, pool 103.7 GiB, host MemAvailable 121.5 GiB) 1-row [PASS] 1/1 qwen_flash_attention HRX test summary: 1 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 1 total, 110 ms 2-addon full HRX test summary: 411 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 411 total, 106897 ms 3-addon test-hrx-ops test-hrx-ops summary: 295 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 295 total, 407025 ms 4-publish-rows HRX test summary: 7 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 7 total, 176 ms window 2026-11-24T12:58:38Z - 13:07:13Z: no amdgpu reset / wedged / page fault / ring timeout line in dmesg during the run (the only such lines are uptime 2737 s, ~11:03Z, from an earlier job). Before (merged pin d2369fe, add-on full suite): 410 passed, 0 failed, 1 known-fail, 411 total; the known-fail was qwen_flash_attention "engine#3380: decode-split FA always publishes a Q8_1 alternate that no consumer reads" at tests/hrx-ops-test.cpp:5143. After: 411 passed, 0 failed, 0 known-fail. Not verified here: no no-add-on device run of hrx-ops-test (it has five pre-existing failures at this pin that this change does not touch); no decode tok/s change measured (the change removes a metadata registration, not kernel work, so no throughput claim). Assisted-by: DeepSeek Harness (deepseek-flash) Co-authored-by: bong-water-water-bong <[email protected]>
Refs 1bit-MONSTER/engine#2935. Follow-up to #444.
#444 stamped the add-on with its path and the sha256 of
kernels/*.hipat configure time. Measured on a build tree at 42b5444 + hrx-system 7f423692:kernels/hrx_kernel_ids.h) replaced in place with an older mtime: ninja rebuilt 0 code objects and the library kept a kernel symbol the header no longer names. Headers were not hashed, and nothing re-runs CMake for a content change ninja cannot see.What changes
hip/hip_addon_identity.pyhasheskernels/*, the matchers andaddon.cmake, at configure time and in every build (a rule that always runs and leaves the stamp alone when nothing changed). Code objects and matcher objects depend on the stamp.Measured (no device; target
ggml-hrx; staged add-on copies with old mtimes).hipchanged in place, old mtime.cppchanged in placeWith this change the identity rule runs in every build, so ninja no longer prints "no work to do"; nothing downstream moves when nothing changed.
Not run on a device. The engine pin bump should target a head that includes this.
🤖 Generated with Claude Code