[DIAGNOSTIC - DO NOT MERGE] fix(load_tokenizer): default to use_fast=True#26
Open
hallerite wants to merge 3 commits into
Open
[DIAGNOSTIC - DO NOT MERGE] fix(load_tokenizer): default to use_fast=True#26hallerite wants to merge 3 commits into
hallerite wants to merge 3 commits into
Conversation
Forces transformers' Rust TokenizersBackend instead of letting AutoTokenizer silently fall back to PythonBackend, whose __init__ -> _add_tokens -> get_vocab() raises NotImplementedError (get_vocab is unimplemented on the PythonBackend class). Reproduced under concurrent RendererPool init for GLM-4.5-Air with trust_remote_code=False; the failure rate climbs with per-step concurrency. If fast tokenizer files are missing, AutoTokenizer with use_fast=True raises a clear OSError instead of corrupting the pool silently. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The default-path call site in `load_tokenizer` now passes `use_fast=True`; update the two call-shape tests that compare the captured kwargs by equality. The Kimi pinned-revision branch is intentionally unchanged — its source call site does not pass `use_fast=True`, and the corresponding assertion already reflects that. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
… too The Kimi pinned-revision branch traverses the same HF dispatch logic that exhibits the silent-slow-fallback race; setting use_fast=True explicitly forces the failure to be loud on that path as well. Kimi-K2 family ships tokenizer.json so the fast path is available in practice. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Draft
3 tasks
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
load_tokenizercurrently callsAutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=False)without specifying a backend.AutoTokenizeris a factory that picks between two backends:TokenizersBackend(Rust, fast) — the desired path.PythonBackend(pure Python) — has a latent crash in its__init__.PythonBackend.__init__calls_add_tokens(...), which callsself.get_vocab(). Intransformers/tokenization_utils_base.py:1439:PythonBackenddoes not override this. So whenever HF silently falls back to the Python path, pool construction raises a bareNotImplementedErrorthat surfaces to env workers asModelError() -> NotImplementedError().Reproduction
Observed in prime-rl rollouts on
PrimeIntellect/GLM-4.5-Airwithtrust_remote_code=False:batch_size=256, rollouts_per_example=8.batch_size=512, rollouts_per_example=16.The identical
AutoTokenizer.from_pretrainedcall returnedTokenizersBackendon the head node andPythonBackendon the compute nodes — likely a race in HF's backend selection under concurrent first-time loads.Stack:
Fix
Pass
use_fast=Trueexplicitly. This forces the Rust path. If fast tokenizer files are genuinely missing,AutoTokenizerraises a clearOSErrorinstead of silently routing to the half-implemented Python class.This is also a latent upstream bug in
transformers(PythonBackend._add_tokens -> get_vocabis unreachable), but the renderers-side default is the right call regardless.🤖 Generated with Claude Code