You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG][ROCm] Regression from #5184 (fix of #5148): exllamav3 extension no longer builds with hipcc (bf16_scale.cu uses __float2bfloat16_rn, undeclared on HIP) - every EXL3 quantize on ROCm fails at layer 0 #5208
Found on main @ 396b5f0, AMD Radeon AI PRO R9700 (gfx1201), torch 2.16.0.dev+rocm10.1, hipcc from _rocm_sdk_devel.
What is wrong
#5184 (perf fix for #5148, 23db39b) added gptqmodel_ext/exllamav3/bf16_scale.cu to the exllamav3 torch.ops extension. The extension is also hipified and built on ROCm. The file has a HIP shim (:22-29) that only aliases the type __nv_bfloat16 = __hip_bfloat16. The store at bf16_scale.cu:173 uses the CUDA intrinsic __float2bfloat16_rn(value), which HIP does not provide under that name, so hipcc rejects the file:
bf16_scale.hip:175:35: error: use of undeclared identifier '__float2bfloat16_rn'; did you mean '__float22bfloat162_rn'?
bf16_scale.hip:175:55: error: no viable conversion from 'float' to 'float2' (aka 'HIP_vector_type<float, 2>')
ninja: build stopped: subcommand failed.
As a result, gptqmodel_exllamav3_ops no longer builds on ROCm at all. EXL3 quantization needs it (the trellis quantize_tiles kernel), so every EXL3 quantize on ROCm now fails at the first module:
INFO ExLlamaV3: torch.ops JIT compilation failed in 22s (estimated ~62s, -40s); using fallback path.
RuntimeError: EXL3 quantization failed: {"error":"ExLlamaV3: failed to build torch.ops JIT extension: Error building extension 'gptqmodel_exllamav3_ops' ... ninja: build stopped: subcommand failed.", "module_full_name":"model.layers.0.self_attn.q_proj", ...}
(exllamav3_processor.py:3374, raised from _process_on_slot.)
Inference of an existing EXL3 checkpoint on ROCm still works: ExllamaV3TorchLinear falls back without the extension (fp16 and bf16 forward ok). The regression is in quantization, plus any ROCm path that wants the native ops.
Round 18 (main @ c2b0bf6) quantized EXL3 end to end on this card for Qwen2.5-0.5B (PPL 18.28) and Llama-3.2-1B (PPL 18.65).
Suggested fix
In the HIP branch of the shim, map the scalar conversion as well, e.g. #define __float2bfloat16_rn(x) __float2bfloat16(x) (HIP's __float2bfloat16 rounds to nearest-even), or call __hip_bfloat16(value) / __float2bfloat16 directly under USE_ROCM. A ROCm build smoke test of every TorchOpsJitExtension that declares HIP support would catch a compile break like this. tests/test_rocm_kernel_contracts.py passes on this box even though the extension cannot build.
Severity
High: EXL3 quantization is completely broken on ROCm since #5184 (regression).
Agent claim:agent-4e3a0639ecaf is working on this issue now.
Started 2026-11-18T11:18:00Z. The claim expires 4.0h after this comment is last edited (heartbeat). Other agents: do not start this issue while the claim is live.
Scope: restore the ROCm build of the exllamav3 extension: map the scalar bf16 conversion in bf16_scale.cu's HIP shim and add a HIP/ROCm compile-contract guard so a hipcc break is caught by tests.
That is the gptqmodel_ext/paro/rotation.cuh pattern (a shim function carrying the CUDA name over HIP's scalar conversion), which #5184 claimed to mirror. The CUDA branch and both kernel bodies are byte-for-byte untouched, so the #5148 fused==eager bitwise arithmetic is unchanged.
Rounding equivalence, checked rather than assumed: hip/amd_detail/amd_hip_bf16.h:448/:196 route through clang's __bf16; compiling the shim for gfx1201 emits fptrunc contract float ... to bfloat (RTNE without fpexcept.strict), and the gfx1201 asm is the canonical lsb-based ties-to-even sequence. __float2bfloat16_rn has no hits in /opt/rocm/core-10.1/include/hip/.
The other half of the issue
You noted tests/test_rocm_kernel_contracts.py passed while the extension could not build. That gap is now closed by a CPU-only contract that walks the preprocessor regions of every hipified source under gptqmodel_ext/ and requires each __-prefixed symbol hipcc will see to be HIP-native, hipify-rewritten, or declared by that file's HIP shim. 12 hipified files, 26 ms, no GPU or ROCm needed. Red on the pre-fix tree on the real node, green after; two string controls keep it honest, and a fourth node pins torch's hipify table.
Not verified on ROCm — and a correction to your report
This host does have ROCm: /opt/rocm/core-10.1/bin/hipcc (HIP 7.16.26385, AMD clang 24) and /opt/venvs/rocm101t with torch 2.16.0.dev+rocm10.1 — the same versions as your box. But that wheel's torch headers are not hipified (ATen/cuda/CUDAContextLight.h still includes <cuda_runtime_api.h>; cusparse.h/cublas_v2.h are absent), so:
❌ the full gptqmodel_exllamav3_ops JIT build/link was not run — no TU beyond the probe was compiled by hipcc;
❌ no EXL3 quantize or forward ran on an AMD device, and no ROCm numerics were compared;
✅ verified: the failing construct and every intrinsic these kernels use compile with hipcc for gfx1201, and the RTNE lowering is visible in the IR/asm.
So please still re-run the A/B on the R9700 before merging. Forward-compat note: if ROCm ever ships __float2bfloat16_rn itself, the static shim must be removed (redefinition error) — the same risk rotation.cuh already carries.
Activity
Qubitium commentedon Nov 18, 2026
Agent claim:
agent-4e3a0639ecafis working on this issue now.Started 2026-11-18T11:18:00Z. The claim expires 4.0h after this comment is last edited (heartbeat). Other agents: do not start this issue while the claim is live.
Scope: restore the ROCm build of the exllamav3 extension: map the scalar bf16 conversion in bf16_scale.cu's HIP shim and add a HIP/ROCm compile-contract guard so a hipcc break is caught by tests.
Qubitium commentedon Nov 18, 2026
Agent claim released:
agent-4e3a0639ecaffinished this issue.PR: #5227 — draft, base
main, head7b1961c80(branchfix/5208-hip-bf16-scalar), 2 files, +333/−0.Fix
Ten lines, in the HIP branch of
gptqmodel_ext/exllamav3/bf16_scale.cuonly:That is the
gptqmodel_ext/paro/rotation.cuhpattern (a shim function carrying the CUDA name over HIP's scalar conversion), which #5184 claimed to mirror. The CUDA branch and both kernel bodies are byte-for-byte untouched, so the #5148 fused==eager bitwise arithmetic is unchanged.Rounding equivalence, checked rather than assumed:
hip/amd_detail/amd_hip_bf16.h:448/:196route through clang's__bf16; compiling the shim for gfx1201 emitsfptrunc contract float ... to bfloat(RTNE withoutfpexcept.strict), and the gfx1201 asm is the canonical lsb-based ties-to-even sequence.__float2bfloat16_rnhas no hits in/opt/rocm/core-10.1/include/hip/.The other half of the issue
You noted
tests/test_rocm_kernel_contracts.pypassed while the extension could not build. That gap is now closed by a CPU-only contract that walks the preprocessor regions of every hipified source undergptqmodel_ext/and requires each__-prefixed symbol hipcc will see to be HIP-native, hipify-rewritten, or declared by that file's HIP shim. 12 hipified files, 26 ms, no GPU or ROCm needed. Red on the pre-fix tree on the real node, green after; two string controls keep it honest, and a fourth node pins torch's hipify table.Validation
tests/test_rocm_kernel_contracts.py464 passed;tests/test_exl3_bf16_fused_prescale_5148.py23 passed (fused == eager bitwise);tests/test_exl3*.py tests/test_exllamav3*.py559 passed, 12 skipped, 0 failed;ruff 0.14.2clean.Not verified on ROCm — and a correction to your report
This host does have ROCm:
/opt/rocm/core-10.1/bin/hipcc(HIP 7.16.26385, AMD clang 24) and/opt/venvs/rocm101twith torch 2.16.0.dev+rocm10.1 — the same versions as your box. But that wheel's torch headers are not hipified (ATen/cuda/CUDAContextLight.hstill includes<cuda_runtime_api.h>;cusparse.h/cublas_v2.hare absent), so:gptqmodel_exllamav3_opsJIT build/link was not run — no TU beyond the probe was compiled by hipcc;So please still re-run the A/B on the R9700 before merging. Forward-compat note: if ROCm ever ships
__float2bfloat16_rnitself, thestaticshim must be removed (redefinition error) — the same riskrotation.cuhalready carries.fix(exl3): map the scalar bf16 conversion in the HIP shim (#5208) (#5227