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][multi-GPU] GPTAQ and FOEM crash whenever 2+ GPUs are visible: Hessian stays on the first batch's device and native inputs are paired by arrival order #4237
Severity: high. Every GPTAQ/FOEM quantize on a multi-GPU host fails with default settings, dense and MoE alike. Version: 7.11.0 @ 9dad249
Summary
In quantization/gptaq.py (process_batch, ~L94-145):
self.H and self.dXXT are allocated once, on the first batch's inp.device (L123-128). Batches arriving from the other GPU then fail at self.H += inp.matmul(inp.t()) (L141) with a device mismatch.
native_inp = self.native_inps.pop(0) pairs native and quantized inputs by arrival order. The data-parallel forward reorders batches, so with variable-length calibration L144 (native_inp - inp) raises a shape mismatch. With equal shapes, the pairs are silently mismatched instead.
quantization/foem.py:~201-218 has the same single-device H/dXXT accumulation.
Plain GPTQ avoids both problems: it keeps per-device partials (_device_hessian_partials, gptq.py:~756) and reduces them in device order.
Reproduce (CUDA_VISIBLE_DEVICES=0,1)
fromgptqmodelimportGPTQModel, QuantizeConfigfromgptqmodel.quantization.configimportGPTAQConfig# or foem=FOEMConfig(alpha=0.25, beta=0.2)qcfg=QuantizeConfig(bits=4, group_size=128, gptaq=GPTAQConfig(alpha=0.25))
m=GPTQModel.load("Qwen/Qwen2.5-0.5B-Instruct", quantize_config=qcfg)
calib= [m.tokenizer(f"The quick brown fox number {i} jumps over the lazy dog and keeps running far away.") foriinrange(16)]
m.quantize(calib, batch_size=1)
Actual:
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:1 and cuda:0! at gptaq.py:141. FOEM fails the same way at foem.py:~215.
The repo's own tests/test_gptaq.py (variable-length calibration) instead fails with The size of tensor a (289) must match the size of tensor b (2017) at gptaq.py:144.
With CUDA_VISIBLE_DEVICES=0 the same script passes.
Failing repo tests:tests/test_moe_gptaq_foem.py::test_tiny_qwen2_moe_gptaq_and_foem_quantize (passes on 1 GPU), tests/test_gptaq.py::TestQwen2_5_GPTAQ::test_qwen2_5.
Expected
Per-device H/dXXT partials reduced in device order, as GPTQ does. Pair native and quantized inputs by batch index, not by pop order. Alternatively, pin GPTAQ/FOEM to one device.
Found during an AI-assisted review (Claude Code) of 9dad249; repros were run on RTX 4090/5090 (CUDA 13) and/or Radeon AI PRO R9700 (ROCm) unless marked static/suspected.
Activity
fix(gptaq): accumulate per-device Hessians and pair native inputs by …