Repository navigation
fix(loader): forward a tokenizer only when the caller supplied one (#6403) - #6412
Merged
Merged
Conversation
…6403) #6386 added `tokenizer=` to `GPTQModel.load()` and forwarded it to the resolved definition unconditionally, so the default `tokenizer=None` became a load kwarg for every definition. `DeepSeekV41FlashQModel` validates its load arguments and rejected the whole V4.1 path with `TypeError: Unsupported DeepSeek V4.1 Flash load arguments: tokenizer` before the checkpoint was read. - `auto.py`: add `tokenizer` to the forwarded kwargs only when it is not `None`. `None` already means "let the definition load the checkpoint's own", so omitting it is the pre-#6386 behaviour. - `deepseek_v41_flash.py`: pop `tokenizer` before the strict-argument check and honour it through `load_hf_tokenizer()`, so the documented `tokenizer=` override works for a V4.1 checkpoint without one. - `loader.py`: the native-quantized-GGUF redirect had the same unguarded `tokenizer=tokenizer_override` (it can be `None`). Fixes #6403
Qubitium
marked this pull request as ready for review
November 29, 2026 15:22
This was referenced Nov 29, 2026
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 #6403.
#6386 added
tokenizer=toGPTQModel.load()and forwarded it to the resolved definition unconditionally, so the defaulttokenizer=Nonebecame a load kwarg for every definition.DeepSeekV41FlashQModel.from_quantized()validates its load arguments (set(kwargs) - selection.keys()), so the whole V4.1 path raised before the checkpoint was read:It is the only definition with that strict check (
grep -rn "Unsupported .* load arguments" gptqmodel/), but the defect is generic:load()should forward only what the caller actually supplied.Changes
gptqmodel/models/auto.py—load()now addstokenizerto the forwarded kwargs only when it is notNone.Nonealready means "let the definition load the checkpoint's own", so omitting it is the pre-#6386 behaviour and cannot change a definition that accepts the kwarg.gptqmodel/models/definitions/deepseek_v41_flash.py— poptokenizerbefore the strict-argument check and honour it. Without this, thetokenizer=escape hatch that #6361/#6386 document still could not be used on a V4.1 checkpoint that ships no usable tokenizer. The supplied tokenizer goes through the sameload_hf_tokenizer()validation and pad-token repair as the checkpoint's own.gptqmodel/models/loader.py— the native-quantized-GGUF redirect had the same unguardedtokenizer=tokenizer_override(it can beNone). Guarded for the same reason, so the invariant holds for everyfrom_quantized()call site.Red → green
6b25d2c69(before)8 failed, 4 passed, 5 skipped, 9 errors— all 17 red nodes with theTypeErrorabove22 passed, 5 skipped(CUDA-gated only)Regression tests
Both new tests fail on
6b25d2c69for the intended reason.tests/test_missing_tokenizer_6361.py::test_load_does_not_forward_an_absent_tokenizer— intercepts bothload()funnels and asserts"tokenizer" not in kwargsby default, and that an explicit tokenizer is forwarded verbatim. Before the fix:tests/module_tree/test_deepseek_v41_flash.py::test_v41_load_accepts_an_explicit_tokenizer— loads the fixture checkpoint with a tokenizer whose pad token ist20(the checkpoint pads with id 2) and asserts the loaded model pads witht20. Before the fix:TypeError: Unsupported DeepSeek V4.1 Flash load arguments: tokenizer.Regression coverage
module_tree/test_deepseek_v41_flash.py+test_missing_tokenizer_6361.pytest_missing_tokenizer_6361,test_missing_processor_metadata_6295,test_awq_native_shape_guard_5345,test_calibration_auto_batch_entrypoints_5504,test_checkpoint_dynamic_exclusion_sources,test_internvl_tied_head_4973,test_internvl_untied_lm_head_4799,test_layer_type_replay,test_requantize_large_hidden_norm_6231,test_tiny_moe_quant_smoke,test_vl_legacy_checkpoint_resave_4802)test_loader.py,test_loader_double_contract_4941.py,test_loader_tokenizer_flag_4941.py,test_load_device_context_4863.py,test_load_state_assertions.pytest_gguf_load_policy_env_removal.py,test_local_model_paths.py(covers the GGUF redirect branch, incl.test_model_loader_from_pretrained_native_bonsai_low_memory_redirects_with_backend)ruff checkclean on all five files.Notes
tokenizer.6b25d2c69was not touched here: [BUG] #6386 overwrites a checkpoint generation_config.pad_token_id with the tokenizer pad id (ovis + qwen3-marin red) #6402 (generation_config.pad_token_idclobbering) and [TEST] #6386 tokenizer usability guard rejects fixture tokenizers in 19 more test files (116 nodes) #6404 (fixture tokenizers rejected by the fix(loader): reject tokenizer-less checkpoints and repair pad token (#6361) #6386 usability guard).