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] Re-saving a loaded quantized model builds the shell with from_config outside _MODEL_LOAD_LOCK, reopening the #4129 default-dtype race #4204
Severity: medium Status: likely. The unlocked call sequence is confirmed; a full save()-vs-load() race did not hit the window in 10 tries on our host. Version: 7.11.0 @ 9dad249
Summary
The save_quantized → get_model_with_quantize path (models/writer.py:~2148, :2446-2459) runs suspend_hf_weight_init() + self.loader.from_config(config, dtype=model_dtype). transformers wraps that in local_torch_dtype, a process-global torch.set_default_dtype.
Only from_pretrained / from_quantized are serialised by _serialized_model_load (models/loader.py). These are also unlocked:
utils/model_dequant.py:~359
utils/tt_blockfloat_quant.py:~2155 (_from_config)
Reproduce (the save-path sequence on one thread, GPTQModel.load on another)
5/8 loads raised model load left a corrupted state: floating parameters are not all torch.float16: {'torch.bfloat16': 34} or torch.get_default_dtype() changed.
The "ok" loads observed default=torch.bfloat16 mid-run.
Expected: every model-construction site, including the save-side shell build, the dequant path and the TT block-float path, takes _MODEL_LOAD_LOCK.
Related: #4129 (closed) fixed only the load entry points.
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: serialize save-side shell build, dequant and TT from_config unde…
fix(load): hold the global-state writer only for the default-dtype wi…
fix(load): hold the global-state writer only for the default-dtype wi…