[diffusion] [NPU] support ring attention on NPU with FIA attention backend#20248
[diffusion] [NPU] support ring attention on NPU with FIA attention backend#20248Makcum888e wants to merge 13 commits intosgl-project:mainfrom
Conversation
Summary of ChangesHello, 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 SGLang framework by enabling ring attention functionality on NPU devices. It achieves this by introducing a dedicated Fused Infer Attention (FIA) backend, which is crucial for handling the specific requirements of ring attention that existing backends like SDPA could not meet. The changes also include updates across various model configurations and the platform interface to seamlessly integrate and utilize this new NPU-optimized attention mechanism, ensuring better performance and compatibility for NPU-based diffusion models. 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 the FIA (Fused Infer Attention) backend to enable ring attention on NPU devices. The changes include adding the new FIA attention backend, implementing its logic as a wrapper around an NPU-specific operator, and integrating it into the platform interface and model configurations.
The implementation is mostly straightforward. However, I've identified a few issues that should be addressed:
- A potential
Nonevalue being passed fornum_kv_headsin the newFIAImpl, which could lead to runtime errors. - Incorrect return type hints for the new
default_ring_attention_backendmethod in both the platform interface and the NPU implementation.
I've provided specific comments and suggestions for these points. Once these are addressed, the changes look good.
python/sglang/multimodal_gen/runtime/layers/attention/backends/fia.py
Outdated
Show resolved
Hide resolved
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…/sglang into fia_attention_backend
python/sglang/multimodal_gen/runtime/layers/attention/backends/fia.py
Outdated
Show resolved
Hide resolved
python/sglang/multimodal_gen/runtime/layers/attention/backends/fia.py
Outdated
Show resolved
Hide resolved
python/sglang/multimodal_gen/runtime/layers/attention/backends/fia.py
Outdated
Show resolved
Hide resolved
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
|
duplicate #21383 |
Motivation
ring attentionrequiresreturn_softmax_lsebutsdpa backendcannot support this option. Support ofring attentionon NPU can be implemented usingnpu_fused_infer_attention_score.Modifications
added new attention backend for NPU - FIA
added new function to platform interface
default_ring_attention_backendto allow the platform to select the default backendAccuracy Tests
Benchmarking and Profiling
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci