Skip to content

Accept the transformers 5.0 ignore_keys argument in validate_rope - #11560

Merged
danielhanchen merged 11 commits into
mainfrom
rope-validate-ignore-keys
Sep 25, 2026
Merged

danielhanchen merged 11 commits into
mainfrom
rope-validate-ignore-keys

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 22, 2026 •

Copy link
Copy Markdown
Member

What this fixes

sarvamai/sarvam-105b-fp8 (and any remote configuration written against transformers 5.0) calls self.validate_rope(ignore_keys = ...) from its config __init__. transformers 5.0 to 5.3 declared that parameter and 5.4 moved it onto the ignore_keys_at_rope_validation attribute, so on 5.4 through 5.17 the load dies inside AutoConfig.from_pretrained with

TypeError: RotaryEmbeddingConfigMixin.validate_rope() got an unexpected keyword argument 'ignore_keys'

before a single weight is read.

fix_transformers_validate_rope_ignore_keys in import_fixes.py wraps RotaryEmbeddingConfigMixin.validate_rope (and every config class that overrides it, including remote classes defined later) to accept the keyword and its 5.0 positional form. The keys are merged into ignore_keys_at_rope_validation for that call only, so model specific keys stay out of the "Unrecognized keys" warning exactly as on 5.0 to 5.3. A build whose validator still takes it (5.0 to 5.3) or has no mixin at all (4.57) is left untouched, and the wrapper is idempotent with the original reachable through __wrapped__.

Tests

tests/test_validate_rope_ignore_keys.py: the keyword and positional call forms the remote code uses succeed after the fix, the ignored keys still suppress the warning and do not leak past the call, the fix is idempotent, and the original signature is preserved underneath. Verified AutoConfig.from_pretrained("sarvamai/sarvam-105b-fp8", trust_remote_code = True) now resolves to sarvam_mla on transformers 5.17.0.

The same change restores transformers.utils.is_torch_fx_available (removed in 5.x, still imported by 4.x era remote code such as Ling-2.6-flash) with its 4.57.6 definition. Test runs: transformers 5.17.0 (7 passed) and 4.57.6 with torch 2.6 (3 passed, 4 skipped as the mixin does not exist there).

transformers 5.0 declared validate_rope(self, ignore_keys) and 5.1 removed
the parameter. Remote configuration code written against 5.0 (sarvam-105b's
convert_rope_params_to_dict) then died in AutoConfig.from_pretrained with an
unexpected keyword argument before a single weight was read. The wrapper
accepts and drops the keyword; a build whose validator still takes it, or
has no mixin at all, is left alone.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T08:37:16.004901Z 568d599 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 22, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

pre-commit-ci Bot and others added 2 commits September 22, 2026 17:01
… is_torch_fx_available

The 5.0 signature also allowed validate_rope(ignore_keys) positionally. The
MLX branch of the package never reaches _gpu_init, so it installs the fix
itself. Remote modeling code written against 4.x (Ling-2.6-flash) imports
transformers.utils.is_torch_fx_available, which 5.0 removed; the 4.x
definition is restored when absent.
chatgpt-codex-connector[bot]

This comment was marked as resolved.

… fx test follow torch availability

Phi3Config, PhimoeConfig, DeepseekV4Config and Phi4MultimodalConfig override the
validator, so a remote subclass of one of them resolved past the mixin wrapper.
Every imported subclass is patched, and a hook on PreTrainedConfig's
__init_subclass__ covers classes defined later (lazy imports, remote code). The
restored is_torch_fx_available test compares against is_torch_available, which
is False on a torch-less MLX host.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 8f9a831909

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: d33779808f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member Author

Confirmed main has nothing in unsloth/import_fixes.py for the ignore_keys keyword, so remote configs like sarvam-105b still fail in AutoConfig on transformers 5.4 and later. Will get this reviewed.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 23, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 23, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 23, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 23, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: ff809b7303

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen

Copy link
Copy Markdown
Member Author

pre-commit.ci run

# Conflicts:
#	unsloth/_gpu_init.py
#	unsloth/import_fixes.py
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Sep 25, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 568d599af8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit de80174 into main Sep 25, 2026
36 checks passed
@danielhanchen
danielhanchen deleted the rope-validate-ignore-keys branch September 25, 2026 10:22
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…slothai#11560)

* Accept the transformers 5.0 ignore_keys argument in validate_rope

transformers 5.0 declared validate_rope(self, ignore_keys) and 5.1 removed
the parameter. Remote configuration code written against 5.0 (sarvam-105b's
convert_rope_params_to_dict) then died in AutoConfig.from_pretrained with an
unexpected keyword argument before a single weight was read. The wrapper
accepts and drops the keyword; a build whose validator still takes it, or
has no mixin at all, is left alone.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Accept a positional ignore_keys, install on the MLX path, and restore is_torch_fx_available

The 5.0 signature also allowed validate_rope(ignore_keys) positionally. The
MLX branch of the package never reaches _gpu_init, so it installs the fix
itself. Remote modeling code written against 4.x (Ling-2.6-flash) imports
transformers.utils.is_torch_fx_available, which 5.0 removed; the 4.x
definition is restored when absent.

* Patch configurations that define their own validate_rope, and let the fx test follow torch availability

Phi3Config, PhimoeConfig, DeepseekV4Config and Phi4MultimodalConfig override the
validator, so a remote subclass of one of them resolved past the mixin wrapper.
Every imported subclass is patched, and a hook on PreTrainedConfig's
__init_subclass__ covers classes defined later (lazy imports, remote code). The
restored is_torch_fx_available test compares against is_torch_available, which
is False on a torch-less MLX host.

* Read test fixtures as utf-8 and apply the repo formatter

* Keep ignore_keys' meaning on transformers 5.4+ by scoping them onto ignore_keys_at_rope_validation for the call

* Trim comments

* Name 5.4 as the release that dropped validate_rope's ignore_keys

* Trim comments

* Make the fx idempotency assert able to fail and skip the own-validator case where 5.0 to 5.3 take ignore_keys natively

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant