[VLM] Introduce FlashInfer CUDNN Prefill as ViT Backend#19003
[VLM] Introduce FlashInfer CUDNN Prefill as ViT Backend#19003yuan-luo wants to merge 1 commit intosgl-project:mainfrom
Conversation
Summary of ChangesHello @yuan-luo, 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 integrates FlashInfer CUDNN Prefill into the Vision Transformer (ViT) component of Vision-Language Models (VLMs). The primary goal is to improve performance by utilizing FlashInfer's optimized prefill operations. This involves adding a dedicated attention class, implementing specialized sequence length management, and updating the system's configuration to enable the new backend. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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 by creating a comment using either
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 Limitations & Feedback Gemini Code Assist 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces FlashInfer CUDNN prefill as a new backend for Vision Transformer attention, which is a great step towards improving performance. My review focuses on two critical issues that appear to be causing the runtime error mentioned in the PR description and could lead to incorrect computations.
- An incorrect type for the
scaleparameter inVisionFlashInferAttention, which likely causes thepybind11casting error. - Incorrect logic for calculating cumulative sequence lengths in
compute_flashinfer_cu_seqlensinqwen3_vl.py, which could lead to incorrect attention results.
Addressing these issues should help in getting the new backend to work correctly. The rest of the changes for plumbing the new backend and its parameters seem correct.
cf0eb75 to
4bc9cb9
Compare
|
/tag-and-rerun-ci |
JustinTong0323
left a comment
There was a problem hiding this comment.
Could you also resolve 3 bugs in devin review? https://app.devin.ai/review/sgl-project/sglang/pull/19003 They are all reasonable imo.
| "sdpa": VisionSdpaAttention, | ||
| "fa3": VisionFlash3Attention, | ||
| "fa4": VisionFlash4Attention, | ||
| "fi": VisionFlashInferAttention, |
There was a problem hiding this comment.
use flashinfer as it's unified naming with --attention-backend
There was a problem hiding this comment.
Sure, will change it.
|
|
||
| return torch.cat(result_parts, dim=0) | ||
|
|
||
| def fast_pos_embed_interpolate_from_list(self, grid_thw): |
There was a problem hiding this comment.
Does this function only apply to qwen3_vl?
There was a problem hiding this comment.
This function only applies to qwen3_vl. For Qwen2.5-VL and some other VLMs we need to adapt it's own function as the flashinfer cudnn needs to do padding in advance.
Sure, will address them. |
|
/rerun-failed-ci |
Motivation
FlashInfer CUDNN Prefill demonstrate strong performance. Introduce it to SGLang as one of VLM ViT attention backends. A new "fi" mm attention backend is added.
Per manual testing, the performance improved 10%. More comprehensive performance test will be conducted soon.
The image understanding is expected.
Client:
Modifications
Accuracy Tests
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci