[GH-ISSUE #157] HIP backend build failure #82

Closed
opened 2026-11-04 01:39:42 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Dasug on GitHub (Sep 29, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/157

Building the HIP backend with ./setup.sh --backend hip failed for me with:

Strata/src/kernels/cuda/qsa_prompt_attn.cu:8:10: fatal error: 'math_constants.h' file not found
8 | #include <math_constants.h>
| ^~~~~~~~~~~~~~~~~~
1 error generated when compiling for gfx1100.

Full setup.sh output
Strata - Qwen3.8-Flash-Next on a normal PC (a GPU + system RAM + CPU)

=== Step 1: checking your PC ===
  Your AMD GPUs:
    GPU 0: AMD Radeon RX 7900 series (gfx1100), 24 GB VRAM - can be used
  [ok] GPU: AMD Radeon RX 7900 series (gfx1100), 24.0 GB VRAM, gfx1100 (AMD, experimental: docs/AMD_HIP.md)
  [ok] RAM: 63 GB
  [ok] CPU: AMD Ryzen 9 5900X 12-Core Processor (AVX2)

=== Step 2: your choices ===
  1) Qwen3.8-Flash-Next   Qwen; GSQ-RCO quants by ISTA-DASLab - the original model
  2) Swift 1.5            UkisAI's fine-tune of Qwen3.8-Flash-Next - thinks much shorter (-63% thinking tokens, 1.8x sooner answers by its authors' numbers)
  3) Qwen3.8-Flash-Next Coder ISTA-DASLab's coding version - half the experts (code, tools, images kept): needs ~32 GB of RAM, faster; weaker outside coding
Which model? [1]:   [ok] model: Qwen3.8-Flash-Next

  1) Q2_0     2-bit, the fastest; download 66 GB, uses ~34 GB of RAM
  2) IQ2_XS   2-bit i-quant, a little better quality, close in speed; download 68 GB, uses ~36 GB of RAM
  3) IQ3_XXS  3-bit i-quant, better quality, slower (more CPU work per token); download 76 GB, uses ~43 GB of RAM
  4) IQ3_S    3.5-bit i-quant, the best quality (matches the full model), the slowest; needs a 64 GB PC with little else running; download 84 GB, uses ~50 GB of RAM
Which size? [3]:   [ok] size: IQ3_XXS

  Context length = how much text the model can see at once (your chat, files, tool output).
  Longer needs more VRAM for it, so fewer experts fit on the GPU:
  1) 8K tokens
  2) 32K tokens
  3) 64K tokens
  4) 128K tokens   (recommended for your GPU)
  5) 256K tokens
Context? [4]:   [ok] context: 131072 tokens

  KV cache precision (the model's memory of the conversation):
  1) 8-bit   (recommended: what every published number was measured with)
  2) 4-bit   half the memory (about 4% faster at 128K), but measurably less precise on long
             documents; long-context lookups (needle tests) still pass
KV cache? [1]:   [ok] KV cache: 8-bit
  [ok] images: off

  EXPERIMENTAL - speed projection: a small control vector applied while the model runs (layers 4-44).
  It changes how the model answers: its package describes it as a refusal-direction projection (the
  model declines far fewer requests). Off unless you choose it; when on, the web app can switch it off
  per chat. Details: data/experimental-speed-projection/README.md
Turn on the experimental speed projection? [n]:   [ok] experimental speed projection: off

=== Step 3: Python packages ===
  [ok] numpy, jinja2, regex, pyyaml, tqdm, requests, cmake, ninja, pillow, psutil already installed

=== Step 4: the Strata engine ===
  [ok] llama.cpp 3cf0325 (gguf-py, ggml, mtmd)
  Compiling the Strata engine for your AMD GPU (10-20 minutes, once) ...
  > /run/media/firestorm-stormfront/user/dasug/repositories/Strata/.venv/bin/cmake -G Ninja -DCMAKE_MAKE_PROGRAM=/run/media/firestorm-stormfront/user/dasug/repositories/Strata/.venv/bin/ninja -S /run/media/firestorm-stormfront/user/dasug/repositories/Strata -B /run/media/firestorm-stormfront/user/dasug/repositories/Strata/build-hip -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_HIP=ON -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_BUILD_TESTS=OFF -DSTRATA_PREFILL_MMQ=ON -DCMAKE_HIP_ARCHITECTURES=gfx1100 -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ -DCMAKE_HIP_COMPILER_ROCM_ROOT=/opt/rocm -DCMAKE_PREFIX_PATH=/opt/rocm -DCMAKE_HIP_FLAGS=--rocm-path=/opt/rocm --rocm-device-lib-path=/opt/rocm/amdgcn/bitcode -DSTRATA_GGML_DIR=/run/media/firestorm-stormfront/user/dasug/repositories/Strata/third_party/llama.cpp
