Skip to content

HIP prefill train 2026-10-29: 27B -15..-20%, Flash-Next QSA tc2 + MoE K64 (gfx1151) - #235

Merged
AzeezIsh merged 23 commits into
mainfrom
train/hip-prefill-2026-10-29
Oct 29, 2026
Merged

AzeezIsh merged 23 commits into
mainfrom
train/hip-prefill-2026-10-29

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

HIP prefill train, 2026-10-29 (gfx1151 / Strix Halo)

One train per platform, --no-ff merge commits, off main 87df79b2f. Every component is HIP-only: its kernels live under kernels/strix-hip/, and its Rust is gated on cfg(atlas_hip), or cfg!(atlas_scale) && !cfg!(atlas_hip) for SCALE. NVIDIA builds see no change.

Components

merged branch what evidence
fix/hip-moe-grouped-min-256 MoE grouped-prefill threshold 1024 → 256 ST-995 84.32 / 82.22 (framework f59) — #145
perf/hip-qsa-verify-active-default MTP stays on past the QSA bound on HIP MTP1 decode 12.1 → 18.75 tok/s at 8k, 17.64 at 32k (f58) — #143 / #144
perf/hip-w4a16-f16a-single-lds NVFP4 F16 GEMM: B-fragment reuse + one LDS buffer bit-identical; part of the +4% set (s56) — #72
perf/hip-moe-f16a-k64 MoE F16 twins: one LDS buffer + 64-wide K step + padding-warp skip bit-identical; Flash-Next −3 to −4% (f73), kernel 1.09–1.17× (s79) — #144
perf/hip-w8a16-n-m128-interior FP8 GEMM interior CTAs take a branch-free load loop bit-identical — #72
perf/hip-fp8-prefill-dequant-blas 27B FP8 projections at M ≥ 1024: dequant once to scratch (8 per thread) + hipBLASLt 27B −7 to −9% (s62) and a further −5% (s70); ST-995 84.42 / 75.17 (s63); agentic 50/50 (s68) — #72
f86ccb6ef (perf/hip-prefill-paged-br64) paged prefill attention _64 at BR=64 on all 8 warps bit-identical; −7 to −8% at 14k (s74) — #72
perf/hip-qsa-attn-tc2 native HIP WMMA qsa_attn_tc2.cu + default ON for atlas_hip Flash-Next −10% at 7.4k, −12% at 12.5k (f66 / f68); needles 12/12, dense ppl identical, above-bound +0.08% (f67) — #144

Combined (already measured as stacks)

  • 27B (test/prefill-9 = this train's 27B-relevant content): −15 to −20% prefill vs main (s75), 236 → 283 tok/s at 7.4k. ST-995 on that exact stack: 84.52 / 75.36 (main 84.12 / 74.65, s83).
  • Flash-Next: main 720 tok/s → +tc2 800 → +MoE K64 826 tok/s at 7.4k.

This train's own verification (before merge)

  • strix s88: 27B main vs this train; 2k / 8k / 14k ×3 + probes.
  • framework f76: Flash-Next main vs this train; 2k / 7.4k / 12.5k ×3 + probes.

Results get posted here, and the merge waits for both. After merge: an AMD build + serve check of the new main.

Not included

  • f96e0fe04: parallel softmax on top of BR64. Bit-identical, 1.05–1.12× kernel bench, but not yet verified end to end (s87).
  • The Flash-Next --max-prefill-tokens 8192 recipe: the agentic pair is still running.

🤖 Generated with Claude Code

AzeezIsh and others added 23 commits October 27, 2026 12:22
…an experts per token)

On native HIP, NVFP4 MoE prefill below ATLAS_HIP_MOE_GROUPED_MIN_TOKENS falls
back to per-token expert GEMVs. The 1024 default was a 2026-09-20 winbox
crossover, measured while a grouped call cost ~15 ms almost regardless of N.
now costs far more than it saves. A warm agent turn adds a few hundred
tokens, so every such turn ran its experts per token (framework f42: one
423-row chunk spent ~7 s in moe_expert_*_shared_t).

