Skip to content

Assigning rope_scaling drops existing RoPE base parameters #49519

Closed

Description

@jinwukong

System Info

Transformers 5.19.0.dev0, unmodified main at ea9259355388f518240f96a8c2dee7311b1c5911 (the same setter remains on current main at 3b829407e8bd56f7f4c7950f1226579d23b50db7).
Linux 6.8.0-137-generic x86_64, glibc 2.39; Python 3.12.15; PyTorch 2.14.1+cpu.
No model weights or GPU are needed.

Who can help?

No response

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

Assigning the v4-style rope_scaling alias to an initialized config replaces rope_parameters, dropping the existing rope_theta and other base parameters (setter).
The CPU-only example below starts with a base of 500000 and raises KeyError: 'rope_type' after the assignment; using the canonical rope_type key also loses the base.

from transformers import LlamaConfig
from transformers.models.llama.modeling_llama import LlamaRotaryEmbedding

config = LlamaConfig(rope_theta=500000.0)
config.rope_scaling = {"type": "linear", "factor": 2.0}
print(config.rope_parameters)
LlamaRotaryEmbedding(config)

Output from the unmodified revision:

{'type': 'linear', 'factor': 2.0}
Traceback (most recent call last):
  File "report-repro.py", line 28, in <module>
    LlamaRotaryEmbedding(config)
  File "src/transformers/models/llama/modeling_llama.py", line 80, in __init__
    self.rope_type = self.config.rope_parameters["rope_type"]
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'rope_type'

Saving and reloading that assigned config restores the constructor default base of 10000 instead of the original 500000.
This also affects real downstream overrides: sgl-project/sglang#41227 reports a 500000 → 10000 fallback and a GSM8K result change from 161 to 106 on the first 200 examples; the review of sgl-project/sglang#43067 confirms that the affected override is used in documented long-context recipes.

Expected behavior

The setter should normalize legacy parameter names and preserve existing base parameters unless the assignment explicitly overrides them.
PR #49515 provides a fix: ten new regressions fail on the unmodified revision, all 45 RoPE tests pass with the fix, and the current PR CI has no failed checks.

Activity

  1. github-actions commented on Nov 12, 2026

    @github-actions
    Contributor

    This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

    Please note that issues that do not follow the contributing guidelines are likely to be ignored.

  2. Rocketknight1 commented on Nov 12, 2026

    @Rocketknight1
    Member

    cc @zucchini-nlp for RoPE

  3. zucchini-nlp commented on Nov 13, 2026

    @zucchini-nlp
    Member

    the linked PR was merged, closing as resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions