mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #2020] [CLOSED] prefill: gfx11 F16 matrix-core routed experts (opt-in STRATA_PF_F16=1): prompt +10-14% on gfx1151 #3812
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#3812
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/2020
Author: @libratechw
Created: 10/12/2026
Status: ❌ Closed
Base:
main← Head:pr/f16-experts📝 Commits (2)
13b30a4prefill: the routed experts on gfx11's F16 matrix cores (opt-in STRATA_PF_F16=1)ae38fd5docs: STRATA_PF_F16=1 on gfx1151 (what it covers, the layer and prompt times, first-token KL)📊 Changes
7 files changed (+868 additions, -10 deletions)
View changed files
📝
CMakeLists.txt(+9 -1)📝
docs/STRIX_HALO.md(+9 -0)➕
src/prefill/moe_f16_common.cuh(+250 -0)➕
src/prefill/moe_f16_kq.cu(+345 -0)➕
src/prefill/moe_f16_kq.hpp(+43 -0)📝
src/prefill/moe_fused_iq.cu(+183 -6)📝
tests/cuda/prefill_fused_iq_test.cpp(+29 -3)📄 Description
Title
Issue: Refs #1258
Summary
With
STRATA_PF_FUSED=1the routed experts of a prompt run on gfx11's int8 matrix cores, each weight sub-block decoded to int8with a per-block epilogue.
STRATA_PF_F16=1runs the covered formats on the F16 matrix cores instead: the codes stay packed inLDS, each wave turns its own rows into F16, and the F16 WMMA accumulates all of K in FP32. The K-quant kernels adapt gufo's
RoutedF16GEMMKernel(97b8645f, MIT; attribution and licence text at the top of both new files). The output differs from theint8 kernels', so it is off by default; gfx12 keeps the int8 kernels.
What changed
src/prefill/moe_f16_common.cuh(new): the switch, the work item, the activations staged as F16, the WMMA loop, the twoepilogues.
src/prefill/moe_f16_kq.cu/.hpp(new): Q4_K / Q5_K gate/up and Q5_1 down (withSTRATA_PF_FUSED_KQ=1). They read theweights 16 / 8 bytes at a time, so each of gate/up and down takes them only when the batch's blobs, offsets and row
strides are aligned to that (the native blobs are promised 2 bytes); otherwise that half stays on its int8 kernel. gfx906,
whose build leaves this file out, covers nothing here.
src/prefill/moe_fused_iq.cu:native_f16_kernelfor IQ2_XXS / IQ2_XS / IQ2_S / IQ3_XXS / IQ3_S / IQ4_XS gate/up and Q2_0 /IQ4_NL / Q8_0 down (through the existing 16-bit loads), and the dispatch.
tests/cuda/prefill_fused_iq_test.cpp,CMakeLists.txt: withSTRATA_PF_F16=1on a gfx11 device the test allows 5e-3against the int8 model and MMQ (measured 2.7e-3) and places the blobs 256-byte aligned, so the F16 kernels are what it
checks; elsewhere the int8 limits stay. ctest
hip_prefill_fused_iq_f16runs the default pairs with the switch,hip_prefill_fused_iq_f16_kqthe four K-quant pairs (it setsSTRATA_PF_FUSED_KQ=1too).docs/STRIX_HALO.md: what it covers, the layer and prompt times, first-token KL.Ryzen AI Max+ 395 (gfx1151, ROCm 7.14.1, Linux), on
296b59d2. One layer,hip_prefill_fused_iq, 16,384 tokens, top 10 over512 experts, median of 3:
Prompt tok/s, the branch's binary without and with
STRATA_PF_F16=1,--serve --prefill 16384 --spec 4, the section-5switches with
STRATA_PF_SWITCH_MIN_T=2048(UD-Q4_K_XL alsoSTRATA_PF_FUSED_KQ=1), a chat request of 4K / 32K tokens,fresh servers alternating, 5 pairs after dropping those with page migration or reclaim; median tok/s and the median of the
pair ratios, every pair faster:
The UD-Q4_K_XL 32K cell is of this code; the layer times and the other three cells are of an earlier head with the same
kernels (before the alignment check and the test changes). Without the switch, the layer's output hashes (six pairs, 2,048
and 16,384 tokens) are 296b59d2's.
First-token KL against a run with no switches, 12 natural-text chat requests of 1.5K-24K tokens, mean (median); the fast arms
with
STRATA_PF_SWITCH_MIN_T=0; the top token is the same in 12 of 12 in every arm:STRATA_PF_F16=1F16 moves further from the default than the int8 path, so this stays opt-in. The records and scripts are in
libratechw/Strata@e5d05554,
2020/.Builds and tests:
hip_prefill_fused_iq*among them), 5 skip, and the samethree fail as on
296b59d2(ple_parity,expert_parity,pool_test).moe_fused_iq.cuandmoe_f16_kq.cucompile for gfx1012, gfx1030, gfx1100, gfx1103, gfx1150, gfx1151, gfx1200 andgfx1201 (77506be1; the head changes neither file). gfx906:
moe_fused_iq.cuno longer leaves thef16kqfunctionsundefined (it did at 77506be1); the whole gfx906 build stops earlier, at
mmq_nvfp4_w4a4.cu(ggml'svendors/cuda.h),which this branch does not touch.
test comment and the doc): builds; ctest, 117 tests: 114 pass, 2 skip, and
ple_parityfails as on296b59d2.Not run: other gfx11 cards (gfx1100-1103, gfx1150), and quality beyond the first-token KL.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.