mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#3540
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/1570
Author: @jkuepker
Created: 10/8/2026
Status: ❌ Closed
Base:
main← Head:gfx12-native-wmma📝 Commits (2)
c5d1885HIP gfx12: native int8-WMMA prompt experts on gfx1200/gfx1201 (opt-in STRATA_PF_FUSED=1, #1277)e667a77docs: gfx12 (R9700) native WMMA prompt experts: switch, measurements; gfx12 in the comments📊 Changes
10 files changed (+153 additions, -28 deletions)
View changed files
📝
CMakeLists.txt(+1 -1)📝
docs/AMD_HIP.md(+12 -0)📝
docs/DETAILS.md(+1 -1)📝
include/strata/kernels/gfx_arch.hpp(+6 -1)📝
include/strata/prefill/moe_fused.hpp(+3 -1)📝
include/strata/prefill/moe_fused_iq.hpp(+2 -1)📝
src/prefill/moe_fused.cu(+2 -1)📝
src/prefill/moe_fused_iq.cu(+110 -16)📝
src/prefill/prefill.cpp(+3 -2)📝
tests/cuda/prefill_fused_iq_test.cpp(+13 -4)📄 Description
Title
Issue: Resolves #1277
Summary
STRATA_PF_FUSED=1runs the native IQ packs' prompt experts on the int8-WMMA kernels insrc/prefill/moe_fused_iq.cu(native_w11_kernel). Those kernels were gfx11-only: on RDNA4 the flag was accepted and MMQ stayed in use, with no banner. This PR makes them build and run on gfx1200 / gfx1201. The arithmetic is the same as on gfx11; the difference is gfx12's WMMA lane layout.The path stays opt-in. It rounds differently from MMQ, and
include/strata/core/arch_defaults.hppholds only bit-exact switches, so this PR does not toucharch_defaults.STRATA_PF_FUSED_NATIVE=0keeps MMQ with the flag set, as before.Measured on a Radeon AI PRO R9700 (gfx1201), Coder IQ1_M pack, MMQ (default) against
STRATA_PF_FUSED=1:hip_prefill_fused_iq: all 10 IQ gate/up + down pairs, plus Q4_K / Q5_K)STRATA_PREFILL_MMQ=0), meanRead the quality rows with their limits:
What changed
src/prefill/moe_fused_iq.cuSTRATA_NAT_W12for__gfx1200__/__gfx1201__,STRATA_NAT_WMMAfor either family. The kernel calls the_gfx12spelling of the iu8 WMMA builtin (the un-suffixed one does not compile on gfx12). Any other target keeps the trapping body.uint2at the matching offsets; each 16-value k step is still one WMMA, so the per-16 scales of IQ2_S / IQ2_XS are untouched. A lane's 8 accumulator rows are consecutive, so a feature's gate and up sit in the same lane: SwiGLU needs no__shfl_xor, and the down tile is stored as twofloat4per lane.dev_info()takes the gfx11 list or gfx12 and also checks that the loaded kernel is the real one (a gfx12-generic or SPIR-V build on a listed card gets the trap stub, which still passeshipFuncGetAttributesand the occupancy query).native_supported()reads theSTRATA_PF_FUSED=1opt-in itself, becausefused::available()/requested()belong to the Q2_0 pack'sexpert_w11_kernel, which is not ported and stays false on gfx12. Off gfx12 the result is unchanged.STRATA_PF_OCC_W=Noverrides it. gfx11 keeps 4.experts_native()refuses admthat is not 16-byte aligned on gfx12 (thefloat4stores); the prompt path's buffers always are.include/strata/kernels/gfx_arch.hpp:gfx_arch_is_gfx12_wmma(), an exact gfx1200 / gfx1201 match (never a prefix), like the gfx11 helper.src/prefill/moe_fused.cu: the device check compares the gfx11 list (gfx_arch_is_gfx11_wmma) instead of the"gfx11"prefix. Same result on every listed part (gfx1100 / 1101 / 1102 / 1150 / 1151); a gfx11 part outside the list no longer matches by prefix.moe_fused_iq.cudoes the same indev_info().src/prefill/prefill.cpp(fused_ring()): a native pack asksnative_supported()alone, where it used to askfused::enabled()first. On gfx12enabled()is false while the native layers do run fused, so without this they would keep MMQ's buffer layout and ring. For the Q2_0 pack the check is stillfused::enabled().include/strata/prefill/moe_fused.hpp,moe_fused_iq.hpp: comments only (the gfx12 case, the 16-byte alignment).tests/cuda/prefill_fused_iq_test.cpp: runs on gfx12 (the skip gate also asksnative_supported()), adds the other four pairs of the Coder IQ1_M pack,S20_Esets the expert count (256 for the Coder pack), and the real-shape check of fused against MMQ is now rel RMS <= 1e-3 and worst row <= 2e-2, where it was rel RMS <= 0.05.docs/AMD_HIP.md: a bullet in the RDNA4 speed switches (what the flag does on gfx12, the start-up line, the numbers above, what was not run).docs/DETAILS.md: theSTRATA_PF_FUSED=1sentence says where the native kernels run on HIP.CMakeLists.txt,include/strata/kernels/gfx_arch.hpp: comments that said these kernels are gfx11 only now include gfx12 (comments only).Extra Notes
How it was tested
-DCMAKE_HIP_ARCHITECTURES=gfx1201.STRATA_PF_FUSED=1and the log path. 3 alternating starts per arm (A B A B A B). Speed from localeval at 4,096 / 16,384 / 32,768 tokens, 3 requests per size, 128 generated tokens, noSTRATA_PREFILL_TIMING. 54 measured requests, every one with 0 reused tokens. The "prompt experts on the fused int8 kernels" line appeared in every fused start and in no MMQ start. The gain in each start pair was +15.2 / +19.1 / +19.3% (4K), +8.2 / +8.3 / +8.5% (16K) and +8.7 / +8.5 / +8.6% (32K); the spread between starts of one arm was 0.1-3.7%.--serve(STRATA_DUMP_FIRST_LOGITS; the run used a local 9-line serve-loop hook that overwrote one file per request; it is not part of this PR, and upstream has since added the same capability in421e163, which writes<path>.<n>), KL computed in float64 from the raw vocab rows. The FP16 reference arm ran the same 66 request bodies as the other two arms (48 x 4K, 8 x 16K, 8 x 32K, plus a determinism canary), all with 0 reused tokens.hip_prefill_fused_iqpasses on the R9700;hip_prefill_fused_moeexits 77 (skip), because the Q2_0 pack's kernels are not ported to gfx12.Rebased build
The numbers above were taken on the development branch before it was rebased onto
fb58e0d. The kernel, header and test files in this PR are byte-identical to what was measured;prefill.cpp(5 lines) now sits on upstream's newer version. The rebased port commit was built for gfx1201 and run again on the R9700 (the second commit changes only docs and comments):hip_prefill_fused_iqpasses, with output byte-identical to the pre-rebase logs (all 10 IQ pairs plus Q4_K / Q5_K, and the same output hash for the IQ2_S / Q2_0 real-shape layer).hip_prefill_fused_moeexits 77 (skip) andarch_defaults_testpasses.ctest -R "hip_prefill_fused|arch_defaults": 3 of 3 pass or skip.hip_prefill_fused_iqtakes 54 s against its 600 s ctest timeout.For reviewers
The test's real-shape gate (fused against MMQ) went from rel RMS <= 0.05 to rel RMS <= 1e-3 and worst row <= 2e-2. The 4 added pairs also run on every backend. Both were measured only on gfx1201 (rel RMS 1.3-1.9e-4, worst row 2.9e-3 to 8.3e-3). If
prefill_fused_iq_testfails at the new bound on sm_80+ or gfx1151, loosen the bound; the kernels are not the cause.On gfx11 the changes are meant to change nothing. The places to check on a gfx1151:
dev_info()insrc/prefill/moe_fused_iq.cu, around line 1038: the exact gfx11 list instead of the prefix, plus the LDS check;src/prefill/moe_fused.cu, around line 611.hip_prefill_fused_iqshould still pass there, andSTRATA_PF_FUSED=1should still print the banner.Not tested
moe_fused.cu,moe_fused_iq.cuandprefill.cppare shared with those targets; the changes there are written to leave them as they were (see "What changed"), but nothing was run on them for this PR.STRATA_PF_FUSED_KQ=1): the Q4_K / Q5_K pairs pass the parity test on gfx12, but there is no end-to-end run.expert_w11_kernel(moe_fused.cu) is not ported; a Q2_0 pack on gfx12 keeps MMQ.Related
bench/results/2026-10-03-community-r9700-windowsfound "no observable effect" ofSTRATA_PF_FUSED=1on an R9700 and no banner. That fits the old behaviour: the flag did nothing on gfx12 before this change.🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.