Repository navigation
Accept the transformers 5.0 ignore_keys argument in validate_rope - #11560
Conversation
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.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex security review |
… 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.
… 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.
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…gnore_keys_at_rope_validation for the call
|
Codex Review: Didn't find any major issues. You're on a roll. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
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. |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
pre-commit.ci run |
# Conflicts: # unsloth/_gpu_init.py # unsloth/import_fixes.py
…r case where 5.0 to 5.3 take ignore_keys natively
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
…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>
What this fixes
sarvamai/sarvam-105b-fp8(and any remote configuration written against transformers 5.0) callsself.validate_rope(ignore_keys = ...)from its config__init__. transformers 5.0 to 5.3 declared that parameter and 5.4 moved it onto theignore_keys_at_rope_validationattribute, so on 5.4 through 5.17 the load dies insideAutoConfig.from_pretrainedwithbefore a single weight is read.
fix_transformers_validate_rope_ignore_keysinimport_fixes.pywrapsRotaryEmbeddingConfigMixin.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 intoignore_keys_at_rope_validationfor 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. VerifiedAutoConfig.from_pretrained("sarvamai/sarvam-105b-fp8", trust_remote_code = True)now resolves tosarvam_mlaon 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).