Skip to content

hrx: the split decode attention published a Q8_1 alternate no consumer reads - it publishes only for a q8 projection (engine#3380) - #511

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
fix/3380-split-fa-q8-cond
Nov 24, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
fix/3380-split-fa-q8-cond

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

engine#3380's known-fail row (qwen_flash_attention) is the split decode attention publishing a
Q8_1 x4 alternate that nothing reads. This makes the publication consumer-driven, the same qualification
the routed publications already use, and removes the known-fail label. Base: 1bit/hrx-vulkan-patched
@ d2369fe2.

What was wrong

match_flash_attention_decode_split_next_q8_dispatch()
(ggml/src/ggml-hrx/dispatch_registration/common/dispatch-flash-attention.cpp:659) appended the alternate
for match.output unconditionally, after reserving the q8 transient the ..._next_q8 kernel binds. A graph
that ends at the attention output - qwen_flash_attention is exactly that - therefore planned a Q8_1
alternate nobody could read, and the row failed at tests/hrx-ops-test.cpp:5143 on
find_alternate_value(...) == nullptr forever.

What changed

dispatch-q8-publication.h already answers this question on the graph:
common_for_each_q8_consumer() walks a value's consumers and the consumers of its 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), and
common_q8_consumer_is_qualified_projection() decides whether that consumer is a projection that reads
Q8_1 x4 (engine #449/#504). The split attention matcher now uses them:

  • 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 - the loom-libs corpus exports only the ..._next_q8 split kernel for this shape, so the
    dispatch must keep running it, and the transient is a kernel binding. An unqualified graph loses only the
    metadata registration; a consumer that appeared later quantizes the activation itself.
  • tests/hrx-ops-test.cpp: the qwen_flash_attention row is a plan-only host case now (it built a graph
    and 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 too, 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, which still find and bind the alternate.

Before / after, device tier

strixhalo, gfx1151, add-on build, package runtime libs (pkg/hrx/llama/bin/libhrx.so.0,
libloomc.so.0), 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, one
box-hold both ticket as root, every command timeout-bounded.

before (merged pin d2369fe2, add-on full suite):
  hrx-ops-test: 410 passed, 0 failed, 1 known-fail, 411 total
  [KNOWN-FAIL] qwen_flash_attention
    "engine#3380: decode-split FA always publishes a Q8_1 alternate that no consumer reads"
    (tests/hrx-ops-test.cpp:5143)

after (this branch, -DGGML_HRX=ON -DLLAMA_BUILD_TESTS=ON -DGGML_HRX_KERNEL_CORPUS_SOURCE_FORMAT=text
       -DGGML_HRX_HIP_COMPILER=/home/bcloud/sdk-gfx1201-devel/llvm/bin/amdclang++
       -DGGML_HRX_HIP_TARGETS=gfx1151
       -DGGML_HRX_HIP_ADDON_DIR=<gpu-kernels 87bdf514>/addons/hip-hrx):
  staged /data/dev/cl-hrxtest/tests-3380b: hrx-ops-test d83361d2ec77c4b330585a5da55fc886,
    test-hrx-ops 6f1ca1d066291f227b5f32346d80ef03, libggml-hrx.so.0 6b79744c130ecebaca66bf264edff7c3
  0-caselist   rc=0, 411 cases, HRX0 guardrail first (GTT 120.0 GiB, pool 103.7 GiB, 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 (qwen_decode_split_flash_attention.*, qwen_decode_attention_output_next_q8.*)
               HRX test summary: 7 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 7 total, 176 ms

Ticket 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 in dmesg are at uptime 2737 s, ~11:03Z, from an earlier job). The
box rebooted ~45 s after this ticket released; the ticket itself completed rc 0 and released normally. Note:
while reading the results back the box was briefly unreachable (12:11-13:13Z) and then answered again with
uptime ~6 min, i.e. it had rebooted; the run logs and status file are intact.

Logs on strixhalo: /data/dev/cl-hrxtest/runs/lane3380b.status,
lane3380b-{0-caselist,1-row,2-addon-hrx-ops-test,3-addon-test-hrx-ops,4-publish-rows}.log;
ticket /data/dev/cl-hrxtest/lane3380b-ticket.sh, stage /data/dev/cl-hrxtest/tests-3380b.

Control (host tier, ryzen, no device; plans are for gfx1151 and execute nothing)

Source fix reverted, 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, ... kQueryTokenCount ... ) == nullptr

Same for the test-hrx-ops rows with the branch source reverted (those seven are device cases; registered host
for this control run only, they are plan-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 the fix, host tier:

$ 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 --hrx-test-output all
[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

What this leaves / review risk

  • The split kernel still computes the q8 copy into its private transient for consumer-less graphs: the
    loom-libs corpus exports only ggml_flash_attention_decode_split_f32_f16_wmma_next_q8 for this shape, so
    only the metadata registration is conditional. Removing that kernel work would need a non-publishing
    split kernel exported (the qwen3_moe corpus defines one; loom-libs does not) and a lower-priority split
    registration - a separate change.
  • tests/test-hrx-ops.cpp's seven fa_decode_split.* rows changed what they assert (no alternate for a
    graph that ends at the attention output, plus the q8 transient binding). That is the semantic edge of
    this PR: the publication is no longer a property of the dispatch alone. Publication-with-consumer remains
    asserted by the hrx-ops-test rows listed above, in both tiers.
  • 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), and no throughput measurement (this removes a metadata entry, not
    kernel work, so there is no perf claim).

Refs 1bit-MONSTER/engine#3380 (do not close: the Lead closes after the engine pin carries this).

…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]>
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