Skip to content

[3/N] elastic-ep: Recapture decode CUDA graphs after scale-up - #33723

Merged
ch-wan merged 30 commits into
sgl-project:mainfrom
zackyoray:elastic-ep-cuda-graph-recapture
Sep 23, 2026
Merged

ch-wan merged 30 commits into
sgl-project:mainfrom
zackyoray:elastic-ep-cuda-graph-recapture

Conversation

@zackyoray

@zackyoray zackyoray commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR follows PR #30553
and adds FULL decode CUDA graph recapture after runtime Elastic EP scale-up.
Primary and joiner ranks rebuild their graphs for the expanded topology before
the new EP size is committed.

The existing scale-up API and EPLB lifecycle are unchanged.

Changes

  • Defer initial decode graph capture on joining ranks until they enter the
    expanded world.
  • Finish the current sampling step, release the old graph state, and rebuild
    decode graphs with the expanded Mooncake WORLD and NIXL rank mask.
  • Require primary and joiner ranks to resolve the same graph mode and capture
    configuration before recapture.
  • Reuse SGLang's existing FULL decode graph initializer and synchronize all
    ranks before committing the scale operation.
  • Add graph-stable FA3 MLA metadata for the validated DeepSeek path.
  • Reject execution modes that do not use the supported decode finalization
    path.

Configuration

Launch primary and joiner groups with the same resolved graph settings:

--cuda-graph-backend-decode full
--cuda-graph-backend-prefill disabled
--cuda-graph-bs-decode 1 2 4 8 16

The scale request and status API are inherited from the base scale-up PR.

Known Limitations

  • Only FULL decode graph recapture is supported. Prefill and piecewise graph
    recapture are outside this PR.
  • Primary and joiner groups must use the same resolved CUDA graph
    configuration and effective capture sizes.
  • Recapture is synchronous. Configuring more decode batch sizes increases the
    scale-finalization pause.
  • The validated DeepSeek MLA path requires FlashAttention 3.
  • Speculative decoding, embedding, diffusion, encoder-only execution, forward
    hooks, and PDMux split-prefill are not supported with Elastic EP recapture.
  • The topology, scale-direction, and post-scale recovery limitations of the
    base scale-up PR still apply.
  • Recapture releases the old decode graph pool before rebuilding. The deployment
    must still leave enough free GPU memory to capture the configured decode graph
    sizes; the manual tests use --mem-fraction-static 0.5.

Test Plan

The manual Elastic EP tests cover direct, single-rank, mixed-cohort, and
repeated scale-up:

  • TestElasticScaleUp4To5CudaGraph
  • TestElasticScaleUp4To6CudaGraph
  • TestElasticScaleUp4To8CudaGraph
  • TestElasticScaleUp4To5To6CudaGraph

Each test captures decode batch sizes 1 2 4 8 16 and checks post-scale
generation, routed joiner traffic, input logprobs, and GSM8K correctness.

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
python -m pytest -v -s \
  test/manual/ep/test_elastic_scale.py::TestElasticScaleUp4To5To6CudaGraph::test_scale_up_on_demand

The repeated 4-to-5-to-6 and direct 4-to-6 validations passed with all five
decode graph sizes captured on every participating rank.

References


CI States

Latest PR Test (Base): ⏳ Run #35830020864
Latest PR Test (Extra): ❌ Run #35830020856
Latest PR Test (AMD ROCm 10): ⏳ Run #35830020903

@zackyoray

Copy link
Copy Markdown
Contributor Author

cc: @ch-wan @UNIDY2002 @ShangmingCai

@zackyoray zackyoray changed the title Elastic ep cuda graph recapture [3/N] elastic-ep: Recapture decode CUDA graphs after scale-up Aug 5, 2026
@UNIDY2002

Copy link
Copy Markdown
Contributor

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Aug 6, 2026
@UNIDY2002

Copy link
Copy Markdown
Contributor

/rerun-failed-ci

4 similar comments
@UNIDY2002

Copy link
Copy Markdown
Contributor

/rerun-failed-ci

@UNIDY2002

Copy link
Copy Markdown
Contributor

/rerun-failed-ci

@UNIDY2002

Copy link
Copy Markdown
Contributor

/rerun-failed-ci

@UNIDY2002

Copy link
Copy Markdown
Contributor

/rerun-failed-ci

@zackyoray

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

3 similar comments
@UNIDY2002

Copy link
Copy Markdown
Contributor

/rerun-failed-ci

@UNIDY2002

Copy link
Copy Markdown
Contributor

/rerun-failed-ci

@UNIDY2002

Copy link
Copy Markdown
Contributor

/rerun-failed-ci

@zackyoray

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@zackyoray

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

3 similar comments
@zackyoray

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@zackyoray

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@zackyoray

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@zackyoray

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

# Conflicts:
#	python/sglang/srt/model_executor/model_runner_components/cuda_graph_setup.py
…20260908

# Conflicts:
#	python/sglang/srt/model_executor/model_runner_components/cuda_graph_setup.py
# Conflicts:
#	python/sglang/srt/model_executor/model_runner.py
@zackyoray

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@zackyoray

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

2 similar comments
@zackyoray

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@zackyoray

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@ch-wan
ch-wan merged commit de123f3 into sgl-project:main Sep 23, 2026
110 of 152 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fastfail run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants