Skip to content

Add DDTree speculative decoding - #29907

Closed
AllenFeiZZ wants to merge 6 commits into
sgl-project:mainfrom
AllenFeiZZ:ddtree-v2
Closed

AllenFeiZZ wants to merge 6 commits into
sgl-project:mainfrom
AllenFeiZZ:ddtree-v2

Conversation

@AllenFeiZZ

@AllenFeiZZ AllenFeiZZ commented Jul 2, 2026 •

Copy link
Copy Markdown

Summary

This PR adds DDTree (Diffusion Draft Tree) speculative decoding support.

DDTree extends DFLASH-style draft execution with tree-based verification. Instead of verifying only a linear draft chain, DDTree can use a larger tree budget to verify multiple candidate branches and improve acceptance length. The worker uses DFlashWorkerV2 for draft-worker initialization, memory pool setup, and CUDA graph handling, while keeping a DDTree-specific non-overlap decode loop for tree construction and verification.

Changes

  • Add DDTreeWorker, DDTreeDraftInput, and DDTreeVerifyInput.
  • Add DDTree tree construction and EAGLE-format tree topology conversion utilities.
  • Register DDTREE as a speculative decoding algorithm.
  • Add --speculative-ddtree-budget.
  • Add DDTree-specific environment knobs:
    • SGLANG_DDTREE_MAX_TOPK
    • SGLANG_DDTREE_DEPTH_BONUS
    • SGLANG_DDTREE_RANK_PROBE
  • Support DDTree target-verify CUDA graph shapes where draft_token_num = ddtree_budget + 1.
  • Support DDTree draft-worker CUDA graph replay with input_embeds.
  • Make hybrid/Mamba target-verify metadata use per-request spec_info.topk and support DDTree tree topology tensors.
  • Disable Mamba conv-window dedup for DDTree full-tree verify, where per-token tree ancestors are required.
  • Route DDTree decode preparation through its own draft input state instead of the EAGLE prepare path.

Validation

Correctness

Tested on a hybrid GDN model with:

  • Target model: an SFT-tuned MoE model with NVFP4 quantization
  • Draft model: a DFLASH draft checkpoint
  • TP: 1
  • Attention backend: Triton
  • max_new_tokens=512
  • max_running_requests=1
  • strict memory check enabled

Single prompt generation succeeds:

  • Output is correct
  • spec_accept_length = 1.8235

The 40-prompt benchmark completes without scheduler exceptions or memory leak reports.

Performance

Benchmark setup:

  • Dataset: 40 prompts
  • Warmup: 3 requests
  • Max new tokens: 512
  • Same target model, draft model, hardware, and runtime config across runs
Method Budget / Block AL mean AL median AR mean TPS mean
DFLASH block=16 2.576 1.607 0.102 146.2
DDTree budget=8 2.329 1.605 0.086 126.2
DDTree budget=16 2.621 1.807 0.105 128.6
DDTree budget=32 2.750 1.903 0.114 119.8

DDTree shows clear budget scaling:

  • budget 8 -> 16: AL mean improves from 2.329 to 2.621 (+12.5%)
  • budget 16 -> 32: AL mean improves from 2.621 to 2.750 (+4.9%)
  • budget 8 -> 32: AL mean improves from 2.329 to 2.750 (+18.1%)

Compared with DFLASH block=16:

  • DDTree budget=16 improves AL mean by +1.7% and AL median by +12.4%
  • DDTree budget=32 improves AL mean by +6.8% and AL median by +18.4%

As expected, larger DDTree budgets trade additional verification work for higher acceptance length.

Contributors

Engine Architecture Group 5, Engine Infrastructure Department, Xiaohongshu (RedNote): Fei Ziyu, Luo Zhaokai, Su Zhan, Chenchen Hong, Jin Huayi.


CI States

Latest PR Test (Base): ❌ Missing run-ci label -- add it to run CI tests.
Latest PR Test (Extra): ❌ Blocked -- run-ci is required first.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@AllenFeiZZ AllenFeiZZ reopened this Jul 2, 2026

@Hayden727 Hayden727 left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main concerns are around correctness and hidden support-matrix assumptions: sampling behavior, TP>1 vocab mapping, full-tree capacity sizing, attention backend coverage, cuda graph eligibility, and page-size guards.

bs = len(batch.reqs)
device = batch.device

