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] GPTQ quantization not reproducible across processes (332/794 tensors differ, 0.38 PPL spread): rocBLAS->hipBLASLt per-process kernel selection in cholesky_inverse/GEMM; ROCBLAS_USE_HIPBLASLT=0 fixes it #4075
Audit of main @ ad0525c on AMD Radeon AI PRO R9700 (gfx1201), torch 2.16.0.dev+rocm10.1. All runs used expandable_segments:False on all three alloc-conf variables, to stay clear of #4072, plus PYTHON_GIL=1 GPTQMODEL_CUDA_WORKERS=1 GPTQMODEL_MAX_PACKERS=1, so they are fully serial.
GPTQ quantization on ROCm is not reproducible across processes; identical runs differ by 0.38 PPL (medium)
Same model, same seed, same calibration, run twice: Qwen2.5-0.5B-Instruct, GPTQ 4-bit g128, 32 C4 samples. On ROCm, 332/794 saved tensors differ (qweight/scales, starting at layer 0). On CUDA (RTX 4090), the same harness gives 0/794.
Root cause (platform, but gptqmodel can avoid it): on ROCm 10.1 / gfx1201, rocBLAS forwards its GEMMs to hipBLASLt, including the GEMMs inside the rocsolver/rocBLAS triangular solves used by torch.cholesky_inverse. hipBLASLt then picks a different GEMM kernel per process for the same shape and data: MT64x64x16 vs MT256x128x8 tiles, or GSU2 split-K vs no split. With AMD_LOG_LEVEL=4, each distinct result maps one-to-one onto a distinct kernel sequence. Within one process the choice is fixed, so repeated calls are bit-identical, which is why single-process determinism tests pass. torch.use_deterministic_algorithms(True) neither raises nor helps. The differences are at ULP level (max 6.1e-5 on values around 600, both equally close to an fp64 reference), but GPTQ's rounding amplifies them.
Op-by-op hash trace of layer 0 across runs:
bit-identical: the captured inputs, all 32 per-batch XᵀX, H, damped H and the cholesky_ex factor;
first divergence: torch.cholesky_inverse(L, out=L) at quantization/gptq.py:1828, where the same input hash gives 3 different outputs across 5 runs;
with cholesky_inverse forced to fp64, runs still differ (333/794), and the next divergence is the fp32 XᵀX GEMM in process_batch;
the gptq_block HIP kernel is bit-identical given identical inputs, so it isn't involved.
Quantize time is unchanged (15.6 s default vs 15.0–17.1 s).
Fix: on ROCm, set ROCBLAS_USE_HIPBLASLT=0 by default unless the user has set it. Setting it after import torch but before the first BLAS call works (6/6 identical), so it can live next to the existing alloc-conf defaults or in utils/rocm.pyquantize_tuning. This also makes docs/rocm-rdna4.md's statement that quantization "selects rocBLAS by default" true; today rocBLAS hands its GEMMs to hipBLASLt anyway. Forcing cholesky_inverse to fp64 alone is not enough. Worth reporting upstream to rocBLAS/hipBLASLt (per-process solution selection). Add a cross-process reproducibility test: quantize twice in separate processes and compare hashes.
Not reproduced with expandable_segments:False
The HSA_STATUS_ERROR_MEMORY_FAULT in dequant_kernel and the garbage g_idx seen over repeated load/forward/del cycles (Llama-3.2-1B GPTQ, TorchLinear, bf16) did not reproduce in 6–15 cycles with GIL=0 and GIL=1. They only appear under the default expandable_segments:True, which is #4072.
Ruled out: this persists with GPTQMODEL_DISABLE_GPTQ_CUDA=1. RTN is bit-identical, and the layer-0 Hessian and linalg.cholesky are identical across processes. The first divergence is cholesky_inverse, consistent with the hipBLASLt root cause above.
Activity
Qubitium commentedon Nov 14, 2026
Independent confirmation on a second R9700 (BDF 9c), with
expandable_segments:False:GPTQMODEL_DISABLE_GPTQ_CUDA=1. RTN is bit-identical, and the layer-0 Hessian andlinalg.choleskyare identical across processes. The first divergence ischolesky_inverse, consistent with the hipBLASLt root cause above.fix(rocm): stop enabling expandable_segments and make quantization re…
fix(rocm): scope the deterministic BLAS pin and stage HIP sources (#4092