Conversation
modified: python/sglang/srt/batch_overlap/two_batch_overlap.py modified: python/sglang/srt/environ.py modified: python/sglang/srt/layers/attention/tbo_backend.py modified: python/sglang/srt/layers/moe/__init__.py modified: python/sglang/srt/layers/moe/utils.py modified: python/sglang/srt/model_executor/runner/decode_cuda_graph_runner.py
There was a problem hiding this comment.
Code Review
This pull request introduces the ability to disable Two-Batch Overlap (TBO) specifically for decode and target verification phases via a new environment variable SGLANG_DISABLE_TBO_FOR_DECODE. The changes integrate checks across batch preparation, attention backend dispatch, and CUDA graph runner components. The review feedback suggests caching the environment variable lookup in is_decode_tbo_enabled() to avoid performance overhead in the hot path, and importing the helper function from the public sglang.srt.layers.moe interface for consistency.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…er.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
modified: python/sglang/srt/model_executor/runner/decode_cuda_graph_runner.py
|
This is quite helpful for reducing TTFT in non-PD deployments. Could someone help take a look at this PR when you have a moment? Thanks! @merrymercy @Ying1123 @hnyls2002 @Fridge003 @ispobock @Qiaolin-Yu @hebiao064 @HaiShaw @ch-wan @BBuf @Edwardf0t1 @wisclmy0611 @zijiexia @JustinTong0323 @sogalin |
1 similar comment
|
This is quite helpful for reducing TTFT in non-PD deployments. Could someone help take a look at this PR when you have a moment? Thanks! @merrymercy @Ying1123 @hnyls2002 @Fridge003 @ispobock @Qiaolin-Yu @hebiao064 @HaiShaw @ch-wan @BBuf @Edwardf0t1 @wisclmy0611 @zijiexia @JustinTong0323 @sogalin |
Motivation
This PR adds a prefill-only mode for two-batch-overlap (TBO).
On some single-node and multi-node non-PD-disaggregated deployments, it is useful to keep TBO enabled for prefill/extend while disabling it for decode and target-verify batches. This allows deployments to benefit from TBO on prefill-heavy workloads without forcing decode CUDA graph capture/replay and attention metadata paths to use TBO splitting.
By default, the existing behavior is unchanged. Decode TBO remains enabled unless
SGLANG_DISABLE_TBO_FOR_DECODE=trueis set.Modifications
Added a new environment variable:
SGLANG_DISABLE_TBO_FOR_DECODEfalsetrue, TBO is disabled for decode and target-verify batches while remaining enabled for prefill/extend.Added
is_decode_tbo_enabled()in the MoE utility layer and exported it throughsglang.srt.layers.moe.Updated TBO scheduling/metadata logic to skip decode-side TBO when the new env var is enabled:
TboDPAttentionPreparer, decode/target-verify batches no longer setcan_run_tbowhen decode TBO is disabled.TboAttnBackend, replay-view child dispatch is skipped for decode/target-verify when decode TBO is disabled.Preserved the default behavior:
SGLANG_DISABLE_TBO_FOR_DECODEis unset orfalse, decode TBO behavior is unchanged.Accuracy Tests
On other machines (non-NVIDIA GPUs), the DeepSeek model achieves 0.97 accuracy on the MATH-500 benchmark.
Speed Tests and Profiling
Due to limited machine resources, the
num_hidden_layersof the DeepSeek-R1-0528 model was changed to 41. The server was deployed on a single node with 8x H20 GPUs as follows:Benchmark script:
python3 -m sglang.bench_serving \ --host 127.0.0.1 \ --port 30000 \ --backend sglang \ --model /workspace1/models/DeepSeek-R1-0528 \ --dataset-name random-ids \ --num-prompts 128 \ --max-concurrency 128 \ --random-input-len 2048 \ --random-output-len 256 \ --random-range-ratio 1.0 \ >> log_128_2K_256.log 2>&1Benchmark Results Summary
SGLANG_DISABLE_TBO_FOR_DECODE=1On other machines (non-NVIDIA GPUs), with tp size=16, ep size=16, dp size=16: when TBO is enabled, TTFT is 80% of the TBO-disabled baseline. After enabling the
SGLANG_DISABLE_TBO_FOR_DECODEenvironment variable, TPOT matches the TBO-disabled baseline; without it, TPOT increases by 50%–100% compared to the TBO-disabled baseline.Checklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #28035201549
Latest PR Test (Extra): ❌ Run #28035199442