Skip to content

More Rope Scaling Implementations (PI, Yarn) #330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

tyler-romero
Copy link
Contributor

@tyler-romero tyler-romero commented Jul 28, 2025

Implements

  1. Position Interpolation
  2. Stepwise (llama 3.1) scaling
  3. Yarn

Copy link

@abertsch72 abertsch72 left a comment

Choose a reason for hiding this comment

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

thanks so much for standardizing this! were you also going to add a way to turn on/off sliding-window-layer scaling? this seems more important now that it seems like some of our sliding window scaling runs actually outperform global-only scaling

"""

def __post_init__(self):
if self.attention_rescale_factor < 1.0:

Choose a reason for hiding this comment

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

do we have to restrict attention rescaling factor to be >1?



@dataclass
class PerFrequencyRoPEScalingConfig(RoPEScalingConfig):

Choose a reason for hiding this comment

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

nit, but the name suggests to me that you get more finegrained control than high/low...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah good point, I'll switch to calling it stepwise

Denominator that determines the *high-frequency* wavelength cut-off
(a smaller value keeps more of the very short wavelengths untouched).
"""

Choose a reason for hiding this comment

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

it would be nice if these params used the same name / interpretation as the YaRN params that control the same thing... minimally, I'd vote for calling them something other than factor because we also have factor above that does a different thing

(I know these names are probably holdovers from the methods, though-- if this is how huggingface does the two methods then maybe it's better to be consistent with them rather than internally consistent)

Copy link
Member

@dirkgr dirkgr left a comment

Choose a reason for hiding this comment

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

The way you preserve backwards compatibility here is by having the base class do basic RoPE extension like the RoPE paper says, and have subclasses that do the fancier stuff?

@tyler-romero
Copy link
Contributor Author

PerFrequencyRoPEScalingConfig is the same as the old rope scaling config. I think its wrong to think of that as the base case, and there are 0 dependencies on that in main, so I'm not sure its worth distorting the factorization of the code for.

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.

3 participants