Repository navigation
Conversation
Merged
3 of 5 tasks
…ail-row bucket Eager prefill steps under decoder SWA bounded replay run layers after the last kv_source layer on each request's last 128 rows. Those rows now replay a breakable CUDA graph captured per 128-row bucket on first use; the SWA KV store, attention and low-ratio sources stay eager breaks reading the live tail metadata. Off by default: SGLANG_DSV4_DECODER_REPLAY_GRAPH_MAX_ROWS=0.
Kernels that size cached workspaces by row count reallocate them on a larger step. A graph captured before the first full prefill chunk kept reading the freed workspace and faulted once flush_cache emptied the CUDA cache.
The TP-padded query buffer is cached on the tail metadata of the step that first needs it, here an eager warmup of the capture. The graph writes it by address on every replay, so the metadata must outlive that step.
…d replay The bank captures tail-row buckets up to 2048 rows (16 buckets, 0.11 GiB per GPU on GB300 TP4) whenever --enable-decoder-swa-bounded-replay is set; SGLANG_DSV4_DECODER_REPLAY_GRAPH_MAX_ROWS=0 keeps the late layers eager.
YAMY1234
force-pushed
the
dsv41-replay-graph-bank
branch
from
October 12, 2026 18:07
d9a7edd to
963a752
Compare
Collaborator
|
Closed due to #43476 merged |
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.
Motivation
With
--enable-decoder-swa-bounded-replay, the layers after the last KV-source layer (21–39 on DeepSeek-V4.1-Flash) run only on each request's last 128 extend rows. That removes about 40% of a prefill step's GPU work. It does not make the step faster. An eager V4.1 prefill forward issues about 2,000 kernel launches per 8K chunk, so it is paced by the host, not the GPU. The trim removes GPU time but no launches.prefill_repro.py(stdlib only)On main, cold prefill with the flag runs at about 49K input tok/s, the same as without it.
Modifications
python/sglang/srt/models/deepseek_v4_replay_graphs.py:DecoderReplayGraphskeeps one breakable CUDA graph per tail-row bucket (multiples of 128) and replays the trimmed late layers from it on eager prefill steps.DeepseekV4Modelsends the tail to the bank when its row count fits a bucket. Steps with DSpark hidden-state capture, context parallelism, a prefill-graph replay, or on ROCm keep the eager path.SGLANG_DSV4_DECODER_REPLAY_GRAPH_MAX_ROWS=2048(16 graphs);0keeps the late layers eager.SGLANG_DSV4_DECODER_REPLAY_GRAPH_DEBUG=1replays segment by segment with a sync and names a faulting segment.--enable-decoder-swa-bounded-replay.test/registered/unit/model_executor/test_decoder_replay_graphs.py(buckets, state round trip, replay refill).Memory: buckets are captured on first use into their own graph pool; after a benchmark run that captured 3 buckets it held 1.15 GiB per GPU. KV capacity is unchanged (62,784,256 tokens on main and with this PR).
Accuracy Tests
DeepSeek-V4.1-Flash, 4×GB300, TP4/EP4, both bounded-replay flags, no tuning flags. Cold prompts, then full prefix hits:
Speed Tests and Profiling
DeepSeek-V4.1-Flash on 4×GB300, TP4/EP4,
--enable-decoder-swa-bounded-replay --chunked-prefill-size 8192 --max-running-requests 64 --mem-fraction-static 0.8, no other tuning flags. Main and this PR on the same node, two rounds in reversed order; each value is the average of both rounds. Cold points send random token-id prompts with one output token; hit points cache the prefix first and add 1,024 new tokens.¹ 74.8K and 65.1K in the two rounds. Layers 0–20 still run eagerly, so the step is host-paced and sensitive to CPU noise (#43535 removes that).
KV capacity is unchanged (62,784,256 tokens). Buckets are captured on first use; in these runs the bank captured 3 buckets, 1.15 GiB per GPU.