feat: RoPE-related typing improvements - #41967
Draft
RyanMullins wants to merge 2 commits into
Draft
Conversation
Member
|
LGTM but cc @zucchini-nlp @ArthurZucker! |
RyanMullins
force-pushed
the
rope-type-hints
branch
from
November 3, 2025 13:49
f300361 to
7e7ab8b
Compare
RyanMullins
force-pushed
the
rope-type-hints
branch
2 times, most recently
from
November 4, 2025 20:04
ddcd9e9 to
cbb3751
Compare
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: gemma3 |
RyanMullins
force-pushed
the
rope-type-hints
branch
from
November 4, 2025 20:11
cbb3751 to
db871df
Compare
zucchini-nlp
reviewed
Nov 5, 2025
zucchini-nlp
left a comment
Member
There was a problem hiding this comment.
Thanks a lot for adding a docstring, much clearer! I just left a few comments to be aligned with current code
Comment on lines
+160
to
+163
| logger.warning( | ||
| "Unable to find a rope_theta and defaults are not supported for this value. Returning the config" | ||
| " un-modified. Verify that the model uses RoPE and that it should have been present in this config." | ||
| ) |
Member
There was a problem hiding this comment.
maybe not raise a warning? Standardization can be called on an already standardized config and this warning will be raised every time it happens
| rope_theta = getattr(config, "rope_theta", None) | ||
|
|
||
| # Case 1: one RoPE theat = one RoPE param per model without nesting | ||
| def process_rope_parameters_for_layer_type(rope_theta: dict[str, float], layer_type: str) -> RopeParameters: |
Member
There was a problem hiding this comment.
let's expect a single theta here, since we're already unfolding thetas dict below
| ) | ||
| return | ||
|
|
||
| config.rope_parameters = RopeParameters(rope_type=rope_type, rope_theta=rope_theta) |
Member
There was a problem hiding this comment.
if we create a new value, we can lose scaling params that existed before like rope_parameters.factor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #41964
total=FalseonRopeParametersRequiredto the relevant properties ofRopeParametersBefore submitting
Pull Request section?
to it if that's the case. Improve typing support and flexibility for RopeParameters #41964
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.