Skip to content

[diffusion] Support BCG for LTX-2.3 / LTX-2.5 - #42928

Closed
niehen6174 wants to merge 14 commits into
sgl-project:mainfrom
niehen6174:ltx-bcg-ci
Closed

niehen6174 wants to merge 14 commits into
sgl-project:mainfrom
niehen6174:ltx-bcg-ci

Conversation

@niehen6174

@niehen6174 niehen6174 commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Breakable CUDA graphs (BCG) did not take effect for LTX-2.3 serving. Requests ran eager, and nothing in the log said so:

  • The stage-1 guided passes (STG / modality, split and batched) called the DiT directly instead of going through the BCG runner.
  • Warmup did not carry the request's guider params, so it captured the official-CFG signatures that serving never replays.
  • The STG perturbation mask was built with a host-to-device copy, which is illegal inside a graph capture.

LTX-2.5 was not on the BCG allowlist at all.

At typical sizes LTX is host-bound: a denoising step issues 36k (LTX-2) to 76k (LTX-2.3) PyTorch ops, so the GPU waits on the CPU. BCG replays each step's DiT forward from captured graphs, which cuts host ops per step about 10x with bit-identical output.

Modifications

  • LTX-2.3 guided passes go through the BCG runner (_ltx2_call_current_model).
  • LTX-2.3 warmup carries the request's guider params, so warmup captures the signatures serving uses.
  • The STG perturbation mask is filled on device.
  • LTX-2.5 is added to the BCG allowlist.
  • The LTX-2 / LTX-2.3 and LTX-2.5 cookbook pages document BCG and its warmup rules:
    • Warm up at the served shape.
    • Name a warmup image for image-conditioned requests.
    • Warm up at the request's quality level.
    • Keep the DiT resident, since graphs hold its weight addresses.
  • Unit test: the LTX-2.3 warmup request carries the stage-1 guider params.

CI cases are unchanged.

Validation

H200 with the H100 setup emulated: 80,900 MiB free per GPU and original two-stage mode. Each run is a CI case with BCG enabled and warmup at the case's shape. Per-step times are not H100 numbers.

Eager vs BCG, 2 runs each, before merging the latest main:

Case Step eager -> BCG E2E eager -> BCG Peak reserved / allocated, BCG (MiB) BCG output vs eager
ltx_2_two_stage_t2v 150 -> 43 ms 7.56 -> 2.87 s 60,002 / 56,645 byte-identical
ltx_2.3_two_stage_t2v_2gpus 179 -> 76 ms 7.02 -> 3.53 s 61,584 / 58,281 byte-identical
ltx_2_3_two_stage_ti2v_2gpus 334 -> 93 ms 11.79 -> 4.10 s 63,236 / 58,319 byte-identical
ltx_2.3_one_stage_ti2v 643 -> 407 ms 20.61 -> 13.12 s 55,332 / 51,746 byte-identical
ltx_2_3_hq_pipeline 896 -> 600 ms 17.52 -> 13.20 s 70,576 / 65,738 byte-identical
ltx_2_5_diffusion_decoder_2gpus 284 -> 147 ms 6.69 -> 5.75 s 71,064 / 69,968 byte-identical

The LTX-2.5 run keeps its DiT resident.

  • Graphs replay in serving: the profile of steps 3-4 shows 289 graph launches per DiT call.
  • Host ops per step drop from about 41k to 2.4k (LTX-2.3 t2v) and from 36k to 3.6k (LTX-2).
  • All cases pass consistency against the H100 GT, except HQ, which already fails in eager on H200. Its BCG output is byte-identical to eager.

After merging the latest main, BCG on the same setup:

Case Graph captures / signature misses Median step E2E Consistency
ltx_2.3_two_stage_t2v_2gpus 3 / 0 76.3 ms 3.54 s pass, md5 equal to eager
ltx_2_3_two_stage_ti2v_2gpus 5 / 0 92.3 ms 4.10 s pass
ltx_2_5_diffusion_decoder_2gpus 2 / 0 151.1 ms 5.20 s pass

test_cfg_parallel_warmup.py passes (54 tests).


CI States

Latest PR Test (Base): ❌ Run #37744453945
Latest PR Test (Extra): ❌ Run #37744453456
Latest PR Test (AMD ROCm 10): ❌ Run #37744453853

Motivation: the stage-1 guided passes (STG / modality) called the DiT
directly, so LTX-2.3 serving never replayed breakable CUDA graphs.

Modifications: send the legacy, split and batched guided passes through
_ltx2_call_current_model.

Validation: serving replays graphs (289 launches per DiT call) and the
output is byte-identical to eager.
Motivation: the batched STG mask was built with a host-to-device copy,
which fails breakable CUDA graph capture.

Modifications: fill the mask on device; values are unchanged.

Validation: the mask equals the old one and captures in a CUDA graph.
Motivation: warmup requests lacked the stage-1 guider params, so BCG
captured only official-CFG signatures that serving never uses.

Modifications: add the request extras to LTX-2.3 synthetic warmup.

Validation: unit test; serving replays the captured guided graphs.
Motivation: LTX-2.5 CI is host-bound like LTX-2 / LTX-2.3.

Modifications: add LTX-2.5 to the BCG model and pipeline-config lists.

Validation: with the DiT resident, serving replays graphs and the output
is byte-identical to eager.
Motivation: LTX CI cases are host-bound at CI sizes, so host slowdowns
push step time over the limits.

Modifications: enable BCG on the LTX-2, LTX-2.3 and LTX-2.5 cases, with
warmup at the request shape, input image and quality=exact. LTX-2.5
keeps its DiT resident, since graphs hold weight addresses.

Validation: per-case eager vs BCG; outputs are byte-identical.
Motivation: CI now runs LTX with BCG, so the cookbook should recommend it.

Modifications: add BCG sections with the warmup rules to the LTX-2 /
LTX-2.3 and LTX-2.5 pages.

Validation: docs only.
Motivation: BCG adds a graph memory pool, and LTX-2.5 now keeps its DiT
resident, so the LTX VRAM peaks and the LTX-2.5 load time exceed their
tolerances.

Modifications: set the runtime VRAM peaks of the six LTX cases, and the
load / warmup peaks and load time of LTX-2.5, with about 5% headroom.
Other timing baselines are unchanged; BCG only makes the cases faster.

Validation: peaks measured on H200 with H100 free memory emulated; the
emulated load peaks match the current H100 baselines exactly.
@github-actions github-actions Bot added documentation Improvements or additions to documentation diffusion SGLang Diffusion labels Oct 7, 2026
@niehen6174
niehen6174 marked this pull request as ready for review October 7, 2026 07:34
@niehen6174 niehen6174 changed the title [diffusion] Run LTX CI cases with breakable CUDA graphs [diffusion] Support BCG for LTX-2.3 / LTX-2.5 and run LTX CI with BCG Oct 7, 2026
@niehen6174

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Oct 7, 2026
Motivation: with the DiT resident, LTX2TextConnectorStage waited for the
text encoder's 24 GB device-to-host offload (317 ms baseline, 843-963 ms
on H100 CI).

Modifications: use text_encoder=snapshot-offload, which drops the device
copy without copying it back to the host.

Validation: H200 with H100 free memory emulated, BCG x2:
LTX2TextConnectorStage 595 -> 14 ms, TextEncodingStage unchanged
(516 -> 521 ms), same VRAM peaks, output byte-identical.
Motivation: the warmup resolutions and frame counts in the LTX cases read
like changed CI request shapes.

Modifications: comment that they restate the shape each request already
resolves to and only configure warmup.

Validation: comment only.
@niehen6174 niehen6174 added the highest-priority CI: all three control labels, plus never batch-cancelled or stale-closed label Oct 7, 2026
# Conflicts:
#	python/sglang/multimodal_gen/test/server/perf_baselines/h100.json
@niehen6174 niehen6174 changed the title [diffusion] Support BCG for LTX-2.3 / LTX-2.5 and run LTX CI with BCG [diffusion] Support BCG for LTX-2.3 / LTX-2.5 Oct 8, 2026
@niehen6174 niehen6174 removed the highest-priority CI: all three control labels, plus never batch-cancelled or stale-closed label Oct 8, 2026
detain added a commit to detain/sglang that referenced this pull request Oct 8, 2026
…project#42928)

