mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5476] [Engine] gfx103x decode: opt-in one-warp MMVQ for K <= 4096 and a per-format expert layout table (STRATA_MMVQ_NW1, STRATA_EXP_TABLE) #5453
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5453
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/5476
Author: @Vop3p
Created: 11/7/2026
Status: 🔄 Open
Base:
main← Head:pr/gfx103x-decode-tables📝 Commits (1)
ca4a88dgfx103x decode: opt-in one-warp MMVQ for K <= 4096 (STRATA_MMVQ_NW1) and a per-format expert layout table (STRATA_EXP_TABLE)📊 Changes
2 files changed (+23 additions, -1 deletions)
View changed files
📝
src/kernels/cuda/iq_kernels.cu(+14 -1)📝
src/kernels/cuda/native_mmvq.cu(+9 -0)📄 Description
Problem and result
Two decode-window kernel choices on gfx1030 (RX 6900 XT). Both pick code that is already in the tree; neither adds a kernel.
STRATA_MMVQ_NW1=1:launch_multi_nlaunches the dense multi-column MMVQ (qkv / gate / q / shared expert at T = 2..4) with 4 warps and 2 rows per block. On gfx1030 with cold weights, the existing templatenative_mmvq_multi_kernel<F, NCOLS, 1, 1>(one warp, one row per block) is faster for K <= 4096. The opt-in only changes the dispatch, and K = 6144 (out) keeps the default. Kernel times, same binary off/on:Not bitwise: one warp per row sums in a different order, with a relative difference < 1e-5.
STRATA_EXP_TABLE=1:native_expert_groupedhas oneexp_mode()for every format, but on gfx1030 the best existing layout depends on the format. A sweep of modes 2..8 against mode 0 withnative_expert_bench(every result bitwise equal) found gate/up IQ2_S and IQ3_S fastest at mode 8 and down Q2_0 fastest at mode 4. IQ3_XXS gate/up and IQ4_NL down are fastest at mode 0; IQ4_NL down is 7-15% slower at mode 8. No single global mode works, so the table picks per format and leaves every other format at the card's default. A strided call (grid_groups < cap_groups) and an explicitSTRATA_EXP_MODEkeep their layout. Bitwise identical to mode 0.The verifier calls
native_expert_groupedwith cap = n x top-k (n = window tokens), and the real group count is only on the device. So the table was measured at that cap (BENCH_CAP) over the possible group shapes, for a whole layer's expert step, against mode 0:Full overlap is rare in real decoding. In 266K recorded verify-window routings from our production runs, 59% of windows have 3 tokens, with a median of 23 distinct expert groups out of a possible 30. Of the entries in those windows, 57% sit in a group of 1, 30% in a group of 2 and 13% in a group of 3. 25% of windows have 1 token, 15% have 2, and 1.3% have 4 or 5.
End to end, 2x RX 6900 XT, 10 cold-start interleaved pairs, both variables off vs on, same binary:
The output text differs from off (MMVQ_NW1 is not bitwise), but each arm produced the same text in all 10 runs, and the number of windows was within one (122/122 at 4K, 126/127 at 32K), so tok/s here is a fair measure.
Related discussion
none (opt-in kernel selections between existing kernels and layouts, measured on one architecture)
Approach
MMVQ_NW1: a static env check inlaunch_multi_nafter the existingb6_launchhook, and only forn_in <= 4096.EXP_TABLE: a static env check that is ignored whenSTRATA_EXP_MODEis set. gate/up mode 8 forgu_typeIQ2_S (22) / IQ3_S (21), down mode 4 ford_typeQ2_0 (42), otherwise the existing choice. It is skipped for strided calls, like the existing CUDA-layout rule above it, and not compiled for gfx906.Validation
Environment: 2x RX 6900 XT (gfx1030, 16 GB, PCIe 4.0 x8 each), Ryzen 5 5600X, 128 GB DDR4-3200, Ubuntu 26.04, kernel 7.0.0-42, ROCm 10.0 runtime (
/opt/rocm/lib).Passed:
54828c7e+ this change,-DSTRATA_ENABLE_HIP=ON -DCMAKE_HIP_ARCHITECTURES=gfx1030 -DSTRATA_NATIVE_EXPERTS=ON -DSTRATA_PREFILL_MMQ=ON -DSTRATA_Q6K_EXPERTS=ON -DGGML_HIP_GRAPHS=ON -DGGML_HIP_NO_VMM=ON -DSTRATA_BUILD_TESTS=ON.native_expert_benchat the verifier's cap: 33 shape/layer/mode combinations, all bitwise equal to mode 0 (layers 1 and 17, one card, 50 iterations).launch_multi_n, not part of this PR).ctest -j 1: 221/224. The three failures are the same on main54828c7ewithout this change:ple_parity(Q2_0 gguf relative path),conversation_copy_streams_test(148 MiB first copy stream) andisa_guard_check(CPU iq512 function).--spec 3 --spec-min-p 0.6 --pipeline-windows 1 --kv int8, parallel 1, our usual HIP env.benchmark.py4K + 32K, 256 tokens each, arms alternating. 0 stalls.Failed:
Not run:
STRATA_MMVQ_NW1is not behind a HIP#if: if set on CUDA, it would also take the one-warp template. That path is untested there. Tell me if you want it limited to HIP.EXP_TABLEis bitwise.MMVQ_NW1changes the summation order (< 1e-5 relative), and I did not run KL for it.Limits
Developed with an AI coding assistant; every number above was measured on the machine described in Validation.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.