Skip to content

[V1][Spec Decode] Apply torch.compile & cudagraph to EAGLE3 #17504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

zixi-qi
Copy link
Contributor

@zixi-qi zixi-qi commented Apr 30, 2025

Follow up on #17211 to add support for Eagle3 torch.compile & cudagraph by moving out the multiple auxiliary hidden states merge

Test plan:

  • offline:

VLLM_TORCH_PROFILER_DIR=/data/users/qizixi/gitrepos/vllm/profiles VLLM_USE_V1=1 python examples/offline_inference/eagle.py --num_spec_tokens 3 --max_num_seqs 1 --num_prompts 10 --method eagle3

  • trace before (propose -> ~16ms)
Screenshot 2025-04-30 at 3 23 22 PM
  • trace after (propose -> ~6ms)
Screenshot 2025-04-30 at 3 23 48 PM

Copy link

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

Just a reminder: PRs would not trigger full CI run by default. Instead, it would only run fastcheck CI which starts running only a small and essential subset of CI tests to quickly catch errors. You can run other CI tests on top of those by going to your fastcheck build on Buildkite UI (linked in the PR checks section) and unblock them. If you do not have permission to unblock, ping simon-mo or khluu to add you in our Buildkite org.

Once the PR is approved and ready to go, your PR reviewer(s) can run CI to test the changes comprehensively before merging.

To run CI, PR reviewers can either: Add ready label to the PR or enable auto-merge.

🚀

@mergify mergify bot added the v1 label Apr 30, 2025
Copy link
Collaborator

@WoosukKwon WoosukKwon left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for doing this! It'd be nice if @luyuzhe111 can also take a look.

@WoosukKwon WoosukKwon added ready ONLY add when PR is ready to merge/full CI is needed and removed ready ONLY add when PR is ready to merge/full CI is needed labels May 1, 2025
@WoosukKwon
Copy link
Collaborator

@zixi-qi Oh can you please fix the format error in the pre-commit test?

@luyuzhe111
Copy link
Contributor

@zixi-qi Thanks for the PR! LGTM overall and only left some minor suggestions.

Factoring the fc layer out of the compiled model seems to be the right thing to do! In this case fc layer will have to run in eager mode, but it's not causing much overhead based on your profiling right?

@zixi-qi
Copy link
Contributor Author

zixi-qi commented May 1, 2025

Address comments and apply pre-commit lint suggestions

@zixi-qi
Copy link
Contributor Author

zixi-qi commented May 1, 2025

@zixi-qi Thanks for the PR! LGTM overall and only left some minor suggestions.

Factoring the fc layer out of the compiled model seems to be the right thing to do! In this case fc layer will have to run in eager mode, but it's not causing much overhead based on your profiling right?

RE moving fc layer into eager mode: this is mostly just an aten:mm so seems pretty cheap
Screenshot 2025-04-30 at 9 25 49 PM

@WoosukKwon WoosukKwon enabled auto-merge (squash) May 1, 2025 04:49
@luyuzhe111
Copy link
Contributor

@zixi-qi thanks for incorporating the suggestions! final thing, were you able to check the acceptance length with torch.compile & cuda graph matches that with eager mode as in #16937 (comment)?

@zixi-qi
Copy link
Contributor Author

zixi-qi commented May 1, 2025

@zixi-qi thanks for incorporating the suggestions! final thing, were you able to check the acceptance length with torch.compile & cuda graph matches that with eager mode as in #16937 (comment)?

This is a great point, there does seem to be a difference in acceptance rate between with and without eager, below tests are run with mt_bench + patching #16367

  • eagle3 eager
--------------------------------------------------
mean acceptance length:         3.52
--------------------------------------------------
acceptance at token 0:1.00
acceptance at token 1:0.74
acceptance at token 2:0.54
acceptance at token 3:0.41
acceptance at token 4:0.30
acceptance at token 5:0.23
acceptance at token 6:0.17
acceptance at token 7:0.13
  • eagle3 cudagraph
--------------------------------------------------
mean acceptance length:         2.79
--------------------------------------------------
acceptance at token 0:1.00
acceptance at token 1:0.55
acceptance at token 2:0.38
acceptance at token 3:0.29
acceptance at token 4:0.21
acceptance at token 5:0.16
acceptance at token 6:0.12
acceptance at token 7:0.09

Eagle pass does not have the same issue, so perhaps moving the fc had a negative impact on numerics?

  • eagle eager
--------------------------------------------------
mean acceptance length:         2.47
--------------------------------------------------
acceptance at token 0:1.00
acceptance at token 1:0.67
acceptance at token 2:0.39
acceptance at token 3:0.21
acceptance at token 4:0.11
acceptance at token 5:0.05
acceptance at token 6:0.03
acceptance at token 7:0.01
  • eagle cudagraph
--------------------------------------------------
mean acceptance length:         2.47
--------------------------------------------------
acceptance at token 0:1.00
acceptance at token 1:0.68
acceptance at token 2:0.39
acceptance at token 3:0.20
acceptance at token 4:0.11
acceptance at token 5:0.06
acceptance at token 6:0.03
acceptance at token 7:0.02

@WoosukKwon WoosukKwon disabled auto-merge May 1, 2025 17:40
@WoosukKwon
Copy link
Collaborator

@zixi-qi My guess is that this can be related to vLLM's compilation cache...

@luyuzhe111
Copy link
Contributor

@zixi-qi thanks for sharing the testing results. if you think there is something wrong with cuda graph implementation for EAGLE3, you can add VLLM_LOGGING_LEVEL=DEBUG for more checks (such as input address).

@luyuzhe111
Copy link
Contributor

luyuzhe111 commented May 1, 2025

@zixi-qi oh actually, you forgot to capture the EAGLE3 model here. if you look at the profiling traces more closely, you probably should see there was no cuda graph launch for eagle3 previously.

@zixi-qi
Copy link
Contributor Author

zixi-qi commented May 1, 2025

@zixi-qi oh actually, you forgot to capture the EAGLE3 model here. if you look at the profiling traces more closely, you probably should see there was no cuda graph launch for eagle3 previously.

Noob question which line were you referring to? This is trace from current PR
Screenshot 2025-05-01 at 12 22 15 PM

@luyuzhe111
Copy link
Contributor

@zixi-qi i meant the dummy_run() method of eagle proposer, which is called here from the cuda graph capture method.

@WoosukKwon
Copy link
Collaborator

@luyuzhe111 @zixi-qi I've updated the PR. Thanks for catching the bug! Will merge once it passes the CI.

@zixi-qi
Copy link
Contributor Author

zixi-qi commented May 1, 2025

@luyuzhe111 @WoosukKwon

Thanks so much for catching and fixing the issue! Also verified locally that the acceptance rate issue is fixed

--------------------------------------------------
mean acceptance length:         3.57
--------------------------------------------------
acceptance at token 0:1.00
acceptance at token 1:0.75
acceptance at token 2:0.55
acceptance at token 3:0.42
acceptance at token 4:0.31
acceptance at token 5:0.24
acceptance at token 6:0.18
acceptance at token 7:0.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready ONLY add when PR is ready to merge/full CI is needed v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants