feat(backend/python): AMD multi-arch ROCm torch for transformers/diffusers/kokoro (consumer/RDNA GPUs) - #10997
feat(backend/python): AMD multi-arch ROCm torch for transformers/diffusers/kokoro (consumer/RDNA GPUs)#10997walcz-de wants to merge 6 commits into
Conversation
localai-org-maint-bot
left a comment
There was a problem hiding this comment.
The ROCm work is substantial, but the stacked commit fix(rocm): update Go backend Dockerfile for TheRock packaging contains Co-authored-by: localai-org-maint-bot .... LocalAI policy explicitly forbids AI/bot Co-Authored-By trailers; AI assistance must be recorded with Assisted-by: AGENT_NAME:MODEL_VERSION [TOOLS] instead (see .agents/ai-coding-assistants.md). Please rewrite that commit trailer before merge.
@mudler tagging you because this is a repository-policy blocker on the otherwise valuable ROCm series.
81a0f1c to
21d2c92
Compare
d2b2c83 to
59bf78c
Compare
localai-org-maint-bot
left a comment
There was a problem hiding this comment.
DCO passes. Two blocking issues:
-
gfx1151default breaks CDNA builds —AMDGPU_TARGETSis never set in any of the 36 hipblas matrix entries (verified: grep finds nothing in .github/backend-matrix.yml). The install.sh blocks default togfx1151(Strix Halo / consumer RDNA). The old wheel (download.pytorch.org/whl/rocm7.0) served CDNA (gfx942 MI300X / gfx950) too. So every hipblas transformers/diffusers/kokoro build — including datacenter CDNA — would get a gfx1151 torch that won't enumerate a MI300X. Fix: setAMDGPU_TARGETSper matrix entry (gfx942/950 for CDNA, gfx1151 for consumer), or gate the AMD-index install on an RDNA flag. -
Rebase onto #10978 — This PR's
Dockerfile.golangis the simpler version (no amdrocm-blas-dev fallback). It lacks #10978's commit-4 fix, so merging as-is would re-break qwen3-tts hipblas. Rebase onto a merged #10978 and adopt its Dockerfile.golang.
The multi-arch ROCm torch approach is sound — just needs per-entry GPU targeting and the rebase.
…1 / Strix Halo) ROCm 7.14 adds native gfx1151 (Strix Halo / RDNA 3.5) runtime support. The prebuilt ROCm images pinned rocm/dev-ubuntu-24.04:7.2.1, which predates gfx1151 support, so the published -gpu-rocm-hipblas-* images do not run on that hardware even though gfx1151 is already in AMDGPU_TARGETS. Bump the pin to rocm/dev-ubuntu-24.04:7.14.0-full everywhere it is referenced: - .github/backend-matrix.yml (all hipblas backend build entries) - .github/workflows/base-images.yml (base-grpc-rocm-amd64 gRPC cache is rebuilt on 7.14 so it stays ABI-compatible with the new runtime base) - .github/workflows/image.yml + image-pr.yml (core hipblas image) - .agents/*.md examples + backend/Dockerfile.base-grpc-builder comment Verified on gfx1151 / Strix Halo: a full ROCm 7.14 stack (LocalAI + llama.cpp hipblas, vLLM, embeddings/reranker) runs natively, no HSA_OVERRIDE_GFX_VERSION needed. Other AMD architectures (gfx908/90a/942/1030/1100/1200/1201) build on the same base and are covered by CI; I do not have that hardware to test at runtime. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: stefanwalcz <stefan.walcz@walcz.de>
…gister lib paths)
ROCm 7.x moved to 'TheRock' packaging. Bumping the base to
rocm/dev-ubuntu-24.04:7.14.0-full surfaces two build breakages, fixed here in
ALL THREE spots that installed the legacy ROCm dev metapackages:
1) Legacy hipblas-dev / hipblaslt-dev / rocblas-dev metapackages were removed
(consolidated + arch-split: amdrocm-blas<ver>-gfx*, amdrocm-blas-dev, ...).
'apt-get install' of the old names fails. The -full base already ships the
BLAS dev libs+headers, so the install is dropped in:
- Dockerfile (requirements-drivers) -> core image
- .docker/install-base-deps.sh (section 6) -> C++ backend builder
- backend/Dockerfile.python (hipblas block) -> Python backends (vllm,
sglang, transformers, diffusers, kokoro, ...)
2) TheRock scatters the ROCm libs across /opt/rocm/lib,
/opt/rocm/lib/rocm_sysdeps/lib and /opt/rocm/llvm/lib with no ld.so.conf.d
entry, so the dynamic linker can't resolve them and the built backends fail
at RUNTIME ('... cannot open shared object file') — a failure CI never sees
because it only surfaces when a backend loads on an AMD GPU. Fixed by
registering all three lib dirs in /etc/ld.so.conf.d/rocm.conf before ldconfig
in all three blocks.
Validated end-to-end on gfx1151 / Strix Halo (build + GPU inference, llama-cpp).
Ref: https://rocm.docs.amd.com/en/latest/about/transition-guide-TheRock.html
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: stefanwalcz <stefan.walcz@walcz.de>
Apply the same ROCm 7.14 dependency + linker-path migration to backend/Dockerfile.golang: the removed legacy hipblas-dev / hipblaslt-dev / rocblas-dev metapackages are no longer installed (the rocm/dev-ubuntu-*:*-full base already ships them), and TheRock's scattered ROCm lib dirs are registered in /etc/ld.so.conf.d/rocm.conf before ldconfig so cgo-based Go backends resolve the ROCm runtime libraries at build/link and runtime. Identified by the LocalAI maintenance bot; re-authored under my identity per DCO. Assisted-by: Codex:gpt-5 Signed-off-by: stefanwalcz <stefan.walcz@walcz.de>
…kends The -full base ships the ROCm BLAS runtime libraries but not the CMake package-config files (hipblasConfig.cmake / hipblas-config.cmake) that find_package(hipblas) resolves against. Dropping the legacy -dev metapackages is correct for runtime-only paths, but from-source CMake/cgo backends (e.g. qwen3-tts) fail at configure time (find_package(hipblas)) without them. Install TheRock's development component amdrocm-blas-dev in the Go/C++ backend hipblas path so those backends build again, while keeping runtime-only paths dev-free. Fixes the qwen3-tts hipblas configure failure surfaced in CI. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: stefanwalcz <stefan.walcz@walcz.de>
Select the BLAS development package set advertised by each ROCm base image so shared Go backend builds work with both legacy ROCm 6.x and TheRock-based ROCm 7.x images. Assisted-by: Codex:GPT-5 [Codex CLI] Signed-off-by: Stefan Walcz <stefan.walcz@walcz.de>
…users/kokoro The community whl/rocm7.0 torch wheel these backends install does not enumerate consumer/RDNA AMD GPUs (torch.cuda.device_count() == 0 on e.g. Strix Halo / gfx1151), so they silently fall back to CPU or fail to load. AMD publishes a stable ROCm 7.14 torch for essentially every AMD arch on its multi-arch index, selected per GPU via the torch[device-gfx<arch>] extra. Install torch from that index in an isolated step: the index returns 403 for packages it doesn't serve (accelerate/transformers/...), which uv treats as fatal, so only the torch family is pulled there and everything else resolves from PyPI. The arch comes from the build via a new AMDGPU_TARGETS ARG/ENV on backend/Dockerfile.python. AMDGPU_TARGETS is the repo-wide comma-separated gfx list, and the device extras compose: torch[device-gfx942,device-gfx1151] installs both device packages side by side (verified against the index). So the whole list is mapped, not its first entry. Which arches an image carries is therefore a matrix decision, and the hipblas entries for these three backends now say so explicitly (gfx942,gfx950,gfx1151: both CDNA data-center arches plus Strix Halo) instead of inheriting the repo-wide 11-arch default. Each device package is ~1.6 GB installed, measured, so that default would add ~17 GB per image; adding a further arch is one matrix entry at ~1.6 GB. Only gfx1151 was validated on real hardware (transformers generates text, diffusers runs SD-1.5, kokoro runs TTS); the mechanism is arch-generic for any AMD GPU AMD ships a device wheel for. Signed-off-by: stefanwalcz <stefan.walcz@walcz.de>
59bf78c to
b9b7be9
Compare
What
The community
whl/rocm7.0torch wheel that thetransformers,diffusersandkokorobackends install does not enumerate consumer/RDNA AMD GPUs —torch.cuda.device_count() == 0on e.g. Strix Halo / gfx1151 — so those backends silently fall back to CPU or fail to load.AMD publishes a stable ROCm 7.14 torch for essentially every AMD arch on its multi-arch index (
repo.amd.com/rocm/whl-multi-arch/), selected per GPU via thetorch[device-gfx<arch>]extra. This switches the three backends to it.How
AMDGPU_TARGETSARG/ENVonbackend/Dockerfile.python, soinstall.shcan pick the GPU arch.uvtreats as fatal — so only the torch family is pulled there, everything else resolves from PyPI.AMDGPU_TARGETSis the repo-wide comma-separated gfx list, and the device extras compose:torch[device-gfx942,device-gfx1151]resolves and installs both device packages side by side. The whole list is mapped, not its first entry.Which arches an image carries
That is now a matrix decision, stated explicitly instead of inherited. The three
hipblasentries setamdgpu-targets: 'gfx942,gfx950,gfx1151'— both CDNA data-center arches plus Strix Halo.The reason is size: one
rocm-sdk-device-gfx*package is ~1.6 GB installed (measured). The repo-wide 11-arch default would add ~17 GB per image. Adding a further arch is one matrix entry at ~1.6 GB, so the trade-off sits where it is made.Testing
Hardware-validated on gfx1151 (Strix Halo, ROCm 7.14): transformers generates text, diffusers runs SD-1.5, kokoro runs TTS — all on the GPU. Only gfx1151 was tested on real hardware; the mechanism is arch-generic for any AMD GPU AMD ships a device wheel for.
Dependency
Stacks on #10978 (ROCm 7.14 base). The reviewable change is the top commit — the rest is #10978.