Skip to content

fix(load): resolve the wrapper checkpoint directory from subfolder - #5461

Merged
Qubitium merged 1 commit into
mainfrom
fix/5358-subfolder-processor
Nov 19, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/5358-subfolder-processor

Conversation

@ZX-ModelCloud

Copy link
Copy Markdown
Collaborator

Summary

Fixes #5358.

GPTQModel.load(parent, subfolder="nested") resolved the config, tokenizer and
weights under nested, but constructed the model wrapper with parent.
BaseQModel.__init__ loads the processor from the wrapper's checkpoint root,
so a multimodal checkpoint stored entirely under parent/nested raised
ValueError: Unrecognized processing class, or silently used a processor from
the parent directory when one existed there.

What Changed

  • gptqmodel/models/loader.py (from_pretrained): resolve the requested
    subfolder once with resolve_checkpoint_subfolder and hand the effective
    directory to wrapper construction, the before_model_load hook and the
    quantized-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.
  • Config, tokenizer and weight loading keep forwarding subfolder to
    Transformers, so Hub and local checkpoints resolve as before.
  • Out of scope: the native block-float and GGUF probes still inspect the
    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/nested and write a
different valid processor at parent, so a silent root fallback is
detected instead of only a crash. The assertion reads the processor's
image_seq_length marker (nested 4, root control 8).

Red evidence (only the loader change temporarily reverted):

python -m pytest tests/test_checkpoint_subfolder_resolution.py -k processor -q -ra
# FAILED test_public_load_reads_the_processor_from_the_requested_subfolder
# FAILED test_quantized_load_reads_the_processor_from_the_requested_subfolder
# assert 8 == 4   (root processor used instead of the nested one)

Green evidence:

python -m pytest tests/test_checkpoint_subfolder_resolution.py -q -ra
# 22 passed

python -m pytest tests/test_loader.py tests/test_load_strict_kwargs_4945.py \
  tests/test_loader_tokenizer_flag_4941.py tests/test_loader_double_contract_4941.py \
  tests/test_gemma3_vl_support.py -q -ra
# 71 passed, 1 failed (pre-existing)

python -m pytest tests/test_vl_legacy_checkpoint_resave_4802.py \
  tests/test_legacy_layout_load_no_copy_4959.py -q -ra
# 13 passed

bash format/check.sh
# All checks passed!
  • Unit tests have been executed and passed, or the reason they are not applicable is documented.
  • I added a new simple/fast unit test for this change, or documented why that is not applicable.

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_processor
    fails at the same assertion ([(1, 11), (1, 12)] != [(1, 12), (1, 13)]).
  • tests/test_local_model_paths.py load tests fail because their
    SimpleNamespace model double lacks log_budget.
  • The heavyweight tests/models/test_ouro.py and tests/models/test_spark2_5.py
    generation harness fails its keyword assertion on the downloaded model.

Model Support / Module Plan

Not applicable: no MODEL_MAP entry, model definition, alias or module plan is
changed.

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

  • Reviewed this PR.
  • Checked that the code matches existing project structure, APIs, and conventions.
  • Avoided unnecessary monkeypatching and used the project's normal extension points where possible.
  • Minimized and compacted the impacted code surface.
  • Considered and eliminated potential regressions.

Kernel Accuracy Requirements

Not applicable: no kernel, fusion or dispatch change.

Notes

resolve_checkpoint_subfolder is the same helper from_quantized already uses
for the quantize config and adapter manifest, so both load paths now agree on
the checkpoint directory and keep rejecting a subfolder that escapes it.

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
ZX-ModelCloud marked this pull request as ready for review November 19, 2026 06:49
@Qubitium
Qubitium merged commit abb84bf into main Nov 19, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/5358-subfolder-processor branch November 19, 2026 06:50
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.
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] Multimodal processor loading ignores the checkpoint subfolder

2 participants