[PR #7] [MERGED] HIP prompt speed: tuned hipBLASLt GLM projections, runtime sub-batch (7900 XT, R9700, Strix Halo) #276

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

📋 Pull Request Information

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

Base: main ← Head: perf/glm-prompt-hipblaslt


📝 Commits (8)

  • ea1d6b3 Add experimental Linux gfx1100 setup and GLM HIP compatibility
  • cdf403a Port Strata multi-architecture HIP checks and RDNA4 intrinsics
  • fd1b89d Check HIP architecture list normalization and rejection cases
  • 44170e0 Document multi-architecture R9700 validation and compile-only gfx1151
  • fede389 Let HIP choose the GLM prefill chunk
  • 951ee6d HIP prompt speed: tuned hipBLASLt GLM projections and a runtime sub-batch
  • eed624c Keep the hipBLASLt prompt path HIP-only and link the GLM binaries in order
  • 9acdc27 Update AMD audit docs for GLM hipBLASLt

📊 Changes

33 files changed (+1376 additions, -95 deletions)

View changed files

📝 .gitignore (+4 -0)
📝 CMakeLists.txt (+20 -5)
📝 README.md (+3 -0)
📝 cmake/hip_backend.cmake (+47 -8)
📝 docs/AMD_HIP.md (+5 -0)
➕ docs/AMD_MAYA.md (+142 -0)
➕ docs/AMD_RDNA4.md (+78 -0)
➕ docs/AMD_UPSTREAM.md (+71 -0)
📝 include/strata/core/device.hpp (+3 -0)
📝 include/strata/hip_compat/cublas_v2.h (+4 -0)
➕ include/strata/hip_compat/cuda_profiler_api.h (+4 -0)
📝 include/strata/hip_compat/cuda_runtime.h (+10 -0)
📝 include/strata/hip_compat/intrinsics.hpp (+71 -33)
📝 maya.py (+136 -10)
📝 setup.py (+7 -6)
📝 src/core/device.cu (+51 -5)
📝 src/core/device_main.cpp (+1 -1)
📝 src/core/glm_fast_path.cu (+6 -0)
📝 src/core/glm_model.cu (+1 -1)
📝 src/core/glm_prefill.cu (+47 -17)

...and 13 more files

📄 Description

Faster prompt processing on AMD. Tracking issue: #6.

Experimental AMD support for Maya: Linux, one GPU, text only. It carries the former #3 (RX 7900 XT setup) and #4 (R9700 and multi-architecture builds), rebased on v1.0.10.

What changes

  • hipBLASLt for the GLM prompt projections: hgemm_q in src/core/glm_prefill.cu goes through the existing strata::prefill::Gemm::f16 when STRATA_HIPBLASLT_TUNING names a table. Without a table nothing changes; shapes without a row keep plain hipBLAS. HIP only.
  • Runtime sub-batch: STRATA_GLM_PREFILL_SUB replaces the compile-time 256-token sub-batch of the mixers and the dense FFN. The default is still 256, so CUDA behaviour is unchanged.
  • Engine-sized prompt chunk: maya.py no longer forces STRATA_GLM_PREFILL_CHUNK=256 for HIP. On cards with 20 GB or more it writes STRATA_GLM_PREFILL_SUB=1024 and STRATA_GLM_PREFILL_MB=4096 (borrowed from the expert pool only while a prompt runs), plus the card's table when one is shipped.
  • Tuner: tools/hip/tune_hipblaslt scales its absolute-error gate with sqrt(K / 4096). A fixed 0.01 rejected every solution for the K=16384 projection even though relative L2 was 5e-5 against the 1e-4 limit.
  • Tables: tools/hip/{gfx1100,gfx1151,gfx1201}-glm-hipblaslt-100202.txt (hipBLASLt 1.2.x, ROCm 7.2). The gfx1201 table keeps only rows at least 2% faster than hipBLAS, which is already close on RDNA4.
  • Build: the hipBLASLt member, include and setup in PrefillState are HIP-only, so CUDA's prompt path is unchanged. On HIP, glm_model_test, glm_pack_test and glm_model_big_test link strata_engine strata_prefill, as strata does.
  • Attention: HIP now uses upstream's F32 prompt attention unchanged (v1.0.7's 32-row FP16 tile, 34 KB); the HIP-only 16-row tile is gone. The tensor-core kernels stay CUDA-only.

Measured

GLM-5.3-Flash Maya-S-v2 IQ2_XXS, 8K context, prompt tok/s:

Setting RX 7900 XT Ryzen AI Max+ 395 (8060S) R9700
chunk forced to 256 (#3 as first written) ~50 ~70 -
engine-sized chunk ~198 ~116 -
+ tuned hipBLASLt ~253-259 ~195 -
+ sub-batch 1024, prompt budget 4 GB ~413 (4K prompts) ~217 ~490-560

The Strix Halo numbers come from a local build of the same prompt-path change. Per GEMM, hipBLASLt is 3-7.5x faster than hipblasGemmEx on gfx1151 and the 7900 XT; on gfx1201 it's ~1-1.7x.

Tested on this branch

  • Rebased on v1.0.10 and built for gfx1100;gfx1201;gfx1151 with ROCm 7.2.1.
  • GPU checks, 16/16 on both the RX 7900 XT and the R9700: glm_{hc,kda,ffn,dsa,layer}_parity, glm_model_test, hip_intrinsics, hip_handoff, hip_glm_handoff, hip_glm_prefill_attention, iq1_s_parity, hip_prefill_mmq_parity, hip_expert_cache_staging, the device selftest, and glm_hc_parity under HC2 and HC1.
  • tools/test_maya_hip.py (6 tests, one new for these config defaults) and tools/test_hip_archs.py (5) pass.
  • Full model on the RX 7900 XT with the config maya.py now writes: 7 smoke checks (arithmetic, code, a two-turn conversation, three 400-token answers) and 5 back-to-back prompt+answer rounds pass. The table loads (60 rows, gfx1100, version 100202) with zero fallbacks; prompts run at 307-385 tok/s on 1.8-2.5K-token prompts.
  • Not tested here: the CUDA build (no NVIDIA toolchain). With the hipBLASLt code HIP-only, glm_prefill.cu no longer references strata::prefill::Gemm on CUDA, and the CUDA link lines are as on main.
  • Follow-up: --bench and --report still use build/ and nvidia-smi; a separate PR will give them select_build_backend() and an AMD GPU query.

Known issue (not in this PR)

The experimental all-experts-in-RAM mode (STRATA_GLM_RAM_ALL, not part of this PR) hits an intermittent GPU memory fault after a few requests, with or without the CPU lane or prefetching. Maya's normal exclusive tiers with a large RAM budget are stable. I'll follow up in #6.


🔄 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/7 **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:** `perf/glm-prompt-hipblaslt` --- ### 📝 Commits (8) - [`ea1d6b3`](https://github.com/mw00/project-maya/commit/ea1d6b35882ecc9a90deaa9e9865dacbf43711fa) Add experimental Linux gfx1100 setup and GLM HIP compatibility - [`cdf403a`](https://github.com/mw00/project-maya/commit/cdf403ae5094059efa4609295cfe7902aa2bf0be) Port Strata multi-architecture HIP checks and RDNA4 intrinsics - [`fd1b89d`](https://github.com/mw00/project-maya/commit/fd1b89d42f254ef74a9744f895b9d79a324d0b82) Check HIP architecture list normalization and rejection cases - [`44170e0`](https://github.com/mw00/project-maya/commit/44170e022f18d6d811606fe19109485cb1e2aa0d) Document multi-architecture R9700 validation and compile-only gfx1151 - [`fede389`](https://github.com/mw00/project-maya/commit/fede3892095ee5704a8796873c048e5a30fafd3b) Let HIP choose the GLM prefill chunk - [`951ee6d`](https://github.com/mw00/project-maya/commit/951ee6d6a01241128c90a72a8ced785a6e109464) HIP prompt speed: tuned hipBLASLt GLM projections and a runtime sub-batch - [`eed624c`](https://github.com/mw00/project-maya/commit/eed624c700cac83c18a6b9ea89b14de4a9ac19b4) Keep the hipBLASLt prompt path HIP-only and link the GLM binaries in order - [`9acdc27`](https://github.com/mw00/project-maya/commit/9acdc2757fbb28b48173d134bfa2b77ad3827f2a) Update AMD audit docs for GLM hipBLASLt ### 📊 Changes **33 files changed** (+1376 additions, -95 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+4 -0) 📝 `CMakeLists.txt` (+20 -5) 📝 `README.md` (+3 -0) 📝 `cmake/hip_backend.cmake` (+47 -8) 📝 `docs/AMD_HIP.md` (+5 -0) ➕ `docs/AMD_MAYA.md` (+142 -0) ➕ `docs/AMD_RDNA4.md` (+78 -0) ➕ `docs/AMD_UPSTREAM.md` (+71 -0) 📝 `include/strata/core/device.hpp` (+3 -0) 📝 `include/strata/hip_compat/cublas_v2.h` (+4 -0) ➕ `include/strata/hip_compat/cuda_profiler_api.h` (+4 -0) 📝 `include/strata/hip_compat/cuda_runtime.h` (+10 -0) 📝 `include/strata/hip_compat/intrinsics.hpp` (+71 -33) 📝 `maya.py` (+136 -10) 📝 `setup.py` (+7 -6) 📝 `src/core/device.cu` (+51 -5) 📝 `src/core/device_main.cpp` (+1 -1) 📝 `src/core/glm_fast_path.cu` (+6 -0) 📝 `src/core/glm_model.cu` (+1 -1) 📝 `src/core/glm_prefill.cu` (+47 -17) _...and 13 more files_ </details> ### 📄 Description Faster prompt processing on AMD. Tracking issue: #6. Experimental AMD support for Maya: Linux, one GPU, text only. It carries the former #3 (RX 7900 XT setup) and #4 (R9700 and multi-architecture builds), rebased on v1.0.10. ### What changes - **hipBLASLt for the GLM prompt projections:** `hgemm_q` in `src/core/glm_prefill.cu` goes through the existing `strata::prefill::Gemm::f16` when `STRATA_HIPBLASLT_TUNING` names a table. Without a table nothing changes; shapes without a row keep plain hipBLAS. HIP only. - **Runtime sub-batch:** `STRATA_GLM_PREFILL_SUB` replaces the compile-time 256-token sub-batch of the mixers and the dense FFN. The default is still 256, so CUDA behaviour is unchanged. - **Engine-sized prompt chunk:** `maya.py` no longer forces `STRATA_GLM_PREFILL_CHUNK=256` for HIP. On cards with 20 GB or more it writes `STRATA_GLM_PREFILL_SUB=1024` and `STRATA_GLM_PREFILL_MB=4096` (borrowed from the expert pool only while a prompt runs), plus the card's table when one is shipped. - **Tuner:** `tools/hip/tune_hipblaslt` scales its absolute-error gate with `sqrt(K / 4096)`. A fixed 0.01 rejected every solution for the K=16384 projection even though relative L2 was 5e-5 against the 1e-4 limit. - **Tables:** `tools/hip/{gfx1100,gfx1151,gfx1201}-glm-hipblaslt-100202.txt` (hipBLASLt 1.2.x, ROCm 7.2). The gfx1201 table keeps only rows at least 2% faster than hipBLAS, which is already close on RDNA4. - **Build:** the hipBLASLt member, include and setup in `PrefillState` are HIP-only, so CUDA's prompt path is unchanged. On HIP, `glm_model_test`, `glm_pack_test` and `glm_model_big_test` link `strata_engine strata_prefill`, as `strata` does. - **Attention:** HIP now uses upstream's F32 prompt attention unchanged (v1.0.7's 32-row FP16 tile, 34 KB); the HIP-only 16-row tile is gone. The tensor-core kernels stay CUDA-only. ### Measured GLM-5.3-Flash Maya-S-v2 IQ2_XXS, 8K context, prompt tok/s: | Setting | RX 7900 XT | Ryzen AI Max+ 395 (8060S) | R9700 | |---|---|---|---| | chunk forced to 256 (#3 as first written) | ~50 | ~70 | - | | engine-sized chunk | ~198 | ~116 | - | | + tuned hipBLASLt | ~253-259 | ~195 | - | | + sub-batch 1024, prompt budget 4 GB | ~413 (4K prompts) | ~217 | ~490-560 | The Strix Halo numbers come from a local build of the same prompt-path change. Per GEMM, hipBLASLt is 3-7.5x faster than `hipblasGemmEx` on gfx1151 and the 7900 XT; on gfx1201 it's ~1-1.7x. ### Tested on this branch - Rebased on v1.0.10 and built for `gfx1100;gfx1201;gfx1151` with ROCm 7.2.1. - GPU checks, 16/16 on both the RX 7900 XT and the R9700: `glm_{hc,kda,ffn,dsa,layer}_parity`, `glm_model_test`, `hip_intrinsics`, `hip_handoff`, `hip_glm_handoff`, `hip_glm_prefill_attention`, `iq1_s_parity`, `hip_prefill_mmq_parity`, `hip_expert_cache_staging`, the device selftest, and `glm_hc_parity` under HC2 and HC1. - `tools/test_maya_hip.py` (6 tests, one new for these config defaults) and `tools/test_hip_archs.py` (5) pass. - Full model on the RX 7900 XT with the config `maya.py` now writes: 7 smoke checks (arithmetic, code, a two-turn conversation, three 400-token answers) and 5 back-to-back prompt+answer rounds pass. The table loads (60 rows, gfx1100, version 100202) with zero fallbacks; prompts run at 307-385 tok/s on 1.8-2.5K-token prompts. - **Not tested here:** the CUDA build (no NVIDIA toolchain). With the hipBLASLt code HIP-only, `glm_prefill.cu` no longer references `strata::prefill::Gemm` on CUDA, and the CUDA link lines are as on main. - **Follow-up:** `--bench` and `--report` still use `build/` and `nvidia-smi`; a separate PR will give them `select_build_backend()` and an AMD GPU query. ### Known issue (not in this PR) The experimental all-experts-in-RAM mode (`STRATA_GLM_RAM_ALL`, not part of this PR) hits an intermittent GPU memory fault after a few requests, with or without the CPU lane or prefetching. Maya's normal exclusive tiers with a large RAM budget are stable. I'll follow up in #6. --- <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:42 +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#276
No description provided.