Squash of 10 commits 15c51f5..23afdf8 (net diff from PR base
785005d applied cleanly with git apply -3). Routes LTX-2.3 guided
passes through the BCG runner, builds the LTX-2 STG mask on device,
warms LTX-2.5 on the guided path, allows BCG for LTX-2.5 in
server_args, CI case + cookbook doc updates. Coexists with our
sgl-project#32513/sgl-project#40755 ltx_2.py picks without conflict.

Tests: test_cfg_parallel_warmup.py 52 passed; unit -k ltx 135 passed.
@niehen6174

Copy link
Copy Markdown
Collaborator Author

Closing this in favor of #43667, which makes the same changes (routing the LTX-2.3 guided passes through the BCG runner, carrying the guider params into warmup, building the STG mask on device) and more; the two conflict. LTX-2.5 can already turn on BCG on main since #43568, which keeps unvalidated models enabled with a warning.

@niehen6174 niehen6174 closed this Oct 13, 2026
detain added a commit to detain/sglang that referenced this pull request Oct 15, 2026
…ject#4

Conflict resolutions (35 files), preserving stack behavior:

srt/utils/common.py: make_layers — folded our per-layer empty_cache body
  INTO upstream's stage-binding build() (layer_stack refactor sgl-project#43453-43460).
  Upstream removed is_building_neighbour_layer/building_neighbour_layer
  entirely (our earlier sgl-project#42481 pick); only user was qwen4_exp.
srt/models/qwen4_exp.py: import unions (cached_property/partial/TYPE_CHECKING,
  linear_attn_parallel_group); dropped dead is_building_neighbour_layer import;
  prefetch_stream keeps our _graph_prefetch_buffer line with upstream's
  ple_offload_embedding conditional; our PLE host-staging design kept
  (_offloads_ple guard moot under new stage facts).
srt/managers/cache_controller.py: upstream sgl-project#43550 absorbed our sgl-project#39830
  prefetch-degrade fixes; took upstream restructure, deleted auto-merge's
  stale duplicate tails (double-ack/deadlock hazard), kept our rationale
  comments. Fenced start_writing + load_fence_stream survive.
srt/mem_cache/hybrid_cache/hybrid_cache_controller.py: same pattern;
  sidecar degrade comment updated ('upstream adopted unconditionally').
model_executor/pool_configurator.py: UNION draft-cell sizing — our FP4
  _compute_eagle_fp4_draft_cell_size branch + upstream HiSparse
  draft_loc_space_scale else-branch. b05a7c1 None layer_info guard intact.
srt/layers/attention/qsa/sparse_attn.py: kept OUR FP8-descale chunk loop
  (superset; upstream sgl-project#41933 only re-commented); took upstream
  _pack_qsa_prefill_kv + pack_qsa_prefill_kv; our ck interface keeps
  k_scale/v_scale/max_q; __all__ union.
qsa/mqa.py: import functools + min_scored_len kwarg into our triton-first
  _resolve_mqa_backend dispatch; upstream ctas_per_row rework kept.
qsa/qsa_indexer.py: batch-invariance gate moved INTO upstream's shared
  use_fast_topk predicate.
qwen_sparse_attn_backend.py: imports union; gather path UNION — upstream
  pack_qsa_prefill_kv used when scales are unit (QSA stores unscaled K/V),
  our index_select fallback when checkpoint k/v descales != 1.0.
managers/schedule_policy.py: add_chunked_req UNION — upstream slot-reserve
  gate first, then our prefill_chunk_alignment truncation (monotone-safe);
  all 3 alignment sites (1177/1340/1608) intact.
managers/tokenizer_manager.py: import unions (PositionalEmbedsTransport +
  RequestPreprocessor + watermarking fns).
entrypoints/openai/serving_base.py: kept OUR request_preprocessor.run path.
model_executor/runner/eager_runner.py: took upstream TCPCG eager-fallback
  removal (sgl-project#42287); kept our shared cp_extend_forward call shape (our
  runner_utils/cp_extend.py is byte-equivalent to upstream's
  _execute_extend_cp — single source of truth).
runner/flashinfer_autotune.py: import union (can_run_dummy_draft_extend +
  cdiv/ceil_align + upstream get_eager_max_batch_size sgl-project#43789).
arg_groups/model_hook.py: Gemma4 accepted_backends union fa4 + flashinfer
  (NVFP4-KV enablement).
multimodal_gen/runtime/layers/lora/linear.py: KEPT OUR sgl-project#37460 pipeline
  structure; upstream runtime_lora_scale==0 early-return ordering adopted;
  _add_lora_delta/_add_lora_output_offset wired into pipeline; kept
  UPSTREAM's quality-tiered _scale_lora_delta (deleted our simple variant).
  DEBT: upstream RowParallel bias_in_gemm lossless opt not ported (perf-only).
multimodal_gen/runtime/layers/attention/layer.py: _gather_sharded_sequence
  took upstream sgl-project#43793 .contiguous() fix (subsumes our 55aaa02 guard);
  our _forward_with_kv_gather k/v guards kept (separate path, not covered).
configs/pipeline_configs/base.py + configs/sample/minimax_h3.py + envs.py:
  unions (supports_continuous_batching / teacache_params+fields /
  SGLANG_TEACACHE_CALIBRATE).
models/dits/ltx_2.py mask-fill: took upstream (identical to our fix).
ltx_2/denoising.py: took upstream pass_specs (sgl-project#43667) — subsumes our
  legacy one-stage branch; our _ltx2_model_forward_context helpers already
  upstreamed (entry-142 sgl-project#42928 CONFIRMED SUPERSEDED).
ltx_2/decoding_av.py: KEPT OUR split-stage AV decode (independent pool
  scaling) over upstream single-class restructure; adopted upstream
  chunked pinned-memory _postprocess_video; TODO(merge-4): upstream
  EncodeWhileDecoding streaming + rank-0 retain gating not ported.
kernels/ops/diffusion/activation/silu_mul_bitexact.py: our out= column-slice
  support + XPU guard UNION with upstream @replay_launches (sgl-project#43859).
kernels/ops/diffusion/README.md + docs performance-optimization.mdx: unions.
rust/sglang-renderer: ACCEPTED upstream crate removal (sampling.rs git rm);
  our sgl-project#42779 top_k vocab-bound port moves to sglang-server message/sampling.rs
  (follow-up).
Tests: anthropic test_serving — UNION fake-class exception param + our
  request_preprocessor stubs, took upstream's _FakeNonStreamingOpenAI removal
  (68 pass). test_server_args — union both new tests (pre-existing GPU-only
  collection ENV fail unchanged). test_lora_inference_mode — took upstream
  sgl-project#43028 runtime_scale+quality-tier test (supersedes our adapted variant;
  our kept quality-tiered _scale_lora_delta satisfies it).
  test_fused_moe_triton_config — kept our int4-filename + RTX-PRO-6000 JSON
  tests despite upstream sgl-project#43503 test-drop. test_hicache_file_lru_unit —
  union our corrupt-page-degrade class + upstream sgl-project#42077 uncached-batch test
  (40 pass). test_hicache_host_register — upstream alias host_common.
  test_cuda_graph_setup — took upstream rewrite of our override-decode-runner
  test into draft-local-capture-sizes test (sgl-project#43303 API).

Verified auto-merged stack markers survived: flashinfer_backend KVLocPlan/
prefill_wrappers_ragged/NVFP4-KV forwarding, memory_pool set_kv_buffer_prefix_valid,
fp8 grouped_moe kwarg, fp8_utils reshape fix 3642490, SGLANG_QWEN4_PLE_FILE_REUSE,
schedule_batch freed_rows fix, prefill_chunk_alignment sites, sgl-project#42736 autotune
default-on, PCIe-IPC vocab gathers, flashinfer 0.7.1 pin taken (NOT installed).

Co-Authored-By: Claude Opus 5.5 (1M context)
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 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