[RoPE] allow models to configure local RoPE - #39397
Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
run-slow: arcee, aria, bamba, bitnet, cohere, cohere2, csm, deepseek_v3, dia, diffllama, doge, dots1, emu3, falcon, falcon_h1, fuyu |
|
This comment contains run-slow, running the specified jobs: models: ['models/arcee', 'models/aria', 'models/bamba', 'models/bitnet', 'models/cohere', 'models/cohere2', 'models/csm', 'models/deepseek_v3', 'models/dia', 'models/diffllama', 'models/doge', 'models/dots1', 'models/emu3', 'models/falcon', 'models/falcon_h1', 'models/fuyu'] |
|
Failing slow tests are failing on |
gante
left a comment
There was a problem hiding this comment.
Two overall comments:
1 -- unbloating
In the spirit of unbloating: can we move boilerplate code into a separate model-agnostic function?
e.g. instead of
rope_scaling_dict = (
getattr(config, "rope_scaling", None) if is_global else getattr(config, "local_rope_scaling", None)
)
if rope_scaling_dict is not None and isinstance(config.rope_scaling, dict):
self.rope_type = rope_scaling_dict.get("rope_type", rope_scaling_dict.get("type"))
else:
self.rope_type = "default"something like
self.rope_type = extract_rope_type_from_config(config, is_global)2 -- future-proofing
This PR adds is_global: bool = True as a toggle to select the right config key to load RoPE parameterization from. What if we make it rope_config_key: str = "rope_theta" instead? That way, we can enable as many levels of RoPE as we want.
(or would this be too complex? WDYT?)
It is not only the theta that changes, but the RoPE type might be different. For ex in gemma3 local attention is simple RoPE and the global attention applies scaling. Thus we have config keys: Happy to simplify it if you have any ideas. Maybe we can do smth like |
|
@zucchini-nlp I see 🤔 In general, my concern is about the case where more types of RoPE are added, but the flag we add in this PR wouldn't be able to accommodate it. Secondarily, we should try to nudge users into nesting parameterization, since RoPE can take several parameters and things can get messy really fast (i.e. instead of xxx / local_xxx, have the structure you suggested by default, Perhaps
Potentially missing: some attribute in the dict to control which layers use a certain rope type? (similar to the |
|
[For maintainers] Suggested jobs to run (before merge) run-slow: arcee, aria, bamba, bitnet, cohere, cohere2, csm, deepseek_v2, deepseek_v3, dia, diffllama, doge, dots1, emu3, ernie4_5, ernie4_5_moe |
|
There is a cleaner PR |
What does this PR do?
Failing tests reported by CI bot after removing deprecations in #38838
The main fixes are in test files and in ModernBert/Llama. The test was failing because RoPE needs to use local theta in local attention layers. I think at this point we can allow
local_rope_theta, looks like ModernBert isn't the only arch using two different RoPE configurations