[PR #19] [MERGED] HIP: faster decode expert kernels on RDNA3/3.5 (RX 7900 XT +8.6% answers, bit-identical) #285

Closed
opened 2026-10-29 21:23:47 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/19
Author: @boxwrench
Created: 10/8/2026
Status: ✅ Merged
Merged: 10/8/2026
Merged by: @mw00

Base: main ← Head: amd/hip-expert-kernels


📝 Commits (2)

  • 6f0bdf6 HIP: improve RDNA decode expert bandwidth with packed signs
  • cb0abc8 HIP: retain legacy IQ3_XXS down on gfx1151

📊 Changes

5 files changed (+795 additions, -14 deletions)

View changed files

📝 CMakeLists.txt (+5 -0)
➕ docs/AMD_EXPERT_KERNELS.md (+151 -0)
➕ include/strata/kernels/glm_expert_bench.hpp (+21 -0)
📝 src/kernels/cuda/glm_fast.cu (+315 -14)
➕ tests/hip/expert_kernel_bench.cpp (+303 -0)

📄 Description

Faster decode expert kernels on RDNA3 / RDNA3.5 (HIP only). The routed-expert gate/up and down kernels for the Maya-S formats read their weights more efficiently; results are bit-identical to the current kernels.

What changes (src/kernels/cuda/glm_fast.cu, HIP builds)

  • Cheaper packed-sign arithmetic for the IQ2_XXS / IQ2_S / IQ3_XXS grids, two-row blocks for the down kernels, and codebook placement chosen by measurement.
  • Per-architecture dispatch: gfx1100 uses the new gate/up and down kernels; gfx1151 uses the new gate/up and IQ2_S down and keeps the current IQ3_XXS down (the new one measured 3% slower there); gfx1201 keeps the current kernels (not tuned). STRATA_HIP_EXPERTS_LEGACY=1 forces the current kernels everywhere.
  • tests/hip/expert_kernel_bench.cpp (hip_expert_kernel_bench): times old vs new at the decode shape (8 experts, 4096 x 2048) and checks parity.
  • CUDA builds are unchanged. Notes and numbers: docs/AMD_EXPERT_KERNELS.md.

Measured

Kernel benchmark, RX 7900 XT (gfx1100), all parity checks bit-identical (max abs 0, rel L2 0):

kernel current new
gate/up IQ2_XXS 93.7 us (369 GB/s) 66.7 us (519 GB/s)
down IQ2_S 57.8 us (372 GB/s) 39.9 us (539 GB/s)
down IQ3_XXS 48.3 us (532 GB/s) 43.5 us (590 GB/s)

Full model, Maya-S, greedy, the same binary with and without STRATA_HIP_EXPERTS_LEGACY=1:

current new
one RX 7900 XT, answers (median of 4) 15.1 tok/s 16.4 tok/s (+8.6%)
R9700 + RX 7900 XT (#14), answers 32.4 tok/s 33.6 tok/s (+3.9%, within noise)
Strix Halo 8060S, answers (median of 3) 17.8 tok/s 18.0 tok/s (~+1%)

On the Strix Halo the expert kernels were already close to its memory bandwidth (gate/up 204 -> 181 us); its decode is dominated by the dense weights. glm_ffn_parity, glm_layer_parity, glm_model_test, iq1_s_parity and hip_intrinsics pass; no errors in any run.

Not tested: CUDA (no NVIDIA toolchain here; the new kernels are HIP-only).


🔄 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/19 **Author:** [@boxwrench](https://github.com/boxwrench) **Created:** 10/8/2026 **Status:** ✅ Merged **Merged:** 10/8/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `amd/hip-expert-kernels` --- ### 📝 Commits (2) - [`6f0bdf6`](https://github.com/mw00/project-maya/commit/6f0bdf665b4c01a24d086210a2506beae3f87b56) HIP: improve RDNA decode expert bandwidth with packed signs - [`cb0abc8`](https://github.com/mw00/project-maya/commit/cb0abc8accec3d09a47cbd9373ff3256f6554995) HIP: retain legacy IQ3_XXS down on gfx1151 ### 📊 Changes **5 files changed** (+795 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+5 -0) ➕ `docs/AMD_EXPERT_KERNELS.md` (+151 -0) ➕ `include/strata/kernels/glm_expert_bench.hpp` (+21 -0) 📝 `src/kernels/cuda/glm_fast.cu` (+315 -14) ➕ `tests/hip/expert_kernel_bench.cpp` (+303 -0) </details> ### 📄 Description Faster decode expert kernels on RDNA3 / RDNA3.5 (HIP only). The routed-expert gate/up and down kernels for the Maya-S formats read their weights more efficiently; results are bit-identical to the current kernels. ### What changes (`src/kernels/cuda/glm_fast.cu`, HIP builds) - Cheaper packed-sign arithmetic for the IQ2_XXS / IQ2_S / IQ3_XXS grids, two-row blocks for the down kernels, and codebook placement chosen by measurement. - Per-architecture dispatch: gfx1100 uses the new gate/up and down kernels; gfx1151 uses the new gate/up and IQ2_S down and keeps the current IQ3_XXS down (the new one measured 3% slower there); gfx1201 keeps the current kernels (not tuned). `STRATA_HIP_EXPERTS_LEGACY=1` forces the current kernels everywhere. - `tests/hip/expert_kernel_bench.cpp` (`hip_expert_kernel_bench`): times old vs new at the decode shape (8 experts, 4096 x 2048) and checks parity. - CUDA builds are unchanged. Notes and numbers: `docs/AMD_EXPERT_KERNELS.md`. ### Measured Kernel benchmark, RX 7900 XT (gfx1100), all parity checks bit-identical (max abs 0, rel L2 0): | kernel | current | new | |---|---|---| | gate/up IQ2_XXS | 93.7 us (369 GB/s) | 66.7 us (519 GB/s) | | down IQ2_S | 57.8 us (372 GB/s) | 39.9 us (539 GB/s) | | down IQ3_XXS | 48.3 us (532 GB/s) | 43.5 us (590 GB/s) | Full model, Maya-S, greedy, the same binary with and without `STRATA_HIP_EXPERTS_LEGACY=1`: | | current | new | |---|---|---| | one RX 7900 XT, answers (median of 4) | 15.1 tok/s | 16.4 tok/s (+8.6%) | | R9700 + RX 7900 XT (#14), answers | 32.4 tok/s | 33.6 tok/s (+3.9%, within noise) | | Strix Halo 8060S, answers (median of 3) | 17.8 tok/s | 18.0 tok/s (~+1%) | On the Strix Halo the expert kernels were already close to its memory bandwidth (gate/up 204 -> 181 us); its decode is dominated by the dense weights. `glm_ffn_parity`, `glm_layer_parity`, `glm_model_test`, `iq1_s_parity` and `hip_intrinsics` pass; no errors in any run. **Not tested:** CUDA (no NVIDIA toolchain here; the new kernels are HIP-only). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:23:47 +07:00
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#285
No description provided.