mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3083] [CLOSED] fix(HIP compat): the Qwen3.6 engine does not compile on ROCm, and gfx906 does not link at all #4443
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#4443
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/3083
Author: @benthic-io
Created: 10/18/2026
Status: ❌ Closed
Base:
main← Head:hip-compat-aliases📝 Commits (3)
1afcf5bfix(HIP compat): the two cuBLAS names the Qwen3.6 engine's GEMM path callsbe72e2dfix(HIP compat): the two int4 staging arrays that bypassed STRATA_SHARED_ALIGN16_U329dde8fefix(gfx906): link moe_f16_kq.cu on the CUDA-target path, or strata does not link at all📊 Changes
3 files changed (+20 additions, -5 deletions)
View changed files
📝
CMakeLists.txt(+9 -3)📝
include/strata/platform/hip_compat/cublas_v2.h(+2 -0)📝
src/kernels/cuda/iq_kernels.cu(+9 -2)📄 Description
Title
fix(HIP compat): the Qwen3.6 engine does not compile on a ROCm target
Issue: Resolves #
Summary
Three separate defects, all on the AMD path, none reachable from a CUDA build:
maindoes not link at all onSTRATA_HIP_GFX906- the Qwen3.6 / qwen35moe engine path cannot be built.src/qwen35/q36_engine.cudoes not compile for HIP - two cuBLAS names the HIP compatibility header does not map.__shared__ alignas(16)the HIP host pass rejects.None is a configuration problem. A
#definecannot come from a CMake option or an environment variable, thedeclaration syntax is fixed by the compiler, and a missing source file is missing.
What changed
CMakeLists.txt-STRATA_HIP_GFX906forcesSTRATA_ENABLE_CUDA ON, so a gfx906 build takes thisadd_library(strata_mmq ...)and not theSTRATA_PREFILL_MMQone below it - and this list omitssrc/prefill/moe_f16_kq.cu, which the other one does list.moe_fused_iq.cucallsf16kq::covers / gate_up / downinside#if defined(__HIPCC__)with noSTRATA_PF_F16opt-in around them, so every HIP build on this pathreferences symbols that are not compiled:
Adding the file resolves it;
f16kq::covers()keeps the gfx11 kernels undispatched elsewhere, so run-timebehaviour is unchanged. Guarded by
STRATA_HIP_GFX906because a CUDA build references none of these symbols andshould not compile a gfx11 kernel file.
include/strata/platform/hip_compat/cublas_v2.h- two missing cuBLAS-to-hipBLAS aliases:cublasSgemm, the F32 projections on the tiled split-K SGEMM (q36_engine.cu:1555)cublasGemmStridedBatchedEx, the prompt chunk's FP16 Q K^T and P V (q36_engine.cu:1958,:1972)src/kernels/cuda/iq_kernels.cu-STRATA_SHARED_INT4, for the twoint4staging arrays at:1856and:2043. These spell the attribute out longhand where the neighbouring line usesSTRATA_SHARED_ALIGN16_U32.That macro exists for exactly this reason (#778) and its comment already records the workaround, so this follows
the established pattern.
int4is 16-byte aligned by type, so under__HIPCC__the explicit attribute isdropped - same layout, as the existing comment says for
uint32_t.Extra Notes
Before, on gfx906:
After:
ninja strata strata-q36is clean.Verified on gfx906 (Radeon VII, 16 GiB), ROCm 7.1, Fedora 44, gcc host compiler,
-DSTRATA_HIP_GFX906=ON -DCMAKE_HIP_ARCHITECTURES=gfx906 -DSTRATA_GGML_DIR=<llama.cpp>. Each file was checkedindividually: it fails to compile without its change and compiles with it. The rebuilt
stratathen serves theIQ4_XS pack (HTTP 200, correct answer, 3982 MiB free with everything loaded) and
strata-q36runs a Qwen3.6GGUF at 262144 cells (1329 tok/s pp2048, 49.3 tok/s tg32 with
--kv-q8).src/prefill/gemm.cualso namescublasSgemm,cublasGemmAlgo_tandCUBLAS_STATUS_INTERNAL_ERROR, but allthree are inside
#if defined(STRATA_EXPERIMENTAL_SM60)(the experimental Pascal path) and are not compiled ina normal HIP build, so no mapping is added for them here.
One thing I noticed but did not change, since it is a design question rather than a defect: the HIP
workarounds are gated on
STRATA_USE_HIP, whichcmake/hip_backend.cmake:98defines for thestrata_hip_runtimetarget - i.e. theSTRATA_ENABLE_HIP=ONbackend.STRATA_HIP_GFX906=ONinstead definesSTRATA_HIP_GFX906and neverSTRATA_USE_HIP, so the 91#if defined(STRATA_USE_HIP)sites across 12 filesare compiled out of a gfx906 build, including
STRATA_HIP_ADAPT_KERNEL_COPY=1(#884, the SDMA hang workaroundin
generate.cpp:259) andSTRATA_FILE_CACHE_OLD_RULE(#1752, a gfx906-specific stall). Onlygenerate.cpp's outer guard at:248is written as(defined(STRATA_USE_HIP) || defined(STRATA_HIP_GFX906)).Worth deciding whether the two backends should agree here; happy to test a patch that defines
STRATA_USE_HIPon the gfx906 path if that is useful.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.