[PR #581] HIP: gfx950 (MI350X / MI355X) support and EXL3 decode without a per-block L2 flush #606

Open
opened 2026-10-29 21:27:25 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/581
Author: @yagop
Created: 10/28/2026
Status: 🔄 Open

Base: main ← Head: mi350x-gfx950


📝 Commits (8)

  • 11a4876 HIP: experimental gfx942 (Instinct MI300X / MI325X, wave64) support
  • eaf9612 HIP: gfx942 hipBLASLt tuning table for hipBLASLt 100401 (ROCm 7.14)
  • 8014acf docs: shorter MI300X / MI325X section
  • f81a260 Add gfx950 (MI350X / MI355X, CDNA4) to the wave64 HIP path
  • af8c9c2 HIP: add up split / paired EXL3 GEMV results in kernels of their own
  • d9c76d4 HIP: mv_reduce_kernel, a block per output block and activation
  • 1d471e0 HIP: optional input split for the routed experts (EXL3_XSPLIT)
  • da6adf2 HIP: keep the experts input split out of the CUDA build

📊 Changes

8 files changed (+542 additions, -15 deletions)

View changed files

📝 cmake/hip_backend.cmake (+17 -1)
📝 docs/AMD_MAYA.md (+17 -0)
📝 include/strata/hip_compat/intrinsics.hpp (+4 -2)
📝 maya.py (+4 -2)
📝 src/kernels/cuda/exl3.cu (+314 -4)
📝 src/kernels/cuda/glm_lat8.cuh (+3 -2)
📝 tests/exl3_test.cu (+85 -4)
➕ tools/hip/gfx942-glm-hipblaslt-100401.txt (+98 -0)

📄 Description

Stacked on #468 (gfx942). The first three commits are #468's; this PR adds two:

  1. gfx950 on the wave64 HIP path (27fd39c): the same compat path as gfx908 and gfx942, with packed FP32 and the sdot4 builtin, and the CUDA lat8 kernel path kept as on gfx942. Experimental: tested on one MI350X (288 GB).
  2. EXL3: split and paired GEMV results summed in their own kernels on HIP (bde4bd2). The details follow.

The problem

On HIP, mv_kernel, moe_gate_up / moe_down (and their mixed variants) and win_gu pass work between blocks the CUDA way. Each block writes its partial rows, calls __threadfence() and bumps a counter, and the last block adds the rows up. On gfx942 / gfx950, __threadfence() at agent scope compiles to buffer_wbl2 sc1 + buffer_inv sc1. That writes back and invalidates the XCD's whole L2, once per block.

On the MI350X, a rocprofv3 thread trace of mv_kernel<12, 2> (DeepSeek-V4.1's 6-bit attention and shared expert) puts ~72% of its latency on the s_waitcnt / s_barrier around those fences. That made the 6-bit GEMVs about half of decode time. Splitting K more made it worse, because each block paid the same fixed cost.

The change (HIP only; CUDA is unchanged)

On HIP, the GEMV blocks only write their partial rows. Four small kernels finish them after the launch: mv_reduce_kernel, moe_swiglu_kernel, moe_combine_kernel and win_swiglu_kernel. The kernel boundary orders the writes once per launch instead of once per block. They compute the same sums in the same split / plan order, with the same epilogue, swiglu and combine, so the output bits are the same. win_experts already combined in a kernel of its own (win_combine_kernel); now its swiglu does too.

Results: MI350X, ROCm 7.14, DeepSeek-V4.1 Flash EXL3 3.5 bpw (LibertAIDAI)

before after
dense 6-bit GEMVs, one layer per token (exl3_test --bench-mv) 0.580 ms 0.310 ms
— wq_b 1280 → 32768 77.7 µs 30.1 µs
— wo_b 8192 → 5120 125.8 µs 40.9 µs
routed experts, mixed kernels (exl3_test --bench) 0.164 ms 0.127 ms
maya-ds4 decode with DSpark (479-token prompt, 384 tokens) 52.0 tok/s 74.3 tok/s
maya-ds4 decode without drafting (256 tokens) 27.1 tok/s 43.2 tok/s
  • Same bits: the --bench-mv and --bench output checksums are identical before and after, and the DSpark run generates the same 384 tokens.
  • Tests: exl3_test and exl3_test --exllamav3 data/exl3-exllamav3 pass, including every check that windows match the token path ("0 of N differ from the token path").

Tests

  • exl3_test gains --bench-mv: the dense GEMVs at DeepSeek-V4.1's widths (K2 12, mul1), with µs per call, the trellis read rate and a checksum of the outputs' bits. BENCH_MV_ONLY=<name> and BENCH_MV_ITERS=<n> pick one shape and the iteration count, for profilers.
  • --bench prints the same kind of checksum.

Not measured

  • gfx942 (MI300X / MI325X): it has 8 XCDs and the same fence code, so I expect a similar gain, but I have no gfx942 machine right now.
  • RDNA (wave32): a single L2 makes the fence cheaper there. The change adds one small launch per split or paired call, so it could cost a little on RDNA. If so, it can be limited to multi-XCD targets.
  • Not changed: glm_fast.cu and mm3_exl3.cu use the same last-block pattern (GLM's path and the prompt path), and probably have the same cost on CDNA.

🔄 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/mw00/project-maya/pull/581 **Author:** [@yagop](https://github.com/yagop) **Created:** 10/28/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `mi350x-gfx950` --- ### 📝 Commits (8) - [`11a4876`](https://github.com/mw00/project-maya/commit/11a4876c5ac93c81255fa4925b9029f03a81f588) HIP: experimental gfx942 (Instinct MI300X / MI325X, wave64) support - [`eaf9612`](https://github.com/mw00/project-maya/commit/eaf9612e3ebbb3322d3955f46717e138c48cfa03) HIP: gfx942 hipBLASLt tuning table for hipBLASLt 100401 (ROCm 7.14) - [`8014acf`](https://github.com/mw00/project-maya/commit/8014acfe29065e0ca621bf1041ac5e8e71a5d3f7) docs: shorter MI300X / MI325X section - [`f81a260`](https://github.com/mw00/project-maya/commit/f81a2603aa0adf79e01735b8d68c6eb3fbeb96d4) Add gfx950 (MI350X / MI355X, CDNA4) to the wave64 HIP path - [`af8c9c2`](https://github.com/mw00/project-maya/commit/af8c9c2345563f79fad740193647e0ff2f519e38) HIP: add up split / paired EXL3 GEMV results in kernels of their own - [`d9c76d4`](https://github.com/mw00/project-maya/commit/d9c76d4532c2e02f4fdfff0cf6f74d4344709052) HIP: mv_reduce_kernel, a block per output block and activation - [`1d471e0`](https://github.com/mw00/project-maya/commit/1d471e0ea664840d1999dfca594b6fea94d463cc) HIP: optional input split for the routed experts (EXL3_XSPLIT) - [`da6adf2`](https://github.com/mw00/project-maya/commit/da6adf2b4eeeaf728968cfafbf9db0b4bf7a8f9f) HIP: keep the experts input split out of the CUDA build ### 📊 Changes **8 files changed** (+542 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `cmake/hip_backend.cmake` (+17 -1) 📝 `docs/AMD_MAYA.md` (+17 -0) 📝 `include/strata/hip_compat/intrinsics.hpp` (+4 -2) 📝 `maya.py` (+4 -2) 📝 `src/kernels/cuda/exl3.cu` (+314 -4) 📝 `src/kernels/cuda/glm_lat8.cuh` (+3 -2) 📝 `tests/exl3_test.cu` (+85 -4) ➕ `tools/hip/gfx942-glm-hipblaslt-100401.txt` (+98 -0) </details> ### 📄 Description Stacked on #468 (gfx942). The first three commits are #468's; this PR adds two: 1. **gfx950 on the wave64 HIP path** (`27fd39c`): the same compat path as gfx908 and gfx942, with packed FP32 and the sdot4 builtin, and the CUDA lat8 kernel path kept as on gfx942. Experimental: tested on one MI350X (288 GB). 2. **EXL3: split and paired GEMV results summed in their own kernels on HIP** (`bde4bd2`). The details follow. ### The problem On HIP, `mv_kernel`, `moe_gate_up` / `moe_down` (and their mixed variants) and `win_gu` pass work between blocks the CUDA way. Each block writes its partial rows, calls `__threadfence()` and bumps a counter, and the last block adds the rows up. On gfx942 / gfx950, `__threadfence()` at agent scope compiles to `buffer_wbl2 sc1` + `buffer_inv sc1`. That writes back and invalidates the XCD's **whole L2**, once per block. On the MI350X, a rocprofv3 thread trace of `mv_kernel<12, 2>` (DeepSeek-V4.1's 6-bit attention and shared expert) puts ~72% of its latency on the `s_waitcnt` / `s_barrier` around those fences. That made the 6-bit GEMVs about half of decode time. Splitting K more made it worse, because each block paid the same fixed cost. ### The change (HIP only; CUDA is unchanged) On HIP, the GEMV blocks only write their partial rows. Four small kernels finish them after the launch: `mv_reduce_kernel`, `moe_swiglu_kernel`, `moe_combine_kernel` and `win_swiglu_kernel`. The kernel boundary orders the writes once per launch instead of once per block. They compute the same sums in the same split / plan order, with the same epilogue, swiglu and combine, so the output bits are the same. `win_experts` already combined in a kernel of its own (`win_combine_kernel`); now its swiglu does too. ### Results: MI350X, ROCm 7.14, DeepSeek-V4.1 Flash EXL3 3.5 bpw (LibertAIDAI) | | before | after | |---|---|---| | dense 6-bit GEMVs, one layer per token (`exl3_test --bench-mv`) | 0.580 ms | **0.310 ms** | | — `wq_b` 1280 → 32768 | 77.7 µs | 30.1 µs | | — `wo_b` 8192 → 5120 | 125.8 µs | 40.9 µs | | routed experts, mixed kernels (`exl3_test --bench`) | 0.164 ms | **0.127 ms** | | `maya-ds4` decode with DSpark (479-token prompt, 384 tokens) | 52.0 tok/s | **74.3 tok/s** | | `maya-ds4` decode without drafting (256 tokens) | 27.1 tok/s | **43.2 tok/s** | - **Same bits:** the `--bench-mv` and `--bench` output checksums are identical before and after, and the DSpark run generates the same 384 tokens. - **Tests:** `exl3_test` and `exl3_test --exllamav3 data/exl3-exllamav3` pass, including every check that windows match the token path ("0 of N differ from the token path"). ### Tests - `exl3_test` gains `--bench-mv`: the dense GEMVs at DeepSeek-V4.1's widths (K2 12, mul1), with µs per call, the trellis read rate and a checksum of the outputs' bits. `BENCH_MV_ONLY=<name>` and `BENCH_MV_ITERS=<n>` pick one shape and the iteration count, for profilers. - `--bench` prints the same kind of checksum. ### Not measured - **gfx942 (MI300X / MI325X):** it has 8 XCDs and the same fence code, so I expect a similar gain, but I have no gfx942 machine right now. - **RDNA (wave32):** a single L2 makes the fence cheaper there. The change adds one small launch per split or paired call, so it could cost a little on RDNA. If so, it can be limited to multi-XCD targets. - **Not changed:** `glm_fast.cu` and `mm3_exl3.cu` use the same last-block pattern (GLM's path and the prompt path), and probably have the same cost on CDNA. --- <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 labels
pull-request
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
mw00/project-maya#606
No description provided.