Skip to content

[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

Closed

Description

@Qubitium

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.
standalone cholesky_inverse (fp32, fixed input), one result hash per process:
  default:                  6 processes -> 4 distinct results
  ROCBLAS_USE_HIPBLASLT=0:  6 processes -> 1 result
end-to-end quantize, saved tensors that differ between runs:
  default 332/794 | GPTQMODEL_ROCM_QUANT_BLAS=hipblaslt 333/794 | fp64 cholesky_inverse 333/794 | ROCBLAS_USE_HIPBLASLT=0: 0/794 (4 runs)
wikitext-2 PPL of 4 identical default runs: 21.657, 21.592, 21.280, 21.592   (3 distinct checkpoints, 0.38 / 1.8% spread)
ROCBLAS_USE_HIPBLASLT=0, 2 runs:            21.472, 21.472                 (identical checkpoint hashes)

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.py quantize_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.

🤖 Generated with Claude Code

Activity

  1. added
    bug
    on Nov 14, 2026
  2. Qubitium commented on Nov 14, 2026

    @Qubitium
    CollaboratorAuthor

    Independent confirmation on a second R9700 (BDF 9c), with expandable_segments:False:

    • Qwen2.5 gptq4, 7 identical runs: PPL 21.13, 21.04, 21.28, 21.13, 21.03, 20.95, 20.84 (CUDA 20.92).
    • Llama gptq4: 25.21 / 26.17. Llama desc_act: 24.78 / 24.33 / 23.82.
    • 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.
  3. added 2 commits that reference this issue on Nov 15, 2026
    99f3b4b
    5a36fee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions