fix(rocm): build on ROCm 6.x, and keep -O0 off the CLR hostcall path (#201, #132) - #216
Open
localai-bot wants to merge 1 commit into
Open
fix(rocm): build on ROCm 6.x, and keep -O0 off the CLR hostcall path (#201, #132)#216localai-bot wants to merge 1 commit into
localai-bot wants to merge 1 commit into
Conversation
mudler
force-pushed
the
row/BACKEND-ROCM-BUILD
branch
from
August 9, 2026 22:08
2b812ab to
a4a14a4
Compare
…201, #132) Two independent ROCm build defects, both reported with the root cause already found, neither reproducible here — there is no AMD GPU and no ROCm toolchain on any maintainer machine, so the reporters are the verification. hipBLAS ships two generations of the *Ex entry points and chooses in the header: the legacy one takes `hipblasDatatype_t` (HIPBLAS_R_*), the current one takes the HIP-wide `hipDataType` (HIP_R_*), and the two are distinct enums with no implicit conversion. `rocm_matmul_hipblaslt.hip` is written ENTIRELY against the current generation — all 18 type constants are HIP_R_*, the compute type is already `hipblasComputeType_t` — but it never asked for it, so it compiled only where that generation is already the default. That is ROCm 7.x, where the row was developed (gfx1201, #140). On ROCm 6.4 all six *Ex call sites fail at once. Selecting the generation the file is written for, at the include, fixes all six without touching a call site. The alternative — a dual mapper and six switched enums — is more code to say the same thing, and would leave the file half-legacy. Nothing else in the TU is generation-sensitive: hipblasCreate, hipblasDestroy and hipblasSetStream are unchanged across both, and everything else is hipBLASLt. The documented first ROCm build passes no `-O` at all, so hipcc compiles at -O0, and at -O0 all eight RmsNorm specialisations come out with `.uses_dynamic_stack: true` plus `hidden_hostcall_buffer` / `hidden_heap_v1` despite performing no hostcall. CLR then creates a hostcall buffer and starts a listener thread on first launch, and its startup/termination handshake is racy — the shared state is `volatile`, not atomic, and the upstream source still carries `FIXME_lmoriche: fix termination handshake`. Under host CPU saturation a delayed listener overwrites the `kExit` that terminate() wrote, and DSO finalisation spins forever on a thread that has already exited. `test_backend_cross_device` prints 11/11 cases, 39/39 assertions, `Status: SUCCESS!` — and never exits. The reporter's controlled A/B relinked the same library with ONLY rocm_rmsnorm.hip.o changed, on a 48-thread host: -O0 gave 14/20 teardown timeouts, -O1 gave 20/20 clean exits, and at -O1 the dynamic-stack and hidden hostcall/heap metadata is gone. They also reproduced the same finaliser loop in a standalone raw-HIP program linking neither vllm.cpp nor doctest, which is what places the defect in CLR rather than in our harness or the test framework. So the definitive fix is upstream in CLR; this keeps our own documented build off the path that triggers it, by flooring HIP device code at -O1 when nothing else sets a level. It yields to any explicit choice: a set CMAKE_BUILD_TYPE or an -O already in CMAKE_HIP_FLAGS wins and nothing is added. Verified here (condition logic only, no HIP): the truth table is '' -> floor, Debug/debug -> floor, Release/RelWithDebInfo -> unchanged, '-O0' -> unchanged, 'Debug' + '-O0' -> unchanged, '-Ofast' -> unchanged, and the `--rocm-path=...` the ROCm block itself sets is correctly NOT read as an -O. FOLLOWING_AGENTS_PROTOCOL Following-Agents-Protocol: true AI-Assisted: true Assisted-by: Claude-Code:claude-opus-5 [ClaudeCode]
mudler
force-pushed
the
row/BACKEND-ROCM-BUILD
branch
from
August 9, 2026 22:25
a4a14a4 to
fb6bb8b
Compare
|
Verified on the #132 reporting hardware (4× RX 7900 XTX gfx1100, ROCm 7.14.0, HIP 7.14.60850, AMD Clang 23, kernel 7.0.0-28-generic). Build config under test: the documented no-build-type command (
Notes, for the record:
#132 verification: PASS as far as this hardware can take it — the documented first-build path no longer enters the hostcall-listener race, verified by controlled A/B on the same machine and load. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #201. Closes #132.
Two independent ROCm build defects, both reported with the root cause already found. Neither reproduces here — no AMD GPU and no ROCm toolchain on any maintainer machine — so the reporters are the verification.
#201 —
hipblasGemmExoverload mismatch (gfx1100, ROCm 6.4)hipBLAS ships two generations of the
*Exentry points and chooses in the header: the legacy one takeshipblasDatatype_t(HIPBLAS_R_*), the current one takes the HIP-widehipDataType(HIP_R_*). Distinct enums, no implicit conversion.rocm_matmul_hipblaslt.hipis written entirely against the current generation — all 18 type constants areHIP_R_*, the compute type is alreadyhipblasComputeType_t— but it never asked for it, so it compiled only where that generation is the default. That is ROCm 7.x, where the row was developed (gfx1201, #140). On ROCm 6.4 all six*Excall sites fail at once.Selecting the generation the file is written for, at the include, fixes all six without touching a call site. The alternative — a dual mapper plus six switched enums — is more code to say the same thing and would leave the file half-legacy. Nothing else in the TU is generation-sensitive:
hipblasCreate/hipblasDestroy/hipblasSetStreamare unchanged across both, and everything else is hipBLASLt.#132 —
-O0device code deadlocks CLR teardown (gfx1100, ROCm 7.14)@VikashLoomba's report is unusually complete and this follows its stated fix boundary.
The documented first ROCm build passes no
-Oat all, so hipcc compiles at-O0. At-O0all eight RmsNorm specialisations come out with.uses_dynamic_stack: trueplushidden_hostcall_buffer/hidden_heap_v1despite performing no hostcall. CLR then creates a hostcall buffer and starts a listener thread on first launch, and its startup/termination handshake is racy — the shared state isvolatile, not atomic, and the upstream source still carriesFIXME_lmoriche: fix termination handshake. Under host CPU saturation a delayed listener overwrites thekExitthatterminate()wrote, and DSO finalisation spins forever on a thread that has already exited.The symptom is
test_backend_cross_deviceprinting 11/11 cases, 39/39 assertions,Status: SUCCESS!— and never exiting.Their controlled A/B relinked the same library with only
rocm_rmsnorm.hip.ochanged, on a 48-thread host:-O0-O1They also reproduced the same finaliser loop in a standalone raw-HIP program linking neither vllm.cpp nor doctest, which is what places the defect in CLR rather than in our harness.
So the definitive fix is upstream in CLR; this keeps our documented build off the path that triggers it, by flooring HIP device code at
-O1when nothing else sets a level. It yields to any explicit choice.Verified here (condition logic only, no HIP):
CMAKE_BUILD_TYPECMAKE_HIP_FLAGS-O1Debug/debug-O1Release/RelWithDebInfo-O0Debug-O0-Ofast--rocm-path=/opt/rocm-O1— correctly not read as an-OThat last row matters: the ROCm block itself sets
--rocm-pathinCMAKE_HIP_FLAGS.@dpblnt @VikashLoomba — a build report either way would be the gate here.