target_predict = torch.argmax(logits_output.next_token_logits, dim=-1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes DDTree verification greedy-only, but the scheduler currently reuses the DFLASH request validator and does not reject normal sampling requests. With default sampling params (temperature=1, top_k=TOP_K_ALL), DDTree will silently return greedy tokens instead of honoring temperature/top-p/top-k/repetition/logit-bias behavior. Please either implement the sampling/rejection path for DDTree, or add a DDTree-specific validator that rejects any non-greedy sampling params with an explicit error.

return

# --- 4) Full tree path (budget > L): compute logits, beam search, compile mask. ---
draft_logits = self._compute_draft_logits(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In full-tree mode this tensor is later top-k'd by build_ddtree_tree, but _compute_draft_logits does not preserve real vocab IDs under TP>1. The TP path concatenates rank-local/padded shard columns, so top-k indices become shard/padding positions rather than global token IDs; it also has a suspicious broadcast in global_logits / global_sum.unsqueeze(-1) that can change the returned shape. The PR only validates TP=1, so TP>1 can build trees with wrong token IDs or malformed logits. Please reuse/port the DFLASH vocab-parallel sampler mapping, or gather (score, global_token_id) candidates per rank and test TP>1.

# DDTree currently uses the non-overlap worker path.
server_args.disable_overlap_schedule = True

block_size = server_args.speculative_num_draft_tokens

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When speculative_ddtree_budget > block_size - 1, the target verify path forwards tree_budget + 1 tokens per request, but the global sizing helpers still key off speculative_num_draft_tokens/block_size. That under-reserves req_to_token headroom, KV/decode allocation, SWA capacity, and MoE token buffers for configs like the benchmarked block_size=16, budget=32. Please add a single DDTree effective-token helper, e.g. max(block_size, speculative_ddtree_budget + 1), and use it in the server/memory sizing paths.

max_extend_len = None
elif forward_batch.forward_mode.is_target_verify():
bs = len(forward_batch.req_pool_indices)
# DDTree full-tree verifies budget+1 tokens (> block_size); use the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This dynamic draft_token_num handling fixes the Triton target-verify path, but DDTree full-tree is not guarded to Triton. Other target-verify backends still assume server_args.speculative_num_draft_tokens in their masks/QO indptr/max query lengths, so budget > block_size - 1 can hit shape mismatches or wrong masks when SGLang auto-selects FlashAttention/DSA/FlashMLA/XPU/TRTLLM. Please either plumb spec_info.draft_token_num through all supported backends, or reject unsupported attention backends at startup with an explicit DDTree error.

self.model_runner.spec_algorithm.is_dflash()
(
self.model_runner.spec_algorithm.is_dflash()
or self.model_runner.spec_algorithm.is_ddtree()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds DDTree to the load_batch token-count path, but can_run_graph() still omits is_ddtree() in the require_mlp_tp_gather branch. For DDTree full-tree, that branch compares max(global_num_tokens_cpu) as if it were batch size instead of dividing by self.num_tokens_per_bs, so graph eligibility/bucketing can be wrong. Please add the same DDTree condition there as well.

# movement (works on hybrid Mamba models; Mamba state is committed
# separately by the worker). Only page_size==1 is supported for now. ---
if model_runner is not None:
assert page_size == 1, "DDTREE full-tree currently supports page_size==1"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If DDTree only supports page_size == 1, this should fail during server argument validation rather than asserting on the first verify request. As written, --page-size > 1 can start successfully and then crash at runtime after verify allocation/state mutation begins. Please either implement the paged KV path or reject this configuration in _handle_ddtree with a clear error.

@AllenFeiZZ

Copy link
Copy Markdown
Author

Thanks for the review! I pushed an update in 93e9850e4 addressing the DDTree comments:

  1. Sampling semantics

    • DDTree verify now reuses the EAGLE eagle_sample() path.
    • Greedy requests still use greedy tree verify.
    • Non-greedy requests now honor target-side sampling params such as temperature / top-p / top-k / penalties / logit bias instead of silently falling back to greedy.
    • --speculative-use-rejection-sampling is explicitly rejected for DDTree for now, since the existing rejection sampling kernel is chain-only and does not support full-tree verification.
  2. TP > 1 full-tree token IDs

    • Fixed _compute_draft_logits() to materialize logits in global vocab-id order for TP > 1.
    • Local shard/padding positions are no longer used as token IDs by build_ddtree_tree().
  3. Effective verify token sizing

    • Added DDTree effective verify token sizing via max(block_size, ddtree_budget + 1).
    • Updated shared logits buffer / decode token sizing / mamba/SWA capacity / MoE token budget / metrics paths accordingly.
  4. Attention backend support

    • DDTree full-tree mode now fails fast unless the resolved prefill/decode attention backend is triton.
    • This avoids silently running unsupported target-verify backends that still assume speculative_num_draft_tokens.
  5. CUDA graph

    • Added DDTree to the can_run_graph() require_mlp_tp_gather batch-size calculation.
  6. page_size

    • Added startup validation rejecting page_size != 1 for DDTree.

Validation done locally with the NVFP4 model:

  • TP=1 + DDTree full-tree (block=16, budget=32) + non-greedy sampling: PASS
  • TP=2 + DDTree full-tree (block=16, budget=32) + non-greedy sampling: PASS
  • TP=1 vs TP=2 greedy AL comparison showed no obvious AL regression.

# same accept order as accept_index_flat (= concatenation per req).
hidden = logits_output.hidden_states
if hidden is not None:
next_target_hidden = hidden[self.accept_index_flat]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only reorders the accepted hidden states for the next draft step; the logits_output.hidden_states returned to the scheduler stays in raw tree-slot order. When a request asks for return_hidden_states, batch_result_processor slices by i * speculative_num_draft_tokens, so a branching accepted path like slots [0, 3] returns hidden rows [0, 1]. Please either reject return_hidden_states for DDTree or reorder/pad logits_output.hidden_states to the same per-request emitted-token stride as accepted_tokens.

server_args.disable_overlap_schedule = True

block_size = server_args.speculative_num_draft_tokens
is_full_tree = server_args.speculative_ddtree_budget > block_size - 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guard misses the smaller-spine case where speculative_ddtree_budget + 1 < speculative_num_draft_tokens. DDTree then verifies fewer tokens than the block size, but non-Triton target-verify backends such as FlashAttention/TRTLLM still size metadata from server_args.speculative_num_draft_tokens, so block=16,budget=8 can build mismatched QO/mask shapes. Please guard whenever budget + 1 != block_size, or plumb spec_info.draft_token_num through every allowed backend.

if self.scheduler.server_args.max_speculative_num_draft_tokens:
draft_per_round = (
self.scheduler.server_args.speculative_num_draft_tokens - 1
self.scheduler.server_args.max_speculative_num_draft_tokens - 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max_speculative_num_draft_tokens is a capacity bound, not the number of draft tokens DDTree actually proposes. For block=16,budget=8 this denominator becomes 15 while each verify round only proposes 8 draft nodes, so the reported accept rate is undercounted. Please use the runtime result.speculative_num_draft_tokens - 1 / DDTree budget for metrics denominators, and mirror that in the per-request metadata path.

@wenqf11

wenqf11 commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Why TPS mean becomes smaller after using DDTree?

@Hayden727 Hayden727 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

​

)

# --- 2) Draft a non-causal block (reuse parent's shared implementation).
draft_hidden, positions_2d, block_ids = self._run_draft_forward(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still drafts a full block_size block even when speculative_ddtree_budget < block_size - 1 and the later verify path truncates to D = budget + 1. That means a budget=8, block_size=16 run pays almost the same draft-model forward/KV allocation cost as the 16-token baseline, plus DDTree bookkeeping. If budget is meant to trade accuracy for speed, the draft forward should either run only the needed length or small-budget DDTree should route through the existing DFLASH-style path.

)

# --- 3) Spine-mode fast path: a degenerate chain tree. ---
if self.tree_budget <= self.block_size - 1:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spine case is a pure linear chain, but it still builds DDTree LCRS metadata and a custom tree mask, then verifies via DDTreeVerifyInput. DFLASH's comparable path uses standard causal verify with custom_mask = None, which avoids this extra mask/topology work. This likely explains why the small/spine budgets can be slower even though they do not verify a wider tree. Please either reuse the DFLASH verify fast path for spine mode or add a benchmark showing this extra protocol cost is negligible.

return

# --- 4) Full tree path (budget > L): compute logits, beam search, compile mask. ---
draft_logits = self._compute_draft_logits(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full-tree construction materializes dense [bs, block_size - 1, vocab] logits before selecting a small top-k. The tree builder only needs a few candidates per depth, so this pays full-vocab bandwidth/activation memory every decode round. For TP>1 the helper also gathers/scatters dense global-vocab logits. A more serving-friendly implementation would compute top-k candidates directly from the vocab-parallel head and gather only (score, token_id) candidates.

topk = min(max(tree_budget // max(L, 1) + 1, 2), V, _max_topk)
top_logits, top_token_ids = torch.topk(logits, k=topk, dim=-1)
log_z = torch.logsumexp(logits, dim=-1, keepdim=True)
top_log_probs = (top_logits - log_z).to(device="cpu", dtype=torch.float32)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This moves the per-position top-k data to CPU, then _build_single_tree uses NumPy/Python heapq per request. That creates a GPU sync in the decode hot path and serial Python work proportional to batch size and budget. This is not inherent to DDTree; the tree selection/topology build should stay on device or be implemented as a batched compiled kernel before using TPS numbers as evidence for/against the algorithm.

batch.spec_info = verify_input
batch.return_hidden_states = False

def _build_flat_tree_mask(self, *, batch, visibility, actual_tree_sizes):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_build_flat_tree_mask does seq_lens.detach().cpu().tolist() / actual_tree_sizes.detach().cpu().tolist(), allocates one D x (prefix_len + D) tensor per request, and then concatenates. For long contexts this is O(batch * D * context_len) mask materialization plus CPU synchronization every decode step. Please preallocate/vectorize this path, or encode the tree visibility in a compact form consumed by the attention kernel.


# accept_index[b]: [root_global_slot, accepted child global slots..., -1...]
# accept_length[b]: number of accepted *draft* tokens (excludes root).
accept_index_cpu = accept_index.tolist()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accept_index.tolist() and predict.tolist() force a device-to-host sync, then the accepted-token path is rebuilt in Python and copied back to GPU tensors below. This places result processing on the critical decode path. The accepted slots/tokens/commit lens should be produced by a device kernel, with only the final scheduler-facing D2H copy happening asynchronously like other spec-v2 workers.

)

# DDTree currently uses the non-overlap worker path.
server_args.disable_overlap_schedule = True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabling overlap scheduling makes DDTree pay all of its CPU tree-build, mask construction, verify, and draft-KV materialization costs serially in the decode loop, while the DFLASH baseline can use the optimized overlap/spec-v2 path. For the benchmark to be actionable, please either implement the overlap path for DDTree or compare against a DFLASH configuration with the same non-overlap scheduling constraints.

Copy link
Copy Markdown
Contributor

@wenqf11 Good question. I don't think the lower TPS should be attributed only to DDTree's algorithmic verify cost yet.

Part of it is expected: DDTree full-tree verifies tree_budget + 1 target nodes, so budget=32 forwards 33 verify nodes vs DFLASH block=16, while the reported AL gain is much smaller than the extra verify work.

But this PR also has several implementation overheads that can depress TPS:

  • budget < block_size - 1 still runs a full block_size draft forward and only truncates later, so budget=8 does not actually save draft compute.
  • Spine mode still goes through DDTree LCRS/custom-mask verify instead of the DFLASH causal verify fast path.
  • Full-tree construction materializes dense vocab logits, then moves top-k data to CPU and builds the tree with Python/NumPy/heapq each decode round.
  • The flat tree mask and accepted-token processing both do CPU syncs (cpu().tolist() / .tolist()) in the hot path.
  • DDTree currently disables overlap scheduling, so these costs are serialized against decode.

So the benchmark currently mixes algorithmic cost with implementation overhead. It would be useful to add a breakdown for draft forward / tree build / mask build / target verify / KV materialization, and compare against DFLASH under the same overlap/non-overlap setting. I left inline comments on the concrete hot-path locations.

root added 3 commits July 15, 2026 12:06
- Reject DDTree return_hidden_states until per-request hidden-state
  ordering is implemented (validate_dflash_request gains is_ddtree kwarg).
- Guard non-Triton DDTree whenever verify_token_num != block_size
  (covers both full-tree and smaller-spine cases in _handle_ddtree).
- Report spec accept rate from actual proposed drafts instead of
  max_speculative_num_draft_tokens capacity: plumb spec_num_proposed_drafts
  through GenerationBatchResult, Req, metrics_reporter, io_struct,
  output_streamer, multi_tokenizer_mixin, detokenizer_manager, and
  tokenizer_manager (with fallback for legacy payloads).
In upstream main, ServerArgs.page_size defaults to None and is only
resolved to 1 later in _handle_page_size(). The DDTree startup guard
was rejecting page_size != 1 unconditionally, which caused every default
DDTree launch to fail with

    ValueError: DDTREE currently supports only page_size == 1.
                Got page_size=None.

Allow None (means 'use default', which resolves to 1); only reject when
the user explicitly sets page_size to a value other than 1.
…nv-state regressions

Sync ddtree-v2 with upstream/main: resolve conflicts, drop
model_runner_kv_cache_mixin for upstream KVCacheConfigurator, and adapt
DDTree to upstream API changes (ParallelState ctor, mem_cache.allocation
moves, ForwardBatch.init_new kwarg, resolve_num_tokens_per_req).

Fix two regressions found via pre/post-merge tensor-dump bisection:

1. SM120 NVFP4 MoE garbage output. trtllm-gen MoE is SM100-only, so
   upstream falls back to FLASHINFER_CUTLASS on SM120, but that runner
   assumes the dispatcher pre-quantizes activations to fp4 (only true
   under DP-attention allgather). Under tp-only serving StandardDispatcher
   leaves bf16 activations with scale=None, so the kernel reads garbage.
   Upstream also deleted the self-contained cutlass_moe_fp4 path. Restore
   cutlass_moe_fp4 (+ its JIT kernels) and select it unless the
   fp4-allgather path is active.

2. DDTree tree-branch conv-state corruption. HybridReqToTokenPool now
   needs tree_verify_uses_per_token_ancestors; DDTree keeps
   speculative_eagle_topk==1 but routes the tree-aware mamba scan, so the
   dedup conv-window layout silently corrupted branch conv state. Pass it
   as is_ddtree() in the configurator.

Verified on SM120 (RTX PRO 5000) tp1 + CUDA graph: 4 real prompts produce
byte-identical output vs the pre-merge baseline with matching accept length.
@AllenFeiZZ

AllenFeiZZ commented Jul 16, 2026 •

Copy link
Copy Markdown
Author

Follow-up after my last update (93e9850), addressing the review comments raised since then:
Correctness fixes from the 07-09 review (merged via a56d757):

  • Accept-rate denominator — now computed from the actual number of proposed drafts (runtime DDTree budget) instead of the max_speculative_num_draft_tokens capacity bound, so it's no longer undercounted for configs like block=16, budget=8.
  • return_hidden_states — explicitly rejected for DDTree until per-request hidden-state ordering is implemented, avoiding wrong hidden rows on branching accepted paths.
  • Non-Triton backend guard ([3], [7]) — DDTree now rejects non-Triton attention backends at startup (unless the matching backend/draft_token_num conditions hold), so configs where budget + 1 != block_size can no longer build mismatched QO/mask shapes on FlashAttention/TRTLLM at runtime.
  • SM120 NVFP4 MoE fix (new in this update, from merging latest main). On SM120 (RTX PRO 5000), trtllm-gen MoE is SM100-only so upstream falls back to FLASHINFER_CUTLASS, but that runner assumes the dispatcher already fp4-quantized the activations (only true under DP-attention all-gather). Under tp-only serving StandardDispatcher leaves bf16 activations with scale=None, so the kernel reads garbage. The self-contained cutlass_moe_fp4 path had been removed upstream, so this PR re-adds the NVFP4 JIT kernels (jit_kernel/nvfp4.py, csrc/gemm/nvfp4/*.cuh, csrc/moe/nvfp4_blockwise_moe.cuh, with a getSMVersion rename to avoid a symbol clash) and selects cutlass_moe_fp4 unless the fp4-allgather path is active. Verified on SM120 tp1 + CUDA graph: byte-identical output vs the pre-merge baseline with matching accept length.
    Note on performance: cutlass_moe_fp4 (Triton) is a correctness fallback and is slower than the FLASHINFER_CUTLASS/trtllm paths. It only kicks in on the non-DP-attention SM120 case where those paths are unavailable/incorrect, so it doesn't affect the SM100 / DP-attention high-throughput paths. A faster SM120 NVFP4 MoE path is left as a follow-up.
    Performance comments from the 07-10 review (spine fast-path, dense full-vocab logit materialization, on-device tree build, flat-mask vectorization, accept_index D2H sync, overlap-schedule path): these are decode-path optimizations rather than correctness issues. The current PR is correctness-first; I'll address them as follow-ups and post benchmark numbers.

efschu pushed a commit to efschu/htsglang that referenced this pull request Jul 26, 2026
… group collective

Found by booting it: Nordstern L0 S4 (TP=5 over two hosts, EAGLE3, solo draft
placement, --disable-cuda-graph). Ranks 1-4 reached "Tree cache initialized"
and started their health checks; rank 0 went silent for 8 minutes until the
launcher killed it. py-spy on the solo rank:

    all_gather_object (distributed_c10d.py)
    _harmonize_cuda_graph_plan (model_runner.py:1098)
    init_cuda_graphs (model_runner.py) <- tp_worker <- eagle_worker_v2

Under --speculative-draft-placement solo only the solo rank owns a real draft
runner; the shadow ranks get a stub (install_shadow_draft_runner_surface) and
never call init_cuda_graphs on it. The harmonisation's all_gather_object is
group-wide, so the solo rank entered a collective no other rank would ever
join. This is independent of nnodes -- it is a property of solo placement.

Fix: skip the harmonisation when spec_solo_rank_local_graphs is set. That flag
already declares exactly this ("this runner's graphs are captured rank-locally,
the shadow ranks skip draft capture entirely") and already suppresses the
capture backends' per-warmup TP barrier; the harmonisation is a second group
collective in the same category. It also MUTATES the shared cuda_graph_config,
so letting the draft runner harmonise could disable a phase for the target
runner too.

Also in this commit, from the same window:

* sgl-project#76 GUARD HARDENED (sgl-project#98 sighting). The trigger is no longer "topk > 1" but
  "anything that would activate a tree-masked verify", via the new
  ServerArgs.tree_verify_activation_reason(). Upstream carries three
  unconsolidated PRs (sgl-project#31069/sgl-project#29587/sgl-project#29907) adding
  --speculative-dflash-tree-verify, a SECOND door onto the terrain sgl-project#76 fenced
  off. It does not exist here yet, so it is read with getattr: the guard is
  armed for its arrival instead of waiting to be remembered during a merge.
  The refusal is not theoretical -- see the byte-gate numbers below.
* l0_rank.sh: --max-total-tokens is now optional (MAXTOK=0 leaves the KV pool
  uncapped) because a tok/s number without the context it was reached at is not
  a result (harness rule sgl-project#4).
* l0_launch.sh: forward MAXTOK/MEMFRAC/EXTRA to the second host. They were not
  forwarded, so MAXTOK=0 applied to the main rig only: rank 0 sized its pool to
  133802 tokens while ranks 3/4 silently kept the 2048 default. A capacity
  number measured that way means nothing.

TESTED

CPU: test_uneven_tp_args.py -- 13 passed (TreeSpec*), both directions. The new
flag is rejected under uneven DCP WITH topk=1 (i.e. exactly the case the old
guard would have let through), the healthy path (chain, no tree verify) stays
open with the flag false AND with it absent, the original topk door still
rejects, the message names which flag tripped it, and a single-GPU tree run is
untouched. Full suites: server_args + spec kernel backend -- 271 passed.

GPU, RTX 5090, byte gate step 1 (native sgl_kernel vs Triton spec kernels,
identical inputs, bit comparison of every output tensor of build and verify):
  topk=1 chains  16/16 EXACT   (bs 1-2, steps 2-3, FULL_MASK and QLEN_ONLY)
  topk=2,4 trees 8/32 exact -- tree_mask differs by 6-13 elements, and one
                 case raised a CUDA error inside the Triton kernel
So the group-decision's refusal of topk>1 on the Triton path is now measured,
not precautionary, and this guard's subject matter is the same computation.

GPU, five ranks, both hosts (Llama-3.1-8B fp16, ratio 4,3,3,2,1, ctx 2048,
eager, HTCCL/gloo): S4 (solo) and S3 (split) BOTH BOOT AND SERVE after this
fix. That is the first live proof of the narrowed nnodes gate (f34a343) and
of the capability-keyed spec kernels (4bcb310) -- ranks 3 and 4 have no
sgl_kernel, so the group ran the Triton path end to end.
@github-actions

Copy link
Copy Markdown
Contributor

Thanks @AllenFeiZZ. Closing this because it has had no updates in 91 days.

Reopen it if the work is still relevant.

Some directories moved recently, so an older branch may need retargeting:
sgl-kernel/ -> python/sglang/kernels/aot/, python/sglang/jit_kernel/
-> python/sglang/kernels/jit/, docs/ -> docs/docs/ (.mdx),
bench_serving.py -> benchmark/serving.py, test/srt/ -> test/registered/.

@github-actions github-actions Bot closed this Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants