Skip to content

[diffusion] Fix Hunyuan QKV pack indexing at production video shapes - #36009

Merged
BBuf merged 1 commit into
mainfrom
bbuf/fast-hunyuan-qkv-int64
Aug 24, 2026
Merged

[diffusion] Fix Hunyuan QKV pack indexing at production video shapes#36009
BBuf merged 1 commit into
mainfrom
bbuf/fast-hunyuan-qkv-int64

Conversation

@BBuf

@BBuf BBuf commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • keep Hunyuan QKV-pack row indexing in int64
  • add a production-shaped regression whose merged-projection offset crosses INT32_MAX

Root cause

FastHunyuan at 1280x720x125 frames produces 115,200 image tokens. The merged projection has a 21,504-element row stride, so the final row offset is 2,477,239,296 elements. The Triton program ID was inferred as int32 and overflowed while addressing the strided V view, causing an illegal memory access.

Casting the token index to int64 keeps the derived row-address arithmetic wide without changing the kernel layout or numerics.

H200 validation

  • production shape: FastVideo/FastHunyuan-diffusers, 1280x720, 125 frames, 6 steps, BF16, native SGLang
  • lossless: 103.456 s denoise / 120.824 s saved-request e2e
  • quality=high: 102.366 s denoise / 119.697 s saved-request e2e
  • PyTorch-reference fallback versus fixed kernel ABBA: 121.001 s -> 120.393 s mean e2e (0.505%); all four MP4 files are byte-exact
  • output SHA256: f4a8bffb62398b23e0884ea07b823d5857b436253bf0809fca65a28cf79016e2
  • 41.91 GB isolated model caches were deleted after each model group, with zero weight files left

This is a production-shape correctness fix, not a >=1.5% performance claim.

Tests

  • python3 -m pytest -q test/registered/kernels/ops/diffusion/test_model_fast_paths.py -k hunyuan_qkv_rope_pack (3 passed on H200)
  • pre-commit run --files python/sglang/kernels/ops/diffusion/rope/hunyuan_qkv_pack_triton.py test/registered/kernels/ops/diffusion/test_model_fast_paths.py

CI States

Latest PR Test (Base): ✅ Run #32643228721
Latest PR Test (Extra): ✅ Run #32664629121
Latest PR Test (AMD ROCm 7.2): ⏳ Run #32643228882

@BBuf

BBuf commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci extra

@BBuf
BBuf force-pushed the bbuf/fast-hunyuan-qkv-int64 branch from 495733e to f4c830a Compare August 23, 2026 13:43
@BBuf

BBuf commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

3 similar comments
@BBuf

BBuf commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

@BBuf

BBuf commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

@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 6d40b8a into main Aug 24, 2026
508 of 542 checks passed
@BBuf
BBuf deleted the bbuf/fast-hunyuan-qkv-int64 branch August 24, 2026 05:39
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant