Repository navigation
test(awq): give the Mamba-hybrid fixture tokenizer one token per id - #6637
Merged
Merged
Conversation
`test_awq_batch_size_one_quantizes_a_mamba_hybrid` failed in a random
fraction of fresh processes, independent of test order, device or xdist.
The failures looked like "the tokenizer ... is unusable (129/130 token(s),
model vocab_size=128)" or "WordLevel error: Missing [UNK] token".
Cause: the fixture built `{tok0..tok127 -> 0..127}` and then added
`[PAD] -> 0` and `[UNK] -> 1`, so ids 0 and 1 each had two names. The
tokenizers WordLevel model keeps an id -> token map whose winner depends on
the Rust hash-map seed, which differs per process. On save only one name per
id survives. Across 20 fresh processes, 3 kept both specials (128 tokens),
11 lost `[PAD]` (re-added as id 128, 129 tokens), and 6 lost `[UNK]`, which
cannot be loaded at all. The loader correctly rejects those tokenizers
(#6386), so the test failed whenever the seed dropped a special.
Fix: build the vocabulary with one token per id (`[PAD]`=0, `[UNK]`=1,
`tok2..tok127`) and assert the ids are exactly `range(vocab_size)`, so a
colliding fixture now fails deterministically instead of by seed. The test's
calibration rows (ids 3..26) and its assertions are unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Summary
tests/test_awq_hybrid_recurrent_mask_4671.py::test_awq_batch_size_one_quantizes_a_mamba_hybridfails in a random fraction of fresh processes, regardless of test order, device visibility or-n. The errors are either "The tokenizer in<tmp>is unusable: it cannot encode ordinary text (loaded tokenizer: 129/130 token(s), modelvocab_size=128)" or "WordLevel error: Missing [UNK] token from the vocabulary". Run alone on CPU on main it failed 3 of 10 runs here.Root cause is a stale fixture, not a product bug. The fixture built
{tok0..tok127 -> 0..127}and then set[PAD] -> 0and[UNK] -> 1, so ids 0 and 1 each had two names. ThetokenizersWordLevel model keeps an id-to-token map whose winner follows the Rust hash-map seed, which differs per process, and only one name per id survives save/load. Over 20 fresh processes:[PAD]lost, re-added as id 128 (129 tokens)[UNK]lost, load error "Missing [UNK] token"The collision has been in the test since #4694. The loader now rejects such tokenizers on purpose (#6386, "reject tokenizer-less checkpoints instead of loading an empty tokenizer"). That is likely when the latent fixture bug became visible, but I did not bisect it.
What Changed
[PAD]=0,[UNK]=1,tok2..tok127. It also asserts the ids are exactlyrange(config.vocab_size), so a colliding fixture fails deterministically instead of by hash seed.test_awq_weight_mean.py::test_awq_pseudo_quantize_nan_guard_uses_one_host_read) had an unrelated cause, cache-order leakage in_awq_symmetric_scale_limit, fixed in fix(awq): keep the cached symmetric scale limit free of host reads #6633 (merged).Tests
Matrix results (branch head cfa6d20, both fixes present):
bash format/check.sh # ruff 0.14.2: All checks passed!Measured Impact
Not applicable: test-only change, no runtime, VRAM or accuracy effect.
Model Support / Module Plan
Not applicable: no model, alias, definition or module plan change.
Model test node IDs and results (or "not applicable"): not applicable.
AWQ onboarding safety
Not applicable: no AWQ grouping/search/replay/fold change; only a test fixture tokenizer.
Logic Flow Documentation
Diagram summary: not applicable. This is a test fixture change only.
Review Requirements
Kernel Accuracy Requirements
Notes
I grepped every
models.WordLevel(fixture undertests/. No other fixture gives two tokens the same id (test_nemotron_omni_local_port.pydeletes the placeholder before reassigning its id).🤖 Generated with Claude Code