Skip to content

fix(load): resolve the legacy sidecar through the checkpoint selection (#5379) - #5494

Merged
Qubitium merged 1 commit into
mainfrom
fix/5379-sidecar-subfolder-revision
Nov 19, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/5379-sidecar-subfolder-revision

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #5379.

Root cause

When config.json carries no embedded quantization metadata, GPTQModel.load() decides between the dense and the quantized loader by probing for quantize_config.json / quant_config.json:

for name in [QUANT_CONFIG_FILENAME, "quant_config.json"]:
    if treat_as_local_path:
        if isdir(model_id_or_path) and os.path.exists(join(model_id_or_path, name)):
            ...
    else:
        files = list_repo_files(repo_id=model_id_or_path)   # no revision, always online

The probe ignored the selection the config and weights use:

  • nested checkpoint (subfolder="gptq"): the sidecar beside the nested config was never seen, so the load fell back to the dense path, re-initialized the packed projections and reported "unexpected packed tensors";
  • pinned revision: the listing always read the default revision;
  • offline: the listing raised OfflineModeIsEnabled even though the snapshot was cached.

Fix

New _has_legacy_quant_sidecar(model_id_or_path, config_kwargs, treat_as_local_path=...) 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).

Tests

New tests/test_legacy_sidecar_selection_5379.py (6 tests):

  1. nested sidecar-only checkpoint -> the quantized loader is selected, with subfolder forwarded;
  2. control: a sidecar at the repository root must not select a nested dense checkpoint (the pre-fix behaviour);
  3. local probe resolves the subfolder both ways;
  4. offline probe never calls list_repo_files;
  5. offline probe uses the local cache and forwards subfolder + revision;
  6. remote probe lists the pinned revision and matches gptq/quantize_config.json.

Red -> green (the two public-API tests run against a pristine worktree at upstream/main 58fbec467; the rest import the new helper):

result
58fbec467 2 failed (..._dispatches_to_the_quantized_loader, ..._does_not_select_a_nested_dense_checkpoint)
this branch 6 passed

Regression: tests/test_checkpoint_subfolder_resolution.py, tests/test_model_dequant_v2_metadata_alias_5413.py + the new file -> 31 passed; uvx [email protected] check gptqmodel docs/eora tests setup.py -> clean.

tests/test_checkpoint_quantization.py was not run to completion (it quantizes real models and exceeded ~8 minutes on this host); the selection paths it depends on are covered by test_checkpoint_subfolder_resolution.py.

CPU-only; no GPU needed.

#5379)

`GPTQModel.load()` detects a legacy checkpoint by looking for
`quantize_config.json` / `quant_config.json` when `config.json` has no embedded
quantization metadata. The probe always looked at the repository root and
listed the remote repository unconditionally:

- a nested checkpoint (`subfolder=`) was treated as dense, so packed tensors
  were loaded as dense weights and silently re-initialized;
- a pinned `revision` was ignored;
- an offline caller hit `OfflineModeIsEnabled` while listing files.

Resolve the probe with the same selection kwargs the config and weights use:
local paths check `<model>/<subfolder>`, remote probes list the pinned revision
and match the subfolder-prefixed name, and an offline probe consults only the
local Hub cache instead of listing the repository.
@Qubitium
Qubitium merged commit afd8565 into main Nov 19, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/5379-sidecar-subfolder-revision branch November 19, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant