Skip to content

strix: enable AMD-WMMA prefill attention, _f16a, w8a16_n, and DP4A dispatch on SCALE - #438

Merged
AzeezIsh merged 1 commit into
mainfrom
feat/strix-scale18-dispatch
Dec 4, 2026
Merged

AzeezIsh merged 1 commit into
mainfrom
feat/strix-scale18-dispatch

Conversation

@AzeezIsh

@AzeezIsh AzeezIsh commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Stacked on #437 (feat/strix-scale18-parity).

Summary

Unlocks the gfx1151 kernels now shipped in kernels/strix/ (from #437) and replaces the remaining NVIDIA cp.async + mma.sync prefill kernels (inferspark_prefill_paged.cu / prefill_paged_compute.cuh, w8a16_gemm_pipelined, fp8_gemm_t_blockscaled) with the validated AMD-WMMA / DP4A gfx1151 kernels under ATLAS_TARGET_HW=strix (SCALE 1.8.0):

  1. AMD-WMMA prefill attention (fixes intermittent chunked-prefill corruption & adds BR64=64):
    • Adds the 4-line #if defined(__SCALE__) WMMA bitcast wrappers (bf16 + f16) to kernels/strix-hip/common/{prefill_paged_compute.cuh,inferspark_prefill.cu,inferspark_prefill_h128.cu} (hipcc path macro-identical; verified with hipcc --genco --offload-arch=gfx1151).
    • Symlinks kernels/strix/common/{prefill_paged_compute.cuh,inferspark_prefill_paged.cu,inferspark_prefill.cu,inferspark_prefill_h128.cu} to strix-hip/common/.
    • Simplifies crates/spark-model/src/layers/ops/prefill_attn_main_b.rs to uniform BR64=64 now that both strix-hip and strix run the 8-warp AMD-WMMA prefill_paged_compute.cuh.
  2. Enable cfg!(atlas_scale) dispatch for gfx1151 WMMA/DP4A kernels & UMA reclaim:
    • Adds the __SCALE__ WMMA wrapper to kernels/strix-hip/qwen3.6-35b-a3b/nvfp4/w4a16_gemm.cu and symlinks it into kernels/strix/qwen3.6-35b-a3b/nvfp4/ so all strix targets ship _f16a and _s64.
    • strix_f16.rs, strix_s64.rs: enable w4a16_gemm_t_m128_f16a (+ m32_f16a_{n128,n64} twins) and w4a16_gemm_s64 on cfg!(atlas_scale) (keeping moe_w4a16 on cfg!(atlas_hip)).
    • dense_ffn.rs, dense_ffn_dp4a.rs, qwen3_ssm/{init,tests}.rs, qwen3_attention/init.rs, model/impl_a1.rs: enable w4a16_gemv_dp4a* (including M=5..8 split dual) and w8a16_gemv_batch8* on cfg!(atlas_scale).
    • qwen3_ssm/init.rs, qwen3_attention/init.rs, moe/init_optional.rs, nemotron_mamba2.rs, ops.rs, ops/gemm_quant.rs: enable w8a16_gemm_n_m128 (+ m32/m64 small-M twins) on cfg!(atlas_scale) and gate w8a16_gemm_pipelined & fp8_gemm_t_blockscaled off on cfg!(atlas_scale) (eliminating the 26s transpose_fp8_for_prefill boot step and the 809ms/layer FP8 prefill GEMM).
    • weight_loader/qwen35_dense.rs: reclaim dead in_proj_qkv / in_proj_z buffers after concat on cfg!(atlas_scale) (~4 GB UMA VRAM saved).

Measured Impact (vs parent #437 e57bc689a on Framework Desktop gfx1151, SCALE 1.8.0)

Fresh-checkout receipt for pushed SHA 59d815c03 will be posted below once its clean rebuild completes.

Metric (nvidia/Qwen3.8-27B-NVFP4, zero env overrides) #436 (b283c8e44) #437 (e57bc689a) This PR (59d815c03)
Clean build (strix/qwen3.8-27b) 12m 37s 2m 01s 1m 51s
Server boot (cold → ready) ~32s 32.2s 5.0s (MTP4) / 6.0s (DFlash2)
Pre-KV VRAM / KV pool (88% util) ~56 GB / 28 GB 55.7 GB / 28.1 GB 43.4 GB / 40.4 GB (-12.3 GB)
Strict boot (no --dangerously-allow-...) Failed PASS PASS
Math 28t TTFT (391) 10.08s 1.58s 0.205s
Code 33t TTFT (fib(n)) 7.85s 1.51s 0.290s
Needle 2,452t TTFT (ALPHA-7492-ZETA) 178s 57.8s 5.49s (~447 tok/s)
Chunked needle 2,452t reliability — flaky (gb10 cp.async paged attn) 8/8 EXACT (4/4 MTP4 + 4/4 DFlash2)
Code decode (MTP K=4) 16.75 tok/s 26.5 tok/s 32.0 tok/s
Code decode (DFlash2 γ=8) Unsupported 29.4 tok/s 44.20 tok/s

…spatch on SCALE

Unlock the gfx1151 kernels now shipped in kernels/strix/ (via #437) and port
the AMD-WMMA prefill attention kernels from strix-hip so ATLAS_TARGET_HW=strix
(SCALE 1.8.0) reaches full gfx1151 parity on prefill, decode, boot time, and
chunked-prefill correctness:

1. AMD-WMMA prefill attention (eliminates gb10 cp.async paged-attention bug):
   - Add the #if defined(__SCALE__) WMMA bitcast wrappers (bf16 + f16) to
     kernels/strix-hip/common/{prefill_paged_compute.cuh,inferspark_prefill.cu,
     inferspark_prefill_h128.cu} (hipcc path unchanged; all verified via hipcc).
   - Symlink kernels/strix/common/{prefill_paged_compute.cuh,
     inferspark_prefill_paged.cu,inferspark_prefill.cu,
     inferspark_prefill_h128.cu} to strix-hip/common/.
   - Update prefill_attn_main_b.rs to use BR64=64 uniformly now that both
     strix-hip and strix run the 8-warp AMD-WMMA prefill_paged_compute.cuh.

2. Enable cfg!(atlas_scale) dispatch for gfx1151 kernels & UMA reclaim:
   - strix-hip/qwen3.6-35b-a3b/nvfp4/w4a16_gemm.cu: add __SCALE__ WMMA wrapper
     and symlink into strix/qwen3.6-35b-a3b so all strix targets ship _f16a/s64.
   - strix_f16.rs & strix_s64.rs: enable w4a16_gemm_t_m128_f16a (+ m32 twins)
     and w4a16_gemm_s64 on cfg!(atlas_scale) (keeping moe_w4a16 on atlas_hip).
   - dense_ffn.rs, dense_ffn_dp4a.rs, qwen3_ssm/init.rs, qwen3_ssm/tests.rs,
     qwen3_attention/init.rs, model/impl_a1.rs: enable w4a16_gemv_dp4a* and
     w8a16_gemv_batch8* on cfg!(atlas_scale).
   - qwen3_ssm/init.rs, qwen3_attention/init.rs, moe/init_optional.rs,
     nemotron_mamba2.rs, ops.rs, ops/gemm_quant.rs: enable w8a16_gemm_n_m128
     (+ m32/m64 small-M twins) on cfg!(atlas_scale) and gate NVIDIA
     w8a16_gemm_pipelined / fp8_gemm_t_blockscaled off on cfg!(atlas_scale)
     (skipping the 26s FP8 transpose at boot and the 809ms/layer FP8 prefill).
   - weight_loader/qwen35_dense.rs: reclaim dead in_proj_qkv/in_proj_z buffers
     after concat on cfg!(atlas_scale) (~4 GB UMA VRAM reclaimed).

Stacked on #437 (feat/strix-scale18-parity).
@AzeezIsh

AzeezIsh commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Fresh-checkout receipt (59d815c03490becf4cc8c6dc047da9d35512d512, Framework Desktop gfx1151, SCALE 1.8.0)

Built via git archive 59d815c03 with unset SCALE_HOME ATLAS_FAST_LOAD ATLAS_FFN_SMALLM KV_DTYPE DFLASH; ATLAS_TARGET_HW=strix ATLAS_TARGET_MODEL=qwen3.8-27b ./build-amd.sh and served with zero env overrides and no --dangerously-allow-unresolved-kernel-lookups:

  • Build: 123/123 kernels compiled in 1m 55s (clean fresh archive).
  • Strict boot: PASS across all 3 configurations in 6.0s:
    • MTP K=4 / BF16 KV: 43.4 GB pre-KV → 40.4 GB KV (662,240 tokens)
    • DFlash2 γ=8 / BF16 KV: 45.8 GB pre-KV → 30.1 GB KV (493,616 tokens)
    • MTP K=4 / NVFP4 KV: 43.4 GB pre-KV → 40.4 GB KV (2,354,672 tokens)
Mode (nvidia/Qwen3.8-27B-NVFP4) math_28t (391) code_33t (fib(n)) needle_2452t #1 (ALPHA-7492-ZETA) needle_2452t #2 (ALPHA-7492-ZETA)
MTP K=4 (BF16 KV) 0.210s TTFT, exact 0.304s TTFT, 32.25 tok/s, exact 5.87s TTFT, 29.88 tok/s, exact 5.70s TTFT, 29.49 tok/s, exact
DFlash2 γ=8 (BF16 KV) 0.195s TTFT, exact 0.290s TTFT, 42.74 tok/s, exact 5.69s TTFT, exact 5.58s TTFT, exact
MTP K=4 (NVFP4 KV) 0.218s TTFT, exact 0.306s TTFT, 32.06 tok/s, exact 5.88s TTFT, 29.13 tok/s, exact 5.75s TTFT, 29.32 tok/s, exact

Combined with the pre-push run on identical source (4/4 MTP4 + 4/4 DFlash2), chunked needle is 14/14 exact (ALPHA-7492-ZETA) across BF16 KV, NVFP4 KV, MTP K=4, and DFlash2. All 4 modified kernels/strix-hip/ files also pass hipcc --genco --offload-arch=gfx1151.

@AzeezIsh
AzeezIsh changed the base branch from feat/strix-scale18-parity to main December 4, 2026 19:32
@AzeezIsh

AzeezIsh commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Stack verification: see #436.

@AzeezIsh
AzeezIsh merged commit 4a9abb0 into main Dec 4, 2026
20 of 23 checks passed
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