64 is the bound the bf16/fp8 arms above already use. Flash-Next NVFP4,
framework gfx1151 Linux, b9ab4ed54, f46, cold TTFT 1024 -> 64:
  132 tok 2.50 -> 0.81 s, 253 tok 4.63 -> 1.07 s, 470 tok 8.36 -> 1.09 s,
  649 tok 11.61 -> 1.31 s; 1035/1676 tok unchanged (already grouped).
  Marconi resume, 6.1k prefix + 300 new tokens: 5.76 -> 1.36 s.
Greedy output on a 300-token prompt changes by one word ('linking' ->
'combining'). Short prefills now take the same grouped arithmetic every
prompt of 1024+ tokens already used. Accuracy and agentic gates run with
this exact value (framework f47 agentic, f48 ST-995). HIP-only (cfg gate),
NVIDIA byte-unchanged; also covers the other NVFP4 MoE models on HIP.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ast the inert bound, +56% at 8k)

On gfx1151 the switch defaulted OFF ('unmeasured there'). As a result,
Flash-Next MTP stopped as soon as QSA selection activated past ~2k
tokens, and long-context decode ran at AR speed.

Framework f55 (main 8863dc5, Flash-Next NVFP4, MTP1, Gufo-matched rows):
- tg at 8k / 32k cached depth: 12.1 -> 18.9 / 18.0 tok/s;
- tg at depth 0: unchanged (18.6);
- C>1: unchanged (the multi-sequence guard refuses rows of several
  sequences).

This matches GB10's #70 measurement (+56% at 5.1k), which flipped NVIDIA's
default.

Accuracy: every gfx1151 Flash-Next ST-995 and agentic gate run this week
already set =1:
- f05 84.12/81.47;
- f22 84.12/82.33;
- f48 84.52/81.97;
- agentic f47/f51/f53.
So the new default is the configuration those gates measured.

The flip is native HIP only (atlas_scale && !atlas_hip stays OFF). SCALE
strix is still unmeasured. =0 still restores the refusal.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… 64-row halves (no spill)

The F16 NVFP4 prefill GEMM (27B dense FFN, 43.5% of a cold 7.4k 27B prefill on
strix, s40) ran its ch loop outermost. Every B fragment was therefore loaded
from LDS twice per 32-K step, once per 64-row half: 32 B-fragment reads
feeding 32 WMMA.

With h/nb outer and both halves inner, each B fragment is read once and feeds
acc0 and acc1: 16 reads per step. Each accumulator still sees the same
operands in the same h order, so the output is bit-identical.

Side effect: VGPRs drop from 256 (+2 spilled, 12 B scratch) to 249 with no
spill.

Bench and bit-identity check: strix s41.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
moef_body, the body of moe_w4a16_fused_gate_up_t_f16a and
moe_w4a16_grouped_gemm_ptrtable_t_f16a, double-buffered its A/B tiles in
31 KB of LDS. That allows only 4 CTAs per WGP, and on gfx1151 the F16
prefill GEMMs measure LDS-occupancy-bound: the dense twin reads 5.35 waves
per CU, strix s40 rocprofv3.

One buffer halves the footprint, so twice the CTAs fit. The register
prefetch still overlaps the next tile's global loads with this tile's WMMA;
the cost is a second barrier per K-step. Each accumulator sees the same
operands in the same order, so the output is bit-identical.

Not yet measured: pending the dense-twin result (s44) and a Flash-Next
prefill A/B.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…bound on gfx1151)

rocprofv3 on strix (s40) measured 5.35 waves per CU for this kernel, with
DRAM read at 46 GB/s and MemUnitBusy at 40%. Its 41 KB of double-buffered
LDS fits only ~3 CTAs in a WGP's 128 KB.

One buffer halves that. The register prefetch keeps the next tile's global
loads overlapping this tile's WMMA, at the cost of a second barrier per
K-step. Combined with the B-fragment reuse in the previous commit, VGPRs
are 248 with no spill.

Measured in one process with a rotating arm order, 15 rounds x 5 reps,
medians (strix s45 / s45b, gfx1151), main -> this:
  27B gate/up 2048x17408x5120   21.9 -> 25.3 TF/s
  27B down    2048x5120x17408   21.1 -> 24.3
  27B attn    2048x6144x5120    20.2 -> 25.7
  FNext attn q 2048x12288x2560  19.2 -> 22.8
  FNext 2048x16384x2560         19.3 -> 24.8
  27B gate/up M512              18.3 -> 22.5
The output hash is identical to main on every shape.

The B-fragment reuse alone was 16-25% slower (more live VGPRs at the same LDS
occupancy). Single buffer alone is +7..+16%. Both together: +15..+28%.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On gfx1151 the K-loop of this FP8 prefill GEMM runs 615 instructions per
32-K step for 16 WMMA: 204 SALU and 19 global loads, mostly the per-element
fallback paths of W8N128_LOAD_REGS unrolled into the hot loop.

Interior CTAs now run a loop whose loads are plain aligned 16-byte vectors.
Interior means the whole 128x128 tile is inside M x N and K % 16 == 0, which
covers every production shape. Edge CTAs keep the general loop. Both load the
same bytes, so the output is unchanged.

strix s51, one process, interleaved, medians, base -> interior:
  2048x12288x5120  15.76 -> 16.54 TF/s
  2048x5120x6144   14.62 -> 15.35
  2048x1024x5120   13.43 -> 15.80
  2048x6144/5120x5120  +1%
  2000x6144x5120 (tail tiles take the general loop)  15.28 -> 15.13
relL2 vs an fp64 reference is identical to base on every shape.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Same-build agentic-webserver A/B on framework, Flash-Next NVFP4, 50 iterations:
  1024 (main): 50/50 webserver_ok, 50/50 directions; Sigma wall 15,441 s;
               median TTFT 5.08 s (f51)
    64:        45/50 and 47/50 (two runs, f47/f53); every failure was
               'no Cargo.toml was written'
   256:        49/50, 50/50 (one /ping timeout); Sigma wall 13,049 s;
               median TTFT 3.65 s (f57)

256 keeps the warm-turn win on every chunk of 256 rows and up (470 tok
8.36 -> 1.06 s, 649 tok 11.61 -> 1.30 s). Shorter chunks stay on the
per-token path that 1024 used. ST-995 at 256: framework f59.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…SLt at M >= 1024

w8a16_gemm_n_m128 dequantizes every B tile inside its K loop once per
128-row M tile, which is 16x over at a 2048-row prefill chunk. It runs at
14-19 TF/s. The NVFP4 GEMM and rocBLAS BF16 reach 25-28 TF/s on the same
box, against a WMMA peak of ~48 TF/s (strix s59/s60).

On HIP with M >= ATLAS_HIP_FP8_BLAS_MIN_M (default 1024, 0 = off), the op
now:
  1. dequantizes the weight into a per-stream BF16 scratch, using the
     existing dequant_fp8_blockscaled_bf16 kernel (E4M3 x FP32 block scale
     -> BF16 RNE, the same operands the fused kernel feeds its WMMA);
  2. runs bf16_gemm (hipBLASLt).
It falls back to the fused kernel if the dequant kernel, scratch or BLAS
is unavailable.

strix in-process bench at M=2048 (s61), with rocBLAS standing in for
hipBLASLt:

  GDN qkvz 16384x5120  18.3-19.2 -> 13.5 ms
  attn q   12288x5120  13.6-15.1 -> 10.0-10.9 ms
  attn k/v  1024x5120   1.2-1.3  -> 0.93 ms
  GDN out   5120x6144   7.2      -> 6.7 ms

99.1% of outputs are bit-equal, relL2 2e-4, from accumulation order only.
Not bit-identical end to end: this needs probes plus an accuracy gate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…x1151)

On HIP, qsa_prefill_attn_tc2 had no kernel: try_kernel returned 0 and
prefill always ran the scalar qsa_prefill_attn_g. That kernel reaches
~2.2 TF/s and is 22.6% of an 8k Flash-Next NVFP4 prefill (framework f60).

This adds a native HIP qsa_attn_tc2.cu with the same entry name, the same
arguments and the same grid ([1, rows], 128 threads), so the existing
launcher drives it under ATLAS_QSA_ATTN_TC2=1. gfx1151 keeps default OFF
until it is measured.

The body is strix-hip's validated inferspark_prefill_paged_64 WMMA kernel
(bf16 QK^T, smem online softmax, FP16 PV). Only the addressing changes,
as in gb10's tc2:
  - the M tile is the two kv heads' q-heads of one row;
  - keys are gathered through the row's selection list, with per-token
    offsets computed once per BC=32 tile;
  - there is no causal mask.
LDS is ~56 KB.

Not bit-identical to _g (different summation tree, FP16 P). This is the
same numerics class as gb10 tc2, whose gate is ppl + needles.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
f66 (framework, Flash-Next NVFP4, interleaved x3): cold TTFT 7.4k
10.25 -> 9.21 s (-10%), 12.5k 17.83 -> 15.69 s (-12%). Unchanged below
the 2051-token QSA bound.

f67 gate, the one gb10 tc2 was defaulted on with:
  - dense ppl 9.6649 -> 9.6649, max |dlp| 0;
  - above-bound ppl 5.2421 -> 5.2464 (+0.08%);
  - needles 12/12 on both arms.
ppl.py's per-token clause (> 0.5 nats) trips above the bound. Any
non-bit-identical change there trips it, because QSA top-k is chaotic;
mean |dlp| is 0.090. ATLAS_QSA_ATTN_TC2=0 restores the scalar kernel.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dentical)

On the gfx1151 FP8 prefill route, dequant_fp8_blockscaled_bf16 runs once
per FP8 projection per chunk. Its one-element-per-thread mapping measured
3.8 ms per launch, 7.3% of a 16k 27B prefill (strix s69, 4.28 of 58.4 s
GPU).

dequant_fp8_bs128_bf16_v8 computes the same expression (copied LUT x FP32
scale -> BF16 RNE) on 8 consecutive k per thread, with one 8-byte load and
one 16-byte store, so the scratch is bit-identical. The route prefers it,
falls back to the old kernel when the twin is absent, and declines the
route when K % 8 != 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-identical)

The HIP _64 paged prefill entry was clamped to BR64=32 while its launchers
spawn 256 threads, so half returned at once and each K/V tile load fed only
32 query rows. At 64 rows on 8 warps (Q.K^T on warps 0-3, P.V as 4 row
groups x 2 d-halves), LDS is 62.6 KB, inside the 64 KB cap because K and V
already share one buffer.

Each row's arithmetic is unchanged (same BC=32 tiles in the same order,
same 16-row WMMA blocks, same per-row softmax), so the output is
bit-identical. Masked scores now contribute an explicit p = 0. That matches
the old value wherever a row has a valid key, and covers the one tile shape
BR=64 adds: a sliding-window row whose first tile is entirely masked.

strix kernel bench, 27B geometry, 2048-row chunk (s72): kv 2k 1.35x,
8k 1.61x, 16k 1.59-1.68x, 100% bit-equal. Attention is 25% of a 16k 27B
prefill (s69).

The paged / fp8 / nvfp4 _64 launchers use BR=64 on atlas_hip. The batched
_64 launchers always passed 64, so on the clamped kernel they left query
rows 32..63 of every 64-row band unwritten under Q12 kernel-batched prefill
(strix s73 checks this).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… warps (bit-identical)

