Skip to content

Conversation

tdoublep
Copy link
Member

@tdoublep tdoublep commented Aug 10, 2025

Essential Elements of an Effective PR Description Checklist

  • The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)".
  • The test plan, such as providing test command.
  • The test results, such as pasting the results comparison before and after, or e2e results
  • (Optional) The necessary documentation update, such as updating supported_models.md and examples for a new model.

Purpose

The mamba2 layer has a lot of CPU overhead which mean its performance is really poor for small batches unless CUDA graphs are used. This means that the default V1 performance is still significantly worse than the default V0 performance (see below).

We recently merged #21401 which solves this problem by enabling full CUDA graphs for decode-only batches. This PR proposes to enable this by default for models with mamba2. Without this change, users will continue to experience poor performance when switching from V0 to V1, unless they really know what they are doing.

In my view, this PR and #21549 would be the last steps required to enable V1 by default for these models and to start stripping out the V0 code.

cc @heheda12345 @tlrmchlsmth

Test Plan

  • default V0 performance (main)
  • default V1 performance (main)
  • default V1 performance (this PR)

Test Result

Default V0 performance (main):

python benchmark_latency.py \
	--model ibm-granite/granite-4.0-tiny-preview \
	--input-len 31500 \
	--output-len 512 \
	--batch-size 1	\
	--num-iters-warmup 3 \
	--num-iters 3 

Avg latency: 3.505638455351194 seconds
10% percentile latency: 3.501975697884336 seconds
25% percentile latency: 3.5030823255656287 seconds
50% percentile latency: 3.5049267050344497 seconds
75% percentile latency: 3.5078387099783868 seconds
90% percentile latency: 3.509585912944749 seconds
99% percentile latency: 3.5106342347245665 seconds

Default V1 performance (main):

VLLM_USE_V1=1 VLLM_ATTENTION_BACKEND=FLASHINFER python benchmark_latency.py \
	--model ibm-granite/granite-4.0-tiny-preview \
	--input-len 31500 \
	--output-len 512 \
	--batch-size 1	\
	--num-iters-warmup 3 \
	--num-iters 3 

Avg latency: 8.384082738310099 seconds
10% percentile latency: 8.35280047832057 seconds
25% percentile latency: 8.372324891504832 seconds
50% percentile latency: 8.40486558014527 seconds
75% percentile latency: 8.406232006032951 seconds
90% percentile latency: 8.40705186156556 seconds
99% percentile latency: 8.407543774885125 seconds

Default V1 performance (this PR):

VLLM_USE_V1=1 VLLM_ATTENTION_BACKEND=FLASHINFER python benchmark_latency.py \
	--model ibm-granite/granite-4.0-tiny-preview \
	--input-len 31500 \
	--output-len 512 \
	--batch-size 1	\
	--num-iters-warmup 3 \
	--num-iters 3 

Avg latency: 3.398241866302366 seconds
10% percentile latency: 3.3959803130012007 seconds
25% percentile latency: 3.397328175487928 seconds
50% percentile latency: 3.3995746129658073 seconds
75% percentile latency: 3.3998219304485247 seconds
90% percentile latency: 3.399970320938155 seconds
99% percentile latency: 3.4000593552319334 seconds

(Optional) Documentation Update

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.

🚀

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 enables full CUDA graphs by default for hybrid models to improve performance, which is a great optimization. I have one suggestion regarding the implementation to ensure user configurations are not unintentionally overridden.

@mergify mergify bot added the new-model Requests to new models label Aug 10, 2025
@tdoublep tdoublep changed the title [V1] [Hybrid] Enable Full CUDA graph by default for hybrid models in V1 [V1] [Hybrid] Enable Full CUDA graph by default for models with mamba2 layers in V1 Aug 10, 2025
Copy link
Member

@mgoin mgoin left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me, the difference is huge! The main concern would be if we enable full cudagraph by default for Mamba2 but one of the non-mamba layers needs to use an attention backend without full cg support

@mgoin mgoin added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 10, 2025
Copy link
Collaborator

@heheda12345 heheda12345 left a comment

Choose a reason for hiding this comment

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

Amazing speedup! Can you update the doc?

Copy link

mergify bot commented Aug 11, 2025

This pull request has merge conflicts that must be resolved before it can be
merged. Please rebase the PR, @tdoublep.

https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/syncing-a-fork

@mergify mergify bot added the needs-rebase label Aug 11, 2025
@Josephasafg
Copy link
Contributor

Josephasafg commented Aug 12, 2025

@tdoublep This is great. Suggestion - Everything here is not very mamba2 specific, meaning, once we add full cuda support to mamba1 (we have the PR waiting to be opened), we would want to add this code to it as well without duplicating it. So perhaps its worth removing the 2 suffix from the names here, so we can just take it as is once FCG is supported. wdyt?

@tdoublep
Copy link
Member Author

@Josephasafg Do you expect that the effect of FCG is as significant for mamba1 as for mamba2?

@Josephasafg
Copy link
Contributor

Josephasafg commented Aug 13, 2025

@tdoublep from the initial runs I had made, it looks to be significant (but not as mamba2)
These are some of the numbers I had gotten

No FCG

VLLM_USE_V1=1 VLLM_ATTENTION_BACKEND=FLASHINFER python benchmark_latency.py \
        --model ai21labs/AI21-Jamba-Mini-1.7-FP8 \
        --input-len 31500 \
        --output-len 128 \
        --batch-size 1  \
        --num-iters-warmup 3 \
        --num-iters 3 \
        --max-num-seqs 1 \
        --enforce-eager
Profiling iterations: 100% 3/3 [00:14<00:00,  5.00s/it]
Avg latency: 4.998069426355262 seconds
10% percentile latency: 4.991475126799196 seconds
25% percentile latency: 4.994978636037558 seconds
50% percentile latency: 5.0008178181014955 seconds
75% percentile latency: 5.002534412546083 seconds
90% percentile latency: 5.003564369212836 seconds
99% percentile latency: 5.004182343212888 seconds

with FCG

VLLM_USE_V1=1 VLLM_ATTENTION_BACKEND=FLASHINFER python benchmark_latency.py \
        --model ai21labs/AI21-Jamba-Mini-1.7-FP8 \
        --input-len 31500 \
        --output-len 128 \
        --batch-size 1  \
        --num-iters-warmup 3 \
        --num-iters 3 \
        --max-num-seqs 1 \
        --compilation-config='{"full_cuda_graph": true}'

Profiling iterations: 100% 3/3 [00:09<00:00,  3.21s/it]
Avg latency: 3.2101284717209637 seconds
10% percentile latency: 3.2057920150924475 seconds
25% percentile latency: 3.2082151676295325 seconds
50% percentile latency: 3.212253755191341 seconds
75% percentile latency: 3.2131044175475836 seconds
90% percentile latency: 3.2136148149613293 seconds
99% percentile latency: 3.2139210534095763 seconds

@tdoublep
Copy link
Member Author

@Josephasafg Could you also share V0 numbers for the same benchmark?

@Josephasafg
Copy link
Contributor

@tdoublep For V0 I had gotten this

Avg latency: 5.413307532668114 seconds
10% percentile latency: 5.40432041650638 seconds
25% percentile latency: 5.406467076041736 seconds
50% percentile latency: 5.4100448419339955 seconds
75% percentile latency: 5.418516643927433 seconds
90% percentile latency: 5.423599725123495 seconds
99% percentile latency: 5.426649573841132 seconds

@heheda12345
Copy link
Collaborator

@Josephasafg Did you include #22653 in your benchmark?

@Josephasafg
Copy link
Contributor

@heheda12345 yes, it's based on it , which is why I haven't opened the PR yet.

@heheda12345
Copy link
Collaborator

@tdoublep Can you make this PR not that mamba2 specific?

@tdoublep
Copy link
Member Author

@tdoublep Can you make this PR not that mamba2 specific?

Yes I can. Just need to decide how to handle the mamba-only case (e.g., models that are not actually hybrid so we can't check is_hybrid).

@tdoublep tdoublep force-pushed the hybrid-fcg-default branch from 8d164ad to a265687 Compare August 26, 2025 20:20
@tdoublep
Copy link
Member Author

@heheda12345 PTAL - I've had another go at this, much simpler now.

@tdoublep tdoublep changed the title [V1] [Hybrid] Enable Full CUDA graph by default for models with mamba2 layers in V1 [V1] [Hybrid] Enable Full CUDA graph by default for hybrid models in V1 Aug 26, 2025
@mergify mergify bot removed the needs-rebase label Aug 26, 2025
@tdoublep
Copy link
Member Author

After this one, we should merge: #23650

@Josephasafg
Copy link
Contributor

Josephasafg commented Aug 26, 2025

Nice clean solution. I'm wondering if we should keep this mamba specific or consider a more general solution for other models down the line, perhaps this approach works well for now.

Copy link
Collaborator

@heheda12345 heheda12345 left a comment

Choose a reason for hiding this comment

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

LGTM! Really clean now.

@heheda12345 heheda12345 enabled auto-merge (squash) August 26, 2025 22:19
@heheda12345 heheda12345 merged commit 5f1af97 into vllm-project:main Aug 26, 2025
42 checks passed
tc-mb pushed a commit to tc-mb/vllm that referenced this pull request Aug 27, 2025
epwalsh pushed a commit to epwalsh/vllm that referenced this pull request Aug 28, 2025
xiao-llm pushed a commit to xiao-llm/vllm that referenced this pull request Aug 28, 2025
xiao-llm pushed a commit to xiao-llm/vllm that referenced this pull request Aug 28, 2025
zhewenl pushed a commit to zhewenl/vllm that referenced this pull request Aug 28, 2025
dumb0002 pushed a commit to dumb0002/vllm that referenced this pull request Aug 28, 2025
2015aroras pushed a commit to 2015aroras/vllm that referenced this pull request Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-model Requests to new models ready ONLY add when PR is ready to merge/full CI is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants