Skip to content

[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

Closed

Description

@Qubitium

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

from gptqmodel import GPTQModel, QuantizeConfig
A, B = "<model-A>", "<model-B, same architecture>"     # e.g. Qwen3-0.6B and a fine-tune of it
cal = ["The quick brown fox jumps over the lazy dog. " * 8 + str(i) for i in range(32)]
qcfg = QuantizeConfig(bits=4, group_size=128)          # default offload_to_disk=True
a = 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)   # True
a.quantize(cal, batch_size=4, calibration_data_min_length=1)
b.quantize(cal, batch_size=4, calibration_data_min_length=1)   # strictly sequential
a.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

  1. added
    bug
    on Nov 16, 2026
  2. self-assigned this
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions