Repository navigation
perf(qwen35): faster concurrent verify rounds on RDNA4 (MMQ tiles and prefetch, batched commit) - #964
Merged
Conversation
davide221
added a commit
to Graffioh/lucebox-hub
that referenced
this pull request
Nov 8, 2026
main now has Luce-Org#946. server/CMakeLists.txt: both PRs added a unit test to the same two target lists and the same block; keep both (test_gdn_single_commit, then test_glue_fusions), as on the stacked branch of Luce-Org#964.
Graffioh
force-pushed
the
perf/qwen35-c4-throughput
branch
from
November 9, 2026 09:41
b232c34 to
fc658bc
Compare
…mn calls A concurrent verify round multiplies 24-48 columns, past the 16-column tile twins and on the parent tiles. Three changes to those calls, always on where their rules allow them: - Measured tile (mmq-tile-twin-gate.h): a dense MMQ call of 17-48 columns on RDNA4 takes the tile and x-tile measured fastest for its type and output height on the Qwen3.8-27B UD-IQ4_XS tensors. Every x-tile accumulates each element over k in the same order, so the outputs match the parent bit for bit. Each twin has one bridge entry that takes the x-tile. - x48 at 32 columns: the q8_0-path MMA dot of a tile of 48 or more columns runs a body one 16-column tile shorter when that tile lies past the call's columns. The kept outputs are computed as before. - Prefetching kernel (64-row twins): each phase's global loads are issued one phase early, into registers, behind a barrier that waits for shared memory only. Bit-exact without a split. Inside ggml_backend_cuda_set_mmq_splitk_scope (thread-local, off by default) the prefetching kernel also splits k in 2 or 4 for small grids. The split sum is deterministic but not bit-exact against the unsplit one, so only the concurrent engine holds the scope, around a verify of two or more lanes. The per-tile counters belong to the backend context and are zeroed on its stream. Co-Authored-By: Claude Fable 5.2 <[email protected]>
… place Two changes to the concurrent fixed-chain round, both bit-exact: - ggml_backend_cuda_tree_commit_transaction_host validates the commit from the engine's host copies of the maps instead of reading them back, then commits in four launches: K/V rows as 16-byte vectors, feature rows, every layer's recurrent state, every conv window. Each element gets the same operands in the same order as the per-layer kernels. A refused preflight changes nothing and the engine falls back to the device-validated transaction. - The tree commit reads the replay log through the GDN result's view, as SINGLE_REPLAY already does, and the mapped verify feeds z to the fused silu*mul as a strided view (strided_gdn_plan). Co-Authored-By: Claude Fable 5.2 <[email protected]>
Graffioh
force-pushed
the
perf/qwen35-c4-throughput
branch
from
November 9, 2026 20:03
fc658bc to
09dc998
Compare
Graffioh
marked this pull request as ready for review
November 9, 2026 20:03
davide221
reviewed
Nov 9, 2026
davide221
left a comment
Contributor
There was a problem hiding this comment.
Code review
No issues found. Checked for bugs and logic errors in the changed code.
Reviewed 09dc998f · 1 candidate issue checked, kept at ≥70% confidence · add the code-review label to review again
9 tasks done
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.
Summary
Five changes to the concurrent DFlash verify round of Qwen3.8-27B on the R9700. At C4 a round verifies 4 lanes × 8 tokens, so most of its MMQ calls are 32 columns wide: past the 16-column RDNA4 tile twins, on the parent tiles. Per-request throughput over main: +16% at C3 and C4, +9-10% at C5 and C6, +7-8% at C7 and C8, +3-4% at C2 and paged C1, with no regression at any lane count and 0 errors (measured before the q8_1 producers moved out, see Evidence).
None has a runtime switch: each is always on where its rules allow it. Everything is bit-exact except split-k, which runs only inside a batched verify of two or more lanes. A single request's output is therefore unchanged.
mmq-tile-twin-gate.h). A dense MMQ call of 17–48 columns on RDNA4 takes the tile measured fastest for its type and output height, on the real Qwen3.8 tensors at N = 24/32/48. For example, IQ3_S 5120-row goes from 252 to 204 µs, and the Q5_K lm_head from 2036 to 1691 µs. Every x-tile accumulates each element over k in the same order, so the outputs match the parent bit for bit. Each twin has one bridge entry,mul_mat_q_case_rows<rows>_<type>(ctx, args, stream, mmq_x).mmq.cuh).vec_dot_q8_0_q8_1_mmagets a second compile-time body for the firstmmq_x - 16columns, taken when the tile's valid columns fit. At N=32, IQ4_XS goes from 166.4 to 155.2 µs (−6.7%). At N=48 it is within 1–2.6%, running the full body.mmq.cuhmul_mat_q_pf). The 64-row twins run their plain 2D calls of 17–48 columns through a kernel with these properties:__syncthreads()also drains every outstanding global load, which is why the loads never overlapped the dot products.ggml_backend_cuda_set_mmq_splitk_scope(thread-local, off by default) it splits k in 2 or 4 for grids under 256 workgroups, at 16 or more k-iterations per split on average. The last split to finish a tile sums the partials in split order, so the result is deterministic but not bit-exact against the unsplit sum.gdn-replay-log.cu).ggml_backend_cuda_tree_commit_transaction_hostvalidates the concurrent fixed-chain commit from the engine's host copies of the maps instead of reading them back. It then commits in four launches: K/V rows as 16-byte vectors, feature rows, every layer's state, and every conv window. The per-element arithmetic is the same. A refused preflight falls back to the device-validated transaction.qwen35_target_graph.cpp,glue_fusions.h). The tree commit reads the replay log through the GDN result's view, as SINGLE_REPLAY already does.strided_gdn_planlets the mapped verify feed z to the fused silu*mul as a strided view.Two commits: the MMQ work (
ggml-cuda), then the commit and in-place reads (qwen35).Evidence
Throughput across lane counts, R9700. Setup:
--profile qwen38-r9700, paged attention,--max-concurrency 8.dd85248d3against this branch, interleaved ABBA (twice at C4), each server run with a warm-up. Both arms carry a small private patch that returns step counts and token ids.fc658bc15) that also carried the q8_1 producers, now in perf(ggml-cuda): RMS norms and SWIGLU write their MMQ reader's q8_1 rows #969. They measured +0.64% (±0.51) and +0.34% (±0.36) steps/s at C4, so read each row as up to about 1% high. The table has not been re-run on this head. What changed since, besides the producers moving out, is the twin dispatch (same kernels per call, checked by the parity test) and where the split-k counters live.Why it is uneven:
Outputs at C > 1 are not compared byte for byte: the engine is not batch-invariant, so two runs of main differ there too.
C1 identity, R9700 (also on
fc658bc15). Setup:max_tokens2048, AR burst pinned off.Result: 30/30 identical by token ids, 26,327 tokens and 4,997 steps in both arms, 0 errors. Token ids came from main and the branch each built with a small private patch that returns them; the plain builds match too, on content, reasoning text, token count and finish reason (30/30). Rate 102.67 → 103.36 tok/s (+0.7%, one run each). The 23-column DDTree verify takes the new tiles and the prefetch kernel; split-k never engages there. Peak VRAM goes up by 6 MB.
Per-change increments (measured while developing, each on top of the previous ones, with runtime switches since removed and instrumentation that counted verify steps; C4 ABBA×2, steps/s paired by request):
Tests (R9700, all pass on this head):
test_mmq_tile_twins: 1980 arm cases compared with the parent tiles at 8/16/24/32/48 columns over 11 types × 9 shapes, with 861 running a twin. They are bit-identical, except inside the split-k scope, where only 64-row wide calls with ≥ 32 k-iterations may differ: those match the unsplit run within 1e-5 relative, and 11 cases split.test_mmq_tile_twin_gate: the per-type choices, including the IQ4_XS 64-row x48.test_glue_fusions: the mapped verify takes the z view.test_glue_fusions_gpu(perf(qwen35): fewer glue launches in the target graph (q8_1 memo, strided gates, gate|up stack) #948's): bit-identical across its 5 arms.test_gdn_replay_log: the host-validated commit writes the device-validated commit's bits (272 B and 12 B rows, an inactive lane, partial and empty prefixes); a refused preflight changes nothing.test_gdn_single_commitand its GPU arms (perf(qwen35): one replay commit instead of three GDN state copies per DFlash step #946): pass.Merge Danger
Door: two-way. Every change is local to its kernel or graph rule, with no format, API or file change, and reverts cleanly. Everything but split-k is bit-exact against the code it replaces. Split-k changes C>1 outputs at the rounding level, as any change to batch composition already does.
Blast Radius: mostly RDNA4. Ramifications:
mmq_x< 128, so the parent tiles and CDNA (MFMA) builds take it too. It only drops column tiles past the call's columns, so it is bit-exact; it was run and measured on the R9700 only.🤖 Generated with Claude Code