Repository navigation
refactor(loader): one immutable checkpoint selection for every consumer (#5586) - #6272
Merged
Merged
Conversation
Qubitium
force-pushed
the
fix/5586-issue
branch
from
November 29, 2026 03:57
a1a7bd7 to
a354d8c
Compare
Qubitium
marked this pull request as ready for review
November 29, 2026 08:18
5 tasks done
Qubitium
added a commit
that referenced
this pull request
Nov 29, 2026
…6385) #6272 moved checkpoint selection into one immutable record passed to model definitions under `_gptqmodel_checkpoint_selection`. DeepSeekV41FlashQModel is the only definition that overrides from_quantized, and it treated the internal kwarg as an unsupported user argument, so every V4.1 load raised TypeError (7 failed + 9 errors in tests/module_tree/test_deepseek_v41_flash.py). Pop the hand-off and reuse its hub_kwargs for the checkpoint, config, and tokenizer reads. Add a regression test that loads a nested checkpoint through GPTQModel.load and directly through the definition; a valid decoy checkpoint at the root proves the handed-off record is reused, not merely accepted. Fixes #6381 Co-authored-by: agent <agent@local>
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 #5586.
Summary
A load with
subfolder=selects one checkpoint. This change introduces one immutableCheckpointSelectionat the public load entry and routes every consumer through one of its two explicit views:hub_kwargs: original source (Hub id or caller root) + normalizedsubfolder/revision/lookup policy for Hub/Transformers calls.local_path+local_kwargs: the selected directory once materialized, withsubfolderremoved, for filesystem-only readers.The selection is frozen, deep-copies nested kwargs (proxies), and keeps
token/use_auth_tokenonly in memory:persisted_kwargsandrepr()omit them.No checkpoint format change.
API
gptqmodel.utils.hf.CheckpointSelection:from_kwargs(source, kwargs, extra_kwargs=None)— validates/normalizes through the existingget_config_selection_kwargs.from_selection_kwargs(source, kwargs)— for an already-merged config/GGUF selection.subfolder,revision,lookup_policy,is_local.hub_kwargs— view 1.persisted_kwargs— wrapper-retained kwargs without transport credentials.materialize(local_root)/local_path/local_kwargs/require_local_path()— view 2.INTERNAL_CHECKPOINT_SELECTION_KWARGcarries the record from the public entry point to the model definition.get_config_selection_kwargsandresolve_checkpoint_subfolderkeep their existing signatures and validation.Migration completed
GPTQModel.load,from_pretrained,from_quantized) builds the selection once and hands the same object to the definition.local_files_only=Truenow forces a cache-only sidecar probe;HF_HUB_OFFLINEstill does. The probe forwardssubfolder, pinnedrevision,cache_dirandtokenwithout listing the repo.selection.local_path; the wrapper keeps the selection for save.hub_kwargs.get_checkpoints), embedding probe, adapter manifest, pre-load hooks, GGUF/floatx probes and the MLX converter uselocal_pathwithlocal_kwargs(nosubfolder).config_load_kwargskeeps the legacy path._config_load_kwargs.Tests
Extended
tests/test_checkpoint_subfolder_resolution.pywith one shared distinguishable Gemma3 fixture (root marker 8 / width 16, child marker 4 / width 32) and these nodes:test_checkpoint_selection_exposes_two_views_and_redacts_credentialstest_root_only_selection_keeps_the_root_as_both_viewstest_local_files_only_sidecar_probe_never_lists_the_repositorytest_remote_sidecar_probe_lists_the_pinned_revisiontest_legacy_sidecar_dispatch_follows_the_selected_checkpointtest_quantized_weight_reader_receives_the_selected_directorytest_native_floatx_probe_receives_the_selected_directorytest_direct_child_and_root_subfolder_load_the_same_dense_checkpointtest_direct_child_and_root_subfolder_load_the_same_quantized_checkpointThe dense/quantized tests compare backend/kernel type, processor marker,
model_local_path, fullstate_dict, and re-save/reload for both spellings. Root-only load stays at the root.Red evidence (source reverted to HEAD
2d3261d)Result: 4 failed
The two
repositoryvsrepository/nestedfailures are the intended root-vs-selected-directory defect; the sidecar failure is the offline probe listing the remote repo.Green evidence
Broader checkpoint/subfolder/snapshot family:
The 5 failures are pre-existing/environmental AWQ-CUDA checks (
ValueError: AWQ: CUDA is not available) intest_checkpoint_awq_scales_dtype_6153.py(3) and the CPU-AVX512 AWQ state-invariant cases (2). A representative node fails identically at HEAD, and the two state-invariant nodes pass in isolation both at HEAD and on this branch; the family-order failure is existing test-state pollution.Additional green batch:
Ruff:
/root/venv/bin/ruff check \ gptqmodel/utils/hf.py gptqmodel/models/auto.py gptqmodel/models/loader.py \ gptqmodel/models/base.py gptqmodel/models/writer.py \ tests/test_checkpoint_subfolder_resolution.py # All checks passed!Deferred / unverified
tests/test_checkpoint_quantization.pywas not run to completion (it quantizes real models and is long on this host); the selection paths it uses are covered by the subfolder/resave suites.tests/test_tenstorrent_support.py::test_tt_bf8_device_weight_rebuilds_when_the_source_changesfails on this host withTTNNUnavailable; unrelated to this diff.