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] #5031/#5066 cancelled-run contract: a Ctrl-C during pack_module leaves a half-built TorchLinear (no qweight/qzeros) in the model; every later forward raises AttributeError 'qzeros' #5089
Found on main @ e75181d, RTX 4090 (CUDA 13.2, torch 2.15). Same on c2b0bf64f, so not a regression. #5031/#5066 claim a "Runnable" in-session model after any cancelled quantize() (docs/cancelled-run-contract.md). This window was never covered.
What is wrong
GPTQProcessor.submodule_finalize (gptqmodel/looper/gptq_processor.py:1112-1160) first swaps the projection for its kernel class with create_quant_module(..., register_buffers=False). The kernel goes into the model without qweight/qzeros/scales. Only after that does it call pack_module() -> BaseQuantLinear.pack_gpu() (nn_modules/qlinear/__init__.py:2637) to register and fill those buffers. The weight-only path (WeightOnlyProcessor.submodule_finalize -> pack_module) does the same.
When a Ctrl-C or an exception lands while pack_gpu runs, the model is left holding a half-built TorchLinear. RunExitRecovery.abort() restores the in-flight layer and rehomes the kernels (rehome_failed_run_kernels), but it neither finishes the pack nor puts the original nn.Linear back. So every later forward fails:
AttributeError: 'TorchLinear' object has no attribute 'qzeros'
Packing is a large share of RTN/GPTQ wall time, so the window is wide. A random-time Ctrl-C sweep of RTN (Qwen2.5-0.5B, 4 layers, 33 cancel points) hit it once without any patching.
Repro (deterministic)
KeyboardInterrupt raised at the 60th Tensor.copy_ of a GPTQ run (inside pack_gpu of layer 0), Qwen2.5-0.5B-Instruct truncated to 4 layers:
interrupt at: __init__.py:2779 pack_gpu <- model.py:1428 pack_module <- gptq_processor.py:1153 submodule_finalize
AttributeError: 'TorchLinear' object has no attribute 'qzeros'
The result is identical on c2b0bf64f (interrupt at __init__.py:2733 pack_gpu). RTN through WeightOnlyLooper gives the same error when interrupted by a real timer Ctrl-C during packing.
Suggested fix
Make the kernel swap atomic with respect to packing. Build and pack the quant module off-model and install it with a single setattr once pack() has returned. Alternatively, have the run-exit recovery detect a quant module without its packed buffers (for example qweight missing) and put the original float module back. It is still available as the layers[...] source that pack_module received.
Test that should have caught it
tests/test_run_exit_recovery_contract_5060.py injects faults only at looper helper boundaries. Add a node that interrupts inside pack_module (GPTQ and RTN) and asserts that the next forward runs.
Severity
Low to medium. This is a loud failure, not silent corruption, but the cancelled-run contract says the model stays runnable, and the only recovery is to reload the model.
More data, natural interrupts with no patching: 40 _thread.interrupt_main() timer Ctrl-Cs at uniform random times during RTNConfig(bits=4, group_size=128) quantize of the same 4-layer Qwen2.5-0.5B (default offload_to_disk=True), main @ e75181d:
12/40 leave the model unrunnable with AttributeError: 'TorchLinear' object has no attribute 'qzeros' (5) or ... 'g_idx' (7). Both are this half-built-kernel window. g_idx is the first buffer pack_gpu registers.
The other 27 gave a runnable model (loss 15.14-15.356).
On c2b0bf64f the same sweep failed with device mismatches instead (#5011, now fixed). For weight-only methods, this window is now the dominant way a cancelled run leaves the model unusable.
Activity
Qubitium commentedon Nov 18, 2026
More data, natural interrupts with no patching: 40
_thread.interrupt_main()timer Ctrl-Cs at uniform random times duringRTNConfig(bits=4, group_size=128)quantize of the same 4-layer Qwen2.5-0.5B (defaultoffload_to_disk=True),main@ e75181d:AttributeError: 'TorchLinear' object has no attribute 'qzeros'(5) or... 'g_idx'(7). Both are this half-built-kernel window.g_idxis the first bufferpack_gpuregisters.On
c2b0bf64fthe same sweep failed with device mismatches instead (#5011, now fixed). For weight-only methods, this window is now the dominant way a cancelled run leaves the model unusable.🤖 Generated with Claude Code
ZX-ModelCloud commentedon Nov 18, 2026
Agent claim released:
agent-bf42512e3169finished this issue.Pull request: #5152
Reproducing the half-built kernel window after pack_module cancellation on CPU/GPTQ+RTN fixtures
docs: cite has_cpu_offload_hooks by symbol after the model.py line sh…
fix(looper): publish a quant kernel only after packing returns (Model…
refactor(processors): share the stat row, quant-module build and publ…