Skip to content

strix-hip train: the validated gfx1151 stack (build fix + suballoc + carveout + hipBLASLt) - #197

Merged
AzeezIsh merged 43 commits into
mainfrom
integ/strix-hip-train-v1
Oct 27, 2026
Merged

AzeezIsh merged 43 commits into
mainfrom
integ/strix-hip-train-v1

Conversation

@AzeezIsh

Copy link
Copy Markdown
Contributor

Summary

One mergeable branch for the stack that the strix/framework overnight runs validated, superseding the stacked fix PRs:

Evidence (all fingerprinted in ~/ovn-out on strix/framework)

A fresh build+identity confirm job for this exact branch is queued on both boxes.

Generated with Devin

AzeezIsh and others added 30 commits October 2, 2026 02:43
…layer host sort past the inert bound)

Past the 2051-token inert bound every QSA layer selected its top-512 blocks
with a D2H of the scores, a host sort and an H2D upload: 12 stream drains per
decode token on Flash-Next. The device arm (`qsa_select_topk`) was opt-in and
O(complete^2) (rank every block against every other), measured ~71 us per
launch at <= 512 blocks and quadratically worse at agentic lengths; past 4096
blocks the host arm took over regardless.

qsa_select_topk_radix selects the identical set in the identical order:
- key = order-preserving u32 of rank_key (NaN -> -inf, -0 -> +0), i.e. the
  host rank_cmp order;
- four 8-bit MSD histogram passes find the exact block_topk-th largest key T;
  every key > T is taken plus the lowest-index keys == T;
- two block-wide prefix scans over per-thread contiguous index chunks emit the
  selection in ascending order, expanded by ratio, then the tail.
One 1024-thread CTA, O(complete), up to 16384 blocks (65,536 tokens).

The device arm is now the default (ATLAS_QSA_DEVICE_TOPK=0 restores the host
sort); QSA_SELECT_MAX_BLOCKS 4096 -> 16384. The old kernel stays for its test,
which now runs both device arms against the host reference.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he dense M128 and routed-MoE kernels

gfx1151 has no f32->bf16 instruction: the BF16 prefill kernels round every
dequantized weight in software (5 VALU each), which dominates their hot loop
(w4a16_gemm_t_m128: 829 instructions per 32-K step for 32 WMMA; the routed MoE
kernels: 688 for 16, an older port that also lacked the m128 pipeline). WMMA
runs on the same SIMD VALUs, so that work displaces matrix issue.

The *_f16a twins keep the signature, grid and launcher of the kernel they
replace, and use f16 WMMA:
- f16(e2m1) has a zero low byte for every code: one v_perm per four codes;
- times the E4M3 scale (bits<<7 * 256, exact incl. subnormals) with one
  v_pk_mul_f16 per two weights. e2m1*e4m3 is EXACT in f16 (checked over all
  254 non-NaN scale bytes x 16 codes), so the dequant no longer rounds;
- fp32 per-tensor / per-expert scale2 applied once in the epilogue;
- the bf16 A tile converted to f16 while staged in LDS (exact for |a| <=
  65504; saturates beyond);
- the MoE twins get the m128 register-prefetch / double-buffered pipeline.
Hot loop: 378 (dense) and 293 (MoE) instructions per 32-K step.

Wiring: ops::strix_f16 picks the twin under cfg!(atlas_hip) and falls back to
the BF16 kernel, so GB10 never issues the lookup. Used by dense_ffn,
qwen3_attention, qwen3_ssm (m128) and moe/init (gate+up, down).

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

The FP8-weight prefill GEMM decoded each E4M3 weight, multiplied by its
128x128 block scale and rounded to bf16 in software (~11 VALU per weight on
gfx1151). The twin decodes E4M3 to f16 exactly (E4M3 is a subset of f16),
accumulates each 128-K block unscaled and folds it in once per block
(acc += blk * scale, every 4 K-steps), on a uniform condition of the loop
counter so it stays a scalar branch. Hot loop 467 -> ~305 instructions per
32-K step (16 WMMA), the flush included every step. Picked by
ops::w8a16_n_m128_kernel under cfg!(atlas_hip).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A BF16 LM head at num_tokens == 2 fell back to two dense_gemv calls,
reading the whole weight once per verify token. Qwen3.8-Flash-Next ships
its [248320, 2560] LM head BF16, so every MTP verify step read 1.27 GB
twice: 2 x 5.87 ms of a 111 ms step on gfx1151 (ATLAS_TRACE_LAUNCH_SYNC,
winbox, 2026-10-02). The FP8 and NVFP4 branches already had batch2 arms.

Route it to dense_gemv_bf16_batch2 on HIP only. The strix-hip kernel is
bit-identical to two dense_gemv_bf16 calls: same 32-lane walk per row and
the same shuffle reduction, with the second token as an independent
accumulator. The gb10/strix (NVIDIA) builds use 64 lanes per row plus a
shared-memory reduction, which reorders the sum, so the handle stays 0
there and the fallback runs unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
strix job 146 (gfx1151, Linux ROCm 7.13), BF16 vs F16 twin TF/s:
27B attn-like 18.29 / 18.12, out-like 17.41 / 18.20, mlp-like 15.56 / 15.06.
Neutral, so it does not ship (neutral opt-in switches do not merge).
This reverts commit 398d34c.

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

strix job 146 (gfx1151), BF16 vs F16 twin TF/s at M=2048: the twin wins
on 27B gate/up (+21%), 27B down (+13%) and Flash-Next GDN qkvz (+15%),
and loses where BF16 already reaches ~22 TF/s: Flash-Next attn q (-6%),
27B qkv (-2%), Flash-Next out (-9%). N*K >= 40M separates the six shapes
exactly. The shared launcher swaps back to the BF16 base below the cut;
ATLAS_F16_M128_MIN_NK overrides it. The routed-MoE twins stay ungated
(2.1x gate+up, 1.9x down on Flash-Next).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
strix-hip links the cudart->HIP shim (libcudart_hip_shim.cpp maps
cudaMemcpy2DAsync to hipMemcpy2DAsync on Linux and Windows), so the
per-row copy_d2d_async fallback is unnecessary there. QSA ingest calls
copy_d2d_2d_async with 2048 rows per chunk per attention layer; the
SYNC launch trace shows ~138 ms of host time per qsa_block_pool launch
from those per-row copies.
w4a16_gemm gathers per-element byte loads across 64 rows and pays two
barriers per 16-K step; on gfx1151 the Flash-Next router shape
(N=512, K=2560) runs it at ~0.3 TF/s at M=2048. The _s64 twin keeps the
identical dequant expression, WMMA fragment construction, ascending
k-step accumulation order, grid and block; only the staging changes -
64 K per stage (one barrier pair per 4 k-steps), 16-byte A loads into
sA[64][72], and per-thread packed B loads (one uint4 + 2 scale bytes)
into sB[64][72]. No WMMA is issued for a k-step with kb >= K so the
-0.0/+0.0 edge is preserved. Added to both strix-hip w4a16 modules
(qwen3.6-27b and qwen3.6-35b-a3b; flash-next symlinks the latter).

MoeLayer's w4a16_gemm handle resolves to the twin under cfg!(atlas_hip)
via layers::ops::w4a16_gemm_kernel; the lookup is gated so targets
without the symbol issue no lookup and leave no failed row in the boot
kernel audit.
Native-HIP (strix-hip) lacks the FP8 prefill GEMM kernels - fp8_gemm*
and fp8_fp8_gemm* are inline-PTX, not WMMA-ported - so the q/k/v/o FP8
copies built by predequant_for_prefill were consumed by fallback FP8
launches that no strix-hip target ships fast paths for. With the
predequant skipped, cache_skip_qkv.rs, paged_qkv.rs and paged_oproj.rs
fall through to their existing nvfp4_t arms (w4a16_gemm_t_m128 /
w4a16_gemm_n128). Decode never reads q_fp8..o_fp8 (it keys on the
native-FP8 source weights via *_weight.as_fp8()). Mirrors the sibling
guard in linear_attn_arms.rs. qwen4_exp attention layers build through
the same function, so they inherit the guard.
PR #155 swapped MoeLayer::moe_fused_gate_up_t / moe_grouped_gemm_t to
their _f16a twins, but no dispatch site ever launches those handles -
production prefill (forward_prefill_routed.rs) goes through the _k64
handles. That is why winbox B2 (with #155) vs B1 measured TTFT 1.01x
with byte-identical greedy output: the twins never ran.

Init now records whether BOTH twins resolved
(ops::moe_f16_prefill_engaged); when they did, the two plain
transposed-NVFP4 prefill arms launch them via the existing n128
launchers (moe_w4a16_fused_gate_up_n128 /
moe_w4a16_grouped_gemm_ptrtable_n128). The twins have the same
signatures as their BF16 bases and a 64-row blockIdx.y M tile with no
grid striding, so the launchers pass max_m_tiles, not grid_m_strided.
Env opt-in arms (m128, fp4, fp8-down) keep priority; e8m0, cutlass and
untransposed fallbacks unchanged; non-HIP untouched.
… (C5)

Job 160 (gfx1151, ROCm 7.13): hipBLASLt is 2.3-2.6x faster than dense_gemm_bf16_pipelined on every Flash-Next BF16 shape and ~19x the scalar dense_gemm at the 27B MTP fc shape, at bf16-rounding-level error. Four sites now try hipBLASLt first and fall back to their existing kernel on Err, warn-once per site (hip_bf16_proj_or): the mHC collapse tries it at every shape (the machine-fill gate stays NVIDIA-only), the SSM out_proj and force_bf16 QKVZ arms fall back to dense_gemm_bf16_pipelined, and the 27B MTP drafter prefill fc falls back to scalar dense_gemm. The fallback stays on every site — 9fc8e57 moved this path off cuBLASLt on an older ROCm.

cfg(atlas_hip) only; NVIDIA paths unchanged.
… cap)

moe/mod.rs sat at exactly 500 on main and the train's moe_f16_prefill field
pushed it to 502; the init.rs additions pushed it to 501. Move the three
pointer-table types (ExpertPtrTable, Fp8ExpertPtrTable, ExpertPtrSet) into
a new types.rs re-exported through the moe module — same pattern as
ptr_table_build — and tighten the f16-twin comment by one line.
mod.rs 458, init.rs 500. cargo check -p spark-model green on strix-hip.
CI 'typos' job on PR #166 fails on two comment occurrences of
'subtile' (suggests subfile/subtitle/subtle). Hyphenate.
9 of 10 gate legs measured on GB10 (reiner) at the PR head:
ttft-warm-gate, ttft-cold-gate, decode-floor, concurrency-sweep,
ssm-state-poisoning-gate, agentic-webserver, vision-fidelity,
bfcl-subset (88.14% overall on n=995), bfcl-subset-echolp (87.65%).

video-fidelity has no record: its recipe's util=0.70 leaves ~0.4 GB less
KV headroom than this build needs (84.1 GB committed vs 83.7 GB budget)
at serve time — a footprint delta worth a follow-up look.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Main moved under the gate records (factory/build.rs, m2_setup.rs,
transformer_layer.rs since 9316140) — records must cover head+main per
the serialized-landing protocol; suite re-run follows on reiner.
9/10 legs re-measured on reiner (GB10) after merging main into the
branch — the earlier records stamped 9316140 were invalidated by
main-side factory/ changes (serialized-landing protocol). bfcl-subset
88.14%, echolp 87.65% at this tree.

video-fidelity still lacks a record: serve fails its util=0.70 KV budget
by ~0.6 GB on this ckpt (84.3 committed vs 83.7 budgeted) — either a
real footprint delta on this build or a recipe margin issue; follow-up
queued.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…mlink

#174 moved the radix top-k into kernels/gb10/qwen3.8-flash-next/nvfp4/
qsa_radix.cuh, which qsa_indexer.cu #includes. strix-hip's Flash-Next target
reaches qsa_indexer.cu through a symlink, and the HIP build mirrors only the
target's own directory (build.rs hip_mirror_source), so the quoted include
had no file to resolve to and the target stopped compiling.

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

#174 moved the radix top-k into kernels/gb10/qwen3.8-flash-next/nvfp4/
qsa_radix.cuh, which qsa_indexer.cu #includes. strix-hip's Flash-Next target
reaches qsa_indexer.cu through a symlink, and the HIP build mirrors only the
target's own directory (build.rs hip_mirror_source), so the quoted include
had no file to resolve to and the target stopped compiling.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#174 changed kernels that strix-hip shares with GB10, and every strix-hip
target stopped compiling:

- 17 shared kernels in kernels/gb10/common now #include "atlas_pdl.cuh".
  strix-hip/common reaches them by symlink, and the HIP build mirrors only
  the target's own directory, so the header was not found. Link it beside
  them; its griddepcontrol body is guarded by __CUDA_ARCH__ >= 900 and
  compiles to nothing on HIP.
- strix-hip's DFlash2 selector and the shared QSA indexer now use __ldcg,
  which HIP does not declare. Add a force-included compat shim that maps it
  onto a volatile (coherent, L2-served) load.

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

The HIP build compiles a mask-widened mirror of each kernel directory under
OUT_DIR, so an #include "../…" that resolves next to the source in kernels/
names nothing from the mirror. #174 added the first one strix-hip reaches
("../../common/atlas_pdl.cuh" in the GDN kernel shared by the 35B-A3B and
Flash-Next targets), and both stopped compiling. Rewrite such includes to
the absolute path they name from the original directory, which is how
clang resolves them on the unmirrored file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
spark stopped linking on strix-hip once #174 called three driver/cuBLASLt
functions the HIP shims did not export:

- cuLaunchKernelEx (PDL launches, atlas-core registry/launch.rs). The only
  attribute Atlas passes is programmatic stream serialization, whose kernel
  side (atlas_pdl_enter) compiles to nothing on HIP; forward to the existing
  cuLaunchKernel shim with plain stream order.
- cublasLtMatrixLayoutSetAttribute: only the GLM head-batched MLA GEMM uses
  it, behind ATLAS_GLM_PAGED_PREFILL_MLA_GEMM; return UNSUPPORTED.
- cublasLtMatmulAlgoCheck: the fixed-algorithm pin treats nonzero as
  'fall back to the tile kernel'; return the stub status.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ayout; scalar-only __ldcg

Hardening from the Qwen3.8-Max review of the #174 build fix:
- cuLaunchKernelEx drops attributes only when every one is programmatic
  stream serialization (id 6, a no-op on HIP); any other id returns
  CUDA_ERROR_INVALID_VALUE instead of silently changing semantics.
- static_assert the CUlaunchConfig field offsets the Rust side relies on.
- __ldcg shim: static_assert scalar width, and say plainly that it is a cache
  hint, not a fence (the callers fence: __threadfence + atomic ticket in the
  DFlash2 selector, a barrier in the QSA indexer).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#156 put w8a16_gemv_batch8_dyn_vl2_n2 ahead of _dyn_vl2 in
fp8_verify_gemv_tier, so on atlas_hip the mock-resolved R=7 verify launches
grid [N/16]. The test still expected [N/8] and failed on every HIP test run
([768,1,1] and [128,1,1] were in the seen grids). NVIDIA builds are
unchanged (per_block 4).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ve-out APU

cuda_free_memory_bytes and the backend's free_memory took
max(cuMemGetInfo free, /proc/meminfo MemAvailable), which is right where the
device draws from host RAM (GB10, GTT-backed Strix Halo). On an APU with a
dedicated carve-out larger than host RAM it is wrong: the 128 GB Framework at
a 96 GiB BIOS carve-out has 31 GiB of host RAM, so every free-memory read
during a Flash-Next load returned the ~26-27 GB of host MemAvailable while the
carve-out filled (sysfs vram_used peaked at 92.5 GiB). The KV budget and the
MoE transpose tier were sized from it and the first KV alloc hit a full
device (#145).

unified_free() applies the MemAvailable floor only when the device total is
no more than ~10% above host MemTotal. Unit tests cover GB10, GTT Strix and
the carve-out case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…teg/strix-hip-train-v1

# Conflicts:
#	crates/spark-model/src/layers/moe/forward_prefill_routed.rs
#	crates/spark-model/src/layers/moe/init.rs
#	crates/spark-model/src/layers/moe/mod.rs
#	crates/spark-model/src/layers/moe/types.rs
#	crates/spark-model/src/layers/ops.rs
#	crates/spark-model/src/layers/ops/hyper_connection_lowrank_gemm.rs
#	crates/spark-model/src/layers/qsa.rs
#	crates/spark-model/src/layers/qwen3_ssm/trait_prefill_helper.rs
#	kernels/gb10/qwen3.8-flash-next/nvfp4/qsa_indexer.cu
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

DevLab runner evidence (fresh ephemeral gfx1151 runner, devlab-strix.yml job=build):

  • fix/hip-suballoc-145 (contains this chain): build PASS — 169 s, binary 24053b47dfb93c84, HIP shims built (run 39105009616).
  • main @ post-ci(cla): allowlist devin-ai-integration[bot] and data-angel #193 (same runner, same workflow): build FAIL — fatal error: 'atlas_pdl.cuh' file not found on every mirrored kernel + __ldcg undeclared (run 39105011577).

So main's strix-hip build is broken on a clean gfx1151 runner exactly as diagnosed in the overnight boxes (the #174 fallout), and this branch is the fix. This is CI-side confirmation on top of the box evidence.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Verification ledger posted on #145 — highlights: builds where main does not (DevLab), output-identical across all three models, ST-995 triple-confirmed 84.42/75.22, FNext-on-Linux + 35B first-ever serve legs, 84.02/81.44 on the fp4l merge arm. Remaining flag: hc_pre_down_mt eager registration to drop the dangerously flag.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

AMD train candidate gate: main 504063a + #197 + #204 (merged as b9ab4ed54), on strix (gfx1151, 64 GB):

So #204 together with #197 gives AMD a working main with no accuracy regression. A Flash-Next NVFP4 regression check of #195 on framework is still running.

🤖 Generated with Claude Code

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

2026-10-27 merge-readiness status. Every check below ran on the AMD boxes only.

main + this PR + #204, merged as b9ab4ed54 (test/main-197-hipfix):

  • Builds for strix-hip with all models (strix s20, framework f03). Main alone does not build for gfx1151 (atlas_pdl.cuh, __ldcg, __float2bfloat16_rn).
  • 27B, ST-995: 84.12 / 74.65 on strix (s20, run-1792775551367679462, DFlash2 γ8 profile, 0 faults). The fafb7349d head of this PR read 84.42 / 75.22 (s14).
  • Flash-Next, ST-995: 84.12 / 81.47 on framework, thinking default (f05, run-1792777040459298748). The f22 train read 84.12 / 82.33.
  • Agentic, this PR's head: 50/50 webserver_ok, 50/50 followed_directions, Σwall 9,379 s (strix s19, run-1792658188290604510).

Superseded on merge: this PR contains the full heads of #152, #153, #155, #166, #182 and #186, so those can close as merged. #187, #188, #192 and #204 are not contained.

Red CI checks:

Not done: the GB10 boot check that the train policy asks for. The owner has scoped this campaign to the AMD boxes, so whether to merge without it is the owner's call.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Proposed rider for this PR: fix/hip-moe-grouped-min-64 (10a902576, based on this PR's head fafb7349d). It is a one-line HIP-only default change, ATLAS_HIP_MOE_GROUPED_MIN_TOKENS 1024 → 64.

Why: with the F16 grouped twins this PR carries from #155, the 1,024-row fallback to per-token expert GEMVs became a large regression for short prefills and warm agent turns. Root cause: #145 (comment)

Validated on framework (b9ab4ed54 = main + this PR + #204):

  • ST-995: 84.52 / 81.97 at 64, against 84.12 / 81.47 at 1024 (f48 vs f05).
  • Cached-prefix prefill: 53 → 499 tok/s at 8k depth, 147 → 470 at 32k (f49 vs f41).
  • Cold TTFT at 649 tokens: 11.6 → 1.3 s (f46).
  • Agentic at 64: 45/50 (f47). The same-build 1024 baseline (f51) is still running.

Not pushed: push is disabled in this clone, so the owner pushes it.

@AzeezIsh
AzeezIsh merged commit c377430 into main Oct 27, 2026
20 of 23 checks passed
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Merged as c3774309e. #187 (e2bb47ad4) and #188 (8863dc5e5) followed. The owner cleared merging on 2026-10-27.

Basis:

  • Gated on its own platform:
  • Without this PR, main did not build for gfx1151.
  • For GB10, I read every runtime hunk:
    • They are cfg(atlas_hip) / try_kernel_gated.
    • meminfo::unified_free takes the old free.max(MemAvailable) branch on a unified box (device total ≈ host MemTotal).
    • anchor_relative_includes runs only in hip_mirror_source.
    • No kernels/gb10 file changes.
    • CI's nvcc→PTX (all gb10 targets) and workspace tests were green.

Not verified before merging: the exact merge result with today's #212 train on AMD. These jobs are queued now:

Results will go on this PR.

Superseded: #152, #153, #155, #166, #182 and #186 are marked merged by GitHub. #184 was closed in favour of this PR.

Local branches, rebased onto 8863dc5e5, waiting on a push (push is disabled in this clone):

  • fix/hip-moe-grouped-min-64 5f57b08cc: HIP MoE grouped threshold 1024 → 64 (keeps moe: HIP unit tests take the grouped dispatch they assert (6 #174 GLM tests failed or hung on HIP) #188's test default of 1).
    • Gated: ST-995 84.52/81.97, cached-prefix prefill ~9× faster, warm-turn TTFT 4×.
    • Agentic A/B vs 1024 is still running (f51).
  • perf/hip-qwen4exp-moe-decode 750a18bfb (on top of the above): builds qwen4exp_moe_decode for strix-hip and lets ATLAS_QWEN4EXP_MOE_FAST run on HIP.
    • The batched-decode trace (f50) shows the routed MoE not amortizing across rows; this targets that.
    • A/B pending (f52).

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Post-merge check, strix half: main 8863dc5e5 (#212 + this PR + #187 + #188) builds and serves on gfx1151. strix s31.

  • BUILD OK for all strix-hip models (models=*), binary 96dd7b81f4af.
  • 27B NVFP4 on the MTP recipe, probed:
    • short, code, 2k and 10k answers are all coherent;
    • 10k first token median 0.69 s;
    • ~21 tok/s decode including prefill;
    • 0 faults.

The framework half (f54) builds the same sha and serves Flash-Next without --dangerously-allow-unresolved-kernel-lookups. It runs after the current framework jobs.

@AzeezIsh

Copy link
Copy Markdown
Contributor Author

Post-merge check, framework half: main 8863dc5e5 builds and serves Flash-Next without --dangerously-allow-unresolved-kernel-lookups. framework f54.

  • BUILD OK for all strix-hip models, binary 96dd7b81f4af (same sha as the strix check, s31).
  • Flash-Next NVFP4 on MTP1, served without the unresolved-lookup escape hatch. Before hc_token_fused: never on under HIP (strix-hip Flash-Next decode aborts on main) #187, a plain serve stopped in the kernel audit on hc_pre_down_mt.
  • Probes coherent, 10k first token 0.45 s, ~22.1 tok/s decode including prefill, 0 faults. That matches the pre-merge b9ab4ed54 build: f43 measured 0.45 s and 22.1 tok/s.

Both AMD boxes have now verified the merged main.

AzeezIsh added a commit that referenced this pull request Oct 28, 2026
…e cap; main red since #197)

Pure move into init_batched.rs (BatchedKernels::resolve), same shape as
init_optional/init_t_rows: batch2/batch3/batch5 fused verify, token-major
prefill trio, atomic-c4 pair. Same kernel names, gating and field values.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@AzeezIsh

Copy link
Copy Markdown
Contributor Author

AMD NVFP4 prefill campaign, 2026-10-28 (strix + framework, gfx1151 Linux): what's ready to push, and the remaining gap. Push is disabled in my clone, so these are local branches for the owner. Each was measured on the box shown; evidence is linked per issue.

Ready (evidence complete)

branch sha what evidence
perf/hip-qsa-attn-tc2 881c0b550 + 62e4d801d HIP WMMA QSA attention (new qsa_attn_tc2.cu); 2nd commit = default ON for atlas_hip Flash-Next prefill −10% at 7.4k, −12% at 12.5k (f66, f68); needles 12/12, dense ppl identical, above-bound +0.08% (f67) — #144
perf/hip-fp8-prefill-dequant-blas 432e74045 27B FP8 projections at M ≥ 1024: dequant once to scratch + hipBLASLt 27B prefill −7 to −9% (s62); ST-995 84.42 / 75.17 vs main 84.12 / 74.65 (s63) — #72
fix/hip-moe-grouped-min-256 909dc8b20 MoE grouped-prefill threshold 1024 → 256 ST-995 84.32 / 82.22 (f59) — #145
perf/hip-qsa-verify-active-default 88cffac78 MTP stays on past the QSA bound on HIP MTP1 decode 12.1 → 18.75 tok/s at 8k, 17.64 at 32k, 0 declines (f58) — #143 / #144
perf/hip-w4a16-f16a-single-lds, perf/hip-moe-f16a-single-lds, perf/hip-w8a16-n-m128-interior d6057db77, 9be597d00, c921e864e NVFP4 / MoE / FP8 GEMM register + LDS fixes bit-identical, 27B prefill +4%, 9/9 pairs; neutral on Flash-Next — #72

Recipe change (measured, not a code change)

Flash-Next --max-prefill-tokens 8192 (vs 2048): −12% at 7.4k / −9% at 12.5k on top of tc2 (f69). Same gate as tc2 passes (f70: needles 12/12, above-bound ppl +0.11%). It's a single-stream recipe: bigger chunks lengthen concurrent decode stalls. Agentic f71 (8192) vs f72 (2048) is queued on the tc2 build. On the 27B, chunk 4096 is neutral (s66).

Cumulative Flash-Next at ~7.4k on framework: 10.25 s → 8.13 s (720 → 907 tok/s).

Where the time is now, and what doesn't help

  • Both models are GPU-bound during prefill: 27B 99.7% busy (s58), Flash-Next 98.3% (f65). Host and launch overhead is not the gap.
  • On gfx1151, WMMA f16, bf16 and iu8 all peak at ~48 T (s60), so int8 isn't a 2× path on this chip. The NVFP4 dense GEMM already matches rocBLAS at 24–28 TF/s (s59).
  • Remaining levers, in order:
    • Flash-Next routed MoE (~25%) at 11–15 TF/s, from ~40 rows per expert per chunk. Bigger chunks recover part of it; a padding-free M tile is the kernel fix.
    • QSA tc2 restructure: it still runs ~2.4–2.9 TF/s in isolation. Gathers are ~⅓ of it (s67 locality probe); the rest is the one-thread-per-row softmax, idle warps and 2 CTAs per WGP.
    • 27B attention (inferspark_prefill_paged_64, 9% at 6.6k → 22% at 16k), the same WMMA body as tc2.
  • Neutral (closed): MoE twin M-tile striding (f62), EXACT_TILES=0 (f63), single-LDS on Flash-Next (f61), GDN recompute_wu scratch fix (s57), 27B chunk 4096 (s66).

The gap to Gufo is still ~1.9× at 8k on Flash-Next (907 vs ~1,721 tok/s) and ~2× on the 27B. Gufo's dense parts are Q8_0 and its experts Q4_K (~6 GB/token vs our ≥8.5), so part of that is format, not kernels.

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