Repository navigation
[Diffusion] DAG-based disaggregation: replace the fixed 3-stage role orchestration with a declarative topology scheduler - #32550
niehen6174 wants to merge 14 commits into
Conversation
Introduce a declarative DAG package so diffusion disaggregation can express named pools, conditional routes, and fan-out/join without the fixed encoder/denoiser/decoder role model.
…protocol Add topology loading and result-endpoint derivation, DAG server/worker launch helpers, and transport protocol/codec updates needed by named DAG nodes. Drop the unused mock transfer-backend CLI choice.
…estScheduler Replace the fixed three-role orchestrator queues with DAG scheduling, teach workers fan-out staging/recv by edge, and let pipelines filter stages from the compiled plan while keeping classic deployments working.
Ship linear and conditional-join example topologies for Z-Image, with unit tests that compile the plans and assert resolution-based routing.
Teach the test harness to render --disagg-dag topologies and multi- instance GPU layouts, and add a Z-Image DAG smoke that mirrors the classic 1-rank layout.
Bring back LTX topology compile/layout unit tests alongside the Z-Image examples so shipped DAG configs stay validated without requiring GPU e2e.
Keep only the baseline ltx2_dual_vae.yaml in shipped topology tests until the multi-GPU layouts are ready to land with e2e coverage.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Allow video/audio VAE stages to run as independent DAG nodes and wire generate_audio through the OpenAI video API for conditional audio pruning.
Cover denoiser fan-out, muxed AV output, generate_audio=false pruning, and stage-plan split on the 4-GPU ltx2_dual_vae topology.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Use a colocated 2-GPU layout so the LTX dual-VAE pytest fits the existing multimodal 2-gpu suite, and move LTX topology stage-coverage checks into unit tests.
Avoid building the pipeline during topology validation so large models like LTX-2 do not require weight loading or distributed init; stage coverage remains enforced by unit and E2E tests.
Add the required blank line between imports and module-level constants.
The LTX dual-VAE e2e no longer sets MC_FORCE_TCP=1 in setUpClass so RoCE hosts can exercise real Mooncake RDMA when MC_GID_INDEX is set. Document RoCE GID setup and reserve MC_FORCE_TCP for TCP-only runs.
Resolve decoding_av.py by keeping dual-VAE stage split and adopting main's autocast_context helper for video/audio decode paths.
|
/tag-and-rerun-ci |
mickqian
left a comment
There was a problem hiding this comment.
The 14:30 UTC CI follow-up snapshot reported conflicts with main on this head; the latest query is UNKNOWN, which does not confirm resolution. I do not have push access to the fork. Please merge main and resolve the conflicts before final CI. The missing run-ci label has been restored and verified via one trigger comment; no duplicate trigger is needed.
Replace the three-role DiffusionServer with a plan-driven DAG router: topology YAMLs (configs/disagg_topologies/), runtime/disaggregation/dag/ (plan/spec/predicate/scheduler/state), per-node result demux, edge transfer state machine, and conditional-join/linear example topologies. LTX-2 AV decoding splits into LTX2VideoDecodingStage / LTX2AudioDecodingStage so a dual-VAE topology can scale them independently (ltx2_dual_vae.yaml). Squash of sgl-project#32550 (13 commits, base 2026-07-29) applied with git apply -3; conflict resolutions vs the evolved tree: - orchestrator.py: taken wholesale from the PR (14 conflicts). Our Sep/Oct additions (GLM AR-batch dispatch/monitor machinery and _deserialize_request_metrics in result-frame handling) are NOT re-ported: the DAG router has no equivalent hooks yet. - launch_server.py: DiffusionServer -> from_classic_args at both classic call sites; dropped server_args=/glm_distributed_mode_enabled= kwargs (new signature is plan-only); generalized warmup_mode by plan.is_source; dag_validate gate before plugin hooks; KNOWN REGRESSION guarded: GLM distributed denoiser mode (GlmImagePipeline + --srt-encoder-url without encoder/decoder urls) now raises NotImplementedError in launch_disagg_server instead of silently mis-routing. - scheduler_mixin.py: PR's node-based worker rewrite as base; grafted our features: _advertised_pool_work_endpoint for TransferRegisterMsg, GLM distributed relay_compute prefetch handler + _execute_glm_distributed_denoiser_request + _is_glm_distributed_mode, _broadcast_recv_reqs (called from managers/scheduler.py), extract/restore_extra_tensors overlay, broadcast_pyobj import path fix, TransferStagedMsg dataclass (with node=) replaces hand-built staged JSON in _disagg_stage_and_notify. - transport/protocol.py: node field added to staged message (kept our default_factory scalars). - decoding_av.py: PR's video/audio stage split rebuilt on top of our LTX-2.5 evolution: module-level _decode_video keeps the batch.use_diffusion_decoder branch (diffusion decoder + generator seed, resolve_decode_precision) and _prepare_latents denorm; the DAG video node also receives diffusion_decoder from the pipeline (ltx_2_pipeline.py). _decode_audio_into + audio/AV classes per PR. - video_api.py: kept our kwargs-dict shape; generate_audio forwarded via _extra_value like other optional overrides. - docs path: none needed (PR carried no doc moves); topologies yaml landed. Verified: py_compile of all 23 touched py files; import smoke of orchestrator/scheduler_mixin/dag/decoding_av; test_dag_disagg.py 34 pass; unit disagg suite (extra_tensors/roles/trace) 54 pass 3 skip. GPU e2e (disagg servers) deferred - prod GPUs busy.
sgl-project#32550's orchestrator rewrite dropped _deserialize_request_metrics and the metrics scalars from the terminal result path (known regression + broke test_performance_metrics.py import). Restores the helper, forwards metrics/metrics_list/peak_memory_mb/usage from terminal scalar_fields, exempts them from per-node emit allowlists (any terminal may carry them; first-wins), and populates OutputBatch as the classic path did.
… of sgl-project#33036) Squash of 14 commits 5d2f658..12e5682 (net diff from PR base 1270204 applied with git apply -3). Adds --parallel-stage-execution {auto|serial} (default serial): parallel_executor builds groups from stages declaring concurrency safety and overlaps independent CUDA conditioning stages (Wan I2V text+image encoders first), with explicit collective sequencing for distributed, residency-manager coordination in component_manager, and stage-contract markers in stages/base.py, text_encoding.py, image_encoding.py + per-pipeline declarations. Conflict resolutions: - component_manager.py imports: union (theirs threading + ours Iterable). - cli.mdx: kept our fuller cfg-parallel/encoder-parallel bullets, appended theirs' new --parallel-stage-execution bullet. - composed_pipeline_base.py (which carries our sgl-project#32550 DAG hooks) and parallel_executor.py auto-merged cleanly; re-verified by tests. Tests: test_parallel_stage_groups.py + test_server_args.py 221 passed; unit -k "pipeline or executor or component or residency or stage" 651 passed.
… of sgl-project#43064) Squash of 13 commits 48c3a28..da3d8c6 (PR rebased onto main tip 407f7f0; net diff via git apply -3). Removes rethrow-only wrappers, obsolete channels_last_3d/sinc fallbacks, identity assignments; shares BCG model unwrapping, component-name normalization, and LLM-encoder weight loading (load_llm_encoder_weights). Conflict resolutions: - encoders/llama.py + qwen3.py: took theirs (shared helper call). Ported load_stacked_weight() def from merged upstream sgl-project#42988 (not in our tree) into weight_utils.py as the helper's dependency. - layers/lora/linear.py: kept OURS in all 4 blocks — our sgl-project#37460 rework already removes the per-class inits/forwards this PR targets; the one clean hunk (redundant LinearWithLoRA.__init__) applied. - disaggregation/orchestrator.py: kept OURS (file is our sgl-project#32550 DAG rewrite; the PR's receiver-dispatch dedupe targeted old main shape). Net file unchanged. - Skipped two PR file-hunks outright: vaes/alias_free.py and model_specific_stages/kandinsky6/decoding.py exist only upstream of our merge-base (not in this tree). Tests: py_compile all; unit -k lora/encoder/padding/breakable/vision/ transfer 347 passed; weight_utils runai-module failures pre-existing (env lacks runai_model_streamer), file untouched by PR.
|
The implementation here is fairly complex, so I am closing this for now. We can pick it up again when there is a concrete need. |
Motivation
1.1 Today: a fixed 3-stage role orchestration
The current diffusion disaggregation (#21701) hardcodes the pipeline into
Encoder → Denoiser → Decoderwith exactly threeRoleTypes, driven by a linear state machine where a request advances along a single fixed path. This is structurally limiting in three ways:if role == ...branches.DiffusionServeris a single-point dispatcher with fixed pool membership.Figure M1 — The fixed 3-stage baseline vs. the three requirements real models cannot express (fan-out/join, conditional routing, too many stages).
1.2 Real models can't be expressed
LTX-2, a realistic video/audio model, needs three things a fixed 3-stage line cannot express:
when: "generate_audio"; likewise super-resolution runs only for high-res requests (width*height > 1920*1080), otherwise the edge is pruned.In short, the topology itself must become a first-class citizen — nodes, pools, and edges as declarative config, not scattered
if/else.1.3 Target topology: LTX-2 as an example
We want one declarative topology to describe the diagram below: multiple named pools, the denoiser fanning out to two VAEs (the audio branch a conditional edge), both VAEs as their own terminal sinks, with the orchestrator merging video/audio into one mp4 via ffmpeg outside the graph.
Figure M2 — The real LTX-2 topology: the denoiser fans out to two terminal VAEs (audio is a
when: generate_audioconditional edge). No in-graph mux node; merging is done outside the DAG via ffmpeg.2. Design
After the change, the system consists of three planes:
ExecutionPlan.DagRequestSchedulermakes decisions using per-requestRequestDagStateledgers.The orchestrator is reduced to a thin shell that only does I/O and makes no decisions. The overview below places
ExecutionPlan/State/Schedulerback into their real positions across the three planes.Figure D2 (chapter overview) — Three-plane view: the Spec becomes a read-only Plan at compile time; on the control plane the Scheduler makes decisions using per-request State while the Orchestrator only performs I/O; on the data plane tensors are transferred directly between worker pools via RDMA, with the denoiser fanning out to the video / audio VAE pools.
2.1 Four-layer data structure: Spec → Plan → State → Action
The core design splits orchestration into four layers with single-direction dependency and orthogonal responsibilities. Upstream only depends on downstream and never the reverse, so each layer can be tested independently:
user-written
dag/spec.pyRoleSpec/PoolSpec/StageSpec/RouteSpec/DagSpec, describes what the topology "looks like"; loadable from YAMLcompiled
dag/plan.pyExecutionPlan+CompiledNode/CompiledEdge, pre-computes derived values (in/out_degree, capability bits, AST predicates, stage_owner); zero runtime parsing, pure lookupsper-request ledger
dag/state.pyRequestDagState: node_status, remaining/arrived_inputs, pending_pushes, route_ctx, partial_output — only records "where this one request is"instruction
dag/scheduler.pySourceDispatch / EdgeTransfer / CompleteRequest / FailRequest, the instructions the Scheduler hands to the thin shell to executeFigure D1 — The four-layer data structure: Spec describes the shape → Plan is the pre-compiled truth → State is per-request progress → Action is the instruction.
2.2 Compile once, read-only twice: control and data planes share one Plan
The key design, visible in the overview above: compilation happens once at startup and produces an immutable
ExecutionPlan. From then on both runtime planes share it read-only (the two upward dashed references in the diagram):Neither plane ever re-parses the topology; both do O(1) lookups against the shared Plan. This is the key to zero runtime parsing.
2.3 Compile pipeline: bad topologies fail at startup
ExecutionPlan.compile(spec)is the single entry point and a pure function (no I/O). Predicates are parsed into ASTs at compile time; errors are accumulated and raised all at once at the end asPlanValidationError. As a result the runtime can trust the Plan unconditionally — zero parsing, pure lookups:Figure D3 — The 7-step compile pipeline + validation: errors are accumulated and raised together; a bad topology fails at startup, never at runtime.
2.4 State / Scheduler are orthogonal
DagRequestScheduler) — the single "brain" in the process, a pure function with no I/O. It holds the global resources (free_slots / policies / ready / states) and answers "who can occupy which slot on which instance right now, and what Action to emit next".RequestDagState) — a per-request ledger that answers "where this one request is".The two are orthogonal: the Scheduler does not track single-request progress, and a State does not know about other requests' occupancy.
2.5 Four Actions → Orchestrator loop
The Orchestrator (
DiffusionServer) is the only thin shell that touches I/O. The pattern is alwaysactions = scheduler.on_*(...)→_execute(actions):Figure D4 — The four-Action loop: the Scheduler produces instructions → the Orchestrator thin shell performs the real I/O → worker reports flow back.
2.6 Concurrency semantics: fan-out / join / conditional routing
pending_pushesis a reference count, and the producer slot is released only when it reaches zero;filter_manifestshares the underlying bytes to avoid multiple copies. In LTX-2 a single denoiser staging feeds bothvae_videoandvae_audio.arrived_inputs == expected_inputs; pruned edges also count as resolved, which is the core of deadlock avoidance; currently onlyjoin: allis supported (anyis rejected at compile time). A typical example isconditional_vsr:vae_videohas two inbound edges (from denoiser / from vsr) whose predicates are complementary, so exactly one is always pruned — precisely because pruned counts as resolved, the join never waits forever.RouteSpec.whenuses an AST allowlist interpreter (noteval) to evaluate the request's scalar metadata (such asgenerate_audio,width*height) on the orchestrator side; a false edge is_prune_edged, and when all inbound edges of a node are pruned it is markedSKIPPEDand pruning cascades.Figure D5 — Concurrency semantics: fan-out (ltx2, reference counting controls slot release) and join (conditional_vsr, complementary predicates always prune exactly one edge; pruned counts as resolved to avoid deadlock).
2.7 Removing RoleType: capability bits
The runtime no longer has
if role == ENCODER / DENOISER / DECODER; instead it does O(1) capability queries against the Plan:is_source,is_terminal,is_sender(out_degree > 0),is_receiver(in_degree > 0),needs_scheduler_init. As a result a single topology can have multiple "scheduler-needing" nodes (such as LTX-2's stage1/stage2) — something the three enumerated roles cannot do, but a graph can.3. Implementation
3.1 New modules and changed files
New
runtime/disaggregation/dag/):spec.py(4 config classes + YAML/JSON loading),plan.py(ExecutionPlan.compile / from_classic_roles),predicate.py(AST allowlist predicates),state.py(RequestDagState),scheduler.py(DagRequestScheduler+ Actions).configs/disagg_topologies/{ltx2_dual_vae, conditional_vsr, zimage_linear}.yaml.test/unit/test_dag_disagg.py,test/single_test_file/test_disagg_ltx2_dag.py.docs/dag-disagg-implementation.md.Modified
orchestrator.py(rewritten, removed the three-role hardcoding, ~ -1254 lines),scheduler_mixin.py.transport/{protocol,engine}.py,launch_server.py,server_args/disagg.py.composed_pipeline_base.py,ltx_2_pipeline.py+decoding_av.py,video_api.py.3.2 CLI / deployment changes & backward compatibility
--disagg-dag(topology file or inline),--dag-node(this worker's node name),--dag-validate(validate and exit).--encoder/denoiser/decoder-urlsdeployment is unchanged — it goes throughfrom_classic_args()and compiles into a linear DAG.Figure I1 — Two entry paths converge: both the classic CLI and the DAG topology compile into the same ExecutionPlan, leaving a single code path at runtime.
4. Example & Test
4.1 Three-tier test pyramid
Figure T1 — The three-tier test pyramid: A compile/validate (CI, no GPU) → B scheduling semantics (mock, seconds) → C end-to-end (multi-GPU); every requirement is covered by ≥ 2 cases.
(every commit)
from_classic_args()is equivalent to running them directly (top priority)(mock, seconds)
generate_audio=falsethe audio edge is pruned; in conditional_vsr,width*height≤1920*1080takes the direct edge, otherwise it goes through VSR, and both branches converge tovae_video(nightly/manual)
consistency_thresholdsproving the output was not broken4.2 Example walkthrough: LTX-2 dual-VAE disaggregation (4 GPUs)
This section shows how to run a DAG deployment end-to-end: validate the topology, start the orchestrator and workers, and submit a video request.
What you are starting
Topology:
python/sglang/multimodal_gen/configs/disagg_topologies/ltx2_dual_vae_dev.yaml(one URL per pool, no SP). Production-scale multi-replica layout:python/sglang/multimodal_gen/configs/disagg_topologies/ltx2_dual_vae.yaml(§4.7).Prerequisites
sglang/).export MC_FORCE_TCP=1for a TCP-only quick start (no HCA/GID setup), or (B) omitMC_FORCE_TCP, use--net=hostin Docker, and on RoCE setexport MC_GID_INDEX=<global RoCEv2 index>in every shell before launch (index is host-specific; check InfiniBand sysfsgid_attrs/typesandgids). Multi-node production: omitMC_FORCE_TCP, configure--disagg-ib-device, and setMC_GID_INDEXon RoCE.4.3 Step 0 — Validate the topology
Compile the DAG and print the execution plan before allocating GPUs. This checks graph structure (cycles, pools, terminals, predicates). It does not load weights or start services.
Success ends with:
--model-pathresolves the pipeline class name for a quick sanity check. Full pipeline-vs-topology stage matching happens when workers start.4.4 Step 1 — Start the server head
Start the orchestrator first (HTTP front-end + DAG scheduler). Do not pass
--dag-nodeon the head.The head listens for client traffic on port
30000and talks to workers over the pool URLs in the YAML.4.5 Step 2 — Start one worker per DAG node
Open four separate terminals. Each runs one
sglang serveworker on its own GPU. Use the same--model-pathand--disagg-dagon every process.--dag-node--disagg-role--scheduler-portencoderencoderdenoiserdenoiservae_videodecodervae_audiodecoderImportant
--dag-nodedecides which pipeline stages this process runs.--disagg-roleis the legacy launch label; map both VAE nodes todecoder.Role … readyin each log before sending traffic.Terminal 1 — encoder (GPU 0)
Terminal 2 — denoiser (GPU 1)
CUDA_VISIBLE_DEVICES=1 sglang serve \ --model-path Lightricks/LTX-2.3 \ --disagg-role denoiser \ --disagg-dag python/sglang/multimodal_gen/configs/disagg_topologies/ltx2_dual_vae_dev.yaml \ --dag-node denoiser \ --disagg-server-addr tcp://127.0.0.1:35000 \ --scheduler-port 35020 \ --num-gpus 1 --base-gpu-id 0 \ --disagg-transfer-pool-size 1073741824 \ --dit-layerwise-offload trueTerminal 3 — video VAE (GPU 2)
Terminal 4 — audio VAE (GPU 3)
4.6 Step 3 — Submit a request
Video with audio (denoiser fans out to both VAE terminals; head muxes mp4):
Poll
GET /v1/videosuntil the jobstatusiscompleted, then download:Silent video — set
"generate_audio": false. The orchestrator prunes the conditionaldenoiser → vae_audioedge;vae_audiodoes not run for that request.4.7 Scaling beyond the dev example
The checked-in
python/sglang/multimodal_gen/configs/disagg_topologies/ltx2_dual_vae.yamltargets production-scale pools (multiple URLs per node,parallelism: {sp: 2}). To use it as written:--disagg-instance-id= index in the URL list).--num-gpuson each worker to match that pool'sparallelism.sp.See
python/sglang/multimodal_gen/docs/dag-disagg-implementation.mdfor fan-out/join semantics and poolcapacitybehavior.Classic three-role deployment is unchanged — omit
--disagg-dagand use--encoder-urls/--denoiser-urls/--decoder-urlsas before. That path compiles to the same linear DAG aspython/sglang/multimodal_gen/configs/disagg_topologies/zimage_linear.yaml.4.8 Automated tests (optional)
CI and regression coverage live in
python/sglang/multimodal_gen/test/unit/test_dag_disagg.pyandpython/sglang/multimodal_gen/test/single_test_file/test_disagg_ltx2_dag.py. They are not required to operate a cluster manually.Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #30423746530
Latest PR Test (Extra): ❌ Run #30423746193