Skip to content

[diffusion] Fuse Cosmos3 Nano T2I attention on Hopper - #36571

Merged
BBuf merged 1 commit into
sgl-project:mainfrom
BBuf:codex/diffusion-cosmos3-nano-t1-fused-hopper
Aug 27, 2026
Merged

BBuf merged 1 commit into
sgl-project:mainfrom
BBuf:codex/diffusion-cosmos3-nano-t1-fused-hopper

Conversation

@BBuf

@BBuf BBuf commented Aug 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • enable the existing fused QK normalization, mRoPE, and KV-pack kernel for Cosmos3-Nano T2I on single-GPU Hopper
  • keep Blackwell behavior unchanged
  • retain the split path for Cosmos3-Super dense MLP, Hopper TP/SP configurations, and torch.compile
  • add focused unit coverage for every selection guard

H100 validation

Hardware: NVIDIA H100 80GB HBM3, CUDA_VISIBLE_DEVICES=0. Native SGLang backend, Cosmos3-Nano T2I preset, 1024x1024x1, 35 steps, seed 42, lossless output, synchronized same-GPU ABBA.

Metric Baseline mean Candidate mean Change
Denoise latency 1818.63 ms 1599.87 ms -12.03%
End-to-end latency 3055.53 ms 2809.43 ms -8.05%
Peak memory 34244 MB 34242 MB stable

All four ABBA outputs are byte-identical: SHA256 c93da30473d6b145615f86645730d391182d9fa845426e49de0623ae4cdd72a2. SSIM is 1.0 and PSNR is infinite.

A five-denoise-step torch profile shows GPU kernel time decreasing from 253.393 ms to 231.242 ms (-8.74%) and launches decreasing from 12,264 to 4,344 (-64.6%). The fused QKNorm + RoPE + KV-pack kernel is invoked 360 times in the candidate trace.

The branch is rebased onto main commit 7f27bf4708a. A fresh model smoke on 0669407 reports 1.600 s denoise latency and the same output hash; the intervening commits only add a CUDA 13.4 container and wheel ABI metadata, without changing diffusion code.

Tests

  • python -m pytest python/sglang/multimodal_gen/test/unit/test_cosmos3.py -q
    • 119 passed, 31 subtests passed
  • python -m pytest test/registered/kernels/ops/diffusion/test_rope.py -q -k qknorm_rope_pack_kv
    • 2 passed
  • selected-file Black pre-commit hook
  • git diff --check
  • python -m py_compile on both changed files

Related background: BBuf/how-to-optim-algorithm-in-cuda#21


CI States

Latest PR Test (Base): ✅ Run #33051882279
Latest PR Test (Extra): ✅ Run #33058373303
Latest PR Test (AMD ROCm 7.2): ❌ Run #33051882303

@github-actions github-actions Bot added the diffusion SGLang Diffusion label Aug 26, 2026
@BBuf
BBuf force-pushed the codex/diffusion-cosmos3-nano-t1-fused-hopper branch from e43b8fa to 2d4acc0 Compare August 26, 2026 22:29
@BBuf
BBuf force-pushed the codex/diffusion-cosmos3-nano-t1-fused-hopper branch from 2d4acc0 to 59220d1 Compare August 27, 2026 07:57
@BBuf
BBuf marked this pull request as ready for review August 27, 2026 07:58
@BBuf BBuf added run-ci CI: run the baseline test suite on this PR mergeable labels Aug 27, 2026
@BBuf
BBuf merged commit 1af95ff into sgl-project:main Aug 27, 2026
203 of 217 checks passed
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