mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #5146] [Engine] DFlash2: opt-in Q4_0 GEMM variant table for gfx103x (STRATA_DF2_Q4_RDNA2=1) #5325
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#5325
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/5146
Author: @Vop3p
Created: 11/3/2026
Status: 🔄 Open
Base:
main← Head:df2-rdna2-q4-table📝 Commits (1)
3e15a40dflash2: STRATA_DF2_Q4_RDNA2=1 (opt-in, gfx103x): the Q4_0 GEMM variant by rows from dflash2_gemm_bench on 2x RX 6900 XT (21 / 38 / 20, 20-21% less GEMM time a round, bitwise the same)📊 Changes
1 file changed (+11 additions, -0 deletions)
View changed files
📝
src/kernels/cuda/dflash2.cu(+11 -0)📄 Description
Problem and result
df2_q4_autopicks variant 17 (tuned on sm_120) for every card except gfx12. On RDNA2 (gfx1030, RX 6900 XT) 17 is not the fastest variant for most of the drafter's matrices.dflash2_gemm_bench 50 q4finds bitwise-identical variants that cut the round's Q4_0 GEMM time by about 20%:That is card 0 of the PR build. Card 1 (a different board, same chip) gives 346.9 -> 278.1 us (-19.8%). All 304 variant/matrix entries are
bitwiseon both cards.With
STRATA_DF2_Q4_RDNA2=1, the table picks by rows: >= 6144 -> 21, >= 2560 -> 38, else 20. Without the variable, nothing changes: the lambda returns false and the function still returns 17. CUDA, gfx12 and every other HIP target are unaffected; the block sits inside the existing#if defined(STRATA_USE_HIP)and checksgcnArchNameforgfx103.End to end, the gain is small. On one RX 6900 XT running the whole model (DFlash2 alone,
--spec 6 --draft-conf 0.5), the draft step per window fell from 6.17 / 6.16 ms to 5.86 / 5.87 ms (-4.9%), in two interleaved pairs off/on/on/off. That is about 0.3 ms of a ~46 ms window, so the expected decode gain is ~0.7%. Measured tok/ms moved +1.7%, but most of that came from tokens per window differing between sampled runs, and the table cannot change acceptance (its results are bitwise the same), so I do not claim it.A data point that may be more useful than the patch: DFlash2 runs on gfx1030 (no upstream report so far), passes the standard protocol's 12/12 sanity checks, and on one card it beats the MTP drafter. Over the whole standard-protocol run (engine
STRATA_DECODE_TIMING, all decode tokens weighted):The standard protocol's own n=3 decode medians swing ±6-12% between rounds (sampling + thinking), so they cannot resolve a 3-5% difference; the tok/ms ranges above do not overlap. This roughly matches the 3-6% in
drafting.pyfor ~4,700 slots. On a two-card layer split the same drafter loses (-10 to -14% tok/ms against MTP + pipelined windows), because DFlash2 turns--pipeline-windowsoff; that is as documented, and the table does not change it.Related discussion
none (opt-in, per-architecture, bitwise-identical kernel choice, like the gfx12 line above it)
Approach
The patch adds one opt-in branch next to the existing gfx12 branch in
df2_q4_auto. It is opt-in rather than a gfx103x default for two reasons: it was measured on one chip only (two boards of the RX 6900 XT), and the end-to-end effect is below 1%. If you would rather make it the gfx103x default, the env check can go away; the result is bitwise the same either way.Validation
Environment: 2x RX 6900 XT (gfx1030, 80 CUs, 16 GB, PCIe 4.0 x8 each, cards at 245 W / -81 mV), Ryzen 5 5600X, 128 GB DDR4-3200, Ubuntu 26.04, kernel 7.0.0-42, ROCm 10.0 (
/opt/rocm/core-10.0clang, runtime/opt/rocm/lib).Passed:
ffa80d73+ one commit),-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: builds clean, including the targetsdflash2_parity,dflash2_q4_parityanddflash2_gemm_bench.dflash2_q4_parity, run on both cards withSTRATA_DF2_Q4_RDNA2set to 0 and to 1: exit 0 all four times, 160 "ok" lines, 0 failures.dflash2_gemm_bench 50 q4on both cards: the table above; 0 non-bitwise entries out of 304 per card.notes/tools/kernel_resources.sh(our script, which reads the code object) on the three selected variants: VGPR <= 96, 0 spills, 0 LDS.ctest -j 1(193 tests): 189 pass or skip, 4 fail.ple_parity,conversation_copy_streams_testandisa_guard_checkfail the same way on our v0.2.10 tree without this change.hip_prefill_mmq_paritydies with SIGFPE (exit 136) on this build, and it also dies with this commit'sdflash2.cuswapped back to main's and that target rebuilt, so this change does not cause it. Our production tree builds withSTRATA_GGML_DIRset to a llama.cpp fb5d45967 checkout and passes there; this branch uses the default ggml. I have not looked further.strata.py bench run --track custom --optional-concurrency. Runs: four arms in one window (off/on/on/off), plus the five-arm × 2 drafter comparison above. Every arm 12/12, 0 stalls.Failed:
Not run:
#if defined(STRATA_USE_HIP), so no code reaches them, but I did not build them.Limits
Measured on one chip only. The end-to-end gain is under 1% because the Q4_0 GEMMs are only part of the draft step: a
STRATA_DF2_PROFILE=1run on the two-card setup put them at 1.88 ms a round, with the head at 0.58 ms and attention at 0.40 ms. The rest of the step is unchanged. Remaining work on the drafter for this card, if anyone wants it, is outside the GEMM: the draft head and the attention.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.