Repository navigation
Conversation
A function-like macro splits its arguments on the commas inside a template argument list, so cudaFuncSetAttribute(kernel<1, 6, true>, ...) failed to compile (fused_gr.cu:1089-1093, 'too many arguments provided to function-like macro invocation'). Restore the template function 0.1.38's hip_compat/ cuda_runtime.h had, and add the two carveout definitions used beside it. gfx906-only: include/strata/platform/hip_compat/ is on the include path only inside if(STRATA_HIP_GFX906); CUDA and the wave32 RDNA backend are untouched.
|
Thanks for the detailed report and the reproducible fix. Our gfx906 build was made with HIP/ROCm 7.14 from mixa3607/rocm-gfx906:7.14-complete, so we have not verified this build path on ROCm 7.2.1. Your explanation of the template commas being split by the function-like macro is clear, and the template wrapper is a sensible fix; the MI50 build and inference results are especially useful. |
|
Two other open PRs fix the same two lines in this header:
All three replace the function-like |
|
Merged for 0.1.40 (cudaFuncSetAttribute as a function on HIP/gfx906). Thank you. |
…lockingSync) Two gfx906 build failures on v0.1.40.2. Both are one-line gates that know about the wave32 HIP backend but not about STRATA_HIP_GFX906 -- the same class as #808 and #1083. Neither is fixed on main (e8ca9af). 1) src/prefill/prefill.cpp:399 builds an event with cudaEventDisableTiming | cudaEventBlockingSync, but the gfx906 compat header include/strata/platform/hip_compat/strata_hip.h maps only cudaEventDisableTiming and cudaEventDefault. The wave32 header include/strata/hip_compat/cuda_runtime.h:39 has the mapping. -> add #define cudaEventBlockingSync hipEventBlockingSync there. A diff of the whole set of cuda* defines between the two headers lists one other name the gfx906 header lacks, cudaDevAttrIntegrated, and that one is already gated upstream (#if defined(__linux__) && !defined(STRATA_HIP_GFX906) in src/core/expert_cache.cpp:31), so it is deliberately not touched here. 2) Link error: undefined symbol void mul_mat_q_case<(ggml_type)14>(ggml_backend_cuda_context&, mmq_args const&, ihipStream_t*) (14 = GGML_TYPE_Q6_K). src/prefill/moe_mmq.cu:219 calls it under #if defined(__HIPCC__) || defined(STRATA_Q6K_EXPERTS), so any HIP compilation references it; mmq.cuh declares the case as an extern template, so the definition must come from template-instances/mmq-instance-q6_k.cu. The CUDA branch of CMakeLists.txt adds that file only under STRATA_Q6K_EXPERTS. STRATA_HIP_GFX906=ON forces STRATA_ENABLE_CUDA=ON, so gfx906 takes the CUDA branch while its .cu files are compiled as HIP. -> widen the gate: STRATA_Q6K_EXPERTS OR STRATA_HIP_GFX906. This adds one MMQ instance to the static library. It does not enable STRATA_Q6K_EXPERTS (the grouped Q6_K expert kernels that allocate extra VRAM), and STRATA_HIP_GFX906 is only ever ON in the gfx906 build, so CUDA and wave32 builds are untouched. Verified on a single Instinct MI50 32 GB (gfx906, wave64), ROCm/HIP 7.14, -DSTRATA_HIP_GFX906=ON -DCMAKE_HIP_ARCHITECTURES=gfx906 -DSTRATA_MMQ_KQUANTS=ON: - the engine builds and serves UD-IQ4_XS (Qwen3.8-Flash-Next) end to end: /v1/models, chat completions, tool calls, MTP drafts accepted; - nm -C shows mul_mat_q_case<(ggml_type)14> in the binary (13 instances: 7 8 12 13 14 16 17 18 20 21 22 23 42); - change 2 is load-bearing: removing mmq-instance-q6_k.cu.o from libstrata_mmq.a and relinking with the same link command line fails with exactly the undefined symbol above (the archive holds one U reference and that one W definition), while the untouched archive relinks cleanly.
…lockingSync) Two gfx906 build failures on v0.1.40.2. Both are one-line gates that know about the wave32 HIP backend but not about STRATA_HIP_GFX906 -- the same class as Niko1221#808 and Niko1221#1083. Neither is fixed on main (ef29f14). 1) src/prefill/prefill.cpp:399 builds an event with cudaEventDisableTiming | cudaEventBlockingSync, but the gfx906 compat header include/strata/platform/hip_compat/strata_hip.h maps only cudaEventDisableTiming and cudaEventDefault. The wave32 header include/strata/hip_compat/cuda_runtime.h:39 has the mapping. -> add #define cudaEventBlockingSync hipEventBlockingSync there. A diff of the whole set of cuda* defines between the two headers lists one other name the gfx906 header lacks, cudaDevAttrIntegrated, and that one is already gated upstream (#if defined(__linux__) && !defined(STRATA_HIP_GFX906) in src/core/expert_cache.cpp:31), so it is deliberately not touched here. 2) Link error: undefined symbol void mul_mat_q_case<(ggml_type)14>(ggml_backend_cuda_context&, mmq_args const&, ihipStream_t*) (14 = GGML_TYPE_Q6_K). src/prefill/moe_mmq.cu:219 calls it under #if defined(__HIPCC__) || defined(STRATA_Q6K_EXPERTS), so any HIP compilation references it; mmq.cuh declares the case as an extern template, so the definition must come from template-instances/mmq-instance-q6_k.cu. The CUDA branch of CMakeLists.txt adds that file only under STRATA_Q6K_EXPERTS. STRATA_HIP_GFX906=ON forces STRATA_ENABLE_CUDA=ON, so gfx906 takes the CUDA branch while its .cu files are compiled as HIP. -> widen the gate: STRATA_Q6K_EXPERTS OR STRATA_HIP_GFX906. This adds one MMQ instance to the static library. It does not enable STRATA_Q6K_EXPERTS (the grouped Q6_K expert kernels that allocate extra VRAM), and STRATA_HIP_GFX906 is only ever ON in the gfx906 build, so CUDA and wave32 builds are untouched. Verified on a single Instinct MI50 32 GB (gfx906, wave64), ROCm/HIP 7.14, -DSTRATA_HIP_GFX906=ON -DCMAKE_HIP_ARCHITECTURES=gfx906 -DSTRATA_MMQ_KQUANTS=ON: - the engine builds and serves UD-IQ4_XS (Qwen3.8-Flash-Next) end to end: /v1/models, chat completions, tool calls, MTP drafts accepted; - nm -C shows mul_mat_q_case<(ggml_type)14> in the binary (13 instances: 7 8 12 13 14 16 17 18 20 21 22 23 42); - change 2 is load-bearing: removing mmq-instance-q6_k.cu.o from libstrata_mmq.a and relinking with the same link command line fails with exactly the undefined symbol above (the archive holds one U reference and that one W definition), while the untouched archive relinks cleanly.
Problem
Building the gfx906 backend (
-DSTRATA_HIP_GFX906=ON) from source fails on ROCm 7.2.1:cudaFuncSetAttributeis a function-like macro ininclude/strata/platform/hip_compat/strata_hip.h, and the call sites pass a template instantiation whose argument list contains commas — the preprocessor splits on them and the macro gets too many arguments.Environment
Error
include/strata/platform/hip_compat/strata_hip.h:154:src/kernels/cuda/fused_gr.cu:1089-1093:5 errors (lines 1089-1093). The preprocessor reads
gr_down_v3_kernel<1, kFusedGrMaxT, false>as several macro arguments (<1,kFusedGrMaxT, …) and chokes on the rest. This is standard preprocessor behaviour, not a toolchain quirk — a plaingcc -Eon the same construct gives "passed 5 arguments, but takes just 3".Fix (2 changes, both in
strata_hip.h)(1)
cudaFuncSetAttributeback to a template function — as it was in 0.1.38'ship_compat/cuda_runtime.h:130(which is why the wave32 backend never tripped on this):(2) Two definitions used beside it were missing from the platform header (present in the old one):
Scope / safety
include/strata/platform/hip_compat/is only added to the include path insideif(STRATA_HIP_GFX906)(CMakeLists.txt:106-120), and the affected calls are inside#if defined(STRATA_HIP_GFX906). CUDA builds use the real CUDA function and the wave32 RDNA backend uses the older header — neither is touched. The change only makes the gfx906 build compile.Verified on MI50 32 GB (IQ2_XS, 4k prompt, 256 decode,
--spec 3)Correctness on both:
17*23 → 391. After the fixmakeis EXIT 0, the binary linkslibhipblas/librocblas, 108gfx906code objects, engine loads and serves.Question for @JeanP00l
Thanks for the gfx906 port — it works great once building. We don't know which ROCm/toolchain you built on: on ROCm 7.2.1 the macro above is a hard error here, yet it built for you (and gcc/clang agree the construct is malformed regardless of version). Could you share your HIP/ROCm version? If your build took a path that skips these lines, that would explain it — and is worth documenting either way.
(We also have a community MI50 benchmark open as #758.)