Skip to content

[Refactor] bcg: Delete capture leftovers and rename capture_stub to on_capture - #46792

Merged
hnyls2002 merged 2 commits into
mainfrom
lsyin/bcg-delete-capture-leftovers
Oct 27, 2026
Merged

hnyls2002 merged 2 commits into
mainfrom
lsyin/bcg-delete-capture-leftovers

Conversation

@hnyls2002

@hnyls2002 hnyls2002 commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Since #46719 the capture pass records each graph break without running it. This removes what that left with no effect.

  • Delete the capture stubs that only filled outputs: DeepEP MoE a2a, paged experts, radix linear attention, pooled-indexer prefill, and the CP interleave indexer. Nothing reads those outputs at capture.
  • Delete barrier_fn from BreakableCUDAGraphCapture and its two callers. It synced ranks before break bodies with rank-coupled collectives, and none run at capture now.
  • Delete the capture-var hiding in the DeepSeek V4 decoder tail break. The body never runs while the outer graph captures.
  • Rename capture_stub to on_capture. It now adds host setup at capture instead of replacing the body. The remaining users are the DeepSeek V4 tail enter and exit, the tail source KV layer id, and the Nemotron-H shared-expert side graph.
  • Tests: drop the _barrier_fn mocks and follow the rename.

No behavior change at replay. At capture, ranks no longer barrier at each break, and the deleted stubs no longer write their output buffers.

Known issue on HIP, pre-existing and not changed here: under the breakable prefill graph, the decoder SWA bounded-replay tail is switched in only at capture, not at replay.

  • The HIP backend builds no graph tail metadata at capture (init_forward_metadata_for_breakable_cuda_graph_capture in deepseek_v4_backend_hip_radix.py) and refreshes none at replay, so LateLayerTail.scatter_indices is None and tail_in_graph is False.
  • deepseek_v4.py then takes the eager branch, attn_backend.enter_late_layer_tail(...), which is segment code: it runs while the graph captures and never at replay. Replays reuse the capture batch's tail rows and metadata, and tail_source_kv_layer_id, which the source KV break sets at every replay, is never cleared.
  • CUDA runs this switch as a graph break since [DeepSeek-V4.1] Run decoder SWA bounded replay inside the breakable prefill CUDA graph #43736; the HIP path ([ROCm][DSV4] Enable breakable CUDA graph prefill #37810, dsv4.1-amd: serve DeepSeek-V4.1 on gfx950 #41308) has no counterpart. Not reproduced on AMD hardware.
  • Possible fixes: give the HIP backend the CUDA graph-tail path, or turn decoder SWA bounded replay off on HIP while the breakable prefill graph is on.

Tests run at this head on B300 and GB300 pass:

  • the BCG, eager-on-graph, radix attention, radix linear attention, paged experts and CP strategy unit tests;
  • test_breakable_cuda_graph.py, test_bcg_with_speculative_decoding.py, test_dp_attention_bcg_kl.py, test_bcg_with_lora.py, test_lora_moe_prefill_cuda_graph.py and test_mamba_cache_kl.py;
  • the DeepSeek V4 Flash FP4 tests (TP 4);
  • the DeepSeek V4.1 Flash bounded-tail and encoder BCG tests;
  • the multimodal BCG unit tests and the Z-Image Turbo BCG tests (single GPU and TP 2).

Two tests fail the same way on main: the test_paged_experts.py GPTQ class and one test_deepseek_v41_bcg_multimodal.py case.


CI States

Latest PR Test (Base): 🚫 Run #40585489132
Latest PR Test (Extra): ❌ Run #40585489265
Latest PR Test (AMD ROCm 10): ⏳ Run #40585489123

@hnyls2002
hnyls2002 force-pushed the lsyin/bcg-delete-capture-leftovers branch from 370ad67 to 035c636 Compare October 27, 2026 20:55
@hnyls2002

Copy link
Copy Markdown
Collaborator Author

