Skip to content

test(fixtures): ship usable tokenizers in #6386-rejected fixtures - #6407

Merged
Qubitium merged 1 commit into
mainfrom
fix/6386-test-fixtures
Nov 29, 2026
Merged

Qubitium merged 1 commit into
mainfrom
fix/6386-test-fixtures

Conversation

@Qubitium

@Qubitium Qubitium commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #6400

Main is red because #6386's tokenizer_is_usable check rejects the tiny WordLevel vocabularies (all special tokens) that many fixtures write next to a synthetic model with vocab_size 32-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:

file before after
tests/test_cpu_offload_tied_both_copies_4943.py no tokenizer at all write_tiny_tokenizer(source, vocab_size=128)
tests/test_hf_bridge_cpu_offload_5022.py build_wordlevel_tokenizer(1024) (rebuilt as Qwen2 BPE, encodes to []); v1 fixture 3-token WordLevel write_tiny_tokenizer for both fixtures; calibration tokenizer loaded with AutoTokenizer
tests/test_checkpoint_interop_4053.py 3-token WordLevel, vocab_size=32 write_tiny_tokenizer(..., vocab_size=VOCAB)
tests/test_required_qweight.py 3-token WordLevel, vocab_size=32 write_tiny_tokenizer(..., vocab_size=config.vocab_size)
tests/test_deepseek_v2_local_port.py 4-token WordLevel, vocab_size=43 write_tiny_tokenizer(..., vocab_size=hf_model.config.vocab_size)
tests/test_checkpoint_compat.py Phi-3 fixture 3-token WordLevel, vocab_size=64 write_tiny_tokenizer(..., vocab_size=64)
tests/test_qwen2_vl_local_port.py WordLevel with t4..t59 (rebuilt as Qwen2 BPE, encodes to []) explicit 64-token byte-level BPE: pad/bos/eos/unk = 0-3, vision tokens = 60-63
tests/module_tree/test_inkling2_loop_plan.py 5-token all-special WordLevel, vocab_size=64 explicit 64-token byte-level BPE: [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

Verification

Same 8 files, clean baseline 1615accf9 vs this branch (based on b1fdd3871, with #6391 merged):

run baseline 1615accf9 this branch
CPU (CUDA_VISIBLE_DEVICES="") 67 failed, 209 passed, 27 skipped 277 passed, 27 skipped
GPU (CUDA_VISIBLE_DEVICES=1, 4090) 70 failed, 16 errors, 217 passed 304 passed

The two reported files specifically:

# baseline
test_hf_bridge_cpu_offload_5022.py test_cpu_offload_tied_both_copies_4943.py -> 21 passed, 16 errors
# this branch
-> 37 passed (GPU) / 19 passed, 18 skipped (CPU)

The CUDA-gated nodes pass rather than skip when a GPU is pinned.

Combined-tree check (current main 6b25d2c69, which already contains #6391 and #6392, plus this patch applied locally):

CPU: 277 passed, 27 skipped
GPU (cuda:1): 304 passed

ruff check on all 8 changed files: clean. git diff --stat HEAD~1 shows only tests/ files (8 files, +116/-102).

#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
Qubitium marked this pull request as ready for review November 29, 2026 14:24
@Qubitium
Qubitium merged commit 97ef567 into main Nov 29, 2026
6 checks passed
@Qubitium
Qubitium deleted the fix/6386-test-fixtures branch November 29, 2026 14:24
Qubitium pushed a commit that referenced this pull request Nov 29, 2026
Picks up main's commits since the previous merge base (6b25d2c):
#6395, #6399, #6407, #6408, #6409, #6410. Auto-merged cleanly; the
stable-ABI guards report no new offenders.
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>
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.

main red: #6386 tokenizer validation rejects test fixtures

1 participant