fix(dp-attn): DP-attention buffer sizing + EAGLE padding for require_attn_tp_gather=True - #26016
Open
ashutoshuiuc wants to merge 52 commits into
Open
ashutoshuiuc wants to merge 52 commits into
ashutoshuiuc wants to merge 52 commits into
Conversation
…alistic perf and auto-discover ut (sgl-project#22086) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Baizhou Zhang <sobereddiezhang@gmail.com>
…gl-project#21649) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Baizhou Zhang <sobereddiezhang@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Letian Ruan <ruanlt420@gmail.com>
…ng (sgl-project#22754) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Byron Hsu <byron+per@periodiclabs.ai>
Co-authored-by: Kurt Shuster <kurt@thinkingmachines.ai> Co-authored-by: satyamk7054 <43010011+satyamk7054@users.noreply.github.com> Co-authored-by: Satyam Kumar <satyamk@linkedin.com>
…y arch name DeepseekV3ForCausalLM models on sm100 (B200) were unconditionally defaulted to fp8 quantization. This breaks BF16 models that share the same architecture (e.g. Moonlight-16B-A3B) because they lack FP8 scale tensors, causing AssertionError in the flashinfer_trtllm MoE runner. Instead of assuming FP8 by architecture name, read the safetensors file header to check if expert weights are actually stored as F8_E4M3. This correctly distinguishes DeepSeek V3/R1 (native FP8 experts) from Moonlight (BF16). Made-with: Cursor
…RCE_STREAM_INTERVAL (sgl-project#23215)
…follow-up to sgl-project#23731) (sgl-project#23734) Co-authored-by: Byron Hsu <byron@periodiclabs.ai> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Jun 13, 2026
yueming-yuan
force-pushed
the
sglang-miles
branch
from
June 18, 2026 21:02
1dbbf3a to
6a4ffcc
Compare
yueming-yuan
requested review from
alphabetc1,
jybsuper,
sogalin and
yichiche
as code owners
June 18, 2026 21:02
yueming-yuan
force-pushed
the
sglang-miles
branch
from
July 7, 2026 06:43
f8cfad3 to
fbc2623
Compare
ehuaa
added a commit
to ehuaa/sglang
that referenced
this pull request
Jul 11, 2026
…kend Fixes two crash sites when running MLA models (e.g. DeepSeek-R1) with --enable-dp-attention + NEXTN/EAGLE speculative decoding on the flashinfer backend, verified on 4-node tp32/dp4/ep32 DeepSeek-R1-0528-bf16: 1. Multi-step draft backend: grow the shared kv_indptr / q_indptr_decode buffers to the capture bound in init_cuda_graph_state and rebind them into the child backends (and their decode indices updaters, which cache references at construction). With dp-attention the max capture bs is rounded up to a multiple of attn_tp_size and can exceed the req_to_token_pool.size bound used in __init__, so the [: bs + 1] slices silently truncated and crashed flashinfer's plan with a size mismatch. 2. Prefill indices updater: with dp-attention the batch is padded before attention (extend_num_tokens / input_ids include padding rows) but the per-request seq_lens do not, so the qo_indptr built from cumsum(seq_lens - prefix_lens) falls short of q.shape[0] and flashinfer ragged prefill rejects the extra rows. Append a dummy padding request to the flashinfer metadata covering the padding tokens (same pattern as the piecewise-cuda-graph padding in flashinfer_backend.py, see sgl-project#26016).
ehuaa
added a commit
to ehuaa/sglang
that referenced
this pull request
Jul 12, 2026
…kend Fixes two crash sites when running MLA models (e.g. DeepSeek-R1) with --enable-dp-attention + NEXTN/EAGLE speculative decoding on the flashinfer backend, verified on 4-node tp32/dp4/ep32 DeepSeek-R1-0528-bf16: 1. Multi-step draft backend: grow the shared kv_indptr / q_indptr_decode buffers to the capture bound in init_cuda_graph_state and rebind them into the child backends (and their decode indices updaters, which cache references at construction). With dp-attention the max capture bs is rounded up to a multiple of attn_tp_size and can exceed the req_to_token_pool.size bound used in __init__, so the [: bs + 1] slices silently truncated and crashed flashinfer's plan with a size mismatch. 2. Prefill indices updater: with dp-attention the batch is padded before attention (extend_num_tokens / input_ids include padding rows) but the per-request seq_lens do not, so the qo_indptr built from cumsum(seq_lens - prefix_lens) falls short of q.shape[0] and flashinfer ragged prefill rejects the extra rows. Append a dummy padding request to the flashinfer metadata covering the padding tokens (same pattern as the piecewise-cuda-graph padding in flashinfer_backend.py, see sgl-project#26016).
21 tasks
yueming-yuan
force-pushed
the
sglang-miles
branch
from
July 29, 2026 20:58
f7ea06e to
3003d70
Compare
yueming-yuan
force-pushed
the
sglang-miles
branch
from
August 27, 2026 07:57
a6100a0 to
97e43b4
Compare
yueming-yuan
requested review from
Duyi-Wang,
huangtingwei9988,
mmangkad and
yctseng0211
as code owners
August 27, 2026 07:57
Zhichenzzz
force-pushed
the
sglang-miles
branch
from
September 8, 2026 05:02
a359142 to
a8e5c63
Compare
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.
Summary
Fixes 7 bugs triggered when running DP-attention with
require_mlp_tp_gather=Falseandrequire_attn_tp_gather=True(e.g.moe_dense_tp_size=1,ep_size=32,dp_size=4,attn_tp_size=8). Discovered while running GLM-4.5-355B-A32B training with EAGLE speculative decoding on 32 nodes (128 GPUs).Fixes
1.
global_num_tokens_gpubuffer sizing (scheduler_dp_attn_mixin.py,cuda_graph_runner.py,eagle_draft_cuda_graph_runner.py,eagle_draft_extend_cuda_graph_runner.py,model_runner.py,forward_batch_info.py)Buffer allocation and
_update_gather_batchonly checkedrequire_mlp_tp_gatherto decide betweendp_sizevs 1 element. With our config (mlp=False, attn=True),get_dp_local_info()indexed out-of-bounds bydp_rank, producing garbage that crashed flashinfer withq.shape[0] does not match qo_indptr[-1].Fix: change all guards to
if require_mlp_tp_gather or require_attn_tp_gather.2. EAGLE draft extend padding for DP-attention (
flashinfer_backend.py,eagle_info.py)EAGLE draft extend has
num_tokens = batch_size * num_draft_tokens, not necessarily divisible byattn_tp_size. The DP-attention all-gather requires alignment but flashinfer metadata (qo_indptr, kv_indptr, kv_indices) wasn't padded to match.Fix: append dummy padding request to flashinfer metadata covering the extra positions, same pattern the non-speculative extend path already uses for piecewise CUDA graph padding.
3. Truncate padded logits in EAGLE verify (
eagle_info.py)After DP-attention-padded forward, logits have
ceil_align(n, attn_tp_size)rows but verify expects exactlybs * draft_token_num.Fix: truncate
next_token_logitsbefore verification.4. Reset heartbeat before declaring server ready (
http_server.py)CUDA graph capture takes ~53s for 355B.
TokenizerManager.last_receive_tstampwas set at object creation, so/health_generatereturned 503 immediately after startup. With DP-attention, one "unhealthy" shard causes NCCL hangs on all others.Fix: reset
last_receive_tstampright before "fired up and ready to roll" log.Config that triggers these bugs
This gives
attn_tp_size = tp_size / dp_size = 8,require_mlp_tp_gather = False(becausemoe_dense_tp_size == 1),require_attn_tp_gather = True.Test plan
/health_generatereturning 200 immediately after server ready instead of 503CI States
Latest PR Test (Base): ❌ Missing
run-cilabel -- add it to run CI tests.Latest PR Test (Extra): ❌ Blocked --
run-ciis required first.Latest PR Test (AMD ROCm 10): ➖ No AMD PR run found for this commit.