Skip to content

Conversation

@SiqiLi-Fighting
Copy link

Motivation

Modifications

Accuracy Tests

Benchmarking and Profiling

Checklist

  • Please use English, otherwise it will be closed.
  • The purpose of the PR, or link existing issues this PR will resolve.
  • The test plan, such as providing test command.
  • (Optional) The necessary documentation update.

@gemini-code-assist
Copy link

Summary of Changes

Hello @SiqiLi-Fighting, 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 introduces a robust framework for Multi-Token Prediction (MTP) and EAGLE3 speculative decoding, significantly enhancing inference throughput by allowing models to predict and verify multiple tokens concurrently. The changes span core components, from low-level FlashAttention kernel modifications to high-level scheduler and model architecture adaptations, ensuring seamless integration and configurable performance optimization for compatible models. The new design addresses the sequential token generation bottleneck and improves resource utilization, laying the groundwork for more efficient large language model inference.

Highlights

  • Multi-Token Prediction (MTP) RFC: Introduced a comprehensive Request for Comments (RFC) outlining the design and implementation plan for Multi-Token Prediction (MTP) as an enhancement to the EAGLE speculative decoding algorithm. This RFC details the motivation, goals, architecture, implementation specifics, configuration, and risks associated with MTP, aiming for significant throughput improvements.
  • EAGLE3 Speculative Decoding Integration: Implemented the core logic for EAGLE3 speculative decoding, including a new EAGLEWorker to manage draft model inference, and EagleDraftInput/EagleVerifyInput data structures to orchestrate the multi-step drafting and verification process. This involves significant changes across the scheduler, model worker, and model execution layers.
  • FlashAttention Kernel Enhancements: Modified the FlashAttention kernel to support custom attention masks and a configurable causal flag. This is crucial for enabling tree-based verification in speculative decoding, allowing for more flexible attention patterns during the verification phase.
  • Model Architecture Adaptations for EAGLE3: Extended Llama, Qwen, and Qwen2/3 models to support EAGLE3, including the introduction of LlamaForCausalLMEagle3 and mechanisms to capture auxiliary hidden states and handle specific weight loading for draft models. This ensures compatibility and efficient operation of speculative decoding with various model families.
  • Memory Management and Padding Refinements: Refactored token slot allocation (alloc_token_slots, alloc_paged_token_slots_extend) into common utility functions and introduced padding_model_worker_batch to standardize padding logic. This improves memory efficiency and flexibility, especially for variable-length sequences in speculative decoding.
  • Radix Cache Updates for Bigram Keys: Updated the Radix Cache to support bigram keys, which are essential for EAGLE's tree-based speculative decoding. This change affects how prefixes are matched and cached, optimizing the lookup process for draft sequences.
  • Server Argument Expansion: Added a comprehensive set of command-line arguments to configure speculative decoding, including algorithm choice (EAGLE, EAGLE3), draft model paths, number of steps, top-k values, and acceptance thresholds. A new check prevents enabling overlap scheduling when speculative decoding is active.
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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

@SiqiLi-Fighting SiqiLi-Fighting force-pushed the feat/eagle-support-rebase-new-padding branch from 35dce26 to f218224 Compare November 11, 2025 08:11
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