Skip to content

hrx-ops-test: the attention-output next-q8 row fused a graph-input residual - it builds the graph-internal one and runs on the host tier (engine#3380) - #506

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
fix/3380-qwen-attn-out-next-q8-selection
Nov 24, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
fix/3380-qwen-attn-out-next-q8-selection

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

hrx-ops-test: the attention-output next-q8 row fused a graph-input residual - it builds the graph-internal one and runs on the host tier (engine#3380)

qwen.matmul.attention_output_q4k_q8_1_x4_next_q8 (Fused, 300, dispatch_registration/qwen/dispatch-qwen-matmul.cpp:487)
was selected in no configuration. The cause is not a predicate that can never hold: it is that the row built a shape the
matcher must refuse, and in the shipped build a higher-priority matcher from the add-on claims the node first.

match_qwen_attention_output_next_q8() requires the residual input to be ValueKind::Transient
(dispatch-qwen-matmul.cpp:318). The fused kernel accumulates the projection into the residual buffer
(qwen3_moe.dense_quantized.output_accumulation=1, same file:437), so writing a caller-owned value would corrupt it
(#95). The row built the residual with ggml_new_tensor_2d, a graph input, i.e. ValueKind::External
(graph/graph.cpp:31-49): the matcher declined at that clause every time, and the projection fell to
common.mul_mat_postops.f32_f32_wmma (or common.mul_mat.f32_f32_decode in the selectors shape). The shipped Qwen3-MoE
graph does not look like that: inpSA is the layer input, produced inside the same graph
(src/models/qwen3moe.cpp:83, 127, 155, 161).

In the shipped build a second thing hides the route. The add-on's hip.gemv_wide is a Fused MUL_MAT matcher at 329 and
claims a one-token Q4_K projection whose q8_1 input exists before this route at 300 is tried. It binds the same q8_1
alternate the FA route publishes (its matcher asks for an existing q8_1 input), so that copy is read, not wasted. That is
the add-on's deliberate choice (it measured 140-212 GB/s against 186-222 for the Loom one-token GEMVs); changing it is a
priority move above 329 and needs its own measurement.

Change

  • tests/hrx-ops-test.cpp: the row's residual comes from a producer, as in the shipped graph, and the graph-internal
    kind is asserted. The plan is 4 dispatches (FA, residual, the fused route, the next projection) and 2 completion
    counters, with the fused kernel present in both graph shapes. Before the change the fixture asserted 3 dispatches for
    a plan that cannot contain the fused route at all.
  • tests/hrx-ops-test.cpp: both rows are host_case rows now - the case builds a graph and reads the plan back, it
    never opens a device - and the known_fail label is gone. On an add-on tree the add-on matcher wins, so the row says
    what it does not assert and returns (the engine#3085 pattern) instead of failing on a name no add-on build produces.
  • dispatch-qwen-matmul.cpp: the registration comment records the transient-residual requirement and the 329 add-on
    matcher above it. tests/test-hrx-ops.cpp's fallback comment now records why its external residual cannot select the
    route (its rows and assertions are unchanged).

Evidence

Host tier on ryzen, no device: the plans are built for gfx1151 and nothing executes.

Control at parent e0e7c8d3, with only the two rows registered host-tier so the case can run without a GPU:

$ GGML_HRX_LOG_DISPATCH=1 build/bin/hrx-ops-test --hrx-test-filter '^qwen_decode_attention_output_next_q8\.' \
      --hrx-test-jobs 1 --hrx-test-output all
[FAIL]    1/2 qwen_decode_attention_output_next_q8.no_selectors
ggml_hrx dispatch: common.flash_attention_decode_split_next_q8 (single)
ggml_hrx dispatch: common.mul_mat_postops.f32_f32_wmma (fused)
ggml_hrx dispatch: qwen.decode_rmsnorm_f32_quantize_q8_1_x4 (fused)
ggml_hrx dispatch: common.mul_mat.f32_f32_decode (fused)
..../tests/hrx-ops-test.cpp:5557: requirement failed: plan.dispatches.size() == 3
[FAIL]    2/2 qwen_decode_attention_output_next_q8.selectors
ggml_hrx dispatch: common.flash_attention_decode_split_next_q8 (single)
ggml_hrx dispatch: common.mul_mat.f32_f32_decode (fused)
ggml_hrx dispatch: common.gather_add_f32 (fused)
ggml_hrx dispatch: qwen.decode_rmsnorm_f32_quantize_q8_1_x4 (fused)
..../tests/hrx-ops-test.cpp:5557: requirement failed: plan.dispatches.size() == 3

With the change:

[PASS]    1/2 qwen_decode_attention_output_next_q8.no_selectors
ggml_hrx dispatch: common.flash_attention_decode_split_next_q8 (single)
ggml_hrx dispatch: qwen.matmul.attention_output_q4k_q8_1_x4_next_q8 (fused)
ggml_hrx dispatch: common.binary_f32 (single)
ggml_hrx dispatch: common.mul_mat.f32_f32_decode (fused)
[PASS]    2/2 qwen_decode_attention_output_next_q8.selectors
ggml_hrx dispatch: common.flash_attention_decode_split_next_q8 (single)
ggml_hrx dispatch: qwen.matmul.attention_output_q4k_q8_1_x4_next_q8 (fused)
ggml_hrx dispatch: common.get_rows.f32 (single)
ggml_hrx dispatch: common.binary_f32 (single)
ggml_hrx dispatch: common.mul_mat.f32_f32_decode (fused)

HRX test summary: 2 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 2 total

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) shows the shadowing and
labels the non-assertion:

ggml_hrx dispatch: common.flash_attention_decode_split_next_q8 (single)
ggml_hrx dispatch: hip.gemv_wide (fused)
...
engine#3380: an add-on kernel (hip:k_d3eccfeebe3f) is in this plan and the loom attention-output route is not selected,
so this row does NOT assert it (engine#3085 pattern; GGML_HRX_LOG_DISPATCH=1 names the registration that took the node)
HRX test summary: 2 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 2 total

Whole suites and tools:

$ build/bin/hrx-ops-test --hrx-test-jobs 4
HRX test summary: 12 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 12 total   (rc 0; was 10 host cases + 2 known-fail device rows)

$ build/bin/test-hrx-ops
test-hrx-ops summary: 2 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 2 total (rc 0)

$ python3 ggml/src/ggml-hrx/tools/check_stale_expectations.py --check --root .
stale-expectations: 490 expectation literal(s), every one selectable by a registration
$ python3 ggml/src/ggml-hrx/tools/check_stale_expectations.py --self-test
self-test ok

Not verified here

No device run and no decode tok/s. The plan-level selection is shown on the host tier in both tree shapes; whether the
fused route beats hip.gemv_wide plus the separate add/rmsnorm/mul dispatches on gfx1151 is unmeasured, and moving this
registration above 329 would need that measurement on the Strix Halo box. No engine pin or add-on change is included.

Refs engine#3380.

AI usage disclosure: YES - drafted and implemented by an assisted coding agent (DeepSeek Harness); the submitter is
responsible for every line.

…sidual - it builds the graph-internal one and runs on the host tier (engine#3380)

engine#3380: qwen.matmul.attention_output_q4k_q8_1_x4_next_q8 was selected in no configuration, and its two
rows were known-fail device cases that no host run ever reached.

match_qwen_attention_output_next_q8() requires the residual input to be ValueKind::Transient
(dispatch_registration/qwen/dispatch-qwen-matmul.cpp:318): the fused kernel accumulates the projection into the
residual buffer (qwen3_moe.dense_quantized.output_accumulation=1, same file:437), so writing a caller-owned value
would corrupt it (#95). The row built the residual with ggml_new_tensor_2d - a graph input, ValueKind::External
(graph/graph.cpp:31-49) - so the matcher declined at that clause every time and the projection fell to
common.mul_mat_postops.f32_f32_wmma / common.mul_mat.f32_f32_decode. The shipped Qwen3-MoE graph does not look
like that: inpSA is the layer input, produced inside the same graph (src/models/qwen3moe.cpp:83, 127, 155, 161).

In the shipped build a second thing hides the route: the add-on's hip.gemv_wide is a Fused MUL_MAT matcher at 329
and claims a one-token Q4_K projection whose q8_1 input exists before this route at 300 is tried. It binds the
same q8_1 alternate the FA route publishes (its matcher asks for an existing q8_1 input), so that copy is read,
not wasted.

- tests/hrx-ops-test.cpp: the row's residual comes from a producer, as in the shipped graph, and the graph-internal
  kind is asserted. The plan is 4 dispatches (FA, residual, the fused route, the next projection) and 2 completion
  counters, with the fused kernel present in both graph shapes.
- tests/hrx-ops-test.cpp: both rows are host_case rows now (the case builds a graph and reads the plan back; it
  never opens a device), and the known_fail label is gone. On an add-on tree the add-on matcher wins, so the row
  says what it does not assert and returns, the engine#3085 pattern, instead of failing on a name no add-on build
  produces.
- dispatch-qwen-matmul.cpp: the registration comment records the transient-residual requirement and the 329 add-on
  matcher above it; tests/test-hrx-ops.cpp's fallback comment records why its external residual cannot select the
  route.

Evidence (host tier on ryzen, no device; the plans are for gfx1151 and execute nothing):

Control at e0e7c8d with only the two rows registered host-tier so the case can run at all:

  $ GGML_HRX_LOG_DISPATCH=1 build/bin/hrx-ops-test --hrx-test-filter '^qwen_decode_attention_output_next_q8\.' \
        --hrx-test-jobs 1 --hrx-test-output all
  [FAIL] qwen_decode_attention_output_next_q8.no_selectors
  ggml_hrx dispatch: common.flash_attention_decode_split_next_q8 (single)
  ggml_hrx dispatch: common.mul_mat_postops.f32_f32_wmma (fused)
  ggml_hrx dispatch: qwen.decode_rmsnorm_f32_quantize_q8_1_x4 (fused)
  ggml_hrx dispatch: common.mul_mat.f32_f32_decode (fused)
  tests/hrx-ops-test.cpp:5557: requirement failed: plan.dispatches.size() == 3
  (the selectors row fails the same way; its projection is taken by common.mul_mat.f32_f32_decode +
  common.gather_add_f32)

With this change:

  [PASS] qwen_decode_attention_output_next_q8.no_selectors
  ggml_hrx dispatch: common.flash_attention_decode_split_next_q8 (single)
  ggml_hrx dispatch: qwen.matmul.attention_output_q4k_q8_1_x4_next_q8 (fused)
  ggml_hrx dispatch: common.binary_f32 (single)
  ggml_hrx dispatch: common.mul_mat.f32_f32_decode (fused)
  [PASS] qwen_decode_attention_output_next_q8.selectors        (same four, plus common.get_rows.f32 before the add)
  HRX test summary: 2 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 2 total

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): hip.gemv_wide
(fused) takes the projection in both shapes, each row labels the non-assertion and exits 0:
  HRX test summary: 2 passed, 0 failed, 0 known-fail, 0 unexpected-pass, 2 total

Full host tier: hrx-ops-test 12 passed, 0 failed, 0 known-fail, 0 unexpected-pass (12 total, rc 0);
test-hrx-ops 2 passed, 0 failed, 0 known-fail (rc 0).
check_stale_expectations.py --check: 490 expectation literal(s), every one selectable; --self-test ok.

Not verified here: no device run, no decode tok/s. Plan-level selection is shown on the host tier; whether the
fused route beats hip.gemv_wide plus separate add/rmsnorm/mul dispatches on gfx1151 is unmeasured, and moving this
registration above 329 would need that measurement.

Assisted-by: DeepSeek Harness (deepseek-flash)
@bong-water-water-bong
bong-water-water-bong merged commit 5fc06eb into 1bit/hrx-vulkan-patched Nov 24, 2026
@bong-water-water-bong
bong-water-water-bong deleted the fix/3380-qwen-attn-out-next-q8-selection branch November 24, 2026 10:01
bong-water-water-bong pushed a commit that referenced this pull request Nov 24, 2026
…ape - an ordered reshape takes the requested value's rows (engine#3380)

**engine#3380**: the split-FA device rows regressed at 6164e5b; fork #503 (c6c654c) is the cause.

**The defect.** #503 made the alternate-value fallback compare layouts, not just full value ranges. The Q8_1 branch
took same_q8_1_x4_geometry(lhs, rhs), which requires *both* values' ne[0] to be 128-aligned
(ggml/src/ggml-hrx/dispatch/command-plan.h:91). The alias source's ne[0] is its own shape, not the row width the x4
copy was written with. A split-FA output is [value_head_size, heads, tokens] and the o_proj consumer reads
ggml_reshape_2d(output, hidden_size, tokens); with value_head_size 64 the source's ne[0] is 64, so
find_alternate_value() refused the alternate published for the FA output and returned nullptr. The row's
q8_alternate != nullptr failed, and for the 4-query row the plan also lost its q8 next-projection dispatch (fewer than
query_token_count + 1 dispatches). At head size 128 the source's ne[0] is 128 and the same lookup passed, which is why
only the head96/value64 rows broke.

**The fix.** The Q8_1 x4 rows are the *requested* value's rows: that is the row width the reader and the publisher use,
and the alternate's byte_count is the same ordered range either way. q8_1_x4_rows_compatible() keeps the ordered-range
requirement - storage, offset, byte_count, type, element count and contiguity all equal, so a transposed view or a
write's storage is still refused exactly as #503 requires - and checks the 128-element row alignment on the requested
value.

The two rows move to the host tier. Like the attention-output rows #506 moved, they build a graph and read the plan
back and never open a device; as device cases nothing could see this regression on a host, and the pre-fix tree fails
them on a host (both asserts reproduce, see the Evidence section).

Refs 1bit-MONSTER/engine#3380
Refs 1bit-MONSTER/engine#3383
bong-water-water-bong added a commit that referenced this pull request Nov 24, 2026
…ape - an ordered reshape takes the requested value's rows (engine#3380) (#508)

**engine#3380**: the split-FA device rows regressed at 6164e5b; fork #503 (c6c654c) is the cause.

**The defect.** #503 made the alternate-value fallback compare layouts, not just full value ranges. The Q8_1 branch
took same_q8_1_x4_geometry(lhs, rhs), which requires *both* values' ne[0] to be 128-aligned
(ggml/src/ggml-hrx/dispatch/command-plan.h:91). The alias source's ne[0] is its own shape, not the row width the x4
copy was written with. A split-FA output is [value_head_size, heads, tokens] and the o_proj consumer reads
ggml_reshape_2d(output, hidden_size, tokens); with value_head_size 64 the source's ne[0] is 64, so
find_alternate_value() refused the alternate published for the FA output and returned nullptr. The row's
q8_alternate != nullptr failed, and for the 4-query row the plan also lost its q8 next-projection dispatch (fewer than
query_token_count + 1 dispatches). At head size 128 the source's ne[0] is 128 and the same lookup passed, which is why
only the head96/value64 rows broke.

**The fix.** The Q8_1 x4 rows are the *requested* value's rows: that is the row width the reader and the publisher use,
and the alternate's byte_count is the same ordered range either way. q8_1_x4_rows_compatible() keeps the ordered-range
requirement - storage, offset, byte_count, type, element count and contiguity all equal, so a transposed view or a
write's storage is still refused exactly as #503 requires - and checks the 128-element row alignment on the requested
value.

The two rows move to the host tier. Like the attention-output rows #506 moved, they build a graph and read the plan
back and never open a device; as device cases nothing could see this regression on a host, and the pre-fix tree fails
them on a host (both asserts reproduce, see the Evidence section).

Refs 1bit-MONSTER/engine#3380
Refs 1bit-MONSTER/engine#3383

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