Skip to content

[diffusion] Refactor utility ownership and document helper placement - #38699

Merged
mickqian merged 4 commits into
sgl-project:mainfrom
mickqian:codex/diffusion-utility-ownership
Sep 10, 2026
Merged

mickqian merged 4 commits into
sgl-project:mainfrom
mickqian:codex/diffusion-utility-ownership

Conversation

@mickqian

@mickqian mickqian commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Remove the 794-line top-level utils.py: keep shared parsing, process, and precision helpers in focused modules; put single-consumer helpers back with their callers; remove unused wrappers.
  • Move realtime video, component-loading, attention-mask, and distributed helpers to their owning domains. Remove the LingBot/SANA model-to-stage imports and add a regression guard for that boundary.
  • Document helper placement in the contributor/new-model guides and update the SANA-WM cookbook's source reference.

No CLI flags, deployment defaults, model registry APIs, or ground truths change. Internal utility import paths change without compatibility re-export chains.

Validation

Remote 2x H200, PyTorch 2.13.0+cu130, Diffusers 0.37.0, Transformers 5.12.1:

  • Focused unit suites: 589 passed, 99 subtests passed, 2 skipped. Covers parsing/configuration, precision, parent-process handling, Wan conditioning, FSDP, attention selection, and realtime/SANA paths.
  • Two-GPU NCCL all-to-all, including CUDA Graph capture and replay: passed.
  • sglang generate/serve --help: passed. Native tiny-SD3 public API test (64x64, 2 steps, Ulysses=2, replicated vs folded encoders): passed, SSIM 0.994886 / PSNR 43.625576 / MAD 0.771159 between the two encoder modes.

Two failures reproduce unchanged on base ffe98a4279ba6e42d1f87dc4eeb6edb4887b9ea4:

  • test_auto_ltx_original_replaces_component_cpu_offload: the fixture mocks memory but not the GPU name, so H200 selects resident.
  • test_ipc_matches_nccl_bitwise: AllToAll4D does not increment the IPC exchange counter. The same routing assertion fails on the base.

Neither assertion is relaxed here. Other accelerators and full-size model workloads have not been exercised for this refactor.

Change Size

With rename detection disabled: existing production files +540/-1538 lines; new production files 736 lines (mostly relocated code); tests/docs +200/-81 lines. Production code decreases by 262 lines. This is an ownership refactor, not a performance-speedup claim.


CI States

Latest PR Test (Base): ✅ Run #34372606013
Latest PR Test (Extra): ❌ Run #34372605600
Latest PR Test (AMD ROCm 10): ❌ Run #34372605956

@github-actions github-actions Bot added documentation Improvements or additions to documentation npu diffusion SGLang Diffusion labels Sep 9, 2026
@mickqian mickqian added the run-ci label Sep 9, 2026
@mickqian
mickqian merged commit ce555ed into sgl-project:main Sep 10, 2026
134 of 143 checks passed
pllimax added a commit to pllimax/sglang that referenced this pull request Sep 10, 2026
* origin/main: (27 commits)
  [Simulator] Give the OFFLINE/BLOCKING comparison tolerances real headroom (sgl-project#38732)
  [Config] msgspec.Struct for the config tier (sgl-project#38753)
  [AMD] ci: move the miles nightlies from rocm700 to rocm10 (sgl-project#37495)
  [Config] One writer for the declaration stash; no exception to the write seal (sgl-project#38752)
  docker(xpu): drop redundant setvars.sh from torch_memory_saver RUN (sgl-project#38665)
  [XPU][Fix] Pack device-pointer tables as uint64 to avoid 64-bit address overflow (sgl-project#35051)
  [CI] Temporarily disable GB300 tests (sgl-project#38770)
  [diffusion] feat: spill large tensors over shared memory like numpy arrays (sgl-project#38656)
  [diffusion] refactor: refactor utility ownership and document helper placement (sgl-project#38699)
  [NPU]Support GLM5.2 and FP8 DSA&Indexer kvcache for 950 (sgl-project#38250)
  [CI] Answer unrecognized slash commands instead of skipping silently (sgl-project#38736)
  [AMD] Parallelize aiter spec-decode KV index building over token blocks (sgl-project#37659)
  [DSv4] Integrate TRT-LLM DSv4 Attention for SM100/103 (sgl-project#30805)
  Add Opt-In for GLM-5.3 Flash breakable prefill CUDA graphs (sgl-project#38522)
  [CI] Install helion 1.4.0 for the KDA Helion kernel tests (sgl-project#38688)
  [Rust] Gate health on startup warmup completion (sgl-project#37994)
  [HiCache] Replace skip_lock_node_ids with a segment lock protocol (sgl-project#36848)
  feat: add optimized Domino rollout to DFlash V2 (sgl-project#36899)
  [CI] Add /run-full-ci and /run-extra-ci slash commands (sgl-project#38734)
  [Model] Support GLM-5.3 Flash NVFP4 loading (sgl-project#38621)
  ...
mqhc2020 pushed a commit to mqhc2020/sglang that referenced this pull request Sep 15, 2026
…placement (sgl-project#38699)

Co-authored-by: Mick Qian <mickqian@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

diffusion SGLang Diffusion documentation Improvements or additions to documentation npu run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant