Skip to content

fix(loader): forward a tokenizer only when the caller supplied one (#6403) - #6412

Merged
Qubitium merged 1 commit into
mainfrom
fix/6403-v41-tokenizer
Nov 29, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/6403-v41-tokenizer

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #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.from_quantized() validates its load arguments (set(kwargs) - selection.keys()), so the whole V4.1 path raised before the checkpoint was read:

TypeError: Unsupported DeepSeek V4.1 Flash load arguments: tokenizer

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 adds 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 and cannot change a definition that accepts the kwarg.

gptqmodel/models/definitions/deepseek_v41_flash.py — pop tokenizer before the strict-argument check and honour it. Without this, the tokenizer= 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 same load_hf_tokenizer() validation and pad-token repair as the checkpoint's own.

gptqmodel/models/loader.py — the native-quantized-GGUF redirect had the same unguarded tokenizer=tokenizer_override (it can be None). Guarded for the same reason, so the invariant holds for every from_quantized() call site.

Red → green

cd tests
CUDA_VISIBLE_DEVICES="" PYTHONPATH=<clone>:<clone>/tests /root/venv/bin/python -m pytest \
  module_tree/test_deepseek_v41_flash.py -q --tb=line -p no:cacheprovider
result
6b25d2c69 (before) 8 failed, 4 passed, 5 skipped, 9 errors — all 17 red nodes with the TypeError above
this branch 22 passed, 5 skipped (CUDA-gated only)

Regression tests

Both new tests fail on 6b25d2c69 for the intended reason.

  1. tests/test_missing_tokenizer_6361.py::test_load_does_not_forward_an_absent_tokenizer — intercepts both load() funnels and asserts "tokenizer" not in kwargs by default, and that an explicit tokenizer is forwarded verbatim. Before the fix:
    assert 'tokenizer' not in {'model_id_or_path': '...', 'quantize_config': None, ...}
    
  2. 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 is t20 (the checkpoint pads with id 2) and asserts the loaded model pads with t20. Before the fix: TypeError: Unsupported DeepSeek V4.1 Flash load arguments: tokenizer.

Regression coverage

suite result
module_tree/test_deepseek_v41_flash.py + test_missing_tokenizer_6361.py 31 passed / 5 skipped (CUDA-gated only)
#6386 family (test_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) 102 passed
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.py included in 63 passed / 12 skipped
test_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) 43 passed

ruff check clean on all five files.

Notes

…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
Qubitium marked this pull request as ready for review November 29, 2026 15:22
@Qubitium
Qubitium merged commit 6f102fc into main Nov 29, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/6403-v41-tokenizer branch November 29, 2026 15:22
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] #6386 forwards tokenizer=None into DeepSeek V4.1 Flash from_quantized; all 17 v41 module-tree tests fail

1 participant