Skip to content

test: migrate the remaining #6386 tokenizer fixtures (#6404) - #6420

Merged
Qubitium merged 2 commits into
mainfrom
fix/6404-fixtures-2
Nov 29, 2026
Merged

Qubitium merged 2 commits into
mainfrom
fix/6404-fixtures-2

Conversation

@Qubitium

Copy link
Copy Markdown
Collaborator

Fixes #6404

#6386's load_hf_tokenizer rejects 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 main and are untouched: test_transformers_unpatched.py (1 passed) and test_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 cause

It built 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:

in-memory len 13 usable True
reloaded   len 13 usable True        # via PreTrainedTokenizerFast.from_pretrained
# but through the loader's own rebuild:
ValueError: The tokenizer in `...` is unusable: it cannot encode ordinary text

It is now a byte-level BPE with the same special tokens and ids (<s>=0, </s>=1, <unk>=2, <pad>=3), every id below vocab_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-less WordLevel fixtures

Migrated to the shared tests/tiny_tokenizer.py::write_tiny_tokenizer. test_local_processor_loading is the exception: the test pins token ids 1 and 3, so it keeps its four-token vocabulary and only gains the missing unk_token.

3. Checkpoints written with no tokenizer files at all

test_fp8, test_fail_closed_checkpoint_5218, test_construction_global_state_5421 now write one next to the model.

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, no bypass env var.

Baseline → after (CPU, CUDA_VISIBLE_DEVICES="", base 407298ad2)

file before after
test_measure_model.py 10 errors, 5 passed 15 passed
test_local_processor_loading.py 8 failed, 6 passed 14 passed
test_gptaq_foem_first_capture_5831.py 6 failed 6 passed
test_gptq_processor_hessian_release_5026.py 5 failed 5 passed
test_compile_load_race_5209.py 3 failed, 2 passed 5 passed
test_fp8.py 3 failed, 18 passed 21 passed
test_gptaq_shuffle_pairing_4869.py 3 failed 3 passed
test_awq_vl_rotary_resolution.py 2 failed, 6 passed 8 passed
test_fail_closed_checkpoint_5218.py 2 failed, 25 passed, 8 skipped 27 passed, 8 skipped
test_processor_finalize_4747.py 2 failed, 3 passed 5 passed
test_construction_global_state_5421.py 1 failed, 7 passed 8 passed
test_awq_falcon_h1_parallel_branch_4741.py 1 failed, 1 passed 2 passed
test_gsq_per_linear_inference_mode_4690.py 1 failed, 3 passed 4 passed
test_transformers_unpatched.py 1 passed 1 passed (already green)
test_hf_bridge_legacy_qzeros_marlin_6274.py 3 passed, 3 skipped 3 passed, 3 skipped (already green)

Consolidated run of all fifteen:

cd tests && CUDA_VISIBLE_DEVICES="" \
  PYTHONPATH=$PWD:$PWD/tests /root/venv/bin/python -m pytest \
  test_tiny_tokenizer_helpers_6404.py test_measure_model.py \
  test_local_processor_loading.py test_gptaq_foem_first_capture_5831.py \
  test_gptq_processor_hessian_release_5026.py test_compile_load_race_5209.py \
  test_fp8.py test_gptaq_shuffle_pairing_4869.py test_awq_vl_rotary_resolution.py \
  test_fail_closed_checkpoint_5218.py test_processor_finalize_4747.py \
  test_construction_global_state_5421.py test_awq_falcon_h1_parallel_branch_4741.py \
  test_gsq_per_linear_inference_mode_4690.py test_transformers_unpatched.py \
  -q -p no:cacheprovider
# 131 passed, 8 skipped

New regression test

tests/test_tiny_tokenizer_helpers_6404.py pins the helper contract through the real load path (load_hf_tokenizer(path, model_config=...)), not from_pretrained, because only the loader's own rebuild reproduces the bug:

base 407298ad2:  4 failed, 3 passed
this branch:     7 passed

It also asserts len(tokenizer) <= vocab_size, every id below vocab_size, and the special-token names other fixtures rely on.

Blast radius: the other 24 users of build_wordlevel_tokenizer

All re-run on this branch, CPU, 0 failures:

group result
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_replay 36 passed
test_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_5213 31 passed, 14 skipped
test_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_5829 16 passed, 10 skipped
test_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_tiles 30 passed, 29 skipped
test_deepseek_v4_support 43 passed

No 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 skipped

ruff check clean on every changed file.

agent 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
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
Qubitium marked this pull request as ready for review November 29, 2026 20:16
@Qubitium
Qubitium merged commit ef7af83 into main Nov 29, 2026
8 checks passed
@Qubitium
Qubitium deleted the fix/6404-fixtures-2 branch November 29, 2026 20:16
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.

[TEST] #6386 tokenizer usability guard rejects fixture tokenizers in 19 more test files (116 nodes)

1 participant