[Diffusion] Fix Sana corrupted output by removing spurious QK norm layers#20656
Conversation
…yers SanaLinearAttention and SanaCrossAttention had norm_q/norm_k RMSNorm layers that are absent from the Sana checkpoint weights. These layers ran with random initialization, corrupting attention outputs and producing garbled images. Remove norm_q/norm_k from both attention classes to match the actual Sana model architecture. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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 resolves a critical bug in the SGLang Sana pipeline that caused corrupted image generation. The problem was traced to the erroneous inclusion of 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 correctly addresses the issue of corrupted image output from the Sana model by removing the spurious norm_q and norm_k RMSNorm layers from SanaLinearAttention and SanaCrossAttention. The changes are consistent with the pull request description, which states these layers do not exist in the model checkpoint. The modifications are confined to deleting the incorrect layer initializations and their applications, which is the right approach to fix this bug. The code is now aligned with the actual model architecture, and I find no further issues with the changes.
|
/tag-and-rerun-ci |
|
/rerun-failed-ci |
5 similar comments
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
|
/rerun-failed-ci |
…rm layers (sgl-project#20656) Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Mick <mickjagger19@icloud.com>
…rm layers (sgl-project#20656) Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Mick <mickjagger19@icloud.com>
…rm layers (sgl-project#20656) Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Mick <mickjagger19@icloud.com>
…rm layers (sgl-project#20656) Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: Mick <mickjagger19@icloud.com>
…rm layers (sgl-project#20656) Co-authored-by: Mick <mickjagger19@icloud.com>
Problem
The native SGLang Sana pipeline produced corrupted/garbled images. The output looked like a mess of random shapes with no semantic content.
Root Cause
SanaLinearAttentionandSanaCrossAttentionboth hadnorm_q/norm_kRMSNormlayers that do not exist in the Sana checkpoint. These layers were initialized with random weights and applied to query/key tensors before attention computation, completely corrupting the attention outputs.Verified by inspecting the checkpoint: no
norm_qornorm_kkeys exist indiffusion_pytorch_model.safetensorsforEfficient-Large-Model/Sana_600M_1024px_diffusers.Fix
Remove
norm_qandnorm_kfromSanaLinearAttentionandSanaCrossAttentionto match the actual Sana model architecture.Test
Ran
pytest python/sglang/multimodal_gen/test/server/test_server_a.py -k sana_image_t2i— PASSED.🤖 Generated with Claude Code