[diffusion] attention: add AITER Sage attention backend#20178
[diffusion] attention: add AITER Sage attention backend#20178mickqian merged 3 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 diffusion model's compatibility and performance by introducing native support for Sage attention on AMD GPUs. By implementing the AITER_SAGE backend, the system can now leverage AMD hardware for attention computations, which was previously limited to NVIDIA GPUs. This change not only broadens hardware support but also delivers a substantial improvement in overall inference latency, making the system more efficient. 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 support for the AITER_SAGE attention backend, which is targeted for AMD GPUs. The changes are well-contained and consistently applied across documentation, configuration, and implementation files. The new backend implementation correctly handles the optional aiter dependency. My primary feedback is to enhance the robustness of the new AITERSageImpl by adding explicit checks for unsupported attention features like causal masking, dropout, and grouped-query attention. This will prevent silent misconfigurations and make the backend safer to use.
| try: | ||
| from aiter.ops.triton.attention.fav3_sage import fav3_sage_wrapper_func | ||
|
|
||
| self.aiter_sage_attn_fn = fav3_sage_wrapper_func | ||
| except ImportError: | ||
| raise ImportError( | ||
| "AITER Sage attention is not available, please update AITER version." | ||
| ) |
There was a problem hiding this comment.
The __init__ method accepts several parameters (causal, num_kv_heads, dropout_p, etc.) that are not used by the implementation. This could lead to silent misconfigurations where a user might expect a feature to be active (e.g., causal attention), but it is not applied. To make the implementation more robust, it's better to explicitly check for unsupported parameter values and raise an error.
if causal:
raise NotImplementedError(
"AITER Sage attention backend does not support causal attention."
)
if dropout_p > 0.0:
raise NotImplementedError(
"AITER Sage attention backend does not support dropout."
)
if num_kv_heads is not None and num_kv_heads != num_heads:
raise NotImplementedError(
"AITER Sage attention backend does not support Grouped Query Attention."
)
try:
from aiter.ops.triton.attention.fav3_sage import fav3_sage_wrapper_func
self.aiter_sage_attn_fn = fav3_sage_wrapper_func
except ImportError:
raise ImportError(
"AITER Sage attention is not available, please update AITER version."
)|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
|
@mickqian All CI (Nvidia + AMD) passed and PR is approved, ready for merge — SGLDHelper bot |
Motivation
Sage attention is supported for NV GPUs, but the support for AMD Sage attention is missing. This PR adds the support for it.
Modifications
AITER_SAGEAccuracy Tests
Benchmarking and Profiling
Performance Comparison Report
1. High-level Summary
2. Stage Breakdown
Output videos
AITER:
https://github.com/user-attachments/assets/62ae8e96-85e0-4b3f-b1dc-c15c708b4738
AITER SAGE:
https://github.com/user-attachments/assets/43f64ee6-dba4-45a5-9bca-8302bcfaff22
Checklist
Review Process
/tag-run-ci-label,/rerun-failed-ci,/tag-and-rerun-ci