Skip to content

Conversation

ydshieh
Copy link
Collaborator

@ydshieh ydshieh commented Sep 2, 2025

What does this PR do?

We have for this test the following error (flaky)

requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://huggingface.co/api/models/hf-internal-testing/namespace-mistralai-repo_name-Mistral-Small-3.1-24B-Instruct-2503/tree/main

This PR just try to cache the tokenizers in a previous step before tests being run
.

mistral_common has a bug and make things a bit hard to handle in a clean way that I have to do a hack with revision=None.

https://app.circleci.com/pipelines/github/huggingface/transformers/144453/workflows/8e42765f-71d4-4733-9574-feb160ff8eda/jobs/1910963/parallel-runs/6/steps/6-113

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@ydshieh ydshieh force-pushed the fix_mistal_common_tests branch from 94f6cc4 to f8fce12 Compare September 2, 2025 14:31
Copy link
Contributor

@vasqu vasqu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, just to be sure iiuc this is for local caching before starting the tests themself

cls.repo_id,
tokenizer_type="mistral",
local_files_only=cls.local_files_only,
# This is a hack as `list_local_hf_repo_files` from `mistral_common` has a bug
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe even a TODO? Imo not a good state to need this workaround 😓

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added:

TODO: Discuss with mistral-common maintainers: after a fix being done there, remove this revision hack

Comment on lines 9 to 10
if is_mistral_common_available():
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We import below as well no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I was tortured by some mistral-common issues and at the end my brain 😵‍💫😵‍💫😵‍💫

Comment on lines +59 to +74
# For `tests/test_tokenization_mistral_common.py:TestMistralCommonTokenizer`, which eventually calls
# `mistral_common.tokens.tokenizers.utils.download_tokenizer_from_hf_hub` which (probably) doesn't have the cache.
if is_mistral_common_available():
from mistral_common.tokens.tokenizers.mistral import MistralTokenizer

from transformers import AutoTokenizer
from transformers.tokenization_mistral_common import MistralCommonTokenizer

repo_id = "hf-internal-testing/namespace-mistralai-repo_name-Mistral-Small-3.1-24B-Instruct-2503"
AutoTokenizer.from_pretrained(repo_id, tokenizer_type="mistral")
MistralCommonTokenizer.from_pretrained(repo_id)
MistralTokenizer.from_hf_hub(repo_id)

repo_id = "mistralai/Voxtral-Mini-3B-2507"
AutoTokenizer.from_pretrained(repo_id)
MistralTokenizer.from_hf_hub(repo_id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how bloated this file will become but might be nice to split into different functions already?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's do something later. For now, the most important is just to git rid of these annoying connection errorrrrrrrrrs!

@ydshieh ydshieh merged commit e690fe6 into main Sep 3, 2025
16 checks passed
@ydshieh ydshieh deleted the fix_mistal_common_tests branch September 3, 2025 03:05
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.

4 participants