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] #4823 (fix of #4813) incomplete: quantize() failing before the looper (empty/too-short calibration, bad rows, checkpoint/session setup) still leaks 2 device-smi sampler threads per attempt; LoopProcessor.__init__ opens handles before validating the dataset #4862
Found on main @ 5cded90, RTX 4090, torch 2.15, device-smi installed.
What is wrong
#4823 (the fix for #4813) closes the processors' Device-SMI handles in the failure branch of ModuleLooper.loop() and WeightOnlyLooper.loop(). Any quantize() that fails before the looper's try still leaks the two sampler threads (device-smi-metrics-gpu and device-smi-metrics-cpu, each polling at 5 Hz) for the life of the process.
LoopProcessor.__init__ opens the handles first (gptqmodel/looper/loop_processor.py:534-535) and only then validates and prepares the calibration dataset in the same constructor (:539-583). Several ValueErrors raised there abort the constructor: "Calibration dataset must not be empty.", "... is empty after CalibrationConfig.prepare_dataset removed all samples ...", and unsupported row types raised from prepare_dataset. The half-built processor is never handed to a looper, so nothing calls release_failed_run(). Each Device thread holds its Device through the bound _fast_metrics_worker, so GC cannot reclaim it either.
The same gap applies to:
processors already built when a later one fails (base.py:2883-2929, e.g. GPTQ + EoRA);
failures between processor construction and module_looper.loop(): checkpoint_session(...) entry (resume validation), install_w4a_llama_replay, and ModuleLooper.__init__.
Repro (Qwen2.5-0.5B-Instruct truncated to 4 layers, GPTQ 4-bit)
start 0
empty list #1: ValueError: Calibration dataset must not be empty. -> device-smi threads 2
empty list #2: ValueError: Calibration dataset must not be empty. -> device-smi threads 4
all rows < min_length #1: ValueError: Calibration dataset is empty after CalibrationConfig.prepare_dataset r -> device-smi threads 6
all rows < min_length #2: ValueError: Calibration dataset is empty after CalibrationConfig.prepare_dataset r -> device-smi threads 8
bad row type #1: ValueError: Quantize: unsupported calibration example type <class 'int'> at index -> device-smi threads 10
bad row type #2: ValueError: Quantize: unsupported calibration example type <class 'int'> at index -> device-smi threads 12
The in-loop failures that #4823 targets are fixed. StopMainLoop, RuntimeError and KeyboardInterrupt from subset_callback at layer 1 each leave 0 threads.
Suggested fix
Open the Device-SMI handles lazily on the first metric query, or at least after the dataset checks in LoopProcessor.__init__. Also wrap processor construction and the code up to module_looper.loop() in _quantize_with_calibration (and the weight-only and EoRA-generation paths) in a try/except BaseException that calls release_failed_run() on every processor already built. Of the two, lazy opening is the more robust, because a processor that is never run then never starts a thread.
Test that should have caught it
tests/test_failed_run_device_smi_cleanup_4813.py covers only failures inside ModuleLooper.loop(). Add a case with an empty or too-short calibration dataset and assert that no device-smi-metrics* thread survives.
Severity
Low-medium. It is the same per-attempt thread and CPU leak as #4813. These are the most common user errors (a bad or too-short dataset), and retry loops in notebooks or services accumulate threads.
Finish #4823: quantize() failing before the looper (empty/short calibration, bad config) must tear down the Device-SMI monitor thread and any other pre-looper resources; add failure-path tests.
Activity
Qubitium commentedon Nov 17, 2026
Agent claim released:
agent-53ba17eb4d83finished this issue.Pull request: #4906
Finish #4823: quantize() failing before the looper (empty/short calibration, bad config) must tear down the Device-SMI monitor thread and any other pre-looper resources; add failure-path tests.
fix(looper): release pre-looper resources on a failed quantize (#4862) (
Port every supported model onto the Transformers 5.23 ABI; never patc…