fix(mistral): guard ReasoningEffort import for older mistral_common versions#45378
Open
hijingsong wants to merge 1 commit intohuggingface:mainfrom
Open
fix(mistral): guard ReasoningEffort import for older mistral_common versions#45378hijingsong wants to merge 1 commit intohuggingface:mainfrom
hijingsong wants to merge 1 commit intohuggingface:mainfrom
Conversation
…ersions ReasoningEffort was added in mistral-common 1.10.0 but the import was unconditional within the is_mistral_common_available() guard. Users with mistral-common < 1.10.0 would get an ImportError that prevented loading any processor, including non-Mistral models like Gemma 4. Wrap the ReasoningEffort import in a try/except, falling back to typing.Any so the type annotation at line 1042 still resolves. Fixes huggingface#45372
Member
|
We have pinned it to 1.10.0 so ig you need to re-install to get the updated version Line 96 in def8e6a |
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.
Fix: Guard ReasoningEffort import for older mistral_common versions
Fixes #45372
Problem
ReasoningEffortwas added inmistral-common>=1.10.0, but the import intokenization_mistral_common.pywas unconditional within theis_mistral_common_available()guard. Users withmistral-common<1.10.0would get anImportErrorthat prevented loading any processor — including non-Mistral models like Gemma 4 and Qwen.Additionally, even stubbing
ReasoningEffort = Nonewas insufficient because line 1042 usesReasoningEffort | Nonein a type annotation, causingTypeError: unsupported operand type(s) for |sinceNoneTypedoes not support the|operator.Fix
Wrap the
ReasoningEffortimport in atry/except ImportError, falling back totyping.Any. This ensures:mistral-commonversionReasoningEffort | Nonetype annotation resolves correctly (Any | Noneis valid)mistral-commonreasoning_effortsupport work correctly whenmistral-common>=1.10.0is installedChanges
src/transformers/tokenization_mistral_common.py: Split the combined import ofChatCompletionRequestandReasoningEffortinto separate imports with atry/exceptguardTesting
Any | Noneresolves correctly at runtimemistral-common>=1.10.0