Conversation
There was a problem hiding this comment.
Summary of Changes
Hello @Lzhang-hub, 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 primarily focuses on extending the SGLang framework to support Qwen2.5-VL with the EAGLE3 speculative decoding algorithm and to enable multi-head Rotary Positional Embedding (mROPE) for Llama-Eagle3 models. The changes involve significant updates to model forward passes, multimodal input processing, and the underlying CUDA graph infrastructure to ensure efficient and correct execution of these advanced features.
Highlights
- EAGLE3 Integration for Qwen2.5-VL: This PR enables the Qwen2.5-VL model to leverage the EAGLE3 speculative decoding algorithm. This is achieved by introducing mechanisms to capture and utilize auxiliary hidden states from specific intermediate layers of the model, which are crucial for EAGLE3's operation. A new
set_eagle3_layers_to_capturemethod has been added to both Qwen2 and Qwen2.5-VL models to configure which layers' hidden states should be captured. - mROPE Support for Llama-Eagle3: Support for multi-head Rotary Positional Embedding (mROPE) has been introduced for Llama-Eagle3 models. This includes updating the model to correctly utilize
mrope_positionsfrom theforward_batchand a specific compatibility fix for Qwen2.5-VL'srope_scalingconfiguration, ensuring that ifrope_typeis 'mrope', it's adjusted to 'default' for proper handling. - Multimodal Input Handling Enhancements: The logic for handling multimodal inputs has been refined. Specifically, the conversation generation now correctly prepends image tokens for Qwen2-VL models. Additionally, the embedding of multimodal inputs (
embed_mm_inputs) has been made more flexible by allowing an optionalplaceholder_tokensargument, and multimodal input processing is now bypassed duringtarget_verifyforward mode. - CUDA Graph Optimization for Positional Embeddings: The CUDA graph runners for both general model execution and EAGLE speculative decoding have been updated to correctly manage mROPE position tensors. This involves changing the sizing and slicing of
mrope_positionsfrom being based on batch size (max_bsorraw_bs) to being based on the total number of tokens (max_num_tokenorraw_num_token), which is more accurate for token-level positional embeddings and improves efficiency.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| 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 issue 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 or fill out our survey to provide feedback.
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
-
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. ↩
There was a problem hiding this comment.
Code Review
This pull request adds support for Qwen2.5-VL with EAGLE3 speculative decoding. The changes are spread across model definitions, CUDA graph runners, and multi-modal utilities.
Overall, the changes look good and align with the PR's objectives. I've identified a few critical correctness issues that will cause runtime errors and should be addressed before merging. I've also left some comments on maintainability and potential improvements.
Here's a summary of the key feedback points:
- Critical issues: There are a couple of bugs in
mm_utils.pyandcuda_graph_runner.pythat will lead to crashes due to incorrect tensor creation and size mismatches. - Maintainability: There are opportunities to improve code clarity by cleaning up temporary solutions, removing redundant code, and avoiding in-place config modifications.
- Consistency: There's a minor inconsistency in handling layer indices for EAGLE3 configuration that should be clarified.
Please review the detailed comments on the specific files.
|
When starting the sglang server with eagle3, the service generally starts up normally, but an error occurs during the Prefill batch. |
|
@LugerW-A Fixed |
|
[2025-08-13 00:39:39] Scheduler hit an exception: Traceback (most recent call last): the recent commit cause this bug after server started up and do Prefill batch |
|
@yutongteng I fixed with commit |
I found that, when the training epoch increases, the acceptance rate actually increase when disable cuda graph, but it remains the same when enable cuda graph |
I encountered this error, is it expected? (FYI: I use sglang:blackwell image) |
|
Without Spec: I cannot see improvement in mmmu, but it's okay. |
|
I benchmark the model's performance by using evalscope with kontext_bench, i got this error |
Increasing the max_position_embeddings parameter in the draft model's configuration can resolve this error. |
@Lzhang-hub We should capture this error and display " Increasing the max_position_embeddings parameter " to the user. Not the CUDA error. |
@JustinTong0323 @mmdbhs Add env |
|
hi @Lzhang-hub I'm using sglang for evaluation, and my commands are as follows: python -m sglang.launch_server \
--model-path Qwen/Qwen2.5-VL-7B-Instruct \
--chat-template qwen2-vl \
--speculative-draft-model-path Rayzl/qwen2.5-vl-7b-eagle3-sgl \
--speculative-algorithm EAGLE3 \
--speculative-num-steps 4 \
--speculative-eagle-topk 6 \
--speculative-num-draft-tokens 24 \
--trust-remote-code \
--chunked-prefill-size -1 \
--cuda-graph-max-bs 1 \
--tp 1 \
--mem-fraction-static 0.7 \
--host 0.0.0.0 \
--port 8080python run_mmstar.py --host http://0.0.0.0 --port 8080 --parallel 1 --num-questions 100The results show that the token acceptance length is very poor. (with eagle3) (without eagle3) Was there something wrong with my operation? |
|
Here are the test results of the draft model obtained by distilling our fine-tuned Qwen2.5-VL-3B-Instruct using SpecForge v0.1.0 (with SGLang v0.5.4). Both the fine-tuning of the teacher model and this distillation process used the same dataset of approximately 48,000 images. With eagle3(sglang v0.5.6 inference) Baseline(Qwen2.5-VL-3B-Instruct with sglang v0.5.6 inference) Hi,@C3236455482 ,perhaps you could try upgrading the sglang version to 0.5.6. Dear @Lzhang-hub, I'm seeing surprisingly modest speedup from Eagle3 on the Qwen2.5VL model—far below the 4–6× reported in the paper for LLMs (which we do observe on regular language models). Could this point to a training issue on my side? I've pasted my training script below—any pointers would be appreciated. |
Motivation
support qwen2.5-vl eagle3 infer
Modifications
Draf model train
qwen2.5-vl-7b eagle3 draft model train ref specforge
Benchmark
speed
server: sglang for qwen-2.5-vl eagle3 infer
benchmark scripts: use mmstar benchmark
Note: draft model
Rayzl/qwen2.5-vl-7b-eagle3-sglis only train on 30k vqa datasets, more data is still training.server cmd:
benchmark:
python run_mmstar.py --host http://0.0.0.0 --port 8080 --parallel 1 --num-questions 100result:
server cmd:
benchmark:
python run_mmstar.py --host http://0.0.0.0 --port 8080 --parallel 1 --num-questions 100result:
e2e speedup 1.5x
acc
we benchmark on MMstar、MMBench_DEV_EN、COCO_VAL
Checklist