[PR #5361] [Engine] gfx906 (MI50/MI60/Radeon VII) performance branch — fastest known 4xMI50 Flash-Next numbers #5403

Open
opened 2026-11-07 16:34:57 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5361
Author: @rpcribari
Created: 11/6/2026
Status: 🔄 Open

Base: main ← Head: int6


📝 Commits (10+)

  • a3dd11f local gfx906 build patches (hip_compat stream-priority macros, align spelling)
  • 5e4719a gfx906: IQ4_NL gate/up experts (STRATA_GU_FMTS; generic layout) + parity coverage
  • 70a5e7d gfx906 prefill: opt-in STRATA_PF_RP=1 - IQ4_NL expert products through mx-llama.cpp's repacked GEMM (vendored src/prefill/rp/, MIT); the group gather writes the repacked layout; rp_expert_bench (bitwise vs MMQ)
  • fe4ab83 gfx906: dense_mmq_bench (dense projections: dequant + hipBLAS FP16 vs int8 MMQ vs repacked, at the engine's shapes)
  • 658a1b7 gfx906: STRATA_DENSE_MMQ=1 (Gemm::native_mmq) on the gfx906 build; STRATA_DENSE_MMQ_SKIP (default attn_k.,attn_v.: K/V stay FP16, keeps the MTP acceptance)
  • 9247000 gfx906: STRATA_DENSE_RP=1 - dense IQ4_NL projections through the repacked GEMM (weight repacked per call into a grow-only scratch; bitwise equal to dense MMQ)
  • 2e75c0d gfx906 dense repack: Q8_0, Q6_K, Q5_K too (mx's device repack kernels vendored in src/prefill/rp/repack-convert.cuh; Q4_K stays MMQ, slower repacked); dense_mmq_bench: bitwise rp-vs-mmq check
  • 43ff98c gfx906 expert repack per product: an IQ4_NL down under non-IQ4_NL gate/up (GSQ-RCO IQ3_S file) takes the repacked GEMM on its own; the other part gathered as GGUF for MMQ (bitwise equal to stock)
  • 1d8e9ee gfx906 dense repack: IQ4_XS (Strata's own layout: IQ4_NL nibble plane + FP32 per-sub-block scales; bitwise equal to MMQ); STRATA_DENSE_MMQ_PROFILE=1 times each dense MMQ call
  • e4f4027 gfx906 expert repack: IQ3_XXS / IQ3_S gate/up (GSQ-RCO IQ3_S file) through the repacked GEMM

📊 Changes

31 files changed (+5046 additions, -147 deletions)

View changed files

📝 CMakeLists.txt (+9 -0)
➕ bench/results/2026-10-30-mi50-32gb-decode/README.md (+79 -0)
📝 docs/AMD_HIP.md (+4 -0)
➕ docs/AMD_MI50.md (+220 -0)
➕ docs/gfx906.md (+70 -0)
📝 include/strata/platform/hip_compat/strata_hip.h (+22 -1)
📝 include/strata/prefill/gemm.hpp (+7 -0)
➕ include/strata/prefill/rp_moe.hpp (+89 -0)
📝 src/core/dflash2.cpp (+1 -1)
📝 src/kernels/cuda/fused_gr.cu (+329 -43)
📝 src/kernels/cuda/iq_kernels.cu (+306 -65)
📝 src/kernels/cuda/native_bf16.cu (+12 -7)
📝 src/kernels/cuda/native_mmvq.cu (+161 -9)
📝 src/kernels/cuda/router_top10.cu (+3 -3)
📝 src/kernels/cuda/sampler.cu (+17 -1)
📝 src/kernels/cuda/verify_kernels.cu (+11 -1)
📝 src/kernels/fused_gr_bench.cpp (+14 -2)
📝 src/kernels/native_expert_bench.cpp (+14 -1)
📝 src/kernels/native_grouped_parity.cpp (+1 -1)
➕ src/prefill/dense_mmq_bench.cu (+226 -0)

...and 11 more files

📄 Description

Problem and result

gfx906 (MI50 32 GB / MI60 / Radeon VII) is the cheapest way into a big-context MoE rig, but on Qwen3.8-Flash-Next the whole gfx906 ecosystem was stuck around 62 t/s decode and ~1250 t/s prefill-8K (best published llama.cpp fork), and Strata layer-split prefill ran one card at a time on this hardware.

This branch (21 commits on 0.2.7) takes a 4x MI50 box to:

metric before after
decode (single stream, MTP) ~95 t/s 125 t/s
prefill 8K 725 t/s 1250 t/s
prefill 32K 843 t/s 1766 t/s

none — opening as a concrete proposal; happy to rebase onto current main or split into reviewable chunks (kernels / pipeline fix / docs), whichever is easier.

Approach

  • Repacked-GEMM prefill stack for gfx906: IQ4_NL/IQ3 expert and dense products through a repacked int8 GEMM (vendored from mx-llama.cpp, MIT), FP16-in/out prompt GEMMs, dense MMQ for projections. Every path bitwise-checked against the stock kernels.
  • Decode kernels: MMVQ with activations in LDS + four lanes per cell, IQ GEMV / grouped-expert address-cycle cuts, DPP/ds_swizzle reductions replacing ds_bpermute, sampler load pipelining, hyper-connection read staging.
  • HIP pipeline fix: reserve the MTP prefill under an in-flight verify window (fixes a decode stall on layer splits).
  • --prefill-pipe for gfx906: with the expert cache fully VRAM-resident the per-chunk fixed cost is small, so r ~ 300-450 wins big; without it a layer-split prefill serializes one card at a time. Guidance in docs/gfx906.md.

All engine-visible behavior is switch-gated (STRATA_* env / existing flags); default-on only on the gfx906 build (-DSTRATA_HIP_GFX906=ON). No changes outside the HIP/gfx906 paths.

Validation

Passed:

  • strata-bench-style throughput runs, revision int6 (14f591d4), 4x MI50 32 GB Gen3 x8, 250 GB RAM, ROCm 7.2.4 container, UD-IQ4_XS pack: decode 125 t/s, pp8K 1250 t/s, pp32K 1766 t/s. Nonce-bearing prompts (no cache hits), warm pass reported, run twice after idle.
  • Deterministic pass/fail quality harness (8 tasks, temp 0, seed 42): 5/8 — identical to the pre-change baseline, no regressions.
  • Kernel bitwise checks: repacked GEMM / FP16 GEMM / MMQ paths vs stock kernels via the *_bench tools — exact match.

Failed:

  • none observed on gfx906.

Not run:

  • CUDA / SYCL / Metal builds — no hardware; changes are confined to ggml/src/ggml-hyperturing HIP paths and gfx906-gated code, but non-gfx906 HIP is unverified here.
  • Windows/HIP — Linux only.

Limits

  • Branch is based on 0.2.7; main has moved ~4k commits. Rebase offered above.
  • --prefill-pipe optimum is rig-dependent (r 300-450 here); a bad ratio costs decode.
  • ROCm >= 7 in a container is the reliable runtime on older host kernels (host ROCm 6.3 cannot launch gfx906 kernels); gfx906 Tensile library required.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/5361 **Author:** [@rpcribari](https://github.com/rpcribari) **Created:** 11/6/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `int6` --- ### 📝 Commits (10+) - [`a3dd11f`](https://github.com/Niko1221/Strata/commit/a3dd11ff4c8900f999f9cc08e825d98a82d415a1) local gfx906 build patches (hip_compat stream-priority macros, __align__ spelling) - [`5e4719a`](https://github.com/Niko1221/Strata/commit/5e4719a720cbd40784d1209c16bf57f37b3f997e) gfx906: IQ4_NL gate/up experts (STRATA_GU_FMTS; generic layout) + parity coverage - [`70a5e7d`](https://github.com/Niko1221/Strata/commit/70a5e7d2675d977dde63f841589521c0719da86e) gfx906 prefill: opt-in STRATA_PF_RP=1 - IQ4_NL expert products through mx-llama.cpp's repacked GEMM (vendored src/prefill/rp/, MIT); the group gather writes the repacked layout; rp_expert_bench (bitwise vs MMQ) - [`fe4ab83`](https://github.com/Niko1221/Strata/commit/fe4ab83e08f8d7116a0d21a97b2923f14e80368d) gfx906: dense_mmq_bench (dense projections: dequant + hipBLAS FP16 vs int8 MMQ vs repacked, at the engine's shapes) - [`658a1b7`](https://github.com/Niko1221/Strata/commit/658a1b728234e8c023c3b3bdc8a905b6775c4383) gfx906: STRATA_DENSE_MMQ=1 (Gemm::native_mmq) on the gfx906 build; STRATA_DENSE_MMQ_SKIP (default attn_k.,attn_v.: K/V stay FP16, keeps the MTP acceptance) - [`9247000`](https://github.com/Niko1221/Strata/commit/9247000cee0d2db584c4aac38914c18246e7a6e6) gfx906: STRATA_DENSE_RP=1 - dense IQ4_NL projections through the repacked GEMM (weight repacked per call into a grow-only scratch; bitwise equal to dense MMQ) - [`2e75c0d`](https://github.com/Niko1221/Strata/commit/2e75c0d2785ed7592990c89e717f6588556e9916) gfx906 dense repack: Q8_0, Q6_K, Q5_K too (mx's device repack kernels vendored in src/prefill/rp/repack-convert.cuh; Q4_K stays MMQ, slower repacked); dense_mmq_bench: bitwise rp-vs-mmq check - [`43ff98c`](https://github.com/Niko1221/Strata/commit/43ff98c5ba0648c8e733d11f3f58ea747ceb7541) gfx906 expert repack per product: an IQ4_NL down under non-IQ4_NL gate/up (GSQ-RCO IQ3_S file) takes the repacked GEMM on its own; the other part gathered as GGUF for MMQ (bitwise equal to stock) - [`1d8e9ee`](https://github.com/Niko1221/Strata/commit/1d8e9eeac0126240747ff9144cd0621213171b0a) gfx906 dense repack: IQ4_XS (Strata's own layout: IQ4_NL nibble plane + FP32 per-sub-block scales; bitwise equal to MMQ); STRATA_DENSE_MMQ_PROFILE=1 times each dense MMQ call - [`e4f4027`](https://github.com/Niko1221/Strata/commit/e4f4027ffced1abb2807fb9aa0414bd3128905eb) gfx906 expert repack: IQ3_XXS / IQ3_S gate/up (GSQ-RCO IQ3_S file) through the repacked GEMM ### 📊 Changes **31 files changed** (+5046 additions, -147 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+9 -0) ➕ `bench/results/2026-10-30-mi50-32gb-decode/README.md` (+79 -0) 📝 `docs/AMD_HIP.md` (+4 -0) ➕ `docs/AMD_MI50.md` (+220 -0) ➕ `docs/gfx906.md` (+70 -0) 📝 `include/strata/platform/hip_compat/strata_hip.h` (+22 -1) 📝 `include/strata/prefill/gemm.hpp` (+7 -0) ➕ `include/strata/prefill/rp_moe.hpp` (+89 -0) 📝 `src/core/dflash2.cpp` (+1 -1) 📝 `src/kernels/cuda/fused_gr.cu` (+329 -43) 📝 `src/kernels/cuda/iq_kernels.cu` (+306 -65) 📝 `src/kernels/cuda/native_bf16.cu` (+12 -7) 📝 `src/kernels/cuda/native_mmvq.cu` (+161 -9) 📝 `src/kernels/cuda/router_top10.cu` (+3 -3) 📝 `src/kernels/cuda/sampler.cu` (+17 -1) 📝 `src/kernels/cuda/verify_kernels.cu` (+11 -1) 📝 `src/kernels/fused_gr_bench.cpp` (+14 -2) 📝 `src/kernels/native_expert_bench.cpp` (+14 -1) 📝 `src/kernels/native_grouped_parity.cpp` (+1 -1) ➕ `src/prefill/dense_mmq_bench.cu` (+226 -0) _...and 11 more files_ </details> ### 📄 Description ## Problem and result gfx906 (MI50 32 GB / MI60 / Radeon VII) is the cheapest way into a big-context MoE rig, but on Qwen3.8-Flash-Next the whole gfx906 ecosystem was stuck around 62 t/s decode and ~1250 t/s prefill-8K (best published llama.cpp fork), and Strata layer-split prefill ran one card at a time on this hardware. This branch (21 commits on 0.2.7) takes a 4x MI50 box to: | metric | before | after | |---|---|---| | decode (single stream, MTP) | ~95 t/s | **125 t/s** | | prefill 8K | 725 t/s | **1250 t/s** | | prefill 32K | 843 t/s | **1766 t/s** | ## Related discussion none — opening as a concrete proposal; happy to rebase onto current main or split into reviewable chunks (kernels / pipeline fix / docs), whichever is easier. ## Approach - **Repacked-GEMM prefill stack** for gfx906: IQ4_NL/IQ3 expert and dense products through a repacked int8 GEMM (vendored from mx-llama.cpp, MIT), FP16-in/out prompt GEMMs, dense MMQ for projections. Every path bitwise-checked against the stock kernels. - **Decode kernels**: MMVQ with activations in LDS + four lanes per cell, IQ GEMV / grouped-expert address-cycle cuts, DPP/`ds_swizzle` reductions replacing `ds_bpermute`, sampler load pipelining, hyper-connection read staging. - **HIP pipeline fix**: reserve the MTP prefill under an in-flight verify window (fixes a decode stall on layer splits). - **`--prefill-pipe` for gfx906**: with the expert cache fully VRAM-resident the per-chunk fixed cost is small, so r ~ 300-450 wins big; without it a layer-split prefill serializes one card at a time. Guidance in `docs/gfx906.md`. All engine-visible behavior is switch-gated (`STRATA_*` env / existing flags); default-on only on the gfx906 build (`-DSTRATA_HIP_GFX906=ON`). No changes outside the HIP/gfx906 paths. ## Validation **Passed:** - `strata-bench`-style throughput runs, revision `int6` (`14f591d4`), 4x MI50 32 GB Gen3 x8, 250 GB RAM, ROCm 7.2.4 container, UD-IQ4_XS pack: decode 125 t/s, pp8K 1250 t/s, pp32K 1766 t/s. Nonce-bearing prompts (no cache hits), warm pass reported, run twice after idle. - Deterministic pass/fail quality harness (8 tasks, temp 0, seed 42): 5/8 — identical to the pre-change baseline, no regressions. - Kernel bitwise checks: repacked GEMM / FP16 GEMM / MMQ paths vs stock kernels via the `*_bench` tools — exact match. **Failed:** - none observed on gfx906. **Not run:** - CUDA / SYCL / Metal builds — no hardware; changes are confined to `ggml/src/ggml-hyperturing` HIP paths and gfx906-gated code, but non-gfx906 HIP is unverified here. - Windows/HIP — Linux only. ## Limits - Branch is based on 0.2.7; main has moved ~4k commits. Rebase offered above. - `--prefill-pipe` optimum is rig-dependent (r 300-450 here); a bad ratio costs decode. - ROCm >= 7 in a container is the reliable runtime on older host kernels (host ROCm 6.3 cannot launch gfx906 kernels); gfx906 Tensile library required. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5403
No description provided.