Repository navigation
qwen4exp: the fused top-k mask's zero base row is one host input, not a FILL per QSA layer (engine#679) - #483
Merged
bong-water-water-bong merged 1 commit intoNov 22, 2026
Conversation
… a FILL per QSA layer (engine#679) The fused TOP_K_MASK path built its base row with ggml_fill(f16 [n_kv], 0) in every QSA layer. HRX has no f16 FILL, so each of those nodes ran on the CPU and split the decode graph once per QSA layer (12 CPU splits per Flash-Next decode step in the 11-21 scheduler log, ~0.8 ms of host round trip each). The row is now one input of llm_graph_input_kpool, zeroed on the host in set_input and shared by every QSA layer. Same values, so the mask and the output are unchanged; only the FILL nodes and their splits go away. Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong
left a comment
Author
There was a problem hiding this comment.
Verdict: APPROVE (review by lane cl-kernel).
- Correctness:
ggml_top_k_maskallocates its own result (ggml.c,ggml_new_tensor_4d) andGGML_OP_TOP_K_MASKis not inggml_op_can_inplace(ggml-alloc.c). So no QSA layer can write into the shared zero row, and the allocator cannot reuse its buffer even when the last consumer has the same layout (decode, n_tokens=1). The new assert pins type and length to whatbuild_qsa_selexpects:type_maskuses the sameflash_attn ? F16 : F32rule.set_inputzeroes the row on every ubatch, including reused graphs, andcan_reusealready keys onn_kv, which is the row's length. The host-buffer assert is consistent with how the scheduler places inputs. - Measurements: they support the change. The FILL nodes come off the CPU (17 -> 5 nodes off HRX, 26 -> 2 splits). Greedy output is token-identical across 8 runs per prompt with 0.0 logprob difference. Decode tok/s ranges don't overlap at every length (18.8k: 17.41-17.74 -> 18.16-20.12).
test-llama-archspasses all 172 architectures. The PR states plainly that the ggml-org#679 20.0 bar is not reached yet. - Merge order: independent of the others (merges cleanly with each); fine to land second. Needs an engine pin bump afterwards, as noted in the CL-I679 STATE file.
This was referenced Nov 22, 2026
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.
Overview
The fused top-k mask of Qwen3.8-Flash-Next (qwen4exp) built its all-zero base row with
ggml_fill(f16 [n_kv], 0)in every QSA layer. HRX has no f16 FILL, so each of those 12 nodes ran on the CPU and cut the decode graph at every QSA layer. The row is now one input ofllm_graph_input_kpool, zeroed on the host inset_inputand shared by all QSA layers. The values are the same, so the mask and the output do not change; only the FILL nodes and their splits go away (engine#679).Measured
strixhalo (gfx1151), rc-2026-11-22-c35 package
llama-serverwith onlylibllama.so.0swapped (base = 7737fa3, this = 7737fa3 + this commit, both built the same way; the ggml symbol imports are identical to the package's libllama). Qwen3.8-Flash-Next UD-IQ3_XXS,-ngl 99 -c 32768 -np 1 -ub 2048 --cache-reuse 256,GGML_HRX_GRAPH_PROGRAM_CACHE=128,GGML_HRX_STRICT=0,GGML_HRX_IQ3S_TABLE_DECODE=0(both arms; see below), power mode balanced, onebox-hold gputicket, MES failures 0 -> 0, amdgpu error lines 0 -> 0.GGML_HRX_STRICT=1refusal line): base17 of 6556 nodes off HRX (DUP x 1, GET_ROWS x 3, SET_ROWS x 1, FILL x 12), 26 splits-> this5 of 6544 nodes off HRX (DUP x 1, GET_ROWS x 3, SET_ROWS x 1), 2 splitsRanges are disjoint at every length. Prefill at 18,781 tokens: 495-510 -> 547-585 tok/s.
test-llama-archs(CPU, ryzen): all 172 architectures pass, qwen4exp included.The ggml-org#679 bar is 20.0 tok/s at 18.8k; the median is not there yet (one run 20.12).
Additional information
GGML_HRX_IQ3S_TABLE_DECODE=0was needed in both arms because the shipped default fails on this GGUF:kernel loom_libs:ggml_mul_mat_id_swiglu_f32_f32_wmma_iq3s_table has 7 bindings but its ABI requires 6. That is a separate fix (separate PR, once it is verified on a device build).Requirements
🤖 Generated with Claude Code