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] Offload bundles are keyed only by module name in a directory shared by every copy of a QuantizeConfig, so a second quantize() silently overwrites the first model's quantized weights #4202
Severity: high (silently wrong checkpoint with the default config; no threads needed) Version: 7.11.0 @ 9dad249
Summary
utils/offload.py:387 (and the .tmp/.old swap at :405) writes each bundle to os.path.join(disk_path, name). The path depends only on the module name.
quantization/config.py:41-63 and :4644-4647 create one auto temp dir per config object, and _SharedTemporaryDirectory.__copy__/__deepcopy__ deliberately return the same directory. Even copy.deepcopy(qcfg) per model shares it.
The layer finaliser (looper/stage_layer.py:~1430) offloads with force=True into that dir, and save() later reads back whatever bundle is on disk.
So two same-architecture models (base/instruct, two fine-tunes) loaded with one QuantizeConfig share offload_to_disk_path. Model B's finaliser replaces the model.layers.N.* bundles that model A's accelerate hooks still point to, and a.save() writes B's qweight/scales. The same happens with an explicit shared offload_to_disk_path across threads or processes.
Reproduce
fromgptqmodelimportGPTQModel, QuantizeConfigA, B="<model-A>", "<model-B, same architecture>"# e.g. Qwen3-0.6B and a fine-tune of itcal= ["The quick brown fox jumps over the lazy dog. "*8+str(i) foriinrange(32)]
qcfg=QuantizeConfig(bits=4, group_size=128) # default offload_to_disk=Truea=GPTQModel.load(A, quantize_config=qcfg); b=GPTQModel.load(B, quantize_config=qcfg)
print(a.quantize_config.offload_to_disk_path==b.quantize_config.offload_to_disk_path) # Truea.quantize(cal, batch_size=4, calibration_data_min_length=1)
b.quantize(cal, batch_size=4, calibration_data_min_length=1) # strictly sequentiala.save("A-q"); b.save("B-q")
# compare A-q/model.safetensors with a fresh-process quantize+save of A alone
Actual (3-layer Qwen3-0.6B vs a copy with negated layer weights, R9700):
42/98 tensors in A-q (all 21 qweight + 21 scales) differ from the reference, and 42/42 of those are bit-equal to B's checkpoint.
B-q is correct.
Two quantize() threads with an explicit shared offload_to_disk_path gave the same 42/42 contamination.
The reference is stable: 6/6 serial runs were bit-identical.
Expected
Each quantize run gets a private offload namespace (e.g. a per-run/per-model subdirectory), or sharing is detected and refused.
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: isolate offload bundles per quantize run (#4202) (#4297)