From ee77a7d3307db377682effcfe44e394edbadf0a3 Mon Sep 17 00:00:00 2001 From: Jackey Hua <107608053+zhendonghua@users.noreply.github.com> Date: Fri, 26 Jun 2026 12:17:34 -0700 Subject: [PATCH] [Fix] DSA: size cudagraph page_table to req_to_token width (#29379) Co-authored-by: Claude Opus 4.8 (1M context) --- python/sglang/srt/layers/attention/dsa_backend.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/sglang/srt/layers/attention/dsa_backend.py b/python/sglang/srt/layers/attention/dsa_backend.py index eb48fd0ac..18066b0db 100644 --- a/python/sglang/srt/layers/attention/dsa_backend.py +++ b/python/sglang/srt/layers/attention/dsa_backend.py @@ -1003,11 +1003,11 @@ class DeepseekSparseAttnBackend( max_bs + 1, dtype=torch.int32, device=self.device ), # fake page_table for sparse_prefill - # Add extra columns for speculative draft tokens to avoid - # overflow during target_verify when max_seqlen_k = seq_len + num_draft_tokens + # Match req_to_token's width exactly. It is over-allocated beyond + # context_len because spec decoding lets seq_len transiently overshoot. "page_table": torch.zeros( max_num_tokens, - self.max_context_len + (self.speculative_num_draft_tokens or 0), + self.req_to_token.shape[1], dtype=torch.int32, device=self.device, ),