Repository navigation
fix(load): resolve the legacy sidecar through the checkpoint selection (#5379) - #5494
Merged
Merged
Conversation
#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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5379.
Root cause
When
config.jsoncarries no embedded quantization metadata,GPTQModel.load()decides between the dense and the quantized loader by probing forquantize_config.json/quant_config.json:The probe ignored the selection the config and weights use:
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";revision: the listing always read the default revision;OfflineModeIsEnabledeven though the snapshot was cached.Fix
New
_has_legacy_quant_sidecar(model_id_or_path, config_kwargs, treat_as_local_path=...)ingptqmodel/models/auto.py, called with the same_get_config_load_kwargs()the config load uses:<model>/<subfolder>/<name>;HF_HUB_OFFLINE): never list the repository - probe the local Hub cache withhf_hub_download(..., local_files_only=True).Tests
New
tests/test_legacy_sidecar_selection_5379.py(6 tests):subfolderforwarded;list_repo_files;subfolder+revision;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):58fbec467..._dispatches_to_the_quantized_loader,..._does_not_select_a_nested_dense_checkpoint)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.pywas not run to completion (it quantizes real models and exceeded ~8 minutes on this host); the selection paths it depends on are covered bytest_checkpoint_subfolder_resolution.py.CPU-only; no GPU needed.