Repository navigation
test: migrate the remaining #6386 tokenizer fixtures (#6404) - #6420
Merged
Merged
Conversation
added 2 commits
November 29, 2026 15:33
#6386's `load_hf_tokenizer` rejects a checkpoint tokenizer that cannot encode ordinary text. 47 nodes across 13 files still built one of three unusable shapes; #6407 already migrated the other eight files. Three root causes: * `build_wordlevel_tokenizer` (`tests/tiny_remote_models.py`) produced a `WordLevel` model. Transformers 5 rebuilds a *saved* `WordLevel` as a `BPE` without an unknown token, so the tokenizer was usable in memory and encoded prose to nothing once written to disk. It is now a byte-level BPE with the same special tokens and ids (`<s>`=0, `</s>`=1, `<unk>`=2, `<pad>`=3) and every id below `vocab_size`. This alone fixes five files. * All-special or unk-less `WordLevel` fixtures in the rest; they now use the shared `write_tiny_tokenizer`, except `test_local_processor_loading`, which keeps its four-token vocabulary (the test pins ids 1 and 3) and only gains the missing `unk_token`. * Checkpoints written with no tokenizer files at all (`test_fp8`, `test_fail_closed_checkpoint_5218`, `test_construction_global_state_5421`). `test_model_load_lock_4204._write_tiny_rtn_checkpoint` is fixed in place rather than duplicated: `test_compile_load_race_5209` imports it, and its only other user is the GIL-skipped test in that file. No product code changes; the guard is untouched. Fixes #6404
7 tasks done
Qubitium
added a commit
that referenced
this pull request
Nov 29, 2026
…coder reload fixture (#6433) #6386 rejects a checkpoint without a usable tokenizer, and `test_quantized_checkpoint_reloads_with_tied_decoder` saves its tiny DiffusionGemma source with `save_pretrained` only, so `GPTQModel.load` fails at fixture setup ("Tokenizer files are missing") before the #5514/#5716 reload path is reached. Write `tests/tiny_tokenizer.py::write_tiny_tokenizer` next to the model, as #6407 did. `vocab_size=60` keeps every tokenizer id below the config's image/boi/eoi ids (60-62); the calibration rows and forward inputs are pre-tokenized ids 1-56, so the test still feeds exactly the same data. The remaining files from the same sweep are covered by the open draft #6420 (#6404); this is the one rejected fixture it does not touch. No product code changes; the #6386 check is exercised as-is. Co-authored-by: Claude Opus 5.5 <[email protected]>
Qubitium
marked this pull request as ready for review
November 29, 2026 20:16
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 #6404
#6386's
load_hf_tokenizerrejects a checkpoint tokenizer that cannot encode ordinary text. #6407 migrated eight files; this migrates the rest of the list. 47 red nodes across 13 files → 0, on CPU.Two of the fifteen listed files were already green on current
mainand are untouched:test_transformers_unpatched.py(1 passed) andtest_hf_bridge_legacy_qzeros_marlin_6274.py(3 passed, 3 skipped — #6395 fixed it).Three root causes
1.
build_wordlevel_tokenizer(tests/tiny_remote_models.py) — the shared root causeIt built a
WordLevelmodel. Transformers 5 rebuilds a savedWordLevelas aBPEwithout an unknown token, so the tokenizer was usable in memory and encoded prose to nothing once written to disk:It is now a byte-level BPE with the same special tokens and ids (
<s>=0,</s>=1,<unk>=2,<pad>=3), every id belowvocab_size. This one change fixes five files. 24 other test files use this helper; all were re-run (see below).2. All-special or
unk_token-lessWordLevelfixturesMigrated to the shared
tests/tiny_tokenizer.py::write_tiny_tokenizer.test_local_processor_loadingis the exception: the test pins token ids 1 and 3, so it keeps its four-token vocabulary and only gains the missingunk_token.3. Checkpoints written with no tokenizer files at all
test_fp8,test_fail_closed_checkpoint_5218,test_construction_global_state_5421now write one next to the model.test_model_load_lock_4204._write_tiny_rtn_checkpointis fixed in place rather than duplicated:test_compile_load_race_5209imports it, and its only other user is the GIL-skipped test in that file.No product code changes; the guard is untouched, no bypass env var.
Baseline → after (CPU,
CUDA_VISIBLE_DEVICES="", base407298ad2)test_measure_model.pytest_local_processor_loading.pytest_gptaq_foem_first_capture_5831.pytest_gptq_processor_hessian_release_5026.pytest_compile_load_race_5209.pytest_fp8.pytest_gptaq_shuffle_pairing_4869.pytest_awq_vl_rotary_resolution.pytest_fail_closed_checkpoint_5218.pytest_processor_finalize_4747.pytest_construction_global_state_5421.pytest_awq_falcon_h1_parallel_branch_4741.pytest_gsq_per_linear_inference_mode_4690.pytest_transformers_unpatched.pytest_hf_bridge_legacy_qzeros_marlin_6274.pyConsolidated run of all fifteen:
New regression test
tests/test_tiny_tokenizer_helpers_6404.pypins the helper contract through the real load path (load_hf_tokenizer(path, model_config=...)), notfrom_pretrained, because only the loader's own rebuild reproduces the bug:It also asserts
len(tokenizer) <= vocab_size, every id belowvocab_size, and the special-token names other fixtures rely on.Blast radius: the other 24 users of
build_wordlevel_tokenizerAll re-run on this branch, CPU, 0 failures:
test_adapter_forward_dtype_contract,test_awq_deepseek_v4_hash_moe_4880,test_awq_deepseek_v4_rotary_4695,test_awq_hash_moe_kept_rows_5015,test_awq_laguna_rotary_label_4874,test_awq_shared_indexer_replaytest_checkpoint_legacy_shadow_5723,test_dense_load_explicit_device_5373,test_excluded_device_warmup,test_exl3_cancelled_run_5083,test_exl3_head_bits_tied_6347,test_exl3_torch_constant_cache_5213test_failed_run_model_state_5009,test_load_device_context_4863,test_optimize_generate_cpu_offload_5099,test_quantize_device_sequence_4875,test_requant_embed_lm_head_flag_6244,test_resume_first_capture_release_5829test_run_exit_recovery_contract_5060,test_save_dispatch,test_weight_only_failed_run_device_5011,kernels/test_exl3_public_load_hip_5836,kernels/test_exllamav3_quantize_tilestest_deepseek_v4_supportNo regression on #6407's eight files
pytest test_cpu_offload_tied_both_copies_4943.py test_hf_bridge_cpu_offload_5022.py \ test_checkpoint_interop_4053.py test_required_qweight.py \ test_deepseek_v2_local_port.py test_qwen2_vl_local_port.py \ test_checkpoint_compat.py module_tree/test_inkling2_loop_plan.py -q # 277 passed, 27 skippedruff checkclean on every changed file.