Add regression test for offline tokenizer loading (fixes #43200)#43212
Open
Anri-Lombard wants to merge 1 commit intohuggingface:mainfrom
Open
Add regression test for offline tokenizer loading (fixes #43200)#43212Anri-Lombard wants to merge 1 commit intohuggingface:mainfrom
Anri-Lombard wants to merge 1 commit intohuggingface:mainfrom
Conversation
The underlying issue was already fixed on main - this adds a test to prevent regression.
5 tasks
This was referenced Apr 29, 2026
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
This PR adds a regression test for issue #43200 where
AutoTokenizer.from_pretrained()failed in offline mode (HF_HUB_OFFLINE=1) even when the model was cached locally.Good news: The underlying bug was already fixed on main as part of the tokenizer refactoring. The
_patch_mistral_regexfunction now correctly checksis_offline_mode()and setsis_local = Trueto prevent network calls (seetokenization_utils_tokenizers.pylines 1177-1178).This PR adds a test to prevent regression.
Root Cause (for reference)
In v4.57.3, commit d3ee5e8 added
_patch_mistral_regexwhich calledmodel_info()without handling offline mode:When
HF_HUB_OFFLINE=1and using a model ID (not local path),is_base_mistral()was called andmodel_info()raisedOfflineModeIsEnabled.The Fix (already on main)
The refactored code in
tokenization_utils_tokenizers.pynow includes:This ensures
is_base_mistral()is never called in offline mode due to short-circuit evaluation.Test Plan
test_offline_tokenizerpassesTestOfflinetests pass