Skip to content
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

[V1][Core] FlashInfer attention backend for V1 #14061

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

Conversation

aurickq
Copy link
Contributor

@aurickq aurickq commented Feb 28, 2025

Implement FlashInfer attention backend for V1.

Outstanding items that need feedback:

  • Need a better way to abstract out the AttentionMetadata creation interface, currently it just handles it case-by-case in the GPU runner for each attention backend. Solved after rebase
  • Is the use_cascade_attention logic still valid for FlashInfer? This was copied from the FlashAttention implementation.
  • Cascade attention seems to have different outputs from normal attention. Sometimes this difference is significant, but still coherent. Is this an expected behavior of cascade attention? Seems to match now after fixing a bug

Current limitations:

  • It appears we cannot set the kv cache dtype using the MultiLevelCascadeAttentionWrapper interface in FlashInfer. This means we only support cascade attention when the kv cache dtype is the same as the query dtype.
  • Only tested on simple cases so far, need more comprehensive testing.

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

mergify bot commented Feb 28, 2025

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

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

Copy link
Contributor

@aarnphm aarnphm left a comment

Choose a reason for hiding this comment

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

Very much early on, but from the looks of things seems like a lot of code moved from v0.

tests would be awesome here as well 😃

@mergify mergify bot removed the needs-rebase label Feb 28, 2025
@aurickq aurickq changed the title [WIP][V1][Core] FlashInfer attention backend for V1 [V1][Core] FlashInfer attention backend for V1 Mar 1, 2025
@aurickq
Copy link
Contributor Author

aurickq commented Mar 1, 2025

PR is ready. But there are some performance issues that seem to be due to using BatchPrefillWithPagedKVCacheWrapper for all prefill and decode tokens. Maybe this wrapper is not well-optimized for decoding sequences with short query lengths.

V1 FlashAttention:

Input token throughput (tok/s):          21448.32  
Output token throughput (tok/s):         2745.38

V1 FlashInfer (This PR):

Input token throughput (tok/s):          11372.04  
Output token throughput (tok/s):         1455.62

V0 FlashInfer:

Input token throughput (tok/s):          15157.36  
Output token throughput (tok/s):         1940.14

V0 FlashInfer with BatchDecodeWithPagedKVCacheWrapper replaced with BatchPrefillWithPagedKVCacheWrapper:

Input token throughput (tok/s):          9479.15   
Output token throughput (tok/s):         1213.33

There is a big performance degradation from using BatchPrefillWithPagedKVCacheWrapper for decode tokens in V0. In V1, we use a single BatchPrefillWithPagedKVCacheWrapper for mixed prefill/decode batches, which may be causing the poor performance.

Copy link

mergify bot commented Mar 1, 2025

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

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 Mar 1, 2025
@mergify mergify bot removed the needs-rebase label Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants