Conversation
Summary of ChangesHello @lifuhuang, 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 significantly enhances the system's ability to leverage FlashAttention v4 for prefill operations, aiming to improve performance and efficiency. It achieves this by removing previous hardcoded limitations on fa4 usage and by refactoring the attention backend selection process into a dedicated utility, making the system more robust and easier to configure for different attention mechanisms. Highlights
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
|
ee191ca to
666024a
Compare
There was a problem hiding this comment.
Code Review
This pull request adds support for MHA prefill with FlashAttention 4 by removing assertions that previously restricted its use. The changes also include a refactoring of the attention backend determination logic into a new utility function.
My main feedback is to further improve the refactoring by moving the new determine_attention_backends function into the ServerArgs class as a method. This would improve code structure by eliminating a dependency from the low-level server_args.py module to the large utils.py module, which is better for maintainability. I've left specific suggestions on how to achieve this.
Co-authored-by: Hieu Pham <hyhieu@gmail.com>
666024a to
0ac0424
Compare
| raise NotImplementedError("haven't implemented flash_attn_with_kvcache for fa4") | ||
| assert ( | ||
| flash_attn_varlen_func_v4 is not None | ||
| ), "FA4 is not available, please check your installation." |
There was a problem hiding this comment.
TODO: Need to check in first and bump up sgl-kernel.
|
The H100-H200 series is not supported by FA4, right? |
It was restricted to sm100 because of we only tested this on blackwell primary optimization object. |
zhyncs
left a comment
There was a problem hiding this comment.
@lifuhuang can u upgrade sgl-kernel v0.3.15 in this pr
done |
Co-authored-by: Hieu Pham <hyhieu@gmail.com>
Co-authored-by: Hieu Pham <hyhieu@gmail.com>
(co-author @hyhieu)
Updates: the kernel change has been checked in separately in: #10940
Motivation
Add support for FA4 MHA prefill, changes mostly based on: #9428
Modifications
Accuracy Tests
FA4:
Baseline (TRTLLM-MHA):
Benchmarking and Profiling
For the model I am benchmarking: openai/gpt-oss-20b. I am not seeing significant difference between fa4 and trtllm-mha, both are significantly faster than triton, expectedly.
FA4:
TRTLLM-MHA
Triton
Checklist