Repository navigation
test(fixtures): ship usable tokenizers in #6386-rejected fixtures - #6407
Merged
Merged
Conversation
#6386 rejects a checkpoint whose tokenizer cannot encode ordinary text, and transformers 5 no longer raises for a checkpoint without tokenizer files. Several tiny fixtures wrote a 3-5 token `WordLevel` vocabulary (all special tokens) or no tokenizer at all next to a model with `vocab_size` 32-1024, so `GPTQModel.load` now fails at fixture setup. Replace those vocabularies with a real byte-level tokenizer: * `tests/tiny_tokenizer.py` where the embedding has room for its alphabet; * an explicit 64-token byte-level BPE where the fixture pins token ids (`test_qwen2_vl_local_port.py`: pad/bos/eos/unk 0-3, vision tokens 60-63; `module_tree/test_inkling2_loop_plan.py`: image token id 4, EOS id 3). No product code changes; the new validation is exercised as-is. Fixes #6400
Qubitium
marked this pull request as ready for review
November 29, 2026 14:24
Qubitium
pushed a commit
that referenced
this pull request
Nov 29, 2026
This was referenced Nov 29, 2026
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
added a commit
that referenced
this pull request
Nov 29, 2026
#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 Co-authored-by: agent <agent@local>
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 #6400
Main is red because #6386's
tokenizer_is_usablecheck rejects the tinyWordLevelvocabularies (all special tokens) that many fixtures write next to a synthetic model withvocab_size32-1024. This is a test-only fix: no product code changes, and the new validation is exercised as-is.What changed
Every fixture now writes a real byte-level tokenizer that can encode ordinary text:
tests/test_cpu_offload_tied_both_copies_4943.pywrite_tiny_tokenizer(source, vocab_size=128)tests/test_hf_bridge_cpu_offload_5022.pybuild_wordlevel_tokenizer(1024)(rebuilt as Qwen2 BPE, encodes to[]); v1 fixture 3-tokenWordLevelwrite_tiny_tokenizerfor both fixtures; calibration tokenizer loaded withAutoTokenizertests/test_checkpoint_interop_4053.pyWordLevel,vocab_size=32write_tiny_tokenizer(..., vocab_size=VOCAB)tests/test_required_qweight.pyWordLevel,vocab_size=32write_tiny_tokenizer(..., vocab_size=config.vocab_size)tests/test_deepseek_v2_local_port.pyWordLevel,vocab_size=43write_tiny_tokenizer(..., vocab_size=hf_model.config.vocab_size)tests/test_checkpoint_compat.pyWordLevel,vocab_size=64write_tiny_tokenizer(..., vocab_size=64)tests/test_qwen2_vl_local_port.pyWordLevelwitht4..t59(rebuilt as Qwen2 BPE, encodes to[])tests/module_tree/test_inkling2_loop_plan.pyWordLevel,vocab_size=64[EOS]= 3, `<The two id-pinned fixtures build the BPE with an explicit vocab instead of
BpeTrainer: the trainer appends the byte-level space token and merges past the requested size, which would move the pinned ids.Files intentionally not touched
tests/test_hf_bridge_legacy_qzeros_marlin_6274.py— owned by fix(offload): reselect resident CPU Marlin with deferred qzeros (#6152 follow-up) #6391 (merged; its fixture fix is on main).tests/test_int3_legacy_qzeros_6375.py— owned by fix(hf): materialize 3-bit symmetric qzeros + fix INT3 legacy fixture (#6375) #6392 (merged; fixture tokenizer + separate 3-bitqzeros_symmetric_wordbug).tests/test_hf_bridge_cpu_offload_5022.pywas listed as "patched by fix(offload): reselect resident CPU Marlin with deferred qzeros (#6152 follow-up) #6391", but fix(offload): reselect resident CPU Marlin with deferred qzeros (#6152 follow-up) #6391 only added tests there; its fixture tokenizer was still broken, so this PR fixes it.Verification
Same 8 files, clean baseline
1615accf9vs this branch (based onb1fdd3871, with #6391 merged):1615accf9CUDA_VISIBLE_DEVICES="")CUDA_VISIBLE_DEVICES=1, 4090)The two reported files specifically:
The CUDA-gated nodes pass rather than skip when a GPU is pinned.
Combined-tree check (current
main6b25d2c69, which already contains #6391 and #6392, plus this patch applied locally):ruff checkon all 8 changed files: clean.git diff --stat HEAD~1shows onlytests/files (8 files, +116/-102).