Skip to content

[v1][attention] Support Hybrid Allocator + FlashInfer #21412

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 4 commits into
base: main
Choose a base branch
from

Conversation

heheda12345
Copy link
Collaborator

@heheda12345 heheda12345 commented Jul 22, 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

Support hybrid allocator + flashinfer backend. Achieved by letting the attention backend know the set of layers that use this backend, and only performs plan for these layers.

Limitation:
For a model with both sliding window attention and full attention, when hybrid allocator is disabled, both the two types of layer use the same attention metadata builder, and flashinfer cannot handle this case. As a temporary solution, I add an error message to tell user to set disable_sliding_window manually. (This config was set automatically when using flashinfer backend before this PR).

Test Plan

Run basic.py with "google/gemma-3-1b-it"

Test Result

Not cap the max length to the sliding window size, and generate meaningful result

VLLM_ATTENTION_BACKEND=FLASHINFER python3 basic.py

output
------------------------------------------------------------
Prompt:    'Hello, my name is'
Output:    " Alex. I'm a software engineer.\n\nI'm passionate about creating"
------------------------------------------------------------
Prompt:    'The president of the United States is'
Output:    ' currently Joe Biden. He was elected in November 2020.\n\n'
------------------------------------------------------------
Prompt:    'The capital of France is'
Output:    ' Paris.\nThe largest city in the world is Tokyo.\nThe most populous'
------------------------------------------------------------
Prompt:    'The future of AI is'
Output:    ' being shaped by a critical question: can we build AI that is aligned with human'
------------------------------------------------------------

(Optional) Documentation Update

Signed-off-by: Chen Zhang <zhangch99@outlook.com>
Signed-off-by: Chen Zhang <zhangch99@outlook.com>
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

Warning

Gemini is unable to generate a review due to a potential policy violation.

@mergify mergify bot added rocm Related to AMD ROCm v1 labels Jul 22, 2025
Signed-off-by: Chen Zhang <zhangch99@outlook.com>
@heheda12345
Copy link
Collaborator Author

CC @LucasWilkinson @WoosukKwon

@heheda12345
Copy link
Collaborator Author

@LucasWilkinson seems that we met the same problem when hybrid allocator is disabled as here. #21093 (comment)

@WoosukKwon
Copy link
Collaborator

For models like Gemma 3, is it using flash-attn for global attn and flashinfer for sliding window attn?

Signed-off-by: Chen Zhang <zhangch99@outlook.com>
@heheda12345
Copy link
Collaborator Author

@WoosukKwon No, all layers are using flashinfer. Mixing flash-attn + flashinfer should be easy with the current design but prefer to put it into next pr if you think it is needed.

@WoosukKwon
Copy link
Collaborator

@heheda12345 Great. I think we shouldn't mix the two.

Copy link

mergify bot commented Jul 24, 2025

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

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 Jul 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase rocm Related to AMD ROCm v1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants