Repository navigation
fix(load): resolve the wrapper checkpoint directory from subfolder - #5461
Merged
Merged
Conversation
The dense and quantized loaders forwarded `subfolder` to Transformers for the config, tokenizer and weights but constructed the wrapper with the repository root. `BaseQModel.__init__` loads the processor from `model_local_path`, so a checkpoint stored entirely under `parent/nested` either raised "Unrecognized processing class" or silently used a processor from the parent directory. Resolve the requested subfolder once in `from_pretrained` and hand the effective checkpoint directory to wrapper construction, the pre-load hook and the quantized embedding probe, matching what `from_quantized` already does for the quantize config and adapters. Config, tokenizer and weight loading keep forwarding `subfolder` to Transformers.
ZX-ModelCloud
marked this pull request as ready for review
November 19, 2026 06:49
This was referenced Nov 19, 2026
Qubitium
added a commit
that referenced
this pull request
Nov 19, 2026
`GPTQModel.load(root, subfolder="gptq")` used to construct the wrapper with the repository root, so an immediate `save()` rebuilt its export shell from the root and failed with `ValueError: Unrecognized model`. #5461 resolved the wrapper directory; this test locks the behaviour the issue asks for. Quantize a tiny Llama into `root/gptq` with RTN, load it through the subfolder, save it to a fresh directory, reload and compare every packed tensor. It also asserts the wrapper keeps the directory the load selected, which is the root cause, and that the repository root carries no config to fall back to.
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.
Summary
Fixes #5358.
GPTQModel.load(parent, subfolder="nested")resolved the config, tokenizer andweights under
nested, but constructed the model wrapper withparent.BaseQModel.__init__loads the processor from the wrapper's checkpoint root,so a multimodal checkpoint stored entirely under
parent/nestedraisedValueError: Unrecognized processing class, or silently used a processor fromthe parent directory when one existed there.
What Changed
gptqmodel/models/loader.py(from_pretrained): resolve the requestedsubfolder once with
resolve_checkpoint_subfolderand hand the effectivedirectory to wrapper construction, the
before_model_loadhook and thequantized-embedding probe.
from_quantized: hand the same resolved directory to wrapper construction,the pre-load hook, the embedding probe and the vLLM/SGLang loaders, matching
the directory already used for the quantize config and adapters.
subfoldertoTransformers, so Hub and local checkpoints resolve as before.
repository root before a subfolder is resolved.
Tests
New regression in
tests/test_checkpoint_subfolder_resolution.py:test_public_load_reads_the_processor_from_the_requested_subfolder(dense)test_quantized_load_reads_the_processor_from_the_requested_subfolder(quantized)
Both build a tiny local Gemma3 VL checkpoint under
parent/nestedand write adifferent valid processor at
parent, so a silent root fallback isdetected instead of only a crash. The assertion reads the processor's
image_seq_lengthmarker (nested4, root control8).Red evidence (only the loader change temporarily reverted):
Green evidence:
Pre-existing failures, reproduced on a pristine base checkout and unrelated to
this diff:
tests/test_gemma3_vl_support.py::test_gemma3_vl_prepare_dataset_accepts_pretokenized_text_without_processorfails at the same assertion (
[(1, 11), (1, 12)] != [(1, 12), (1, 13)]).tests/test_local_model_paths.pyload tests fail because theirSimpleNamespacemodel double lackslog_budget.tests/models/test_ouro.pyandtests/models/test_spark2_5.pygeneration harness fails its keyword assertion on the downloaded model.
Model Support / Module Plan
Not applicable: no
MODEL_MAPentry, model definition, alias or module plan ischanged.
AWQ onboarding safety
Not applicable: no model definition, AWQ grouping, search, replay or folding
change.
Logic Flow Documentation
Not applicable: this is a local path-handoff fix. The decision and stage order
are unchanged; only the already-resolved checkpoint directory is handed to the
existing consumers. No new branch, fallback or lifecycle is introduced.
Review Requirements
Kernel Accuracy Requirements
Not applicable: no kernel, fusion or dispatch change.
Notes
resolve_checkpoint_subfolderis the same helperfrom_quantizedalready usesfor the quantize config and adapter manifest, so both load paths now agree on
the checkpoint directory and keep rejecting a subfolder that escapes it.