Repository navigation
strix-hip train: the validated gfx1151 stack (build fix + suballoc + carveout + hipBLASLt) - #197
Conversation
…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]>
…A/B attribution 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]>
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.
…ad bf16 batch2)
…155 + C4 (engage routed-MoE F16 twins)
… (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]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
… into integ/strix-hip-train-v1
…nteg/strix-hip-train-v1
…/strix-hip-train-v1
…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
|
DevLab runner evidence (fresh ephemeral gfx1151 runner,
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. |
|
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: |
|
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 |
|
2026-10-27 merge-readiness status. Every check below ran on the AMD boxes only. main + this PR + #204, merged as
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. |
|
Proposed rider for this PR: 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):
Not pushed: push is disabled in this clone, so the owner pushes it. |
|
Merged as Basis:
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
|
|
Post-merge check, strix half: main
The framework half (f54) builds the same sha and serves Flash-Next without |
|
Post-merge check, framework half: main
Both AMD boxes have now verified the merged main. |
…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>
|
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)
Recipe change (measured, not a code change)Flash-Next 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
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. |
Summary
One mergeable branch for the stack that the strix/framework overnight runs validated, superseding the stacked fix PRs:
fix/strix-hip-build-after-174— anchored includes, cuLaunchKernelEx + cuBLASLt exports, PDL-attr refusal, scalar-only__ldcg(was strix-hip: restore the gfx1151 build after #174 #181)fix/strix-hip-fnext-qsa-radix— qsa_radix.cuh link for the FNext target (was strix-hip: link qsa_radix.cuh beside the Flash-Next qsa_indexer.cu symlink #189)fix/hip-test-fp8-verify-n2-tier— n2-tier test expectation on HIP (was qwen3_ssm test: expect the n2 FP8 verify tier (16 outputs/block) on HIP #183)fix/carveout-free-memory— don't report host MemAvailable as device free on carve-out APUfix/hip-suballoc-145— slab sub-allocator: geometric slabs, hardened free path, one-empty-slab bound (was hip shim: slab sub-allocator for the request sizes hipMalloc rounds up (#145) #190)perf/hip-bf16-hipblaslt(perf: strix-hip BF16 GEMMs via hipBLASLt (hip-p0→C5 train) #166) — conflicts with qwen3.8-flash-next: two-GB10 TP=EP=2 (Enntity series + RC16) with RDMA GID and cuBLASLt startup fixes #174 resolved using the train's validated resolution (bf08b701tree)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