Repository navigation
hrx: the routed q8 publish scan saw only direct consumers - it walks full ordered reshape aliases (engine#3384) - #504
Merged
bong-water-water-bong merged 1 commit intoNov 24, 2026
Conversation
…full ordered reshape aliases (engine#3384) The decode fused producer qwen3_moe_rmsnorm_f32_quantize_q8_1_x4 publishes its Q8_1 x4 alternate only when has_qualified_q8_consumer() finds a projection that reads it (dispatch_registration/qwen/dispatch-qwen-rmsnorm.cpp:54). The dense test went through layout aliases (common_has_qualified_q8_projection_consumer), but the routed test walked graph.index().consumers(value.id) directly. A routed gate/up that reads the value through a ggml_reshape_2d is a MUL_MAT_ID whose input is the reshape's output, not the rmsnorm-mul output, so no consumer qualified, the fused producer declined, and the plan fell back to ggml_rmsnorm_binary_f32 with f32 gate/up. - common_for_each_q8_consumer() (common/dispatch-q8-publication.h:57) walks every consumer of the value and of each layout alias over it, and hands each consumer the value it actually reads. It sees through a layout alias only when the alias is a contiguous full ordered value range (same storage, offset, byte count, type and element count, contiguous) - the same rule find_alternate_value uses for the alternate, so the consumer the scan qualifies is one the scheduler can serve the alternate to. A transposed view or a partial view is still refused, because its bytes are not the value's. - has_qualified_q8_consumer() runs the routed predicate over that walk (dispatch-qwen-rmsnorm.cpp:66-70). The dense helper keeps its own single-consumer walk; this change is the routed half only. - tests: decode_routed_moe.q6_k.alias_gate_input (tests/hrx-ops-test.cpp:10053) and routed_moe_decode.q6_k.true (tests/test-hrx-ops.cpp:6828) leave known_fail_device_case. Evidence (host tier on ryzen, HRX sees the RX 9070 XT; both rows schedule for gfx1151 and execute nothing): - Add-on build (-DGGML_HRX=ON -DLLAMA_BUILD_TESTS=ON -DGGML_HRX_KERNEL_CORPUS_SOURCE_FORMAT=text -DGGML_HRX_HIP_TARGETS=gfx1151 -DGGML_HRX_HIP_ADDON_DIR=<gpu-kernels b80d7496>/addons/hip-hrx), before the change: hrx-ops-test --hrx-test-case decode_routed_moe.q6_k.alias_gate_input exits 134 with "missing expected kernel: qwen3_moe:qwen3_moe_router_projection_top8_fused_decode_f32" and the plan loom_libs:ggml_rmsnorm_binary_f32, router top8, hip:k_8eabfd3fb3bc, hip:k_102cc93009af, binaries, qwen3_moe:qwen3_moe_rmsnorm_f32_quantize_q8_1_x4, hip:k_d3eccfeebe3f. Its plain sibling decode_routed_moe.q6_k exits 0. test-hrx-ops --hrx-ops-test-test-case routed_moe_decode.q6_k.true exits 134 at "requirement failed: gate_up_routed"; routed_moe_decode.q6_k exits 0. - With the change both exit 0. With GGML_HRX_LOG_DISPATCH=1 the alias row matches qwen.decode_rmsnorm_f32_quantize_q8_1_x4 (fused), llm.moe_router.projection_top8_fused_decode (fused), llm.routed_ffn.decode_gate_up_swiglu_q4k_q8 (fused), hip.moe_decode.mmid, hip.gemv_wide. - Filtered suite runs: hrx-ops-test --hrx-test-filter '^decode_routed_moe\.q6_k(\.alias_gate_input)?$' gives 2 passed, 0 failed, 0 known-fail, 0 unexpected-pass; test-hrx-ops --hrx-ops-test-test-filter '^routed_moe_decode\.q6_k(\.true)?$' gives 2 passed, 0 failed, 0 known-fail, 0 unexpected-pass. - Plain build (no add-on): the alias row fails at the same subsequence before (exit 134) and exits 0 after. - All 10 host cases of hrx-ops-test and both of test-hrx-ops pass on the add-on build; check_stale_expectations.py --check reports 490 expectation literals, every one selectable, --self-test ok. Not verified here: the 2026-11-23 measurement the issue asks for (decode tok/s with the alias graph, q8 publish on versus off) needs the Strix Halo gfx1151 device and an engine build; these rows are scheduling rows with no value check. Co-authored-by: bong-water-water-bong <[email protected]> Assisted-by: DeepSeek Harness (deepseek-flash)
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
hrx: the decode q8 publish declines when the routed gate/up reads its input through a reshape alias (engine#3384)
qwen3_moe_rmsnorm_f32_quantize_q8_1_x4publishes its Q8_1 x4 alternate only whenhas_qualified_q8_consumer()finds a projection that reads it (
dispatch_registration/qwen/dispatch-qwen-rmsnorm.cpp:54). The dense test alreadylooked through ordered layout aliases; the routed test walked
graph.index().consumers(value.id)directly, so withthe routed gate/up reading a
ggml_reshape_2dof the rmsnorm-mul output the consumer was the reshape, nothingqualified, the fused producer declined, and the plan fell back to
ggml_rmsnorm_binary_f32with f32 gate/up.Change
common_for_each_q8_consumer()(common/dispatch-q8-publication.h:57) walks every consumer of the value and ofeach layout alias over it, and hands each consumer the value it actually reads. It sees through a layout alias only
when the alias is a contiguous full ordered value range (same storage, offset, byte count, type, element count,
contiguous) - the same rule
find_alternate_valueuses for the alternate, so a consumer qualified here is one thescheduler can serve the alternate to. A transposed view or a partial view is still refused: its bytes are not the
value's.
has_qualified_q8_consumer()runs the routed predicate over that walk(
dispatch-qwen-rmsnorm.cpp:66-70). The dense helper keeps its own single-consumer walk; this is the routed halfonly.
decode_routed_moe.q6_k.alias_gate_input(tests/hrx-ops-test.cpp:10053) androuted_moe_decode.q6_k.true(
tests/test-hrx-ops.cpp:6828) leaveknown_fail_device_caseand aredevice_caserows now.Evidence
Built at this branch's parent
c6c654c3and at the branch, on ryzen, HRX sees the RX 9070 XT; both rows schedulefor gfx1151 and execute nothing.
Add-on build (
-DGGML_HRX=ON -DLLAMA_BUILD_TESTS=ON -DGGML_HRX_KERNEL_CORPUS_SOURCE_FORMAT=text -DGGML_HRX_HIP_TARGETS=gfx1151 -DGGML_HRX_HIP_ADDON_DIR=<gpu-kernels b80d7496>/addons/hip-hrx), before:The plain siblings
decode_routed_moe.q6_kandrouted_moe_decode.q6_kexit 0 both before and after.With the change, both rows exit 0, and
GGML_HRX_LOG_DISPATCH=1on the alias row shows the fused publish chosen:Filtered suite runs (add-on build), so the accounting is visible:
Plain build (no add-on): the alias row fails at the same subsequence before (exit 134) and exits 0 after, so the fix
is not add-on specific. All 10 host cases of
hrx-ops-testand both oftest-hrx-opspass on the add-on build;check_stale_expectations.py --checkreports 490 expectation literals, every one selectable, and--self-testisok.
Not verified here
The 2026-11-23 rule asks for a measured decode win (decode tok/s with the alias graph, q8 publish on versus off)
before this ships. That needs the Strix Halo gfx1151 device and an engine build, and it is not run here: the two rows
are scheduling rows with no value check. The device run must show both rows passing on gfx1151, the alias graph's
routed gate/up reading the published q8 (
qwen3_moe_routed_gate_up_swiglu_q4k_q8in the plan), and an A/B decodetok/s with the alias graph at least as fast with the publish on.
Refs engine#3384.