Skip to content

Fix Mistral yarn warning in Transformers v5#37292

Open
hmellor wants to merge 3 commits intovllm-project:mainfrom
hmellor:fix-mistral-warning
Open

Fix Mistral yarn warning in Transformers v5#37292
hmellor wants to merge 3 commits intovllm-project:mainfrom
hmellor:fix-mistral-warning

Conversation

@hmellor
Copy link
Copy Markdown
Member

@hmellor hmellor commented Mar 17, 2026

As of huggingface/transformers#41250 the ignore_keys argument to validate_rope was removed in favour of ClassVars attached to the config classes themselves.

This PR sets this new ClassVar for Mistral models which use yarn so that the warning from Transformers RoPE validation is suppressed.

cc @juliendenize

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
@hmellor
Copy link
Copy Markdown
Member Author

hmellor commented Mar 17, 2026

@juliendenize could you please confirm that this fix works for you?

@hmellor hmellor mentioned this pull request Mar 17, 2026
5 tasks
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a warning from newer versions of the transformers library for Mistral models using YaRN scaling. It does so by adding ignore_keys_at_rope_validation to the model configuration. My review suggests adding a version guard to this change to ensure compatibility across different transformers versions.

Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@juliendenize juliendenize left a comment

Choose a reason for hiding this comment

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

Hey sorry took a bit of time to answer was off for two days 😄

I had to change to make it >5.2.0 for it to work, hence my suggestion. This is due to 5.3.0.dev being < 5.3.0.

Thanks for finding a clean, Transformers native, solution !

config["rope_parameters"][new_name] = cast(yarn_config.pop(old_name))

# Ignore apply_yarn_scaling in Transformers > v5 RoPE validation to remove warnings
if Version(TRANSFORMERS_VERSION) >= Version("5.3.0"):
Copy link
Copy Markdown
Contributor

@juliendenize juliendenize Mar 19, 2026

Choose a reason for hiding this comment

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

Suggested change
if Version(TRANSFORMERS_VERSION) >= Version("5.3.0"):
if Version(TRANSFORMERS_VERSION) >= Version("5.3.0.dev0"):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Unfortunately if we use 5.2 then there will be JSON serialisation errors because ignore_keys_at_rope_validation is a set.

Does it work for you if you use 5.3.0.dev?

Copy link
Copy Markdown
Contributor

@juliendenize juliendenize Mar 19, 2026

Choose a reason for hiding this comment

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

Yep i updated the suggestion 😄

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.

2 participants