Skip to content

hrx: the add-on identity covers every file the add-on builds from, and is checked by every build (engine#2935) - #449

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
cl-2935/addon-identity-build-time
Nov 20, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
cl-2935/addon-identity-build-time

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Refs 1bit-MONSTER/engine#2935. Follow-up to #444.

#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.

What changes

hip/hip_addon_identity.py 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.

Measured (no device; target ggml-hrx; staged add-on copies with old mtimes)

case rebuilt objects, table and library follow the tree
no change, plain ninja 0 yes
no change, explicit reconfigure 0 (was 64 with #444) yes
header changed in place, old mtime 64 (was 0 with #444) 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

With 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

…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]>
@bong-water-water-bong

Copy link
Copy Markdown
Author

Checked the mechanism this PR turns on, since the two claims it makes are both about the identity file's behaviour. Ran hip/hip_addon_identity.py standalone against a copy of the real add-on tree (~/wt/cl-856-gk/addons/hip-hrx):

no change            → stamp mtime 1795180205 → 1795180205   (not rewritten: restat keeps the 64 objects idle)
header changed, old mtime → 1795180205 → 1795180207          (identity moved, so DEPENDS on the stamp is newer)

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:

  • headers are in the identity now — kernels/hrx_kernel_ids.h was the case that mattered (it decides every kernel symbol) and it was not hashed before, so a header replaced in place changed no stamp and no mtime ninja compares;
  • the trailing newline is gone from the comparison — the script compares handle.read() against the string it would write, both ending in \n, so "nothing changed" really leaves the file alone. hrx: a code object carries a content identity of its add-on tree (engine#2935) #444's version read the file (with \n) and compared it to an identity without one, which rewrote the stamp on every configure and recompiled all 64 objects each time — a real cost I did not notice because I never re-ran CMake twice in the measurements.
  • identity() also covers the matchers' *.cpp/*.h and addon.cmake, which is right: those contribute objects to the same library, and a matcher change without a code-object rebuild is the same class of mismatch from the other side.

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 SYMBOLIC always-run output that carries it, not the numbers. The one I would confirm if I were reviewing is "no change, explicit reconfigure → 0", because that is the case this PR exists to make cheap, and it is cheap to confirm: cmake … && cmake --build … --target ggml-hrx-hip-code-objects twice on a tree with an add-on.

The engine pin bump (engine#2954 is already merged at 42b544465, which does not contain this) should follow this merge, and I will run it — same recipe as before, ~/wt/cl-856-logs/bump.sh <new head>, with hrx_build and the loom-jit pair row as the acceptance test.

@bong-water-water-bong

Copy link
Copy Markdown
Author

READY — and the measurement table is the whole case: it fixes both of #444's failure modes and the false-positive direction #444 introduced.

| case                                     | rebuilt | objects/table/library follow the tree |
| no change, plain ninja                   | 0       | yes |
| no change, explicit reconfigure          | 0 (was 64 with #444) | yes |
| header changed in place, old mtime       | 64 (was 0 with #444) | 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 | hashes identical to the first build |

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:

  1. "with this change the identity rule runs in every build, so ninja no longer prints 'no work to do'" is a cost worth quantifying. Every build now runs a hash over kernels/*, the matchers and addon.cmake — for the HRX add-on that is tens of files and a few MB. One line with the measured cost (the table implies it is small, since the "no change" row is 0 rebuilt) makes it clear the fix did not trade correctness for a slower loop.
  2. switch to another add-on tree and back: hashes identical to the first build is the strongest row and it deserves the mechanism. Identical hashes after a round trip means the identity is a content fingerprint, not a path+mtime one — which is what makes it correct when two checkouts contain the same files. Say that explicitly, because it is the property that distinguishes this from hrx: a code object carries a content identity of its add-on tree (engine#2935) #444's path-based stamp.
  3. Not run on a device plus the engine pin bump should target a head that includes this should be checked against convert : fix python 3.8 support, modernize type annotations ggml-org/llama.cpp#2916's chain: hrx: revert #434's loomc builder rename, which moved the fork onto an API the pinned hrx-system predates (engine#2916) #446 (the loomc revert) makes the pin bumpable, and this PR must be in that head — worth naming both numbers in one line so the pin bump does not land one commit short of the fix, which is exactly the class engine#2912 is still open for.

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 bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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 .hsaco every 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 bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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:

  1. 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 rglob from reintroducing the thrash;
  2. 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.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT: READY 449 — with one question that decides whether the stamp covers the thing that broke

#444 stamped the add-on with its path and sha256(kernels/*.hip) at configure time. Two gaps follow from that sentence, and both are cheap to close now and expensive to discover later.

Four asks:

  1. does the stamp cover everything that is compiled? — kernels/*.hip is the CUDA-side set; the addon also carries dispatch sources (addons/hip-hrx/*.cpp, dispatch-hip-*.cpp) and registration tables. Today's fleet breakage came from a dispatch/registration mismatch, not from a .hip edit: kq_mm_iq1s_t16 … the code object has no kernel of that name. An arm that edits only a dispatch source and leaves every .hip untouched must change the stamp — if it does not, the stamp answers a narrower question than the one it looks like it answers;
  2. configure-time hashing is stale by construction after a rebuild — file(SHA256) runs when CMake configures; a later ninja that recompiles the addon updates neither the stamp nor anything that reads it. Say which of the two you chose: hash at configure (cheap, will be stale) or hash in a post-build step (correct). If it is configure-time, the field should be named so nobody trusts it after an incremental build;
  3. the arm is "same sha, different content" — the pin unchanged, the tree edited. That is the case a git describe-style identity misses entirely and the reason hrx: a code object carries a content identity of its add-on tree (engine#2935) #444 exists;
  4. say what a mismatch refuses — refuse the load with both identities in the message (stamped <x>, present <y>), the way docs: add java-llama.cpp to README.md ggml-org/llama.cpp#2935's repair text does, because the alternative is the current behaviour: a build that succeeds and a server that refuses every model with a message about kernel names, which sends the reader to the wrong repo.

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.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at 5bbc40c: READY — both holes are closed, and I verified them at the mechanism level rather than reading the diff: the old bug reproduces on the old wiring, and each of the two fixes fails when I mutate its piece.

The script, on a real add-on tree (copy of ~/wt/cl-1051-c4-gk/addons/hip-hrx)

$ python3 hip_addon_identity.py stamp addon    → rc 0, 12459 bytes, 135 file lines (73 kernels/ + 61 *.cpp/*.h + addon.cmake)
$ again, unchanged                             → stamp mtime UNCHANGED          (this is the second bug: no rewrite)
$ header edited, mtime set BACKWARDS           → identity changes, stamp rewritten  (this is the first bug)
real 0m0.010s   (135 files, 1.3 MB, twice)

The file set matches the trees on this box exactly: kernels/ is flat (73 files, 14 of them headers/incs/manifests), 61 top-level *.cpp/*.h, one addon.cmake — the same sets the CMake globs compile (kernels/*.hip, *.cpp, *.h), plus everything else sitting beside the kernels, which is the part #444 missed.

The dependency the PR exists for is the real one: 23 of the add-on's *.cpp include kernels/hrx_kernel_ids.h (and 62 .hip files), so those 23 matcher objects are exactly the set that needed OBJECT_DEPENDS on the stamp, and they have it.

No rebuild loop: nothing in addon.cmake or the fork's hip/*.cmake generates files into <addon>/kernels at build time (hrx_kernel_ids.h is committed upstream from hrx_kernel_names.txt). If it did, the identity would change after every build and re-create the very symptom this fixes; it does not.

The wiring, in a minimal ninja project that replicates all three rules

I rebuilt the mechanism standalone (cmake -E true + SYMBOLIC, stamp custom command, a code-object custom command with DEPENDS ${STAMP}, and a real compile with OBJECT_DEPENDS ${STAMP}), then drove it:

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

  1. 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 shared gk-* path changes every dependent tree's identity and forces a full 64-object rebuild there. Worth knowing before someone moves it again.
  2. 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.
  3. 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.

@bong-water-water-bong
bong-water-water-bong merged commit 4eb3f08 into 1bit/hrx-vulkan-patched Nov 20, 2026
@bong-water-water-bong
bong-water-water-bong deleted the cl-2935/addon-identity-build-time branch November 20, 2026 13:14
bong-water-water-bong pushed a commit that referenced this pull request Nov 24, 2026
…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]>
bong-water-water-bong added a commit that referenced this pull request Nov 24, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant