Skip to content

Put the DSA cuda-graph page table in the pausable memory region - #33479

Merged
yueming-yuan merged 1 commit into
sglang-milesfrom
yueming/dsa-cuda-graph-tms
Aug 4, 2026
Merged

yueming-yuan merged 1 commit into
sglang-milesfrom
yueming/dsa-cuda-graph-tms

Conversation

@yueming-yuan

@yueming-yuan yueming-yuan commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Under RL training the engine is paused between rollouts to hand its GPU memory to the trainer. The DSA backend's wide page_tablemax_num_tokens x max_ctx_len int32, the dominant static cuda-graph buffer once speculative decoding widens max_num_tokens — stayed resident across the pause because init_cuda_graph_state allocated it outside the memory saver's cuda-graph region.

page_table and flashmla_metadata are rewritten in full by the replay metadata path before every replay, so neither needs to survive a pause; both move inside the region. cache_seqlens, cu_seqlens_q, cu_seqlens_k and real_page_table are written once at init and would silently come back zeroed after a resume, so they stay outside.

The region comes from TorchMemorySaverAdapter with the GPU_MEMORY_TYPE_CUDA_GRAPH tag, matching how the graph runners tag their pools. Without --enable-memory-saver and SGLANG_MEMORY_SAVER_CUDA_GRAPH=1 the helper returns a nullcontext, so allocation is byte-for-byte unchanged on the default path.

Measured on GLM-5.2 744B (DSA + EAGLE) on GB300.

🤖 Generated with Claude Code


CI States

Latest PR Test (Base): ❌ Run #30877692286
Latest PR Test (Extra): ❌ Run #30877692198

The wide page_table (max_num_tokens x max_ctx_len int32) is the dominant
static cuda-graph buffer under speculative decoding, and it stayed resident
while the engine was paused because it was allocated outside the memory
saver's cuda-graph region.

It and the flashmla metadata are rewritten in full by the replay metadata
path before every replay, so nothing needs to survive a pause. Allocate
both inside the region. cache_seqlens, cu_seqlens_q/k and real_page_table
are written once at init and would come back zeroed after a resume, so
they stay outside.

Only takes effect with --enable-memory-saver and
SGLANG_MEMORY_SAVER_CUDA_GRAPH=1; otherwise the region is a nullcontext
and allocation is unchanged.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@yueming-yuan
yueming-yuan merged commit c447264 into sglang-miles Aug 4, 2026
72 of 82 checks passed
@yueming-yuan
yueming-yuan deleted the yueming/dsa-cuda-graph-tms branch August 4, 2026 04:28
Kh4L pushed a commit to Kh4L/sglang that referenced this pull request Sep 8, 2026
Zhichenzzz pushed a commit that referenced this pull request Sep 19, 2026
…on (#33479)

(cherry picked from commit 5d8e317)
(cherry picked from commit 9607816)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant