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] Regression from #4856 (fix of #4805): every QQQ quantize() crashes at the end (AttributeError: 'QQQTorchLinear' object has no attribute '_torch_dropped_checkpoint' after the in-session class swap) #4940
Found on main @ 3867c82, RTX 5090 (sm_120), torch 2.15 + cu132, transformers 5.22.
What is wrong
Every QQQ quantize() now crashes at the end of the loop, so nothing can be saved. This is a regression from #4856 (fix of #4805), and the same failure pattern as #4451.
At the end of quantize(), rehome_quantized_kernel() (gptqmodel/models/base.py:695) calls _switch_quant_linear_class() (base.py:610-640). That function swaps each packed QQQLinear to QQQTorchLinear with module.__class__ = target_cls, which does not run QQQTorchLinear.__init__, and then calls clear_weight_cache().
#4856 added three new instance attributes that are set only in QQQTorchLinear.__init__ (qqq.py:705-713): _torch_packed_cache, _torch_packed_cache_key and _torch_dropped_checkpoint. It then made clear_weight_cache() -> _materialize_dropped_checkpoint() (qqq.py:931-933) read self._torch_dropped_checkpoint unguarded. On a class-swapped module that attribute does not exist:
File "gptqmodel/models/base.py", line 2627, in quantize
File "gptqmodel/models/base.py", line 695, in rehome_quantized_kernel
File "gptqmodel/models/base.py", line 634, in _switch_quant_linear_class
File "gptqmodel/nn_modules/qlinear/qqq.py", line 723, in clear_weight_cache
File "gptqmodel/nn_modules/qlinear/qqq.py", line 933, in _materialize_dropped_checkpoint
AttributeError: 'QQQTorchLinear' object has no attribute '_torch_dropped_checkpoint'. Did you mean: '_materialize_dropped_checkpoint'?
The #4451 fix had already made the neighbouring _torch_int_mm_failed_shapes read defensive (getattr(self, "_torch_int_mm_failed_shapes", None), qqq.py:726) for exactly this class-swap path. The new attributes were added without that guard.
Repro
fromgptqmodelimportGPTQModelfromgptqmodel.quantization.configimportQQQConfig, CalibrationConfigm=GPTQModel.load("Qwen2.5-0.5B-Instruct", quantize_config=QQQConfig(bits=4, group_size=128))
m.quantize(CalibrationConfig(dataset=c4_texts[:64])) # 64 C4 rows# -> AttributeError: 'QQQTorchLinear' object has no attribute '_torch_dropped_checkpoint'
The same harness quantizes and saves fp8, nf12, awq, gguf, bnb, paro, exl3 and macaq fine on this box. Only QQQ fails, and it fails every time.
Suggested fix
Do not depend on __init__ state for a class-swapped module. Either give QQQTorchLinear class-level defaults (_torch_dropped_checkpoint = None, _torch_packed_cache = None, _torch_packed_cache_key = None), or have _switch_quant_linear_class call an optional target_cls._init_runtime_state(module) hook that each target kernel defines. The hook is more robust, because the next attribute added to __init__ will hit the same path, which is now the third time (#4451, #4856).
Test that should have caught it
A QQQ quantize-then-save smoke test, or a unit test that class-swaps a QQQLinear to QQQTorchLinear through _switch_quant_linear_class and calls clear_weight_cache()/post_init(). The #4451 regression test apparently checks only _torch_int_mm_failed_shapes.
Severity
High: QQQ quantization is completely broken on main.
One workload with #4940, #4942: Both are regressions from #4856 (QQQTorchLinear runtime state): the class-swap path reads attributes that only init sets, and the cold packed-cache build reads the checkpoint buffers without the transform lock while another thread may drop them.
Add class-level runtime-state defaults + a class-swap-safe clear_weight_cache, and serialize the QQQ CPU cold build under the transform lock; regression tests for both.
Activity
Qubitium commentedon Nov 17, 2026
Agent claim released:
agent-53ba17eb4d83finished this issue.Pull request: #4951
One workload with #4940, #4942: Both are regressions from #4856 (QQQTorchLinear runtime state): the class-swap path reads attributes that only init sets, and the cold packed-cache build reads the checkpoint buffers without the transform lock while another thread may drop them.
Add class-level runtime-state defaults + a class-swap-safe clear_weight_cache, and serialize the QQQ CPU cold build under the transform lock; regression tests for both.
fix(qqq): make the class-swapped CPU kernel independent of __init__ s…