Skip to content

Apply Eagle3 to MiniMax-M2.5#7619

Open
SparrowMu wants to merge 8 commits intovllm-project:mainfrom
SparrowMu:eagle3-bak
Open

Apply Eagle3 to MiniMax-M2.5#7619
SparrowMu wants to merge 8 commits intovllm-project:mainfrom
SparrowMu:eagle3-bak

Conversation

@SparrowMu
Copy link
Contributor

@SparrowMu SparrowMu commented Mar 25, 2026

What this PR does / why we need it?

Apply Eagle3 to MiniMax-M2.5 to increase model performance
This will be discard after Eagle3 weight for MiniMax-M2.5 releases and code change accepted by official repo
https://github.com/vllm-project/vllm/pull/37512/changes

Does this PR introduce any user-facing change?

How was this patch tested?

limuyuan added 7 commits March 23, 2026 14:46
Signed-off-by: limuyuan <limuyuan3@huawei.com>
…the class does not update the already-compiled validation schema, so rebuild_dataclass(..., force=True) is required for instance construction to actually run the patched validator.

Signed-off-by: limuyuan <limuyuan3@huawei.com>
…eConfig.__pydantic_decorators__.model_validators[_verify_args].func before rebuild_dataclass, since Pydantic dataclass validation uses the cached Decorator.func rather than the class attribute alone.

Signed-off-by: limuyuan <limuyuan3@huawei.com>
…tive_config validation uses the updated schema when VllmConfig was imported before the patch.

Signed-off-by: limuyuan <limuyuan3@huawei.com>
Signed-off-by: limuyuan <limuyuan3@huawei.com>
…ses on NPU

Signed-off-by: limuyuan <limuyuan3@huawei.com>
@SparrowMu SparrowMu requested a review from wangxiyuan as a code owner March 25, 2026 01:56
@SparrowMu SparrowMu changed the title Apply Eagle3 to MiniMax-M Apply Eagle3 to MiniMax-M2.5 Mar 25, 2026
@github-actions
Copy link
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates Eagle3 speculative decoding capabilities with the MiniMax-M2 model within the vLLM framework. It addresses compatibility issues by patching configuration validation to include MiniMax-M2, registering necessary model aliases, and modifying the MiniMax-M2 model's forward pass to expose auxiliary hidden states required by the Eagle3 mechanism. Additionally, it ensures the MiniMax-M2 model adheres to the SupportsEagle3 interface.

Highlights

  • MiniMax-M2 Whitelist Bypass for Eagle3: Implemented a monkey-patch for vllm.config.speculative.SpeculativeConfig._verify_args to allow MiniMax-M2 model types to be used with Eagle3 speculative decoding, bypassing an upstream whitelist restriction.
  • Eagle3 MiniMax-M2 Model Alias Registration: Registered Eagle3MiniMaxM2ForCausalLM as an alias in the speculative decoding model registry, pointing to the existing Eagle3 implementation, to support specific draft checkpoints.
  • Auxiliary Hidden State Extraction for MiniMax-M2: Extended vllm.model_executor.models.minimax_m2.MiniMaxM2Model.forward to optionally collect and return auxiliary hidden states from specified transformer layers, a requirement for Eagle3 speculative decoding.
  • Eagle3 Interface Integration for MiniMax-M2: Injected set_aux_hidden_state_layers and default layer getters, along with supports_eagle3 attributes, into MiniMaxM2ForCausalLM to enable vLLM to configure the target model for Eagle3 compatibility.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces comprehensive support for MiniMax-M2 models with Eagle3 speculative decoding on NPU. Key changes include patching SpeculativeConfig to allow MiniMax-M2 models in the Eagle3 whitelist, registering Eagle3MiniMaxM2ForCausalLM as an alias in the model registry, and modifying MiniMaxM2Model.forward to collect and return auxiliary hidden states with pipeline parallelism support. Additionally, MiniMaxM2ForCausalLM is updated to conform to the SupportsEagle3 interface, and MiniMaxM2Attention.forward is optimized using a fused kernel. A review comment points out that the documentation for the MiniMaxM2Attention.forward patch is missing from vllm_ascend/patch/__init__.py, which is important for maintainability.

Comment on lines +471 to +495
# 4. `vllm.model_executor.models.minimax_m2.MiniMaxM2Model.forward`
# Why:
# Eagle3 speculative decoding needs auxiliary hidden states from specific
# transformer layers of the target model.
# How:
# Extend `MiniMaxM2Model.forward` to optionally collect and return
# `(final_hidden_states, aux_hidden_states)` when `aux_hidden_state_layers`
# is set by the runtime.
# Related PR (if no, explain why):
# https://github.com/vllm-project/vllm/pull/37512
# Future Plan:
# Remove this patch once upstream MiniMax-M2 integrates Eagle3 support.
#
# 5. `vllm.model_executor.models.minimax_m2.MiniMaxM2ForCausalLM`
# Why:
# vLLM core uses SupportsEagle3-style methods to configure which layers
# should emit auxiliary hidden states.
# How:
# Inject `set_aux_hidden_state_layers` and default-layer getters onto
# `MiniMaxM2ForCausalLM` so vLLM can configure the target model.
# Related PR (if no, explain why):
# https://github.com/vllm-project/vllm/pull/37512
# Future Plan:
# Remove this patch once upstream provides these methods on the model.
#
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The patch for vllm.model_executor.models.minimax_m2.MiniMaxM2Attention.forward in worker/patch_minimax_m2.py is not documented here. This file serves as a manifest for all patches, and for maintainability, it's important to keep it complete and up-to-date. Please add documentation for this new patch. It appears to be a performance optimization using the fused kernel torch.ops.vllm.split_qkv_tp_rmsnorm_rope.

You could add it as item 3 and renumber the subsequent items under ** 17. File: worker/patch_minimax_m2.py**.

Signed-off-by: limuyuan <limuyuan3@huawei.com>
@MengqingCao MengqingCao added this to the v0.18.0rc1 milestone Mar 25, 2026
@MengqingCao MengqingCao added ready read for review ready-for-test start test by label for PR labels Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready read for review ready-for-test start test by label for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants