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] RTN/weight-only quantize() crashes with default offload_to_disk: 'Inference tensors do not track version counter' in file-backed writer (regression from #6473) #6539
On current main (c649fcb), the documented RTN recipe (docs/quantization-guide.md → "RTN W4A16 without calibration") crashes in quantize() for any model whose linears have a bias (opt-125m, Qwen2.5-0.5B-Instruct verified), with the default offload_to_disk=True:
File "gptqmodel/looper/weight_only_looper.py", line 511, in _finalize_quantized_module
self._offload_quantized_module(named)
File "gptqmodel/utils/offload.py", line 1143, in _offload_disk_locked
file_back_module(module, os.path.join(module_offload_dir, FILE_BACKED_NAME), root=root)
File "gptqmodel/weight_loader/filebacked.py", line 157, in write_safetensors
target[cursor : cursor + nbytes].copy_(_host_bytes(tensor))
File "gptqmodel/weight_loader/filebacked.py", line 75, in _host_bytes
flat = tensor.detach().to("cpu").contiguous().reshape(-1)
RuntimeError: Inference tensors do not track version counter.
It is a regression from #6473: on 0043349bf^ (pre-WeightLoader, Accelerate offload) the same script quantizes fine.
Repro
importtorchfromgptqmodelimportGPTQModelfromgptqmodel.quantizationimportRTNConfigm=GPTQModel.load("facebook/opt-125m", RTNConfig(bits=4, group_size=128), device="cuda:0", dtype=torch.float16)
m.quantize() # RuntimeError: Inference tensors do not track version counter.
Root cause
The weight-only finalize path hands the file-backed writer tensors that were created under inference_mode and later rebound with param.data = ... (the #4572 state: is_inference() == False, but no version counter; here the packed module's bias, which aliases the source linear's bias). write_safetensors/_host_bytes (new in #6473) serializes through reshape(-1).view(torch.uint8), and any view op on a counterless tensor raises. The old Accelerate offload never created views of these tensors. The failing tensor in the opt-125m run is model.decoder.layers.0.self_attn.q_proj.bias (fp16, shape (768,)).
Expected
quantize() → save() succeeds, as before #6473. With the fix proposed in the linked PR, opt-125m RTN W4 g128: wikitext2 PPL 31.88 (fp16 27.57), save/reload logits bit-identical.
Proposed fix
Make the writer accept counterless tensors: copy a tensor once when it lacks a version counter before the byte view (gptqmodel/weight_loader/filebacked.py, _host_bytes and the raw-U8 branch).
Additional repro of the same mechanism that PR #6564 does not cover: RTN + format=GEMM + default offload_to_disk still crashes in torch_awq.py:189 pack, because the weight Parameter is already counterless before pack. Details and repro are in the PR #6564 comments.
Activity
Qubitium commentedon Dec 1, 2026
Additional repro of the same mechanism that PR #6564 does not cover: RTN +
format=GEMM+ defaultoffload_to_diskstill crashes intorch_awq.py:189pack, because the weight Parameter is already counterless before pack. Details and repro are in the PR #6564 comments.