Repository navigation
[Perf] diffusion: Turn on breakable CUDA graphs by default for LTX-2/LTX-2.3 two-stage serving - #45977
Merged
Conversation
…-stage serving LTX2TwoStagePipeline stage 1 is ~1.5k tokens and launch-bound; breakable CUDA graphs replay the same kernels, so the output is bitwise equal to eager. The flag stays off everywhere else because the validated-model list records correctness, not speed. - ModelDeploymentConfig.bcg_default_pipeline_class_names: pipelines measured faster with BCG; LTX2PipelineConfig lists LTX2TwoStagePipeline. - enable_breakable_cuda_graph defaults to None. Unset, it turns on in auto/speed mode for an opted-in pipeline on a validated checkpoint when the platform is CUDA with separate host memory, the server warms up at startup (sglang serve), the role is monolithic, ComfyUI mode is off, no torch.compile, Cache-DiT, batching or --lora-path, and both stage DiTs stay resident: no DiT offload or FSDP, a >=130 GiB GPU (the LTX resident rule; capture holds ~7 GB more on Hopper) and LTX-2.3 in resident mode. - BCG warmup captures the full default resolution instead of the 832x480-capped video warmup shape. - External LoRA changes and resume_memory_occupation drop captured graphs: graphs replay capture-time weights and LoRA branches and serving never re-captures, so later requests run eager. Co-Authored-By: Claude Opus 5.5 <[email protected]>
mickqian
requested review from
AgainstEntropy,
BBuf,
HaiShaw,
JustinTong0323,
kevin-mii,
niehen6174,
ping1jing2,
sogalin,
wisclmy0611,
yichiche and
zijiexia
as code owners
October 23, 2026 05:17
Contributor
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Collaborator
Author
|
/tag-and-rerun-ci |
This comment has been minimized.
This comment has been minimized.
This was referenced Oct 23, 2026
Merged
4 of 5 tasks
This was referenced Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
LTX-2 two-stage stage 1 runs at half resolution (~1.5k video tokens), so its step is launch-bound: on 4xB300, TRT-LLM's CUDA-graph configuration runs a stage-1 step in 0.044 s against 0.192 s for sglang eager. Breakable CUDA graphs (BCG) close most of that gap, and the graphs replay the same kernels, so the output is bitwise equal to eager. Today BCG is opt-in, so every flagless LTX deployment leaves this on the table.
BCG stays opt-in everywhere else. The validated-model list records correctness, not speed: FLUX.3 won 1 of 10 cells, Qwen-Image-2.1 on 1 GPU is 0.5% slower, and MiniMax-H3 Ref2VA showed no speedup.
B300 rows: two interleaved rounds, fresh server per arm. H200 rows: see Speed Tests.
Modifications
ModelDeploymentConfig.bcg_default_pipeline_class_names: the pipeline classes measured faster with BCG.LTX2PipelineConfiglistsLTX2TwoStagePipeline; LTX-2.3 inherits it. The field names the pipeline class because one config serves the one-stage, two-stage and HQ pipelines, and only two-stage was measured.--enable-breakable-cuda-graphdefaults to unset._adjust_breakable_cuda_graph_supportresolves an unset flag to on only when all of these hold, and to off otherwise:--performance-modeisautoorspeed;current_platform.is_cuda(), so ROCm, NPU and MPS stay off) with separate host and device memory (GB10 stays off);sglang serve);sglang generateand request warmup would pay a full extra generation;--lora-path;residentmode), and LTX-2.3 inresidentmode.An explicit
--enable-breakable-cuda-graph true|falsealways wins. When the default turns BCG on, the server logs[Diffusion BCG] enabled by default for LTX2TwoStagePipeline; pass --enable-breakable-cuda-graph false to run eager./v1/set_lora, merge, unmerge) orresume_memory_occupationnow drops the captured graphs, and later requests run eager with a warning. The two-stage pipeline's own per-request distilled-LoRA switch is part of the capture and is unaffected.Behavior to know about (one-shot
MISSEDwarning, then eager; no regression against today's eager path):--warmup-num-frames 89. Image-conditioned requests run eager.quality="exact") runs eager; the runners are already keyed per level.Tests:
test_server_args.py::TestBreakableCudaGraphDefault: flagless LTX-2 two-stage serving on a mocked 141 GiB CUDA GPU resolves BCG on and captures 768x512; LTX-2.3 needsresident; explicit off, offline runs, request warmup, memory/manual modes, compile, batching,--lora-path, ComfyUI, one-stage and HQ pipelines, unvalidated checkpoints, every DiT offload form, low free memory and an 80 GB card resolve it off; ROCm (is_cuda()false) and shared-memory devices stay off; explicit on elsewhere is unchanged.test_cfg_parallel_warmup.py::test_bcg_capture_keeps_the_full_default_video_resolution.test_diffusion_bcg_padding.py::TestBCGWeightChangeAfterCapture:set_lora, merge, unmerge andresume_memory_occupationdrop the graphs, and the runner then runs eager.On main the default-on, platform-gate, capture-shape and graph-drop tests fail; the gate-off cases pass there by construction and guard the gates from here on.
Accuracy Tests
LTX-2 two-stage on 2xH200, CFG parallel, the benchmark-default command (
--performance-mode speed), seed 42, 768x512x121. Same MP4 bytes and same decoded-frame md5 for every arm:742a1862…--enable-breakable-cuda-graph false742a1862…742a1862…quality="exact"MISSED)/v1/set_loraWith the CI-shaped request (1 second = 25 frames,
quality="exact",--warmup-num-frames 25 --warmup-sampling-params '{"quality": "exact"}'), BCG, eager and main also produce identical outputs.Speed Tests and Profiling
LTX-2 two-stage, 2xH200, CFG parallel, the benchmark-default command (
--performance-mode speed --dit-layerwise-offload false --enable-torch-compile false, no BCG flag), 768x512x121, 40 steps. diffusion-bench-frameworksingle_e2e(median of 2 measured requests after warmup), fresh server per run, rounds interleaved main / PR / main / PR:Stage breakdown (round 2):
LTX2AVDenoisingStage5.368 → 3.702 s,LTX2RefinementStage1.187 → 1.096 s, decode unchanged (0.67 s). On Hopper the FA attention calls stay eager, so each forward captures 289 segments; on B300 LTX attention is captured as well (1 segment per forward), which is why the gain there is about twice as large.Cost on 2xH200, this PR with and without
--enable-breakable-cuda-graph false, two alternating rounds:--enable-breakable-cuda-graph falseStartup grows by about 6 s once caches are warm (about 20 s on a cold first start), and peak memory by 6.9 GB. On B300 the same comparison was +2 s and +0.95 GB (LTX-2) / +1.1 GB (LTX-2.3).
CI and baselines
No perf or memory baseline should move:
test_diffusion_bcg_*zimage_turbo.py) are image models; the warmup-resolution change only affects video.Risks
Checklist
🤖 Generated with Claude Code
CI States
Latest PR Test (Base): ✅ Run #39950830926
Latest PR Test (Extra): ❌ Run #39950830821
Latest PR Test (AMD ROCm 10): ❌ Run #39950830987