[PR #858] [CLOSED] gfx906 compat: cudaFuncSetAttribute as a template function, the shared-memory carveout name (#646's fused_gr did not build) #2877

Closed
opened 2026-11-04 02:03:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/858
Author: @agurrrrr
Created: 10/4/2026
Status: ❌ Closed

Base: main ← Head: gfx906-fused-gr-compat


📝 Commits (10+)

  • fa16567 setup: an earlier config that does not parse is skipped, not a crash; configs are written atomically (#459)
  • 749d957 setup (--backend hip): a system ROCm without the HIP development files falls back to the wheels (#446)
  • 5a30024 calibrate: the engine's arguments come from the server's engine_args; a failed tuning says why (#447)
  • 9f60d13 serve, setup: name the small split card that caps the prompt chunk; setup recommends the big card alone (#448)
  • eb8da1d /metrics: each request's speculative draft counts, and their sums in the totals (#457)
  • 6a09387 setup (--gguf-dir): GGUFs Strata cannot run are named as such, with the --family/--model to use (#444)
  • d6a91e2 docs: the Coder is weaker outside code, Chinese/CJK text included; the unpruned sizes for that (#438)
  • d8d4ad3 Merge branch 'f-135-eng' into rel-0.1.35
  • 7b600d5 Merge branch 'f-135-small' into rel-0.1.35
  • d9ab843 Engine 0.1.35: Windows AMD uses its bundled HIP runtime (#468 #461), the low-RAM resident mode on Windows 32 GB PCs (#467), fixes #460 #459 #446 #447 #457 #448 #444; setup requires it

📊 Changes

1 file changed (+5 additions, -1 deletions)

View changed files

📝 include/strata/platform/hip_compat/strata_hip.h (+5 -1)

📄 Description

What this fixes

STRATA_HIP_GFX906=ON does not build at main (6f32ec0, v0.1.39). The fused_gr v3 read that cfd3b72 put on
main calls cudaFuncSetAttribute on kernel templates with more than one argument, and sets the shared-memory
carveout: (cfd3b72 is the same work as PR #646 - same author, same subject line - but it went onto main as a direct
commit; PR #646 itself was closed unmerged on 2026-10-04, so the calls below are main's own, from cfd3b72.)

cudaFuncSetAttribute(gr_down_v3_kernel<1, kFusedGrMaxT, false>, cudaFuncAttributeMaxDynamicSharedMemorySize, need1)
cudaFuncSetAttribute(gr_down_v3_kernel<1, 4, true>, cudaFuncAttributePreferredSharedMemoryCarveout, 100);

f166564 added the carveout name to the wave32 compat header (include/strata/hip_compat/cuda_runtime.h), which
already has cudaFuncSetAttribute as a template function. The gfx906 compat header
(include/strata/platform/hip_compat/strata_hip.h) has neither:

  • cudaFuncSetAttribute is a function-like macro there, so the preprocessor splits gr_down_v3_kernel<1, 4, true>
    at its commas into extra macro arguments;
  • cudaFuncAttributePreferredSharedMemoryCarveout is not mapped.

The build stops at fused_gr.cu with 12 errors, the same ones for each of the five calls on lines 1089-1093:

src/kernels/cuda/fused_gr.cu:1089:81: error: too many arguments provided to function-like macro invocation
src/kernels/cuda/fused_gr.cu:1089:17: error: use of undeclared identifier 'cudaFuncSetAttribute'; did you mean 'hipFuncSetAttribute'?
src/kernels/cuda/fused_gr.cu:1089:133: error: comparison between pointer and integer ('hipError_t (*)(const void *, hipFuncAttribute, int)' ...) and 'hipError_t')
...
19 warnings and 12 errors generated when compiling for gfx906.

The change (1 file, +5 / -1): the macro becomes a template function of the same shape as the wave32 header's, and the
carveout name maps to hipFuncAttributePreferredSharedMemoryCarveout. The header is on the include path only under
STRATA_HIP_GFX906 (the STRATA_HIP_GFX906 block is CMakeLists.txt:106-124, and the three include-path entries are
116, 119 and 120), so the CUDA build and the wave32 HIP build do not see it.

How it was checked

AMD Instinct MI50 32 GB (gfx906, PCI id 1002:66a1; rocm-smi reports 34,342,961,152 B of VRAM), EPYC 7452,
125 GiB RAM; CachyOS (kernel 7.2.8), ROCm 7.2.4 (HIP 7.2.53211,
AMD clang 22.0.0git).

result
main (6f32ec0), ninja .../fused_gr.cu.o 12 errors (above)
this branch, ninja (all targets, STRATA_BUILD_TESTS=ON) 269 / 269, 0 errors, 32 s
G=--gcc-install-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/14.3.1
cmake -S . -B build-gfx906 -G Ninja -DSTRATA_HIP_GFX906=ON -DCMAKE_HIP_ARCHITECTURES=gfx906 \
  "-DCMAKE_HIP_FLAGS=--rocm-path=/opt/rocm $G" "-DCMAKE_CXX_FLAGS=$G" -DCMAKE_HIP_COMPILER_ROCM_ROOT=/opt/rocm \
  -DSTRATA_GGML_DIR=<llama.cpp at 3cf0325> \
  -DCMAKE_C_COMPILER=/opt/rocm/llvm/bin/clang -DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++ \
  -DCMAKE_BUILD_TYPE=Release -DSTRATA_BUILD_TESTS=ON
ninja -C build-gfx906

The three flags beyond docs/AMD_HIP.md's command are for this distro's ROCm packaging, not for this change: clang
sits in /opt/rocm/lib/llvm, so CMake guesses the ROCm root as /opt/rocm/lib, fails to identify the HIP compiler
and drops -O3 -DNDEBUG (hence CMAKE_HIP_COMPILER_ROCM_ROOT and --rocm-path); and GCC 16's <format> spells
[[__gnu__::__noinline__]], which HIP's __noinline__ macro breaks (hence GCC 14's headers).

On the card. An engine built from the same source tree (byte-identical to this branch) has served on the MI50
since 2026-10-05: Qwen3.8-Flash-Next GSQ-RCO IQ3_S, --max-context 262144 --kv int8 --spec 4, the experts in host
RAM. Every other cudaFuncSetAttribute call in the gfx906 build (fused_gr.cu:725-731, qsa.cu, the prefill
kernels) now goes through the template and makes the same hipFuncSetAttribute call as the macro did. Measured on that
server, greedy (a range is two runs, a single number one run):

tok/s
decode, short prompts (Korean prose / code) 33.9-34.6 / 39.8-40.9
prompt, 4,526 tokens 375-378
prompt, 42,705 tokens 393
prompt, 78,284 tokens 387

A needle in the 43K and in the 78K prompt is found, and an OpenAI tool call returns the right arguments.

Where those numbers come from: the short-prompt and the 4,526-token rows are the iq3s-0139-alone-mi50 entries of
my bench log (~/code/local-llm/bench/strata-vs-golbang/results.jsonl; greedy, 768 generated tokens, two reports per
prompt), and the 42,705 and 78,284-token rows are long-prompt needle runs against the same server on the same day.

Not covered

  • STRATA_GR_V3=1, the opt-in read that sets the carveout, was not run on the card; this PR only lets it compile.
  • ctest was not run on the card for this PR: the card serves the model above with 586 MiB of VRAM left.
  • The CUDA and the wave32 HIP builds were not rebuilt: neither includes this header.

🔄 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/Niko1221/Strata/pull/858 **Author:** [@agurrrrr](https://github.com/agurrrrr) **Created:** 10/4/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `gfx906-fused-gr-compat` --- ### 📝 Commits (10+) - [`fa16567`](https://github.com/Niko1221/Strata/commit/fa165679f9860552ac97ebd07118bb8db286be4a) setup: an earlier config that does not parse is skipped, not a crash; configs are written atomically (#459) - [`749d957`](https://github.com/Niko1221/Strata/commit/749d957a1790b1a171dd4a01ab3e31b3882c9892) setup (--backend hip): a system ROCm without the HIP development files falls back to the wheels (#446) - [`5a30024`](https://github.com/Niko1221/Strata/commit/5a3002446dbb9dfcabb7d0bd9f113da90cc2f3c0) calibrate: the engine's arguments come from the server's engine_args; a failed tuning says why (#447) - [`9f60d13`](https://github.com/Niko1221/Strata/commit/9f60d13246e46b02b1dd0841980b4d18b0faaea7) serve, setup: name the small split card that caps the prompt chunk; setup recommends the big card alone (#448) - [`eb8da1d`](https://github.com/Niko1221/Strata/commit/eb8da1d8c26ec41e6ffb084fdf579dba7cad10bd) /metrics: each request's speculative draft counts, and their sums in the totals (#457) - [`6a09387`](https://github.com/Niko1221/Strata/commit/6a093874fe037020f49bd5cf053879ff6a133c21) setup (--gguf-dir): GGUFs Strata cannot run are named as such, with the --family/--model to use (#444) - [`d6a91e2`](https://github.com/Niko1221/Strata/commit/d6a91e2d1770d0f469d6ec15890acc7ee93e764c) docs: the Coder is weaker outside code, Chinese/CJK text included; the unpruned sizes for that (#438) - [`d8d4ad3`](https://github.com/Niko1221/Strata/commit/d8d4ad337d3c98ba21d3bd0af1a16e9177e112b6) Merge branch 'f-135-eng' into rel-0.1.35 - [`7b600d5`](https://github.com/Niko1221/Strata/commit/7b600d55ff801caaaa11542af1523050992e049b) Merge branch 'f-135-small' into rel-0.1.35 - [`d9ab843`](https://github.com/Niko1221/Strata/commit/d9ab8435f654c368c586340d490915f6addf56a3) Engine 0.1.35: Windows AMD uses its bundled HIP runtime (#468 #461), the low-RAM resident mode on Windows 32 GB PCs (#467), fixes #460 #459 #446 #447 #457 #448 #444; setup requires it ### 📊 Changes **1 file changed** (+5 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/platform/hip_compat/strata_hip.h` (+5 -1) </details> ### 📄 Description ## What this fixes `STRATA_HIP_GFX906=ON` does not build at `main` (`6f32ec0`, v0.1.39). The fused_gr v3 read that `cfd3b72` put on main calls `cudaFuncSetAttribute` on kernel templates with more than one argument, and sets the shared-memory carveout: (`cfd3b72` is the same work as PR #646 - same author, same subject line - but it went onto main as a direct commit; PR #646 itself was closed unmerged on 2026-10-04, so the calls below are main's own, from `cfd3b72`.) ```cpp cudaFuncSetAttribute(gr_down_v3_kernel<1, kFusedGrMaxT, false>, cudaFuncAttributeMaxDynamicSharedMemorySize, need1) cudaFuncSetAttribute(gr_down_v3_kernel<1, 4, true>, cudaFuncAttributePreferredSharedMemoryCarveout, 100); ``` f166564 added the carveout name to the wave32 compat header (`include/strata/hip_compat/cuda_runtime.h`), which already has `cudaFuncSetAttribute` as a template function. The gfx906 compat header (`include/strata/platform/hip_compat/strata_hip.h`) has neither: - `cudaFuncSetAttribute` is a function-like macro there, so the preprocessor splits `gr_down_v3_kernel<1, 4, true>` at its commas into extra macro arguments; - `cudaFuncAttributePreferredSharedMemoryCarveout` is not mapped. The build stops at fused_gr.cu with 12 errors, the same ones for each of the five calls on lines 1089-1093: ``` src/kernels/cuda/fused_gr.cu:1089:81: error: too many arguments provided to function-like macro invocation src/kernels/cuda/fused_gr.cu:1089:17: error: use of undeclared identifier 'cudaFuncSetAttribute'; did you mean 'hipFuncSetAttribute'? src/kernels/cuda/fused_gr.cu:1089:133: error: comparison between pointer and integer ('hipError_t (*)(const void *, hipFuncAttribute, int)' ...) and 'hipError_t') ... 19 warnings and 12 errors generated when compiling for gfx906. ``` The change (1 file, +5 / -1): the macro becomes a template function of the same shape as the wave32 header's, and the carveout name maps to `hipFuncAttributePreferredSharedMemoryCarveout`. The header is on the include path only under `STRATA_HIP_GFX906` (the `STRATA_HIP_GFX906` block is `CMakeLists.txt:106-124`, and the three include-path entries are 116, 119 and 120), so the CUDA build and the wave32 HIP build do not see it. ## How it was checked AMD Instinct MI50 32 GB (gfx906, PCI id 1002:66a1; `rocm-smi` reports 34,342,961,152 B of VRAM), EPYC 7452, 125 GiB RAM; CachyOS (kernel 7.2.8), ROCm 7.2.4 (HIP 7.2.53211, AMD clang 22.0.0git). | | result | |---|---| | `main` (`6f32ec0`), `ninja .../fused_gr.cu.o` | 12 errors (above) | | this branch, `ninja` (all targets, `STRATA_BUILD_TESTS=ON`) | 269 / 269, 0 errors, 32 s | ```sh G=--gcc-install-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/14.3.1 cmake -S . -B build-gfx906 -G Ninja -DSTRATA_HIP_GFX906=ON -DCMAKE_HIP_ARCHITECTURES=gfx906 \ "-DCMAKE_HIP_FLAGS=--rocm-path=/opt/rocm $G" "-DCMAKE_CXX_FLAGS=$G" -DCMAKE_HIP_COMPILER_ROCM_ROOT=/opt/rocm \ -DSTRATA_GGML_DIR=<llama.cpp at 3cf0325> \ -DCMAKE_C_COMPILER=/opt/rocm/llvm/bin/clang -DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++ \ -DCMAKE_BUILD_TYPE=Release -DSTRATA_BUILD_TESTS=ON ninja -C build-gfx906 ``` The three flags beyond `docs/AMD_HIP.md`'s command are for this distro's ROCm packaging, not for this change: clang sits in `/opt/rocm/lib/llvm`, so CMake guesses the ROCm root as `/opt/rocm/lib`, fails to identify the HIP compiler and drops `-O3 -DNDEBUG` (hence `CMAKE_HIP_COMPILER_ROCM_ROOT` and `--rocm-path`); and GCC 16's `<format>` spells `[[__gnu__::__noinline__]]`, which HIP's `__noinline__` macro breaks (hence GCC 14's headers). **On the card.** An engine built from the same source tree (byte-identical to this branch) has served on the MI50 since 2026-10-05: Qwen3.8-Flash-Next GSQ-RCO IQ3_S, `--max-context 262144 --kv int8 --spec 4`, the experts in host RAM. Every other `cudaFuncSetAttribute` call in the gfx906 build (`fused_gr.cu:725-731`, `qsa.cu`, the prefill kernels) now goes through the template and makes the same `hipFuncSetAttribute` call as the macro did. Measured on that server, greedy (a range is two runs, a single number one run): | | tok/s | |---|---:| | decode, short prompts (Korean prose / code) | 33.9-34.6 / 39.8-40.9 | | prompt, 4,526 tokens | 375-378 | | prompt, 42,705 tokens | 393 | | prompt, 78,284 tokens | 387 | A needle in the 43K and in the 78K prompt is found, and an OpenAI tool call returns the right arguments. Where those numbers come from: the short-prompt and the 4,526-token rows are the `iq3s-0139-alone-mi50` entries of my bench log (`~/code/local-llm/bench/strata-vs-golbang/results.jsonl`; greedy, 768 generated tokens, two reports per prompt), and the 42,705 and 78,284-token rows are long-prompt needle runs against the same server on the same day. ## Not covered - `STRATA_GR_V3=1`, the opt-in read that sets the carveout, was not run on the card; this PR only lets it compile. - `ctest` was not run on the card for this PR: the card serves the model above with 586 MiB of VRAM left. - The CUDA and the wave32 HIP builds were not rebuilt: neither includes this header. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:03:48 +07:00
Sign in to join this conversation.
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
Niko1221/Strata#2877
No description provided.