Repository navigation
Conversation
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
…aths for EAGLE v2 chains Opt-in with one flag, outputs bitwise identical: --enable-speculative-step-cuda-graph captures each EAGLE v2 decode step as one CUDA graph, built on splicing full-backend graphs into an enclosing capture, and turns on six pieces: one TP broadcast for the verify result, a lean sampled verify for chains, fused relay stores with single-request relay views, a fused topk-1 draft-extend tail, one launch for the step graph's input copies, and chain verify sampling in two launches. Each piece has a SGLANG_SPEC_* environment variable as a test / bisect override (0 turns it off under the flag). With the flag off and no override set each changed file runs its existing code. A weight update that asks for a CUDA graph recapture is refused while the step graph is on. The fused relay carries the change proposed in sgl-project#41170; the draft-extend tail uses the two-stage argmax form proposed in sgl-project#41172. At startup, when the flag is on and a step graph runner is active, the HTTP server runs, for each batch size k from 1 to N, one batch of k requests per DP rank with the sampling a chat request without sampling fields resolves to (the chat API's own to_sampling_params over the model's generation config). N is the smaller of the runner's largest batch size (at most 8, and at most the largest of every per-stage graph) and the maximum number of running requests. A batch of token ids reaches the scheduler as one message, so its requests decode as one batch of k, and the step graph captures each of those keys before serving; a batch size still without a key gets one more batch, then a warning. The log lists each captured key with its memory and the time the warmup took. The warmup is skipped with --skip-server-warmup, and with SGLANG_RUST_SERVER one line says so. A failed capture memory check is logged once per key on every rank with the free, needed, reserved and allocated memory. When PyTorch caches enough unused memory, the cache is released once for that key (at most 32 times per process) and the check repeats. /get_server_info reports memory_refusals, last_memory_refusal, cache_releases, captured_keys, max_batch_size and the allocator's num_alloc_retries / num_ooms. The draft-extend tail is registered in the kernel inventory (Triton, CUDA only). Also kernel tests for chain verify sampling, the draft-extend tail and the relay scatter.
9258cb7 to
3ba3fd1
Compare
The sampled startup warmup added by sgl-project#46211 checks whether every requested batch size has a captured graph. Its previous check accepted any key of that size, so the greedy key left by the normal server warmup could hide a missing default-sampling key. That suppressed the intended retry and warning even though the graph needed by default chat requests was absent. Resolve the warmup request's effective SamplingParams, including preferred sampling parameters, and match greedy/top-k/top-p/min-p flags as well as batch size. Exclude constrained keys. Expose the existing capture key's filter flags in runner stats so the check can distinguish those modes. A missing matching key receives the existing single retry, followed by a warning if it is still absent. Successful captures behave as before; this does not guarantee capture when memory is insufficient. Kernel arithmetic, collectives, sampling, and graph replay are unchanged. The original static table protocol disables step graphs, so this fix does not affect that path. Add regression cases for greedy, constrained, top-k, top-p, and min-p key mismatches, and make the fake server honor the request's sampling flags. Remove the redundant assertion that exactly six switches are declared; retain switch resolution, override, and fallback behavior coverage. Validation: reproduce the missed retry with the previous implementation; related CPU tests pass (30 tests, 57 subtests); changed-file pre-commit passes.
|
Completed the companion GLM-5.3 NVFP4 static-table recheck on 8×B300 TP8 using step Step CUDA graphs are off in this static-table comparison, so these numbers do not measure this flag's speedup. The sampling-aware startup warmup fix and test cleanup are in |
Conflicts, each resolved to keep both sides: - arg_groups/field_order.py: main's new fields, then enable_speculative_step_cuda_graph last. - entrypoints/http_server.py: the Rust-server line about the step CUDA graph warm-up, then main's rust_server_sidecar block. - speculative/spec_utils.py: main's KV-cache imports and this branch's child_graph_capture import. - speculative/eagle_utils.py: sgl-project#45474 added the same packed verify broadcast behind SGLANG_Q35MF_EDGE_PACKED_VERIFY_BCAST (_verify_outputs). eagle_sample keeps this branch's _alloc_verify_outputs and _broadcast_verify_outputs, and _alloc_verify_outputs now allocates through _verify_outputs: packed when either variable is set, with the same layout.
- 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.
Three registered CPU tests build objects that the step CUDA graph code reads: - test_full_cuda_graph_backend builds FullCudaGraphBackend without __init__: _keep_raw_graph and graph_epoch get class defaults. - test_backend_resolution resolves a decode backend with no spec config published: resolve_decode_backend reads enable_speculative_step_cuda_graph only when the spec namespace is published. - test_spec_registry's fake server args gain enable_speculative_step_cuda_graph=False, which handle_speculative_decoding now reads.
…pt-ins - SGLANG_ENABLE_EAGLE_POST_VERIFY_CUDA_GRAPH runs its own graphs inside the verify, and SGLANG_Q35MF_EDGE_SPARSE_VERIFY_SAMPLING picks its top-k branch per batch outside the capture key: with either one on, the launch turns the step graph off and keeps the per-stage graphs. - draw_args is annotated with the generator it carries.
One conflict, in DeepseekSparseAttnBackend of python/sglang/srt/layers/attention/dsa_backend.py: main (sgl-project#45946) adds the _call_flash_mla_* wrappers and this branch adds out_graph_metadata_capturable at the same place, after the class attributes. Both are kept: out_graph_metadata_capturable first, next to the attribute comment it refers to, then main's wrappers.
|
@nvrohanv We might need to break down every optimization in this large PR into multiple smaller, clearer PRs, let's discuss offline |
Motivation
At one to four requests with topk-1 EAGLE v2 chains, a decode step on a fast model is a few milliseconds, and a large
share of it is host work and small launches between the per-stage CUDA graphs (draft, target verify, draft extend):
the verify result's three broadcasts, the sampling-info setup, the relay stash and gathers, the draft-extend tail, and
the step graph's input copies. This PR adds one opt-in flag,
--enable-speculative-step-cuda-graph, which captures thedecode step as one CUDA graph and turns on six pieces that remove that work. With the flag off (the default), each
changed file runs its existing code. The pieces do not depend on any model or on the megakernel layer.
Modifications
Every piece below is on with
--enable-speculative-step-cuda-graphand off without it (the default).SGLANG_SPEC_PACKED_VERIFY_BROADCASTSGLANG_SPEC_LEAN_SAMPLED_VERIFYdraft_probsSGLANG_SPEC_FUSED_RELAYSGLANG_SPEC_FUSED_DRAFT_EXTEND_TAILSGLANG_SPEC_STEP_GRAPH_FUSED_INPUT_COPYSGLANG_SPEC_CHUNKED_VERIFY_SAMPLING(under the lean sampled verify)One flag: an override that is not set follows the flag as resolved at startup, so a setup that turns the flag off
(pipeline parallelism, attention DP, topk above 1, ...) turns the six pieces off too.
=0turns one piece offunder the flag, for bisecting;
=1turns it on without the flag, for tests. Each piece keeps its own eligibilitychecks and falls back to the existing code where they fail.
Credit: the fused relay carries the change proposed in [qwen 3.8 next] Fuse speculative relay payload stores and avoid single-request gathers #41170 behind a switch, rebased onto the current FutureMap;
the fused draft-extend tail uses the two-stage argmax in
row_argmax.py, the form proposed for the draft argmax in[qwen 3.8 next] Fuse exact greedy chain verification with argmax finalization #41172. The chunked kernels set their shared memory with
runtime::set_max_dynamic_smem_per_device([JIT] Clean up kernel headers: move runtime helpers, add once.h #41147).Related PRs, both now on SGLang main (this branch merges it): [Feat] [NVIDIA] megakernels: Qwen3.5 binding and EAGLE entry wiring for NVIDIA megakernel plugins #45266 adds a Qwen3.5 binding for megakernel plugins,
runs a plugin's EAGLE draft entries in the draft and draft-extend graphs and captures a megakernel's KV-length
attention graph variants; without
--enable-nvidia-megakernelit changes nothing. [Perf] [NVIDIA] speculative: Move the host work between Qwen3.5 MTP decode graphs into the graphs (1/2) #45474 moves the host work betweenthe Qwen3.5 MTP decode graphs into graphs, into fewer launches or off the critical path, each piece behind a switch
that defaults to off; among them are post-verify CUDA graphs for the EAGLE verify's sampling, acceptance and commits,
and a sampled verify result sent in one broadcast instead of three (the idea of this PR's packed verify broadcast; the
two now share one allocation, see Base below). This PR captures the whole decode step for any model with full decode
graphs and needs no megakernel; a step that does not replay exactly the three per-stage graphs is never captured and
runs the existing path.
Limitation: while
--enable-speculative-step-cuda-graphis on,/update_weights_from_diskwithrecapture_cuda_graphis refused before any weight is loaded. The step graph replays the per-stage graphs itcaptured, and a recapture replaces their runners; recapture support is a follow-up.
Main's verify opt-ins: with
SGLANG_ENABLE_EAGLE_POST_VERIFY_CUDA_GRAPHset ([Perf] [NVIDIA] speculative: Move the host work between Qwen3.5 MTP decode graphs into the graphs (1/2) #45474's post-verify graphs run theirown graphs inside the verify) or
SGLANG_Q35MF_EDGE_SPARSE_VERIFY_SAMPLINGset (it picks its top-k branch per batch,outside the step graph's key), the launch turns
--enable-speculative-step-cuda-graphoff with a warning naming thevariable and keeps the per-stage graphs.
Start-up warm-up: when the flag is on and a step graph runner is active, the HTTP server's start-up sends short
requests with the sampling that a chat request setting no sampling field resolves to (the chat API's own
to_sampling_paramsover the model's generation config; the tokenizer manager merges--preferred-sampling-paramsinto it as into any request), in batches of 1, 2, ..., N requests per DP rank. N is the smallest of 8, the largest
batch size of the per-stage decode graphs and
--max-running-requestsper DP rank. Each batch is one request withdistinct 3-token prompts and 64 new tokens; the tokenizer manager sends it to the scheduler in one message, so with
one DP rank its prompts are prefilled together and decode as one batch. The step graph therefore captures the key of
every batch size from 1 to N, as client requests without sampling fields produce it, before the server takes
requests; SGLang's own warm-up request captures the greedy batch-size-1 key. A batch size that still has no
unconstrained key with the warm-up's sampling flags (greedy, top-k, top-p, min-p) afterwards gets one more batch; if
it is still missing, a warning names it and its key is captured at first use.
One log line gives the warm-up's time and each captured key with its memory. The warm-up is skipped with
--skip-server-warmupand in the offline engine, and withSGLANG_RUST_SERVER=1one log line says it is skipped;then every key is captured at its first use, as before.
Start-up cost: with SGLang's own warm-up request, the server handles 1 + N(N+1)/2 requests per DP rank at start-up
(2 at
--max-running-requests1, 37 at 8; one more batch for a missing size); the N(N+1)/2 added ones each have a3-token prompt and 64 new tokens. They appear in the server's request metrics like SGLang's own warm-up request, so
a client that checks for a server with no earlier requests has to allow for them. In the GLM-5.3 runs below
(8 x B300, TP 8), the warm-up took 7.7 s at
--max-running-requests8, on a host where the same build had startedbefore, and 49.0 s at
--max-running-requests1, on the first start of this build on its host. The step graphs thenheld 394 MB per GPU at
--max-running-requests8 (batch sizes 1 to 8 sampled, 372 MB, plus the greedy batch-size-1key, 22 MB) and 44 MB at 1.
Memory: a key is captured only when every rank has free device memory of at least the largest key captured so far
(256 MiB before the first) plus 1 GiB. If that check fails while PyTorch's caching allocator holds enough unused
memory on every rank to cover the need, that cache is released once for the key (
torch.cuda.empty_cache(), atmost once per key and 32 times per process) and the check is repeated. Otherwise that key's steps run the existing
path, the capture is retried every 256 steps, and each rank logs the refusal once per key with its free, needed,
reserved and allocated memory; each release is logged with the free memory before and after it.
/get_server_inforeports underspec_step_cuda_graphthememory_refusalscount, thelast_memory_refusal(batch size, greedy or sampled, constrained or not, and those four memory figures), the
cache_releasescount,the
captured_keys(batch size, greedy or sampled, the top-k / top-p / min-p flags, constrained or not, and MB ofeach), the runner's
max_batch_sizeand the caching allocator'snum_alloc_retriesandnum_ooms. Device memoryin use can grow
while serving, so a key first met while serving (a greedy batch above 1, a constrained batch, or a batch size the
start-up warm-up did not capture) may still be refused (see the agentic-trace runs below for the previous
revision, which captured batch size 1 only at start-up).
Kernel inventory:
kernels/ops/speculative/__init__.pyregisters the fused draft-extend tail(
speculative.draft_extend_tail, Triton, CUDA only) next todiv_argmax, asunit/kernels/test_kernels_namespace.pyrequires of a public kernel entry point.
Docs: the new flag in
server_arguments.mdx; the flag, its six pieces and their overrides, the start-up warm-up,the memory check and the cache release in
speculative_decoding.mdx.Tests in this PR:
cuda_graph/spec_step/test_child_graph_capture.py,cuda_graph/spec_step/test_eagle_step_cuda_graph_runner.py,unit/managers/test_single_request_relay.py,unit/spec/test_spec_step_graph_fused_input_copy.py(1 GPU),unit/spec/test_eagle_step_cuda_graph_eligibility.py(with the memory refusal, the cache release, the start-upwarm-up and the fallback for main's verify opt-ins),
unit/spec/test_simulated_accept_fixed_shape.py,unit/spec/test_spec_packed_verify_broadcast.py,unit/spec/test_spec_step_graph_switches.py(CPU), one line inunit/spec/test_spec_registry.py's fake server arguments, ande2e/models/test_dsa_glm52_nvfp4_tp_mtp_step_graph.py(4 GPUs, GLM-5.2 NVFP4).Kernel tests of the new CUDA kernels (under
test/registered/, 1 GPU each):kernels/ops/speculative/test_spec_chain_verify_sampling.pytree_speculative_sampling_target_onlythree ways (stock, lean, two-launch chunked) returns the samepredicts/accept_index/accept_token_numbit for bit over random, flat, peaked and tail-only distributions, edge coins, every vector width, one-chunk vocabularies, a zero-mass row and CUDA graph replaykernels/ops/speculative/test_spec_draft_extend_tail.pyunit/layers/test_next_relay.pyscatter_spec_extras) at batch sizes 0, 1 and 129 and widths 1, 17 and 2,560, in CUDA graph replay, with dense sources and indices and with sources whose row stride is wider than their width (a column slice of a wider buffer) and a stride-2 index tensorBase and revisions: this branch is this PR's commit
3ba3fd1d2eon SGLang maindba22e9b68, a fix that matchessampling modes in the start-up warm-up's missing-key check (
bcf3db0ab6, above), a merge of SGLang main286e018594,three commits on top, and merges of SGLang main
00394f9f35and9e9296fdf3:286e018594kept both sides of four conflicts:arg_groups/field_order.py(main's new fields, thenenable_speculative_step_cuda_graphlast),entrypoints/http_server.py(this PR's warm-up line for the Rust server,then main's
rust_server_sidecarblock),speculative/spec_utils.py(main's KV-cache imports and this PR'schild_graph_captureimport) andspeculative/eagle_utils.py: [Perf] [NVIDIA] speculative: Move the host work between Qwen3.5 MTP decode graphs into the graphs (1/2) #45474 added the same packed verify broadcast behindSGLANG_Q35MF_EDGE_PACKED_VERIFY_BCAST(_verify_outputs);eagle_samplekeeps this PR's_alloc_verify_outputsand
_broadcast_verify_outputs, and_alloc_verify_outputsnow allocates through_verify_outputs, packed wheneither variable is set, with the same layout.
eager_on_graphbreak at capture without running it, so a breakreturns
None([Refactor] bcg: Delete capture leftovers and renamecapture_stubtoon_capture#46792 renamedcapture_stubtoon_capture): the step graph's grammar mask breakfills the runner-owned mask and returns
None, and the child-graph test's break writes into a buffer the test owns.[Perf] [NVIDIA] speculative: Move the host work between Qwen3.5 MTP decode graphs into the graphs (1/2) #45474 samples the simulated acceptance length with the worker's generator; the step graph's override takes that
generator and keeps it with the sample's other arguments, so a replay samples with it as the eager step does.
test_full_cuda_graph_backend(
FullCudaGraphBackendgets class defaults for_keep_raw_graphandgraph_epoch),test_backend_resolution(
resolve_decode_backendreadsenable_speculative_step_cuda_graphonly when the speculative config is published)and
test_spec_registry(its fake server arguments setenable_speculative_step_cuda_graph=False).00394f9f35had no conflict, and no line of this PR changed in it.9e9296fdf3had one conflict, inlayers/attention/dsa_backend.py: main ([Feat] sail: support sail fa3 and flashmla [3/N] #45946)adds three methods to
DeepseekSparseAttnBackendthat wrap its FlashMLA calls, at the place where this PR addsout_graph_metadata_capturable. Both are kept, this PR's method first. [Feat] sail: support sail fa3 and flashmla [3/N] #45946 also routes the backend's FlashMLAcalls through the new methods, which call the same functions as before; no line of this PR calls them, and no line
of this PR changed in the merge.
Earlier revisions: against the revision before it (
9258cb78da, also on SGLang maindba22e9b68),3ba3fd1d2ecaptures the keys of batch sizes 1 to N at start-up instead of batch size 1
only, releases PyTorch's cached memory once before a refused capture, reports
captured_keys,cache_releasesandmax_batch_size, and updates the docs and the eligibility tests (5 files). The revision before that (f35a9e5f82,on SGLang main
74c08f3dc5) had no start-up warm-up, no memory-refusal diagnostics and no kernel-inventoryregistration. Apart from those additions, the changes for SGLang main
dba22e9b68since the revisions measured on SGLangmain
af856717c2were these:arg_groups/field_order.pyappendsenable_speculative_step_cuda_graphat the end ofPOSITIONAL_FIELD_ORDER(after main's newest field), as main's positional-slot test requires.
managers/overlap_utils.pythe fused relay branch ofstashcomes after main's check that skips the scatter whenthe graph has already published it. That check's relay is not used by the EAGLE chains measured below, so they run
the same code as before.
speculative/eagle_utils.pywas resolved with this PR's changed lines as before; main'sverify-sampling dispatch reaches, on CUDA, the same
tree_speculative_sampling_target_onlythat this PR extends.typingimport ofspeculative/eagle_worker_v2.pyalso takes main'sCallable.The accuracy results and the per-step table below were measured on SGLang main
af856717c2with the earlierrevisions each one names. The first agentic-trace table below was measured on SGLang main
dba22e9b68with3ba3fd1d2e,the megakernel hooks PR at
465a9dd5b7, #45795 at its head of that time29e8125875and the GLM-5.3plugin PR at
ad0bf9103d; the other agentic-trace runs below name their revisions. Before those runs,3ba3fd1d2ewas checked with the same PRs on one 8-GPU host with dummy weights: at--max-running-requests4 and 8,the start-up warm-up captured the sampled keys of batch sizes 1 to 4 and 1 to 8 and the greedy batch-size-1 key on
all 8 ranks before the server was ready, and short synthetic loads of 2 and 4 concurrent requests (at 4) and of 4
and 8 (at 8) then replayed every decode step, with no memory refusal and no new key.
On SGLang main
286e018594, before the merge of00394f9f35, this branch was checked with the megakernel hooks PR(
ba86b681b5), #45795 (at6ffe9cd46c) and the up-to-date GLM-5.3 plugin PR (b8a85c739b), on8 x B300. The GPU checks ran this branch at
0d39d7fdbb, before the commit with the fallback for main's verifyopt-ins, except the fallback check (the last item), which ran the head of that time. On CPU, this PR's CPU tests
pass, and the registered CPU suites it
touches fail on no test id that does not also fail on SGLang main itself. On the GPU host, this PR's test files (all but the 4-GPU e2e) and
unit/spec/test_spec_registry.pypass,each file in its own process, with and without
SGLANG_IS_IN_CI(0 failed).--enable-nvidia-megakernel --enable-speculative-step-cuda-graph --hicache-async-ready-syncat--max-running-requests8: the start-up warm-up captured the sampled keys of batch sizes 1 to 8 and the greedybatch-size-1 key on 8 / 8 ranks (37 start-up requests, no memory refusal), and GSM8K-200 (5-shot, greedy) scored
0.985 / 0.990 at 4 concurrent requests and 0.985 / 0.995 at 8 (all on / stock).
returned HTTP 200, the first with output that fully matches the regex, the second with output that parses and
validates against the schema.
SGLANG_SIMULATE_ACC_LENset (dummy weights): the start-up warm-up ran its 37 requests and captured its keys withno capture error, and decode steps replayed the step graph.
SGLANG_ENABLE_EAGLE_POST_VERIFY_CUDA_GRAPH=1(dummy weights), the server logsenable_speculative_step_cuda_graph disabled: SGLANG_ENABLE_EAGLE_POST_VERIFY_CUDA_GRAPH is not supported. Falling back to the per-stage CUDA graphs.and serves every request with the megakernel on and the per-stage graphs; on that head the eligibility test file,
with its fallback test, also passes on the GPU host with and without
SGLANG_IS_IN_CI.After each merge of SGLang main (
00394f9f35, then9e9296fdf3), this branch was checked again on CPU: SGLang'spre-commit checks pass on this PR's files; on that main, alone and together with the megakernel hooks PR (merged with
the same main), this PR's CPU tests pass, and the registered CPU suites it touches fail on no test id that does not
also fail on SGLang main itself. After the merge of
9e9296fdf3, this branch was checked again on 8 x B300 togetherwith the megakernel hooks PR (merged with the same main), #45795 (at
6ffe9cd46c) and the GLM-5.3plugin PR, with GLM-5.3 NVFP4 and the same three flags at
--max-running-requests8, at 3 and at 5 draft steps: thestart-up warm-up captured the sampled keys of batch sizes 1 to 8 and the greedy batch-size-1 key on 8 / 8 ranks (37
start-up requests, no memory refusal), the step graph replayed on the DSA attention backend with no fallback, and
GSM8K-200 (5-shot, greedy) scored 0.995 with 3 draft steps and 0.990 with 5 at 4 concurrent requests, and 0.985 with
3 at 8 (one run each). The other GPU checks above ran before these merges.
Accuracy Tests
GLM-5.3 NVFP4, 8 x B300, TP 8, MTP (EAGLE, 3 steps, topk 1, 4 draft tokens), real acceptance, this PR alone on SGLang
main
af856717c2(stock attention and MoE). "On" is--enable-speculative-step-cuda-graphwith the six overrides setto 1, the same pieces as the flag alone; "off" is the flag off with no override set:
test_spec_step_graph_switches.py+ its 3 kernel test files, run on an earlier revision of this PR with an earlier revision of the megakernel hooks PR (#46210) and an earlier version of the HiCache change of #45795 applied), also withSGLANG_IS_IN_CI=trueunit/spec/test_spec_step_graph_switches.py(CPU: launch arguments parsed, resolved and published as a scheduler process publishes them), also withSGLANG_IS_IN_CI=true=0turns off only its piece, and without the flag (or when startup turns it off) all six are offunit/spec/test_eagle_step_cuda_graph_eligibility.py) and of the kernel inventory (test_reclassified_public_entry_points_are_inventoriedinunit/kernels/test_kernels_namespace.py)--max-running-requests4 and 1 to 8 at 16), one request per batch size k with k distinct prompts per DP rank, gives a missing size one more batch and then a warning (a key of another sampling mode or a constrained key does not count), and sends nothing without an active step graph runner; the draft-extend tail is in the kernel inventoryThe "on" runs above set the six overrides to 1 because they were made on earlier revisions of this PR, in which the
overrides did not yet follow the flag; in this revision the flag alone turns on the same six pieces
(the
test_spec_step_graph_switches.pyrow).On the stack of the unit and kernel test row above, the draft-extend tail and relay scatter files also pass when run
as
python3 <file>(15 and 18 passed).On 4 x B300 with this PR alone on SGLang main
af856717c2, the GLM-5.2 NVFP4 step-graph e2e(
e2e/models/test_dsa_glm52_nvfp4_tp_mtp_step_graph.py, 3 tests, real acceptance) passes with the step graph alone(the six pieces off): GSM8K 0.952 (acceptance length 3.96) and the step graph replays with no capture failure.
That run used an earlier revision of this PR, in which the flag turned on the step graph alone. With the flag that
also turns on the six pieces, the e2e was rerun with
3ba3fd1d2ealone on SGLang maindba22e9b68(4 x B300): 3tests OK, GSM8K 0.942, acceptance length 3.97.
Speed Tests and Profiling
Per decode step at one request (
--max-running-requests1): GLM-5.3 NVFP4 on 8 x B300, TP 8, MTP (EAGLE, 3 steps,topk 1, 4 draft tokens), fixed acceptance length 2.99. Stack: SGLang main
af856717c2with earlierrevisions of this PR and of the megakernel hooks PR (#46210) and an earlier version of the deferred HiCache
ready-count sync now proposed in #45795 (
--hicache-async-ready-sync), plus an earlier revision of thesgl-nvidia-mega GLM-5.3 target and draft specs (sgl-project/sgl-nvidia-mega#24; slots
attention,moe,hops,draft, embedding replicationon). Workload (a local client script, not part of this PR): a synthetic multi-turn chat with a 253K-token prefix, then a 150-token and a 1,000-token reply;
HiCache write-back with a 270 GB host pool. ms per decode step = the median client-side chunk interval of the
1,000-token reply after its first 50 chunks.
--enable-speculative-step-cuda-graphwith the six overrides set to 1 (the same pieces as the flag alone).Off, for a single piece: that piece's override set to 0, everything else on (for the step CUDA graph row: the flag
off, the six overrides set to 1). Off, for "all of this PR": the flag off and no override set. The megakernel and
--hicache-async-ready-syncstay on in every run of this table. Without the step graph the fused input copy hasnothing to copy, and without the lean sampled verify the chunked verify sampling, which runs under it, is off too.
sync flag off, twice (not reported here); on; step CUDA graph off, packed verify broadcast off; on; lean sampled
verify off, fused relay off; on; fused draft-extend tail off, fused input copy off; on; chunked verify sampling off;
on.
"all of this PR", the mean of its two). The difference is off - on (positive: the piece makes the step shorter),
computed before rounding.
The seven all-on runs span 0.10 ms (5.37 to 5.47 ms per step). Only the difference for the whole PR is larger than
that range; each single piece's difference is within it.
On a multi-turn agentic coding trace, the public Hugging Face dataset
semianalysisai/cc-traces-weka-062126(splittrain), replayed as recorded (about one hour per run; its requests set no sampling field, so they run with theserver's default sampling): GLM-5.3 NVFP4 on 8 x B300, TP 8, MTP as above, fixed acceptance length 2.99, HiCache
write-back with a 270 GB host pool,
--cuda-graph-max-bs-decodeequal to--max-running-requests, SGLang's compiledRust radix-tree core in every run. "Stock" is SGLang main
dba22e9b68with none of the flags below. "All on" is SGLangmain
dba22e9b68with3ba3fd1d2e, the megakernel hooks PR (465a9dd5b7), #45795 at its head29e8125875and the GLM-5.3 plugin PR (ad0bf9103d), launched with--enable-nvidia-megakernel --enable-speculative-step-cuda-graph --hicache-async-ready-syncand no override set. The servers of each row ran onone host in one session. Each cell is all on / stock.
--max-running-requestsp90 interactivity is 1 / the p90 inter-token latency and p90 end-to-end normalized interactivity is 1 / the p90
end-to-end time per output token (higher is better for both); for p90 time to first token, lower is better. Usage
counts on this SGLang main include a known reasoning-token over-count at
max_tokens; the numbers here count eachrequest's output tokens as its usage
completion_tokens. The all-on server ran once per row. The stock server rantwice per row, on the same host in the same session, and the table uses its second run; against its first run, all
on gives 1.47x p90 interactivity and 1.34x p90 end-to-end normalized interactivity at one user, and 1.25x and 1.12x
at four users.
The gain over stock includes the megakernel's (the GLM-5.3 plugin PR reports it without this PR). At four users, the
all-on server was also run with this PR's previous revision (
9258cb78da, which captures only the batch-size-1 keysat start-up), on the same host in the same session. There the sampled keys of batch sizes 2 to 5 (the sizes that run
reached) were first met while serving, when 7 of the 8 ranks (batch sizes 2 and 3) or 1 of them (batch sizes 4 and
5) had 372-750 MiB free against 1,046 MiB needed, with about 34 GiB on each of those ranks held in PyTorch's caching
allocator but not allocated. The capture check refused them 266 times, and 86 % of the decode steps replayed (36,654
ran the existing path). With this revision (the table's four-user run) there was no memory refusal and no step on the
existing path. This is one run each, so no speed-up is claimed from it. At one user, on the same host in the same
session, this revision and the previous one gave the same p90 interactivity (one run each).
In an earlier session on SGLang main
74c08f3dc5, with an earlier revision of this PR that captured the batch-size-1keys at start-up, the all-on server was also run at one user without that warm-up (that revision's code without the
warm-up but with the diagnostics, and the plugin PR's revision
ef1ead3681), on the same host in the same session.There the sampled batch-size-1 key was refused for memory for the whole run, with 504-506 MiB free on 7 of 8 ranks
against 1,046 MiB needed (most likely trigger: #45565, the larger default MLA prefill CUDA graph;
not isolated), so every step ran the existing path with this PR's other pieces. With the warm-up, p90 interactivity
was 1.005x and p90 end-to-end normalized interactivity 1.010x that run's (one run each): at one user the warm-up makes
the step graph run, but it is not a measurable speed-up there, in line with the step CUDA graph row of the per-step
table above. In another session on that main, with the revision
f35a9e5f82(where, too, the step graph ran nosampled step at one user), this PR's other pieces and the deferred HiCache sync together gave about 2 % higher p90
interactivity than the megakernel server without them, with p90 end-to-end normalized interactivity about the same
(one run each).
On SGLang main
286e018594, the same recipe with this branch, the megakernel hooks PR,#45795 (at
6ffe9cd46c) and the up-to-date GLM-5.3 plugin PR (the revisions named above; this branchat
0d39d7fdbb), launched with the same three flags, against SGLang main286e018594with none of them (one run perserver; the two servers of each row on one host in one session; each cell is all on / stock):
--max-running-requestsThe gain over stock includes the megakernel's, as above.
Checklist
How to run
To bisect, set one piece's override to 0 (for example
SGLANG_SPEC_FUSED_RELAY=0) with the same command.CI States
Latest PR Test (Base): ⊘ Skipped -- a maintainer comments
/tag-and-rerun-cito run CI tests.Latest PR Test (Extra): ⊘ Skipped -- a maintainer comments
/tag-and-rerun-cito run CI tests.Latest PR Test (AMD ROCm 10): ❌ Run #40886818721
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: