Skip to content

[Refactor]: Let each modeling file define M-RoPE implementation #24165

@DarkLight1337

Description

@DarkLight1337

🚀 The feature, motivation and pitch

Currently, M-RoPE is implemented inside a single file (https://github.com/vllm-project/vllm/blob/main/vllm%2Fmodel_executor%2Flayers%2Frotary_embedding%2Fmrope.py) just like other RoPE methods. However when running the model, the model type in the HF config is used to further select the model-specific M-RoPE implementation. This is not maintainable in the long run as the number of models that use M-RoPE increases.

Considering that much of the M-RoPE code is shared between models, with the main difference being how to get the input positions, I propose a SupportsMRoPE interface for the model class to define this step inside each modeling file. This interface should include a flag variable and also a get_mrope_input_positions method to get the input positions specific to that model.

We can also use this interface to determine whether a model supports M-RoPE, instead of having to set this flag in the HF config.

Alternatives

No response

Additional context

cc @ywang96 @Isotr0py

Before submitting a new issue...

  • Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the documentation page, which can answer lots of frequently asked questions.

Metadata

Metadata

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions