[diffusion] kernel: apply fused kernel#14437
[diffusion] kernel: apply fused kernel#14437yingluosanqian wants to merge 8 commits intosgl-project:mainfrom
Conversation
Summary of ChangesHello @yingluosanqian, 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 a recently developed fused kernel for the 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
|
There was a problem hiding this comment.
Code Review
This pull request refactors the ScaleResidualLayerNormScaleShift class into ScaleResidualNormScaleShift, making it a CustomOp with distinct forward_cuda and forward_native implementations. The __init__ method is updated to include a bias parameter and streamline dtype handling. These changes are applied across several model files (causal_wanvideo.py, hunyuanvideo.py, wanvideo.py) where the class is instantiated, involving updates to parameter passing (e.g., removing compute_dtype and adding bias). A new test file (test_scale_residual_norm_scale_shift.py) is introduced to thoroughly validate the accuracy of the refactored class against its native implementation across various input shapes and data types. Review comments identified a critical variable renaming error in wanvideo.py that would cause an AttributeError, an inconsistency in handling integer gate values between forward_cuda and forward_native in layernorm.py, a bug using scale.size instead of scale.numel() for tensor size checks, and a missing typing.Tuple import in the new test file.
Related to #12799
Motivation
PR (#14289) implement the fused kernel, and this PR use it in related diffusion model.
See the kernel PR (#14289) for kernel details (accuracy, benchmark, profiling ....).
Modifications
Accuracy Tests
Benchmarking and Profiling
Checklist