Skip to content

Optimize inference on Strix Halo - #201

Merged
0xShug0 merged 2 commits into
0xShug0:mainfrom
fedeizzo:fedeizzo/rocm-optimizations
Aug 11, 2026
Merged

Optimize inference on Strix Halo#201
0xShug0 merged 2 commits into
0xShug0:mainfrom
fedeizzo:fedeizzo/rocm-optimizations

Conversation

@fedeizzo

@fedeizzo fedeizzo commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Originated from #170

What does this PR do?

  • .devops/nix/package.nix, flake.nix, CMakeLists.txt: add an opt-in rocm-gfx1151 build and ENGINE_HIP_STRIX_HALO_OPTIMIZATIONS CMake option. package.nix automatically deduces strixHaloOptimizations when rocmGpuTargets == [ "gfx1151" ]. It enables the Strix Halo path only for HIP with CUDA-family fast paths and rocBLAS, keeping rocBLAS because hipBLASLt regressed latency on this hardware.
  • include/engine/framework/core/module.h, src/framework/modules/{conv_modules.cpp,optimizations/fast_projection_modules.cpp}: update uses_ggml_cuda_family_backend to allow HIP to use the verified GGML CUDA-family ConvTranspose1d col2im and packed-projection fast paths used by Qwen3-TTS, Higgs-Audio-TTS, Confucius4-TTS, and Irodori-TTS. Other backends keep their existing behavior.
  • include/engine/models/qwen3_tts/tokenizer_speech_decoder.h, src/models/qwen3_tts/tokenizer_speech_decoder.cpp: retain common speech decoder graphs on Strix Halo HIP builds, add upload_static_inputs() to restore static inputs (positions_ and mask_) prior to replaying retained graphs, and remove redundant backend synchronizations after graph execution.
  • tests/unittests/test_conv_transpose_fast_path.cpp, tests/unittests/test_qwen_decoder_packed_projections.cpp: add HIP fast-path classification, parity execution, and backend rejection unit tests.

All Strix-specific behavior is disabled by default. Generic CPU, CUDA, Vulkan, Metal, and generic HIP builds retain their current defaults.

Motivation

Qwen3-TTS repeatedly rebuilt stable decoder graphs on Strix Halo, adding graph construction overhead and variable compute latency. Reusing those graphs removes graph construction overhead and stabilizes speech decoder execution, but reuse is only correct when static graph inputs (positions and attention masks) are restored before every graph replay.

Additionally, expanding uses_ggml_cuda_family_backend allows HIP devices to share the verified CUDA col2im transposed convolution and packed projection fast paths across multiple model architectures (Qwen3-TTS, Higgs-Audio-TTS, Confucius4-TTS, Irodori-TTS).

Gains

Empirical performance and numerical parity results on AMD Radeon 8060S Graphics (Strix Halo gfx1151, 128 GB VRAM):

Workload / Benchmark Baseline / Reference ROCm (gfx1151 Fast Path) Gain / Parity Result
ConvTranspose1d col2im block 2.15 ms 1.77 ms 1.21x speedup (max diff 4.65e-9)
FastPackedProjection4Module Rejected (CPU) Executed (HIP) Verified PASSED (ok)
Qwen3-TTS Speech Decoder Rebuilt graph per chunk Retained graph + input restore 840.89 ms compute time
Higgs-Audio-TTS (4B Model) Standard pipeline HIP Fast Paths 1.81x Real-Time Speed (RTF 0.55)

All unit tests and end-to-end multi-model inference runs (Qwen3-TTS and Higgs-Audio-TTS) produced clean audio output with floating-point parity down to float epsilon (~4.65e-9).

How to use it

Use the specialized Nix development shell:

nix develop .#rocm-gfx1151

Or configure manually:

cmake -S . -B build/rocm-gfx1151 -G Ninja \
  -DCMAKE_BUILD_TYPE=Release \
  -DENGINE_ENABLE_HIP=ON \
  -DGPU_TARGETS=gfx1151 \
  -DENGINE_HIP_STRIX_HALO_OPTIMIZATIONS=ON
cmake --build build/rocm-gfx1151 --parallel

Run audiocpp_cli normally with the HIP backend. The decoder cache activates automatically for the specialized build when the runtime backend is HIP.

For generic ROCm behavior, use nix develop .#rocm or leave ENGINE_HIP_STRIX_HALO_OPTIMIZATIONS=OFF.

AI usage disclosure

AI was used for the following purposes:

  • understand project structure and validate hypothesis about code organization
  • help defining benchmarking scripts (not included in the PR)
  • clean-up code after manual definition

AI was NOT used for the following purposes:

  • optimization ideas
  • basic implementation
  • initial exploration of similar projects like llama-cpp and CrispASR

Expand framework HIP fast-path support for FastPackedProjection4Module and
ConvTranspose1d to accept HIP as a CUDA-family backend. Add opt-in gfx1151
decoder graph reuse on rocBLAS for Strix Halo, restore retained graph inputs
before execution, and add fast-path unit tests.
@fedeizzo
fedeizzo force-pushed the fedeizzo/rocm-optimizations branch from b7632b3 to e3bb9f5 Compare August 9, 2026 17:29
@fedeizzo
fedeizzo marked this pull request as ready for review August 9, 2026 17:30
@0xShug0

0xShug0 commented Aug 10, 2026

Copy link
Copy Markdown
Owner

@fedeizzo Thanks for the update. The overall direction looks good, but I found a few things that should be fixed before merge.

  1. CMakeLists.txt adds tests/unittests/test_qwen3_tts_options_config.cpp, but that file is missing. I validated
    ENGINE_BUILD_TESTS=ON + AUDIOCPP_MODEL_SET=custom + AUDIOCPP_MODELS=qwen3_tts fails at CMake generate with Cannot find source file.

  2. It regresses Metal ConvTranspose1d fast-path eligibility. Current main allows Metal for ConvTranspose1d col2im fast path based on the tests in https://github.com/0xShug0/audio.cpp/blob/main/docs/reports/metal_convtranspose_performance.md . PR changes it to uses_ggml_cuda_family_backend(), which returns only CUDA/HIP. Note that it's not safe to allow Metal to use FastPackedProjection4Module.

  3. Maybe rename uses_ggml_cuda_family_backend to something more explicit, such as uses_ggml_cuda_or_hip_backend?

I'll test Qwen3-related changes later.

Update: The Qwen3-related changes in this PR look safe based on my tests.

- Fix CMakeLists.txt build failure by removing dangling reference to test_qwen3_tts_options_config.cpp.
- Restore Metal eligibility in is_conv_transpose1d_col2im_fast_path_eligible while keeping FastPackedProjection4Module restricted to CUDA/HIP.
- Rename uses_ggml_cuda_family_backend to uses_ggml_cuda_or_hip_backend for explicit naming clarity.
@fedeizzo

Copy link
Copy Markdown
Contributor Author

@0xShug0 done 👍

@0xShug0

0xShug0 commented Aug 11, 2026

Copy link
Copy Markdown
Owner

@fedeizzo Thanks! I'm just waiting for the Nix CPU check. It keeps failing...

Update: Merged!

@0xShug0
0xShug0 merged commit 3be9433 into 0xShug0:main Aug 11, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants