[Experimental] Add ROCm/HIP support (100% vibe‑coded, for testing pur… · unslothai/audio.cpp@7c3c688 · GitHub
Skip to content

Commit 7c3c688

Browse files
IIIIIllllIIIIIlllllhartmarkjunie-agent
authored
[Experimental] Add ROCm/HIP support (100% vibe‑coded, for testing purposes) (0xShug0#48)
* Add ROCm/HIP backend support Enable ENGINE_ENABLE_HIP=ON to build with HIP/ROCm for AMD GPUs. - New BackendType::Hip in module.h - init_backend, backend_type, release_backend_graph_resources, query_backend_memory all support HIP - Reuses GGML's existing ggml-hip with vendor header mapping CUDA→HIP APIs - GGML_USE_CUDA is still defined for HIP (zero new kernel code needed) - Runtime distinguishes HIP devices via 'ROCm' name prefix - Skip audio.cpp's own .cu files (ISTFT, TorchRandom) on HIP builds - --backend hip in CLI help and server config * Add HIP/ROCm backend implementation document * Complete HIP backend: hipBLASLt GEMM, Windows support, gfx1103 - ggml-hip: route all cuBLAS-equivalent GEMM through hipBLASLt (new GGML_HIP_HIPBLASLT option, default ON, falls back to hipBLAS when the package is missing). hipBLASLt ships kernels for arches rocBLAS lacks on Windows (notably gfx1103 / Radeon 780M). Handles legacy hipblasDatatype_t vs hipDataType numbering on ROCm < 6.5, 6.x and 7.x. Pointer-array batched GEMM is emulated per batch element. Verified against CPU reference on gfx1103/ROCm 6.4. - Forward ENGINE_ENABLE_CUDA_GRAPHS to GGML_HIP_GRAPHS so graphs can be disabled on memory-constrained iGPUs (per-graph VRAM reserves caused OOM on the second request). - Add scripts/build_windows_hip.ps1: one-shot Windows HIP build (auto-detects ROCm, GPU targets, cmake, ninja; graphs OFF and NO_VMM ON by default). - Add Hip case to ace_step planner backend switch. - Update docs/HIP.md: hipBLASLt path, support matrix, Windows build instructions, verification checklist. * Document HIP build options for discrete GPUs (Windows and Linux) * Accept rocm as an alias for the hip backend * fix(hip): fix build for RDNA3/GFX1150 and modern HIP compilers Co-authored-by: Junie <junie@jetbrains.com> * Document MSVC 14.51 HIP build incompatibility and older toolset workaround * Update HIP doc to the dynamic backend-registry implementation * Error out when ENGINE_ENABLE_CUDA and ENGINE_ENABLE_HIP are both enabled HIP compiles ggml's CUDA backend sources as HIP code, so both options drive the same ggml backend. Enabling both started CUDA backend setup and then failed confusingly on missing ROCm; fail fast at configure time with a clear message instead. Also pass -DENGINE_ENABLE_CUDA=OFF explicitly in build_windows_hip.ps1. * Document hip/rocm backends in server help text --------- Co-authored-by: Markus Hartung <mail@hartmark.se> Co-authored-by: Junie <junie@jetbrains.com>
1 parent 0433666 commit 7c3c688

13 files changed

Lines changed: 823 additions & 13 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 24 additions & 2 deletions

‎app/cli/args.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ engine::core::BackendType parse_backend(const std::string & value) {
9696
if (value == "cuda") {
9797
return engine::core::BackendType::Cuda;
9898
}
99+
if (value == "hip" || value == "rocm") {
100+
return engine::core::BackendType::Hip;
101+
}
99102
if (value == "vulkan") {
100103
return engine::core::BackendType::Vulkan;
101104
}

‎app/cli/main.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void print_task_list_help() {
4848
<< " --task vad|asr|diar|sep|gen|tts|clon|vc|s2s|align|vdes|spk|svc\n"
4949
<< " --family <name>\n"
5050
<< " --model <path>\n"
51-
<< " --backend cpu|cuda|vulkan|metal|best\n"
51+
<< " --backend cpu|cuda|hip|rocm|vulkan|metal|best (rocm is an alias for hip)\n"
5252
<< " --mode offline|streaming default offline\n"
5353
<< " --device <n>\n"
5454
<< " --threads <n> Backend and OpenMP worker threads, default 4\n"

‎app/server/main.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void print_help() {
4848
<< " [--model-spec-override <json-or-directory>]\n"
4949
<< " [--log] [--log-file <path>]\n"
5050
<< " [--cors-origins <origins>]\n"
51-
<< " --backend cpu|cuda|vulkan|metal default cuda\n"
51+
<< " --backend cpu|cuda|hip|rocm|vulkan|metal default cuda (rocm is an alias for hip)\n"
5252
<< " --busy-timeout-ms <ms> fail a request with 503 when the model has been\n"
5353
<< " busy this long; default 300000, 0 disables\n"
5454
<< " --cors-origins \"*\" experimental; disabled by default. Allows browser\n"

‎app/server/runtime.cpp‎

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)