-- Strata: HIP enabled, arch gfx1100
-- strata: pack/full/experts.bin absent - the expert arena load test is NOT registered
-- ccache found, compilation results will be cached. Disable with GGML_CCACHE=OFF.
-- CMAKE_SYSTEM_PROCESSOR: x86_64
-- GGML_SYSTEM_ARCH: x86
-- Including CPU backend
-- x86 detected
-- Adding CPU backend variant ggml-cpu: -march=native 
-- ggml version: 0.24.0
-- ggml commit:  8fc40dd
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /run/media/firestorm-stormfront/user/dasug/repositories/Strata/build-hip
  > /run/media/firestorm-stormfront/user/dasug/repositories/Strata/.venv/bin/cmake --build /run/media/firestorm-stormfront/user/dasug/repositories/Strata/build-hip --target strata -j 12
[0/2] Re-checking globbed directories...
[1/6] Building HIP object CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o
FAILED: [code=1] CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o 
ccache /opt/rocm/llvm/bin/clang++  -DSTRATA_USE_HIP=1 -DSTRATA_VERSION=\"0.1.25\" -DUSE_PROF_API=1 -D__HIP_PLATFORM_AMD__=1 -D__HIP_ROCclr__=1 -I/run/media/firestorm-stormfront/user/dasug/repositories/Strata/third_party/ggml -I/run/media/firestorm-stormfront/user/dasug/repositories/Strata/include -I/run/media/firestorm-stormfront/user/dasug/repositories/Strata/include/strata/hip_compat --rocm-path=/opt/rocm --rocm-device-lib-path=/opt/rocm/amdgcn/bitcode -O3 -DNDEBUG -std=c++20 --offload-arch=gfx1100 -fPIC -Wall -Wextra -include /run/media/firestorm-stormfront/user/dasug/repositories/Strata/include/strata/hip_compat/cuda_runtime.h -MD -MT CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o -MF CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o.d -o CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o -x hip -c /run/media/firestorm-stormfront/user/dasug/repositories/Strata/src/kernels/cuda/qsa_prompt_attn.cu
/run/media/firestorm-stormfront/user/dasug/repositories/Strata/src/kernels/cuda/qsa_prompt_attn.cu:8:10: fatal error: 'math_constants.h' file not found
    8 | #include <math_constants.h>
      |          ^~~~~~~~~~~~~~~~~~
1 error generated when compiling for gfx1100.
ninja: build stopped: subcommand failed.
  (the build stopped - trying it once more)
  > /run/media/firestorm-stormfront/user/dasug/repositories/Strata/.venv/bin/cmake --build /run/media/firestorm-stormfront/user/dasug/repositories/Strata/build-hip --target strata -j 12
[0/2] Re-checking globbed directories...
[1/6] Building HIP object CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o
FAILED: [code=1] CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o 
ccache /opt/rocm/llvm/bin/clang++  -DSTRATA_USE_HIP=1 -DSTRATA_VERSION=\"0.1.25\" -DUSE_PROF_API=1 -D__HIP_PLATFORM_AMD__=1 -D__HIP_ROCclr__=1 -I/run/media/firestorm-stormfront/user/dasug/repositories/Strata/third_party/ggml -I/run/media/firestorm-stormfront/user/dasug/repositories/Strata/include -I/run/media/firestorm-stormfront/user/dasug/repositories/Strata/include/strata/hip_compat --rocm-path=/opt/rocm --rocm-device-lib-path=/opt/rocm/amdgcn/bitcode -O3 -DNDEBUG -std=c++20 --offload-arch=gfx1100 -fPIC -Wall -Wextra -include /run/media/firestorm-stormfront/user/dasug/repositories/Strata/include/strata/hip_compat/cuda_runtime.h -MD -MT CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o -MF CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o.d -o CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o -x hip -c /run/media/firestorm-stormfront/user/dasug/repositories/Strata/src/kernels/cuda/qsa_prompt_attn.cu
/run/media/firestorm-stormfront/user/dasug/repositories/Strata/src/kernels/cuda/qsa_prompt_attn.cu:8:10: fatal error: 'math_constants.h' file not found
    8 | #include <math_constants.h>
      |          ^~~~~~~~~~~~~~~~~~
1 error generated when compiling for gfx1100.
ninja: build stopped: subcommand failed.

  [X]  command failed (exit 1): cmake

Setup stopped. Fix the item above and run it again - everything already done is kept and skipped.

From my understanding this might be caused since the header file is part of cuda, which I don't have installed since I don't own an Nvidia GPU. I ran the issue through another model and it created a shim include/strata/hip_compat/math_constants.h with the following content:

AI fix
#pragma once
// HIP shim for CUDA's <math_constants.h>. HIP provides the same constants under
// HIP_* names in <hip/hip_math_constants.h>; map the CUDART_* name the kernels use.
#include <hip/hip_math_constants.h>
#define CUDART_INF_F HIP_INF_F

which caused the build to run through. However, I haven't been able to test if it actually works during runtime since I'm still downloading the model (my internet speed isn't that great 😅), so it's always possible the math constants are somehow incompatible between HIP and CUDA or whatever..
I'll hopefully be able to say more once the model has finished downloading. In case it runs fine, would you like a pull request with the shim or would you prefer to solve the issue yourself?

Originally created by @Dasug on GitHub (Sep 29, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/157 Building the HIP backend with `./setup.sh --backend hip` failed for me with: > Strata/src/kernels/cuda/qsa_prompt_attn.cu:8:10: fatal error: 'math_constants.h' file not found 8 | #include <math_constants.h> | ^~~~~~~~~~~~~~~~~~ 1 error generated when compiling for gfx1100. <details> <summary>Full setup.sh output</summary> ``` Strata - Qwen3.8-Flash-Next on a normal PC (a GPU + system RAM + CPU) === Step 1: checking your PC === Your AMD GPUs: GPU 0: AMD Radeon RX 7900 series (gfx1100), 24 GB VRAM - can be used [ok] GPU: AMD Radeon RX 7900 series (gfx1100), 24.0 GB VRAM, gfx1100 (AMD, experimental: docs/AMD_HIP.md) [ok] RAM: 63 GB [ok] CPU: AMD Ryzen 9 5900X 12-Core Processor (AVX2) === Step 2: your choices === 1) Qwen3.8-Flash-Next Qwen; GSQ-RCO quants by ISTA-DASLab - the original model 2) Swift 1.5 UkisAI's fine-tune of Qwen3.8-Flash-Next - thinks much shorter (-63% thinking tokens, 1.8x sooner answers by its authors' numbers) 3) Qwen3.8-Flash-Next Coder ISTA-DASLab's coding version - half the experts (code, tools, images kept): needs ~32 GB of RAM, faster; weaker outside coding Which model? [1]: [ok] model: Qwen3.8-Flash-Next 1) Q2_0 2-bit, the fastest; download 66 GB, uses ~34 GB of RAM 2) IQ2_XS 2-bit i-quant, a little better quality, close in speed; download 68 GB, uses ~36 GB of RAM 3) IQ3_XXS 3-bit i-quant, better quality, slower (more CPU work per token); download 76 GB, uses ~43 GB of RAM 4) IQ3_S 3.5-bit i-quant, the best quality (matches the full model), the slowest; needs a 64 GB PC with little else running; download 84 GB, uses ~50 GB of RAM Which size? [3]: [ok] size: IQ3_XXS Context length = how much text the model can see at once (your chat, files, tool output). Longer needs more VRAM for it, so fewer experts fit on the GPU: 1) 8K tokens 2) 32K tokens 3) 64K tokens 4) 128K tokens (recommended for your GPU) 5) 256K tokens Context? [4]: [ok] context: 131072 tokens KV cache precision (the model's memory of the conversation): 1) 8-bit (recommended: what every published number was measured with) 2) 4-bit half the memory (about 4% faster at 128K), but measurably less precise on long documents; long-context lookups (needle tests) still pass KV cache? [1]: [ok] KV cache: 8-bit [ok] images: off EXPERIMENTAL - speed projection: a small control vector applied while the model runs (layers 4-44). It changes how the model answers: its package describes it as a refusal-direction projection (the model declines far fewer requests). Off unless you choose it; when on, the web app can switch it off per chat. Details: data/experimental-speed-projection/README.md Turn on the experimental speed projection? [n]: [ok] experimental speed projection: off === Step 3: Python packages === [ok] numpy, jinja2, regex, pyyaml, tqdm, requests, cmake, ninja, pillow, psutil already installed === Step 4: the Strata engine === [ok] llama.cpp 3cf0325 (gguf-py, ggml, mtmd) Compiling the Strata engine for your AMD GPU (10-20 minutes, once) ... > /run/media/firestorm-stormfront/user/dasug/repositories/Strata/.venv/bin/cmake -G Ninja -DCMAKE_MAKE_PROGRAM=/run/media/firestorm-stormfront/user/dasug/repositories/Strata/.venv/bin/ninja -S /run/media/firestorm-stormfront/user/dasug/repositories/Strata -B /run/media/firestorm-stormfront/user/dasug/repositories/Strata/build-hip -DCMAKE_BUILD_TYPE=Release -DSTRATA_ENABLE_HIP=ON -DSTRATA_ENABLE_CUDA=OFF -DSTRATA_BUILD_TESTS=OFF -DSTRATA_PREFILL_MMQ=ON -DCMAKE_HIP_ARCHITECTURES=gfx1100 -DCMAKE_HIP_COMPILER=/opt/rocm/llvm/bin/clang++ -DCMAKE_HIP_COMPILER_ROCM_ROOT=/opt/rocm -DCMAKE_PREFIX_PATH=/opt/rocm -DCMAKE_HIP_FLAGS=--rocm-path=/opt/rocm --rocm-device-lib-path=/opt/rocm/amdgcn/bitcode -DSTRATA_GGML_DIR=/run/media/firestorm-stormfront/user/dasug/repositories/Strata/third_party/llama.cpp -- Strata: HIP enabled, arch gfx1100 -- strata: pack/full/experts.bin absent - the expert arena load test is NOT registered -- ccache found, compilation results will be cached. Disable with GGML_CCACHE=OFF. -- CMAKE_SYSTEM_PROCESSOR: x86_64 -- GGML_SYSTEM_ARCH: x86 -- Including CPU backend -- x86 detected -- Adding CPU backend variant ggml-cpu: -march=native -- ggml version: 0.24.0 -- ggml commit: 8fc40dd -- Configuring done (0.1s) -- Generating done (0.0s) -- Build files have been written to: /run/media/firestorm-stormfront/user/dasug/repositories/Strata/build-hip > /run/media/firestorm-stormfront/user/dasug/repositories/Strata/.venv/bin/cmake --build /run/media/firestorm-stormfront/user/dasug/repositories/Strata/build-hip --target strata -j 12 [0/2] Re-checking globbed directories... [1/6] Building HIP object CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o FAILED: [code=1] CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o ccache /opt/rocm/llvm/bin/clang++ -DSTRATA_USE_HIP=1 -DSTRATA_VERSION=\"0.1.25\" -DUSE_PROF_API=1 -D__HIP_PLATFORM_AMD__=1 -D__HIP_ROCclr__=1 -I/run/media/firestorm-stormfront/user/dasug/repositories/Strata/third_party/ggml -I/run/media/firestorm-stormfront/user/dasug/repositories/Strata/include -I/run/media/firestorm-stormfront/user/dasug/repositories/Strata/include/strata/hip_compat --rocm-path=/opt/rocm --rocm-device-lib-path=/opt/rocm/amdgcn/bitcode -O3 -DNDEBUG -std=c++20 --offload-arch=gfx1100 -fPIC -Wall -Wextra -include /run/media/firestorm-stormfront/user/dasug/repositories/Strata/include/strata/hip_compat/cuda_runtime.h -MD -MT CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o -MF CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o.d -o CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o -x hip -c /run/media/firestorm-stormfront/user/dasug/repositories/Strata/src/kernels/cuda/qsa_prompt_attn.cu /run/media/firestorm-stormfront/user/dasug/repositories/Strata/src/kernels/cuda/qsa_prompt_attn.cu:8:10: fatal error: 'math_constants.h' file not found 8 | #include <math_constants.h> | ^~~~~~~~~~~~~~~~~~ 1 error generated when compiling for gfx1100. ninja: build stopped: subcommand failed. (the build stopped - trying it once more) > /run/media/firestorm-stormfront/user/dasug/repositories/Strata/.venv/bin/cmake --build /run/media/firestorm-stormfront/user/dasug/repositories/Strata/build-hip --target strata -j 12 [0/2] Re-checking globbed directories... [1/6] Building HIP object CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o FAILED: [code=1] CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o ccache /opt/rocm/llvm/bin/clang++ -DSTRATA_USE_HIP=1 -DSTRATA_VERSION=\"0.1.25\" -DUSE_PROF_API=1 -D__HIP_PLATFORM_AMD__=1 -D__HIP_ROCclr__=1 -I/run/media/firestorm-stormfront/user/dasug/repositories/Strata/third_party/ggml -I/run/media/firestorm-stormfront/user/dasug/repositories/Strata/include -I/run/media/firestorm-stormfront/user/dasug/repositories/Strata/include/strata/hip_compat --rocm-path=/opt/rocm --rocm-device-lib-path=/opt/rocm/amdgcn/bitcode -O3 -DNDEBUG -std=c++20 --offload-arch=gfx1100 -fPIC -Wall -Wextra -include /run/media/firestorm-stormfront/user/dasug/repositories/Strata/include/strata/hip_compat/cuda_runtime.h -MD -MT CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o -MF CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o.d -o CMakeFiles/strata_kernels.dir/src/kernels/cuda/qsa_prompt_attn.cu.o -x hip -c /run/media/firestorm-stormfront/user/dasug/repositories/Strata/src/kernels/cuda/qsa_prompt_attn.cu /run/media/firestorm-stormfront/user/dasug/repositories/Strata/src/kernels/cuda/qsa_prompt_attn.cu:8:10: fatal error: 'math_constants.h' file not found 8 | #include <math_constants.h> | ^~~~~~~~~~~~~~~~~~ 1 error generated when compiling for gfx1100. ninja: build stopped: subcommand failed. [X] command failed (exit 1): cmake Setup stopped. Fix the item above and run it again - everything already done is kept and skipped. ``` </details> From my understanding this might be caused since the header file is part of cuda, which I don't have installed since I don't own an Nvidia GPU. I ran the issue through another model and it created a shim `include/strata/hip_compat/math_constants.h` with the following content: <details> <summary>AI fix</summary> ```c++ #pragma once // HIP shim for CUDA's <math_constants.h>. HIP provides the same constants under // HIP_* names in <hip/hip_math_constants.h>; map the CUDART_* name the kernels use. #include <hip/hip_math_constants.h> #define CUDART_INF_F HIP_INF_F ``` </details> which caused the build to run through. However, I haven't been able to test if it actually works during runtime since I'm still downloading the model (my internet speed isn't that great 😅), so it's always possible the math constants are somehow incompatible between HIP and CUDA or whatever.. I'll hopefully be able to say more once the model has finished downloading. In case it runs fine, would you like a pull request with the shim or would you prefer to solve the issue yourself?
Author
Owner

@Niko1221 commented on GitHub (Sep 29, 2026):

Thanks @Dasug, confirmed: that header only exists in the CUDA toolkit, and our AMD test PC happened to have it. The fix replaces CUDART_INF_F with the standard INFINITY (from #160, which we'll take on its own), so your shim isn't needed. It will be in the next release. Your runtime results once the model finishes downloading would still be very welcome.

<!-- gh-comment-id:5898199651 --> @Niko1221 commented on GitHub (Sep 29, 2026): Thanks @Dasug, confirmed: that header only exists in the CUDA toolkit, and our AMD test PC happened to have it. The fix replaces `CUDART_INF_F` with the standard `INFINITY` (from #160, which we'll take on its own), so your shim isn't needed. It will be in the next release. Your runtime results once the model finishes downloading would still be very welcome.
Author
Owner

@Niko1221 commented on GitHub (Sep 29, 2026):

Fixed in 0.1.27: qsa_prompt_attn.cu uses the standard INFINITY instead of CUDART_INF_F, so the HIP build no longer needs math_constants.h (the fix from @samuelishida's #160, taken on its own). Thanks @Dasug! ./setup.sh --backend hip builds it on a ROCm-only PC now; results on your card are still very welcome.

<!-- gh-comment-id:5900216867 --> @Niko1221 commented on GitHub (Sep 29, 2026): Fixed in [0.1.27](https://github.com/Niko1221/Strata/releases/tag/v0.1.27): `qsa_prompt_attn.cu` uses the standard `INFINITY` instead of `CUDART_INF_F`, so the HIP build no longer needs `math_constants.h` (the fix from @samuelishida's #160, taken on its own). Thanks @Dasug! `./setup.sh --backend hip` builds it on a ROCm-only PC now; results on your card are still very welcome.
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#82
No description provided.