Skip to content

[diffusion] Fuse LongCat-Image QKNorm and interleaved RoPE - #35995

Merged
BBuf merged 1 commit into
mainfrom
bbuf/longcat-interleaved-qknorm-rope
Aug 24, 2026
Merged

BBuf merged 1 commit into
mainfrom
bbuf/longcat-interleaved-qknorm-rope

Conversation

@BBuf

@BBuf BBuf commented Aug 22, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • extend the shared JIT QKNorm+RoPE kernel to support full-width interleaved FP32 cos/sin caches
  • use it in LongCat-Image joint and single attention blocks
  • verify the fused path against the existing Diffusers chain once at runtime and fall back on any mismatch or JIT failure
  • add kernel/model fast-path tests, a LongCat benchmark shape, and update the diffusion kernel contract doc

H200 results

Setup: 1x H200, meituan-longcat/LongCat-Image, 1024x1024, 50 steps, seed 42.

Prompt: A red panda reading a book beside a sunlit window.

The ABBA runs used the same process-level warmup policy and isolated model cache. The comparison baseline was 3c69a4c744525be0146629fc5933e3ddab609fb2; this branch is rebased onto b98d472158f707c11b39510fa8406253bbfd5008.

Eager end-to-end

Quality main runs PR runs Mean latency reduction
lossless 8.9970 / 9.1171 s 7.4039 / 7.5243 s 17.47%
high 9.0047 / 9.0731 s 7.4223 / 7.4869 s 17.48%

Breakable CUDA Graph

Quality main PR Reduction
lossless e2e, two runs 8.9550 / 9.0867 s 7.4221 / 7.5530 s 16.88%
high denoise stage 8.9729 s 7.4392 s 17.09%

Every BCG cell captured and replayed the expected serving signature without fallback. I report the high-quality denoise stage because the end-to-end sample included a one-time VAE decode layout transition; it is not used as the PR gate.

Kernel/profile evidence

  • longcat_1024 microbenchmark: 741.28 us split vs 54.46 us fused, 13.61x speedup
  • baseline trace: about 2.0 s in the split chain, including 4k QKNorm calls, 18k copies, 12k muls, 6k adds, 12k cats, and 6k negs
  • PR trace: 177.44 ms total across 4k fused kernel calls; total GPU time dropped from about 8.74 s to 7.20 s

Output comparison

Both pairs are byte-identical. Lossless SHA256: d3984b9dabb610ac73b9c5dc13500b3e607e5f7eed548e2cd2f2d93e3ce3dd6f; high SHA256: b252ce3f2f26d6f6cb97b9d3f4176e5116114d3ac68218d4878eebbdded743f9.

main (quality=high) PR (quality=high)
main PR

Validation

  • test_rope.py + test_model_fast_paths.py: 1298 passed
  • targeted runtime-gate model test: passed
  • pre-commit on all changed files: passed
  • final lossless/high BCG smoke: capture/replay succeeded, exact output hashes, no fallback
  • isolated model caches were deleted after every checkpoint group: 29.32 GB -> 0 bytes for eager, BCG ABBA, and final BCG smoke

CI States

Latest PR Test (Base): ✅ Run #32644133248
Latest PR Test (Extra): ✅ Run #32662477489
Latest PR Test (AMD ROCm 7.2): ⏳ Run #32644133196

@BBuf BBuf added diffusion SGLang Diffusion documentation Improvements or additions to documentation jit-kernel run-ci CI: run the baseline test suite on this PR labels Aug 22, 2026
@BBuf
BBuf marked this pull request as ready for review August 23, 2026 13:09
@BBuf BBuf added run-ci-extra CI: also run the extra suite (requires run-ci) bypass-fastfail labels Aug 23, 2026
@BBuf

BBuf commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci extra

@BBuf
BBuf force-pushed the bbuf/longcat-interleaved-qknorm-rope branch from c1f83ef to bc41a9e Compare August 23, 2026 14:01
@BBuf

BBuf commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

1 similar comment
@BBuf

BBuf commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

@BBuf BBuf added the mergeable label Aug 23, 2026
@BBuf
BBuf merged commit 8dcfb3b into main Aug 24, 2026
331 of 363 checks passed
@BBuf
BBuf deleted the bbuf/longcat-interleaved-qknorm-rope branch August 24, 2026 04:07
longxin9715 added a commit to longxin9715/sglang that referenced this pull request Aug 24, 2026
…n-transport1

* 'main' of https://github.com/sgl-project/sglang: (326 commits)
  [diffusion] feat: cache LoRA-merged weights in files the page cache can hold (sgl-project#36062)
  [diffusion] Speed up LingBot high-quality VAE decode (sgl-project#36024)
  [diffusion] Honor XDG cache for model overlays (sgl-project#36019)
  Support streaming session on NPU (sgl-project#32597)
  fix(xpu): read enable_deterministic_inference from the config bag (sgl-project#36149)
  xeon ci fail fast strategy change (sgl-project#36146)
  [diffusion] Fix Hunyuan QKV pack indexing at production video shapes (sgl-project#36009)
  [diffusion] Refresh quality and BCG benchmark skills (sgl-project#36016)
  [MoE] Gather the cutlass MoE activation and its scales in one launch (sgl-project#34915)
  [diffusion] feat: add plain component weight overrides (sgl-project#36086)
  [diffusion] feat: support loading mixed w4a8 text encoders (sgl-project#36037)
  [diffusion] Default Hunyuan VAE to tiled decode (sgl-project#36012)
  fix(xpu): enable compressed-tensors FP8 W8A8 on XPU (RedHatAI FP8-dynamic models) (sgl-project#33057)
  chore: move cuda_vmm_utils.py under srt/utils/ (sgl-project#36053)
  [Intel XPU] Add xpu pass for biased_topk and hash_topk (sgl-project#33323)
  [CPU] Fix NUMA/core binding for DP ranks (sgl-project#32856)
  [Fix] Harden FlashAttention CUDA graph metadata bounds (sgl-project#35454)
  [XPU] Use a fused GDN kernel from sgl-kernel for Qwen3.5 (sgl-project#33354)
  [diffusion] Fuse LongCat-Image QKNorm and interleaved RoPE (sgl-project#35995)
  [diffusion] Keep LongLive2 components resident on large GPUs (sgl-project#35993)
  ...

# Conflicts:
#	python/sglang/srt/multimodal/processors/base_processor.py
#	python/sglang/srt/server_args.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fastfail diffusion SGLang Diffusion documentation Improvements or additions to documentation jit-kernel mergeable run-ci CI: run the baseline test suite on this PR run-ci-extra CI: also run the extra suite (requires run-ci)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant