Skip to content

[diffusion] Accelerate Cosmos3 T2I QKNorm+RoPE - #34932

Merged
BBuf merged 2 commits into
sgl-project:mainfrom
BBuf:agent/optimize-cosmos3-t2i-qknorm-rope
Aug 16, 2026
Merged

BBuf merged 2 commits into
sgl-project:mainfrom
BBuf:agent/optimize-cosmos3-t2i-qknorm-rope

Conversation

@BBuf

@BBuf BBuf commented Aug 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • enable the fused QKNorm + RoPE + KV-pack path for the Cosmos3 image case (T == 1)
  • preserve the eager split path's BF16 rounding boundary before RoPE so lossless output remains bit-exact
  • store the rounded RoPE cache in the activation dtype once instead of casting in every GEN layer
  • explicitly keep regional torch.compile GEN layers on their existing compile-safe path

Why

Cosmos3 video already uses fused QKNorm + RoPE, but T2I stayed on separate QKNorm, RoPE, and KV concatenation operations because the image path needs an intermediate BF16 round. The shared fused kernel now supports that rounding mode. This change wires Cosmos3 T2I into it and avoids repeated per-layer cache casts and KV packing launches.

B300 performance

Measured with the cosmos3-nano-t2i preset in the 2026-08-14 full sweep from #21 on one NVIDIA B300:

Mode Denoise E2E
lossless eager 0.863 s 0.908 s
torch.compile 0.997 s 1.041 s
quality=high 0.867 s 0.912 s

Lossless eager is about 13.4% faster than compile on the measured denoise workload.

Validation

  • added a CUDA regression test that requires exact equality with separate BF16 QKNorm, RoPE, and KV packing
  • full pre-commit and CI registry validation pass on the rebased branch
  • Python syntax compilation passes
  • original isolated candidate: dafa75ce5; this PR is rebuilt on current main

CI States

Latest PR Test (Base): ✅ Run #31933836637
Latest PR Test (Extra): ✅ Run #31946430843

@github-actions github-actions Bot added the diffusion SGLang Diffusion label Aug 15, 2026
@BBuf BBuf added the run-ci CI: run the baseline test suite on this PR label Aug 15, 2026
@BBuf BBuf added the mergeable label Aug 16, 2026
@BBuf
BBuf merged commit 41abbb0 into sgl-project:main Aug 16, 2026
245 of 283 checks passed
saturn-acc pushed a commit to saturn-acc/sglang that referenced this pull request Aug 16, 2026
danielchristiancazares pushed a commit to danielchristiancazares/sglang that referenced this pull request Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diffusion SGLang Diffusion mergeable run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant