mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #638] [CLOSED] hip: AMD Instinct MI50 / MI60 / Radeon VII (gfx906, wave64) as an opt-in build #2735
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2735
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/638
Author: @JeanP00l
Created: 10/3/2026
Status: ❌ Closed
Base:
main← Head:pr-gfx906📝 Commits (6)
4a8d837hip: AMD gfx906 (Instinct MI50 / MI60, Radeon VII; wave64) as an opt-in build, STRATA_HIP_GFX906=ONfde336bdocs: gfx906 (Instinct MI50 / MI60, Radeon VII) build, kernels and measurements in AMD_HIP.md6a12d43gfx906: K-quant/Q5_1/Q8_0 experts take the CUDA layout; gr_down K-split opt-in; gfx906-aware ctest17beb33gfx906: route the verify window's tokens in one BF16 projection + one top-k (bitwise the per-token calls)288c1dddocs: gfx906 verify-window routing in the kernel tablea914b13fused_gr: the gfx906 fast norm/up launches only in the gfx906 build (CUDA and RDNA did not compile)📊 Changes
33 files changed (+2087 additions, -11 deletions)
View changed files
📝
.gitignore(+1 -0)📝
CMakeLists.txt(+71 -5)📝
docs/AMD_HIP.md(+62 -1)📝
include/strata/core/layer.hpp(+3 -0)📝
include/strata/kernels/bf16_gemv.hpp(+4 -0)📝
include/strata/kernels/dp4a.hpp(+3 -0)📝
include/strata/kernels/fused_gr.hpp(+2 -0)📝
include/strata/kernels/iq_kernels.hpp(+3 -0)📝
include/strata/kernels/mrope.hpp(+3 -0)➕
include/strata/platform/hip_compat/cublas_v2.h(+26 -0)➕
include/strata/platform/hip_compat/cuda_fp16.h(+2 -0)➕
include/strata/platform/hip_compat/cuda_runtime.h(+2 -0)➕
include/strata/platform/hip_compat/math_constants.h(+4 -0)➕
include/strata/platform/hip_compat/strata_hip.h(+295 -0)📝
src/core/device.cu(+12 -2)📝
src/core/layer.cpp(+28 -0)📝
src/core/verify.cpp(+9 -0)📝
src/kernels/cuda/fused_gr.cu(+271 -0)📝
src/kernels/cuda/iq_kernels.cu(+656 -1)📝
src/kernels/cuda/native_bf16.cu(+13 -0)...and 13 more files
📄 Description
What
The HIP backend (
STRATA_ENABLE_HIP) is wave32 RDNA only, and the engine refuses a wave64 card. AMD Instinct MI50 / MI60 and Radeon VII (gfx906) are cheap 16/32 GB cards with ~1 TB/s HBM2. This PR adds an opt-in build for them:-DSTRATA_HIP_GFX906=ON -DCMAKE_HIP_ARCHITECTURES=gfx906.It compiles the CUDA sources as HIP through a small compat layer (
include/strata/platform/hip_compat/). A CUDA warp is a logical half of the 64-lane wavefront: 32-wide shuffles, and a ballot of its own half. With the option off, nothing changes for CUDA or the RDNA backend. Every new path is underSTRATA_HIP_GFX906, a macro neither existing build defines.Why a separate option and not
STRATA_ENABLE_HIP+ gfx906The RDNA backend's kernels and compat layer assume wave32 throughout. Treating the CUDA warp as half a wavefront let the CUDA path run unchanged on gfx906 first, and then the hot kernels got wave64 layouts of their own. If you'd rather fold gfx906 into
STRATA_ENABLE_HIP/cmake/hip_backend.cmake, I'm happy to rework it that way. Tell me which you prefer.Correctness fixes found on the way (each changed results or hung)
__fmul_rn/__fadd_rn/__fsub_rncontracted into FMA under HIP. They no longer do, so the elementwise and quantize_act parity tests pass bitwise.__byte_permis a scratch-memory array. The IQ4 table lookup now uses llama.cpp'sv_perm_b32sequence: agent-request decode on 2x MI50 went from 29.9 to 39.2 tok/s.CUDART_VERSIONtoolkit check is skipped under HIP.gdn_rec_parity(cp.async, CUDA occupancy API) is not built for gfx906.wave64 kernels (gfx906 only; each has an env switch back to the CUDA layout for A/B)
Each was checked bitwise against the layout it replaces: parity tests,
native_expert_benchon real GGUF rows, and the greedy text of a fixed request.dp4a(g ^ m, u) - dp4a(m, u)(gfx906 has no byte SIMD;__vcmpne4/__vsub4were ~12 word ops each), grids and activations in LDS, one weight load per groupSTRATA_EXP_MODE=2STRATA_MMVQ_WAVE=0STRATA_ROUTE_PER_TOKEN=1gr_down_multi(opt-in)STRATA_GR_SPLIT=1STRATA_GR_FAST=0docs/AMD_HIP.mdgets a gfx906 section: the build recipe on the community ROCm 7.14 image (AMD dropped gfx906 from current ROCm), the table above, and measurements.Measured (on the port this is cut from)
2x MI50 16 GB (85 W each, PCIe 3.0 x16), Xeon E5-2666 v3, 32 GB DDR4. Coder IQ1_M, 128K context,
--kv int8 --kv-resident 32768,--layer-split 27,--prefill 4096, MTP--spec 4.tg128.These numbers also include #639 (layer-split weight trim) and #640 (mapped arena for small RAM), which are separate PRs.
Verified for this branch
allwithSTRATA_HIP_GFX906=ON(gfx906, ROCm 7.14).allwithSTRATA_ENABLE_HIP=ONfor gfx1100, so the RDNA backend is intact.allwith CUDA 13.0 for sm_86, so the CUDA path is intact.Status
Re-run on 2x MI50 with this branch: ctest 35/35 on the cards and the greedy-text comparison with the port branch are in the comment below; builds checked for gfx906, gfx1100 and CUDA sm_86 at the branch head.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.