Skip to content

[BUG] GPTQModel.load ignores checkpoint selection when detecting legacy quantization sidecars #5379

Closed

Description

@Qubitium

Describe the bug

When config.json lacks embedded quantization metadata, GPTQModel.load() falls back to looking for quantize_config.json or quant_config.json. The lookup ignores the selected subfolder and Hub revision. It also calls the Hub file-listing API in offline mode.

Nested checkpoint reproduction

At 72cef9bac, quantize and save a tiny Llama checkpoint under root/gptq. Remove only the embedded quantization_config field from its config.json, leaving quantize_config.json and the packed weights in place. This mimics a legacy sidecar-only checkpoint.

from gptqmodel import GPTQModel

print(GPTQModel.load("root/gptq", device="cpu").quantized)
print(GPTQModel.from_quantized("root", subfolder="gptq", device="cpu").quantized)
print(GPTQModel.load("root", subfolder="gptq", device="cpu").quantized)

Verified on CPU. The first two calls return True and load packed layers. The third returns False and creates dense layers. Transformers reports unexpected packed tensors and missing dense projection weights, which it initializes.

Offline cache reproduction

Using a complete local Hugging Face cache of a tiny dense Llama checkpoint at a pinned revision, set HF_HUB_OFFLINE=1 and pass local_files_only=True. AutoConfig.from_pretrained() and GPTQModel.from_pretrained() load the snapshot. GPTQModel.load() raises OfflineModeIsEnabled while listing repository files. This was verified without a network dependency using a locally prepared cache.

Expected behavior

The sidecar lookup agrees with the config and weights on subfolder and revision, and honors the caller's offline policy. The nested checkpoint should dispatch to the quantized loader, and the cached dense checkpoint should load without listing the remote repository. Config lookup, sidecar lookup.

Suggested mitigation

The fallback in gptqmodel/models/auto.py could resolve each legacy filename using the same cache-aware file lookup and subfolder, revision, and local-file policy as the config loader. For local paths, it could probe the effective checkpoint directory directly.

A regression could assert that a sidecar-only nested checkpoint installs packed layers, and a separate pinned-cache case could exercise the dense dispatch with network access disabled. As workarounds, the explicit from_quantized() route succeeds for the nested fixture, and using a local snapshot directory avoids the Hub listing call.

Activity

  1. added
    bug
    on Nov 19, 2026
  2. Qubitium commented on Nov 19, 2026

    @Qubitium
    CollaboratorAuthor

    Agent claim: agent-4e3a0639ecaf is working on this issue now.

    Started 2026-11-19T09:10:00Z. The claim expires 4.0h after this comment is last edited (heartbeat). Other agents: do not start this issue while the claim is live.

    Resolve the legacy sidecar lookup through the same subfolder/revision selection as the config and weights, and never list the Hub repository when the caller is offline.

  3. Qubitium commented on Nov 19, 2026

    @Qubitium
    CollaboratorAuthor

    Released: #5494 merged as afd856571.

    Root cause

    • GPTQModel.load() decides between the dense and quantized loader by probing for quantize_config.json / quant_config.json when config.json has no embedded quantization metadata. The probe always looked at the repository root and always listed the remote repository: a nested checkpoint (subfolder=) was treated as dense (packed tensors loaded as dense weights and re-initialized), a pinned revision was ignored, and an offline caller hit OfflineModeIsEnabled.

    Fix

    • New _has_legacy_quant_sidecar() in gptqmodel/models/auto.py, called with the same _get_config_load_kwargs() the config load uses:
      • local: check <model>/<subfolder>/<name>;
      • remote: list the pinned revision and match the subfolder-prefixed name;
      • offline (HF_HUB_OFFLINE): never list the repository - probe the local Hub cache with hf_hub_download(..., local_files_only=True).

    Verification

    • New tests/test_legacy_sidecar_selection_5379.py (6 tests): nested sidecar dispatches to the quantized loader with subfolder forwarded; a root sidecar does not select a nested dense checkpoint; local/remote/offline probes each resolve the selection correctly.
    • Red -> green on 58fbec467: 2 failed -> 6 passed.
    • Regression: test_checkpoint_subfolder_resolution.py + test_model_dequant_v2_metadata_alias_5413.py + new file -> 31 passed; ruff clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions