Skip to content

qwen: publish the next-RMSNorm q8 alternate from the fused routed-down kernel (engine #449) - #107

Merged
bong-water-water-bong merged 2 commits into
1bit/hrx-vulkan-patchedfrom
1bit/t449-qwen-q8
Oct 18, 2026
Merged

bong-water-water-bong merged 2 commits into
1bit/hrx-vulkan-patchedfrom
1bit/t449-qwen-q8

Conversation

@bong-water-water-bong

@bong-water-water-bong bong-water-water-bong commented Oct 18, 2026 •

Copy link
Copy Markdown

Engine #449 item 1. Base 953b639.

What is registered

qwen3_moe:qwen3_moe_routed_down_weighted_reduce_next_rmsnorm_q8_1_x4 is in the corpus (qwen_moe manifest) and was registered nowhere. Its launch signature is the same five buffers as ..._next_rmsnorm_f32, with the last one being the quantized next-projection input instead of the f32 normalized row, so selecting it replaces the f32 row rather than adding work.

Selection is consumer-driven through the new dispatch_registration/common/dispatch-q8-publication.h: publish_q8 is set only when the normalized value feeds a projection that reads Q8_1 x4 (decode Q4_K, or Q6_K with a live output; prefill Q5_K / IQ4_XS), taking the value as its activation operand, with the weight and output geometry the q8 kernels serve; ordered layout aliases of the whole row are followed. A BF16 consumer, a transposed operand or an unqualified output size keeps the f32 path and does no quantization.

Consumer side of the same convention, for review: common_prepare_q8_1_x4_input() (common/dispatch-mul-mat-common.h) makes the matmul matchers bind an existing Q8_1 alternate, and has_q8_alternate() (common/dispatch-kquant-decode.cpp) keeps the f32-only decode kernels away from such an input.

Test

The guard's residual source is now a transient (ggml_dup of the base tensor): that is what a real layer hands the fused kernel, and an external residual keeps its storage (#95), which is why the fused arm was unreachable in this case. Expected producers are the two corpus kernels, arity five for both, because the current q8 form does not materialize a separate f32 copy (the pre-re-head _publish_q8 kernel took a sixth buffer, and the pre-re-head test asserted six).

Device gate (HRX0, strixhalo)

HRX0 in use, not the CPU path: every CSV row carries devices=HRX0 and gpu_info=AMD Radeon 8060S Graphics (Node 1) (gfx1151), and test-backend-ops reports Testing 2 devices / Backend 1/2: HRX0. HRX attaches only with IREE_HAL_AMDGPU_LIBHSA_PATH pointing at TheRock's libhsa (~/therock100/.../_rocm_sdk_core/lib/libhsa-runtime64.so.1); with the distro lib it registers no device and everything silently runs on CPU. Every run went through ~/lb/thermal-run.sh, one process at a time, cooling below 70 C between runs, Tctl <= 65 C.

test-backend-ops -b HRX0: Backend 1/2: HRX0, 1141/1141 tests passed.

llama-bench -p 512 -n 128 -r 2 -dev HRX0 -ngl 99 -t 4, arm A = 953b639, arm B = this PR:

model test A (953b639) B (this PR)
Qwen3-Coder-30B-A3B-Instruct-Q4_K_M pp512 2041.3 +-21.6 t/s 2035.8 +-17.6 t/s
Qwen3-Coder-30B-A3B-Instruct-Q4_K_M tg128 91.317 +-0.013 t/s 91.864 +-0.069 t/s
Qwen3-8B-Q4_K_M pp512 2266.98 +-38.80 t/s 2342.10 +-3.98 t/s
Qwen3-8B-Q4_K_M tg128 42.6466 +-0.0274 t/s 42.7026 +-0.0080 t/s

needle 7341 @4732 (Qwen3-8B, arm B): 3/3 OK, answer 7341, prompt 4732 tokens, identical sha on all three reps.

Dispatches per token: not counted. The backend has no per-graph dispatch counter, and I did not add instrumentation for one run. Structurally this change does not add a dispatch: the same producer runs, writing the q8 row instead of the f32 row, and the projection consumes it through the existing alternate lookup.

Host suite (CPU, ryzen; this fork has no CI, so the table is the gate): 48 passed, 12 failed, 6 known-fail, 0 unexpected-pass, 66 total. The marker for this guard is retired in the same PR, per the ruling.

Refs engine #449, engine #445.

🤖 Generated with Claude Code

…n kernel (engine #449)

The q8 producer the ruling asked for is in the corpus, unregistered:
qwen3_moe:qwen3_moe_routed_down_weighted_reduce_next_rmsnorm_q8_1_x4. Its launch signature
(route weights, routed-down f16 alternate, hidden state accumulated in place, next norm weight,
quantized next-projection input) is the same five bindings as the f32 variant, so selecting it
replaces the f32 normalized row rather than adding one.

Selection is consumer-driven: publish_q8 is set only when the normalized value feeds a projection
that reads Q8_1 x4 (new common/dispatch-q8-publication.h), so a BF16 consumer, a transposed operand
or an unqualified output size keeps the f32 path and no quantize work happens. Layout aliases that
cover the whole row are followed.

Test: the guard's residual source is now a transient (ggml_dup), which is what a real layer feeds the
fused kernel; an external residual keeps its storage (#95), which is why the fused arm was
unreachable in this case. Expected producer names are the two corpus kernels, and the arity is five
for both because the q8 form has no separate f32 buffer. The pre-re-head _publish_q8 kernel took a
sixth buffer and the pre-re-head test asserted six.

Host suite (CPU, ryzen): 45 passed, 13 failed, 7 known-fail, 1 unexpected-pass, 66 total.
The unexpected pass is this guard; its marker is retired in the same PR once the device gate passes,
as instructed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e passed)

Device gate on HRX0 (IREE_HAL_AMDGPU_LIBHSA_PATH=therock100 libhsa, which is what attaches
HRX0 on this box): test-backend-ops -b HRX0 1141/1141 passed; Qwen3-Coder-30B-A3B tg128
91.32 -> 91.86 t/s, pp512 2041 -> 2036 t/s; Qwen3-8B tg128 42.65 -> 42.70 t/s, pp512 2267
-> 2342 t/s; needle 7341 @4732 3/3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bong-water-water-bong
bong-water-water-bong merged commit 29dd882 into 1bit/hrx-vulkan-patched Oct 18, 2026
bong-water-water-bong pushed a commit that referenced this pull request Oct 18, 2026
has_decode_q8_consumer() accepted any MUL_MAT or MUL_MAT_ID consumer, so the decode
rmsnorm+quantize kernel published a q8_1 x4 alternate for a BF16 projection and for a
63-output projection, i.e. it quantized a value nobody reads. That is the part of the
f2099e9 publication loss that survived as a behaviour change rather than a rename.

The check is now the shared consumer qualification from #107: a qualified dense q8
projection (decode Q4_K, or Q6_K with a live output; prefill Q5_K / IQ4_XS), directly or
through a full-range layout alias, or the fused routed-MoE chain where the same route ids
feed the down projection through the GLU with the profile geometry. Anything else keeps
the f32 path and does no quantization.

Host suite, stacked on #107 (CPU, ryzen):
  before: 45 passed, 13 failed, 7 known-fail, 1 unexpected-pass, 66 total
  now:    46 passed, 12 failed, 6 known-fail, 2 unexpected-pass, 66 total

The second unexpected pass is qwen_decode_publication_consumer_qualification. One real
failure also went green: schedule_qwen_terminal_q6k_q8_command.tokens1, whose decode graph
was seeing the unqualified publication. Both #449 markers are retired after the device gate
for this PR, not before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong added a commit that referenced this pull request Oct 18, 2026
…#108)

* qwen: make rmsnorm q8 publication consumer-driven again (engine #449)

has_decode_q8_consumer() accepted any MUL_MAT or MUL_MAT_ID consumer, so the decode
rmsnorm+quantize kernel published a q8_1 x4 alternate for a BF16 projection and for a
63-output projection, i.e. it quantized a value nobody reads. That is the part of the
f2099e9 publication loss that survived as a behaviour change rather than a rename.

The check is now the shared consumer qualification from #107: a qualified dense q8
projection (decode Q4_K, or Q6_K with a live output; prefill Q5_K / IQ4_XS), directly or
through a full-range layout alias, or the fused routed-MoE chain where the same route ids
feed the down projection through the GLU with the profile geometry. Anything else keeps
the f32 path and does no quantization.

Host suite, stacked on #107 (CPU, ryzen):
  before: 45 passed, 13 failed, 7 known-fail, 1 unexpected-pass, 66 total
  now:    46 passed, 12 failed, 6 known-fail, 2 unexpected-pass, 66 total

The second unexpected pass is qwen_decode_publication_consumer_qualification. One real
failure also went green: schedule_qwen_terminal_q6k_q8_command.tokens1, whose decode graph
was seeing the unqualified publication. Both #449 markers are retired after the device gate
for this PR, not before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* tests: retire the #449 marker for consumer-driven rmsnorm publication (device gate passed)

Same gate as the parent commit: test-backend-ops -b HRX0 1141/1141 passed, tok/s level on the
MoE and dense arms, needle 7341 @4732 3/3.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: bong-water-water-bong <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: bong-water-water-bong <[email protected]>
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/t449-qwen-q8 branch November 12, 2026 21:16
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