-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
[v1] Re-add fp32 support to v1 engine through FlexAttention #19754
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
Conversation
Signed-off-by: Isotr0py <[email protected]>
Signed-off-by: Isotr0py <[email protected]>
Signed-off-by: Isotr0py <[email protected]>
Signed-off-by: Isotr0py <[email protected]>
Signed-off-by: Isotr0py <[email protected]>
Signed-off-by: Isotr0py <[email protected]>
👋 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 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 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @Isotr0py, 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 re-enables full FP32 support for the v1 engine, which was previously disabled due to failing tests. My changes involve explicitly routing FP32 attention operations to the FlexAttention backend on CUDA, removing the prior data type restrictions, and updating model initialization to respect the specified data type. I've also added new tests to validate these changes and included minor fixes to ensure overall compatibility and stability.
Highlights
- Re-enable FP32 Support for V1 Engine: I have removed the explicit
V1_SUPPORTED_DTYPES
check invllm/engine/arg_utils.py
that previously restricted the V1 engine to only FP16 and BF16, thereby re-enabling FP32 support. - FlexAttention for FP32 on CUDA V1 Engine: In
vllm/platforms/cuda.py
, I've added logic to ensure that when the V1 engine is active and the model's data type is not FP16 or BF16 (e.g., FP32), theFlexAttentionBackend
is explicitly selected for CUDA devices. - New Test for FP32 Attention Backend Selection: A new test,
test_fp32_fallback
, has been added totests/kernels/attention/test_attention_selector.py
. This test verifies that the correct attention backend (FlexAttention for CUDA V1, TORCH_SDPA_VLLM_V1 for CPU V1) is selected when using FP32. - Ensuring Correct Model Initialization Dtype: I've updated
vllm/model_executor/model_loader/tensorizer_loader.py
to wrap theinit_tensorizer_model
call withset_default_torch_dtype(model_config.dtype)
andtorch.device(device_config.device)
. This ensures that models are initialized with their specified data type and on the correct device, which is crucial for proper FP32 operation. - Test Environment Dtype Consistency: To maintain consistent test environments, I've added
torch.set_default_dtype(torch.float16)
to several test functions intests/v1/worker/test_gpu_model_runner.py
. This ensures these specific tests run with FP16 as the default dtype, preventing unintended interactions with FP32 changes. - FlashInfer Logits Contiguity Fix: A minor fix was applied in
vllm/v1/sample/ops/topk_topp_sampler.py
by adding.contiguous()
to thelogits
tensor before passing it toflashinfer.sampling.top_k_top_p_sampling_from_logits
. This ensures proper memory layout for the FlashInfer operation.
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 is currently in preview and 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 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
The pull request re-adds FP32 support to the v1 engine through FlexAttention. The changes include modifications to the attention backend selection logic, model loading, and sampling operations. The addition of tests ensures the correct behavior of the FP32 fallback mechanism.
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Isotr0py <[email protected]>
There was a problem hiding this 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 with green CI.. please make sure to force run all tests to trigger
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Please fix the linter |
Signed-off-by: Isotr0py <[email protected]>
Signed-off-by: Isotr0py <[email protected]>
Signed-off-by: Isotr0py <[email protected]>
Signed-off-by: Isotr0py <[email protected]>
Signed-off-by: Isotr0py <[email protected]>
This pull request has merge conflicts that must be resolved before it can be |
Signed-off-by: Isotr0py <[email protected]>
…ject#19754) Signed-off-by: Isotr0py <[email protected]> Signed-off-by: Isotr0py <[email protected]>
…ject#19754) Signed-off-by: Isotr0py <[email protected]> Signed-off-by: Isotr0py <[email protected]>
…ject#19754) Signed-off-by: Isotr0py <[email protected]> Signed-off-by: Isotr0py <[email protected]>
…ject#19754) Signed-off-by: Isotr0py <[email protected]> Signed-off-by: Isotr0py <[email protected]> Signed-off-by: Patrick von Platen <[email protected]>
…ject#19754) Signed-off-by: Isotr0py <[email protected]> Signed-off-by: Isotr0py <[email protected]>
…ject#19754) Signed-off-by: Isotr0py <[email protected]> Signed-off-by: Isotr0py <[email protected]> Signed-off-by: avigny <[email protected]>
…ject#19754) Signed-off-by: Isotr0py <[email protected]> Signed-off-by: Isotr0py <[email protected]>
…ject#19754) Signed-off-by: Isotr0py <[email protected]> Signed-off-by: Isotr0py <[email protected]>
…ject#19754) Signed-off-by: Isotr0py <[email protected]> Signed-off-by: Isotr0py <[email protected]> Signed-off-by: Jinzhen Lin <[email protected]>
Essential Elements of an Effective PR Description Checklist
supported_models.md
andexamples
for a new model.Purpose
https://buildkite.com/vllm/ci/builds/21699#01975508-6c54-47d6-a951-82873b896a11
https://buildkite.com/vllm/ci/builds/21699#01975508-6c52-41ed-ba7a-cc1a464cec91
Test Plan
Test Result
Both previous failing tests passed locally.
(Optional) Documentation Update