/rerun-test registered/unit/layers/test_radix_attention.py test_radix_linear_attention.py test_cp_strategy_unit.py test_eager_on_graph.py test_prefill_cuda_graph_runner_helpers.py registered/unit/layers/moe/paged_experts/test_paged_experts.py test_dsv41_late_layer_tail_readers.py registered/cuda_graph/breakable/test_breakable_cuda_graph.py test_bcg_with_lora.py test_bcg_with_speculative_decoding.py test_dp_attention_bcg_kl.py test_mamba_cache_kl.py test_deepseek_v41_flash_gb300_trtllm_bounded_bcg.py test_deepseek_v4_flash_fp4_b200.py test_unified_cache_linker_kl_dsv41.py test_attention_bcg_outputs.py test_qwen_image21.py test_diffusion_bcg_tp_graph_capture.py test_diffusion_bcg_zimage_turbo.py test_diffusion_bcg_tp2_zimage_turbo.py

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🚀 ubuntu-latest (7 tests): ✅ View workflow run

cd test/ && python3 registered/unit/layers/test_radix_attention.py
cd test/ && python3 registered/unit/layers/test_radix_linear_attention.py
cd test/ && python3 registered/cp/test_cp_strategy_unit.py
cd test/ && python3 registered/unit/model_executor/test_eager_on_graph.py
cd test/ && python3 registered/unit/model_executor/test_prefill_cuda_graph_runner_helpers.py
cd test/ && python3 registered/unit/layers/moe/paged_experts/test_paged_experts.py
cd test/ && python3 registered/unit/layers/test_dsv41_late_layer_tail_readers.py

🚀 1-gpu-h100 (3 tests): ✅ View workflow run

cd test/ && python3 registered/cuda_graph/breakable/test_breakable_cuda_graph.py
cd test/ && python3 registered/cuda_graph/breakable/test_bcg_with_lora.py
cd test/ && python3 registered/radix_cache/test_mamba_cache_kl.py

🚀 2-gpu-h100 (2 tests): ✅ View workflow run

cd test/ && python3 registered/cuda_graph/breakable/test_bcg_with_speculative_decoding.py
cd test/ && python3 registered/dp_attn/test_dp_attention_bcg_kl.py

🚀 2-gpu-gb300 (1 test): ❌ View workflow run

cd test/ && python3 registered/e2e/models/test_deepseek_v41_flash_gb300_trtllm_bounded_bcg.py

🚀 4-gpu-b200 (1 test): ✅ View workflow run

cd test/ && python3 registered/e2e/models/test_deepseek_v4_flash_fp4_b200.py

🚀 8-gpu-h200 (1 test): ✅ View workflow run

cd test/ && python3 registered/radix_cache/unified_radix_tree/linker/test_unified_cache_linker_kl_dsv41.py

🚀 1-gpu-h100 (5 tests): ✅ View workflow run

python3 -m pytest python/sglang/multimodal_gen/test/unit/test_attention_bcg_outputs.py -x
python3 -m pytest python/sglang/multimodal_gen/test/unit/test_qwen_image21.py -x
python3 -m pytest python/sglang/multimodal_gen/test/unit/test_diffusion_bcg_tp_graph_capture.py -x
python3 -m pytest python/sglang/multimodal_gen/test/single_test_file/test_diffusion_bcg_zimage_turbo.py -x
python3 -m pytest python/sglang/multimodal_gen/test/single_test_file/test_diffusion_bcg_tp2_zimage_turbo.py -x

@mintlify

mintlify Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
sglang-doc 🟢 Ready View Preview Oct 27, 2026, 9:03 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@hnyls2002 hnyls2002 added the run-ci CI: run the baseline test suite on this PR label Oct 27, 2026
@hnyls2002
hnyls2002 merged commit 010eb72 into main Oct 27, 2026
146 of 191 checks passed
@hnyls2002
hnyls2002 deleted the lsyin/bcg-delete-capture-leftovers branch October 27, 2026 22:06
nvrohanv added a commit to nvrohanv/sglang that referenced this pull request Oct 29, 2026
- sgl-project#46719 records an eager_on_graph break at capture
  without running it, so a break returns None (sgl-project#46792
  renamed capture_stub to on_capture). The step graph's grammar mask
  break fills the runner-owned mask and returns None, and the
  child-graph test's break writes into a buffer the test owns.
- sgl-project#45474 draws the simulated acceptance length from
  the worker's generator (generate_simulated_accept_index(generator=)).
  The step graph's override takes the generator and keeps it with the
  draw arguments, so a replay draws from it as the eager step does.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepseek 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