moef_body gives each warp one 16-row accumulator set, so a 32-wide K step
issued only 16 WMMA between its two barriers, half the dense m128 kernel's
32. Even at ~160 rows per expert, with almost no padding, the twins ran
16-18 TF/s against the dense kernel's ~26.

A 64-wide K step does 32 WMMA per barrier pair (252 VGPRs, no spill, ~28 KB
LDS). Warps whose 16 rows all lie past M_expert also skip their WMMA: they
only computed padding that is never stored. Each output still accumulates
its 16-wide K blocks in the same order, so the result is bit-identical.

strix in-process bench, both variants loaded as code objects, Flash-Next
routing (512 experts, top-10), s78/s79:
  T=2048 (~40 rows/expert)    down 1.12-1.15x, gate/up 1.15-1.17x
  T=8192 (~160 rows/expert)   down 1.09-1.13x, gate/up 1.13-1.16x
100% bit-equal at every shape.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment-only. The tc2 default-flip note put qsa_prefill_attn.rs at 503
lines; the file-size check caps .rs files at 500.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

DevLab Strix runner: native strix-hip build of this train passes. Run 40817890718, job=build, ref=train/hip-prefill-2026-10-29, on an ephemeral DevLab Strix Halo runner (independent of the strix box running the benchmarks).

All 5 strix-hip targets compiled (118–126 kernels each) plus the HIP shims; release build finished in 2m41s, binary edf718af0b9248d9, 0 errors.

Why the previous DevLab run failed (run 40638076889): it was dispatched with ref: 8863dc5e5, an abbreviated SHA. actions/checkout only recognizes full 40-char SHAs, so it fetched refs/heads/8863dc5e5, which doesn't exist, and failed before building. The runner was healthy. Dispatch with a branch name or a full SHA.

Pending before merge: strix s88 (27B, main vs train) and framework f76 (Flash-Next, main vs train).

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Train verification complete. The boxes verified ee68c7da8. The PR head 1efcaf007 adds only a comment trim (fb275ad6c) and rustfmt (1efcaf007), with no code change.

strix s88, 27B NVFP4 (main 87df79b2f vs train, cold TTFT, interleaved ×3):

prompt main r2 / r3 train r2 / r3 Δ
~1.8k 6.87 / 6.60 s 5.83 / 5.93 s −10 to −15%
~7.4k 30.82 / 31.83 s 25.86 / 25.74 s −16 to −19%, 235 → 286 tok/s
~14k 71.01 / 73.47 s 56.52 / 59.49 s −19 to −20%, 196 → 244 tok/s

Probes: greedy-identical on all four. Mean |Δlp| 0 / 0 / 0.019 / 0.024, exactly the FP8 route's value from s62.

framework f76, Flash-Next NVFP4 (main vs train, each at its own defaults):

prompt main r1 / r2 / r3 train r1 / r2 / r3 Δ
~1.9k 2.09 / 2.06 / 2.04 s 2.02 / 1.98 / 1.96 s −3 to −4%
~7.4k 10.17 / 10.26 / 10.28 s 8.81 / 8.85 / 8.85 s −14%, 720 → 834 tok/s
~12.5k 22.53 / 22.18 / 21.89 s 15.12 / 15.15 / 19.25 s −32% (r1–r2), 566 → 830 tok/s

Main at 12.5k is slow because of its 1024 MoE grouped threshold, which this train lowers to 256 (ST-995 84.32 / 82.22, f59). The r3 19.25 s is an outlier, to watch on the post-merge check. Probes: short and code identical. 2k diverges at char 214, the MIN=256 MoE path, which ST-995 gated. 10k diverges at char 218, tc2, gated by f67's ppl + needles.

Accuracy on the stacked 27B content (test/prefill-9): ST-995 84.52 / 75.36 (s83, main 84.12 / 74.65); agentic 50/50 webserver_ok + followed_directions, Σwall 9,846 s (s84, ref 50/50 in 9,926 s).

CI: test, clippy, fmt, deny, llvm-cov, GB10 nvcc→PTX and 500-LoC all pass. DevLab Strix native build passes (run 40817890718). PR benchmark gate is red with the same repo-wide record invalidation (records from 0ad9897308, GB10 subjects) that #217, #219 and #228 merged with.

Merging with a merge commit. A post-merge AMD build + serve check of the new main follows.

@AzeezIsh
AzeezIsh merged commit b5a8f6b into main Oct 29, 2026
25 of 26 checks passed
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Post-merge check of main b5a8f6b15 (this merge).

  • strix s89: native strix-hip build of all models OK (binary 18e31b9945f8). Serves nvidia/Qwen3.8-27B-NVFP4 on the MTP recipe; coherent output; faults 0 (ERROR / panics / illegal / watchdog); decode ~20.7 tok/s.
  • DevLab Strix run 40821938694 (ref = full merge SHA, job=build): success.
  • framework f77 (Flash-Next serve + probes on the merged main) is queued behind the running agentic job; result to follow here.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Post-merge concurrency check: no regression from this merge (strix s90 / s91). The FP8 route keeps a per-stream BF16 scratch, and every earlier check was single-stream, so I tested C=4. Setup: 27B, MAX_BATCH=4 --max-num-seqs 4, four different 2.8–5.1k-token prompts (the FP8 route engages at M ≥ 1024), sent concurrently ×2 rounds vs each alone, greedy 64 tokens.

main concurrent outputs == solo
b5a8f6b15 (with #235, s90) 4/8 (streams 0, 1 differ; 2, 3 match)
87df79b2f (before #235, s91) 2/8 (streams 0, 1, 2 differ; 3 matches)

Outputs are coherent in every case. Where they differ, the concurrent text is the same on both builds (e.g. stream 1: solo "Section 1, Source…" vs concurrent "Section 0, Definit…"). So this is pre-existing C>1 batched-decode numerics: a different summation order than a solo stream. It isn't scratch corruption, and #235 doesn't make it worse. 0 faults, 0 FP8 fallbacks, and Q12 batching didn't engage in either run.

(Separately, not part of this PR: f96e0fe04, a parallel softmax on top of BR64, came out bit-identical but neutral end to end in s87, so it stays out.)

AzeezIsh added a commit that referenced this pull request Oct 29, 2026
…le resident, native MXFP8 sharding, BF16 routing

Qwen3.8-Flash-Next FP4-Local at TP=EP=2 on two GB10s, including the #218 cache-exactness fix. Gate on the merged head 2906e74 (J36): C1/C8/cache C4 equal the references 8/8, prefix 8/8, tools 21/21, SSM replay 12/12, canonical NLL bit-identical. #235's shared-file changes since are cfg(atlas_hip)-gated, so NVIDIA paths are unchanged.
maplepaladin73 pushed a commit to maplepaladin73/atlas that referenced this pull request Oct 29, 2026
The 40M cut was fitted on the double-buffered twin, where the BF16 base
won the small weights. Since the single-LDS + B-reuse twin (Atlas-Inf#235) the twin
wins at every measured shape, 1.22-1.39x (strix s104, M=2048, three
alternating rounds), so the default cut is now 0.

Flash-Next NVFP4 prefill is -3% at 1.9k / 7.4k / 12.5k (framework f82,
interleaved x3). The twin's F16 dequant is exact where the base rounds each
weight to BF16, so outputs change. The f80 gate cleared that: ppl dense
9.6654 -> 9.6383, above-bound 1.0000, needles 12/12. Qwen3.6-27B, whose
5120x5120 qkv crosses the old cut, has its own gate (s105). Qwen3.8-27B is
unchanged: its NVFP4 shapes are all above 40M.

ATLAS_F16_M128_MIN_NK=40000000 restores the old behaviour.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant