From 82e7cdcff9aa5f49156c3ace73a826f30854ae91 Mon Sep 17 00:00:00 2001 From: Baizhou Zhang Date: Sun, 12 Jul 2026 23:25:03 -0700 Subject: [PATCH] [Misc] Remove a few dead code paths in DSA (#30973) --- python/sglang/srt/environ.py | 2 -- .../attention/dsa/dsa_backend_mtp_precompute.py | 8 ++------ .../sglang/srt/layers/attention/dsa_backend.py | 16 +++------------- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/python/sglang/srt/environ.py b/python/sglang/srt/environ.py index edf356ef1..84f78fe72 100644 --- a/python/sglang/srt/environ.py +++ b/python/sglang/srt/environ.py @@ -669,8 +669,6 @@ class Envs: SGLANG_ENABLE_PCG_DSV2_DUAL_STREAM = EnvBool(False) SGLANG_DSA_TOPK_BROADCAST = EnvBool(False) SGLANG_DISABLE_DSA_INDEXER_FUSION = EnvBool(False) - SGLANG_USE_FUSED_METADATA_COPY = EnvBool(True) - SGLANG_DSA_USE_FUSED_METADATA_GENERATION = EnvBool(True) # sgl-kernel SGLANG_SKIP_SGL_KERNEL_VERSION_CHECK = EnvBool(False) diff --git a/python/sglang/srt/layers/attention/dsa/dsa_backend_mtp_precompute.py b/python/sglang/srt/layers/attention/dsa/dsa_backend_mtp_precompute.py index c48126602..ce26ff518 100644 --- a/python/sglang/srt/layers/attention/dsa/dsa_backend_mtp_precompute.py +++ b/python/sglang/srt/layers/attention/dsa/dsa_backend_mtp_precompute.py @@ -11,7 +11,6 @@ from typing import TYPE_CHECKING, Optional import torch -from sglang.srt.environ import envs from sglang.srt.layers.attention.dsa.utils import compute_dsa_seqlens from sglang.srt.layers.attention.utils import seqlens_expand_triton from sglang.srt.utils import is_cuda, is_hip @@ -21,9 +20,6 @@ if TYPE_CHECKING: _is_cuda = is_cuda() _is_hip = is_hip() -_USE_FUSED_METADATA_GENERATION = ( - envs.SGLANG_DSA_USE_FUSED_METADATA_GENERATION.get() and not _is_hip -) @dataclass @@ -125,7 +121,7 @@ class DeepseekSparseAttnBackendMTPPrecomputeMixin: """Precompute metadata for normal decode mode.""" max_len = self.decode_cuda_graph_metadata[bs].page_table_1.shape[1] - if _USE_FUSED_METADATA_GENERATION and _is_cuda and not _is_hip: + if _is_cuda and not _is_hip: from sglang.kernels.ops.attention.dsa_metadata import ( fused_dsa_decode_metadata, ) @@ -244,7 +240,7 @@ class DeepseekSparseAttnBackendMTPPrecomputeMixin: max_seqlen_k = self.decode_cuda_graph_metadata[bs].page_table_1.shape[1] seqlens_expanded_size = bs * self.speculative_num_draft_tokens - if _USE_FUSED_METADATA_GENERATION and _is_cuda and not _is_hip: + if _is_cuda and not _is_hip: from sglang.kernels.ops.attention.dsa_metadata import ( fused_dsa_target_verify_metadata, ) diff --git a/python/sglang/srt/layers/attention/dsa_backend.py b/python/sglang/srt/layers/attention/dsa_backend.py index 5a6467b74..093578e08 100644 --- a/python/sglang/srt/layers/attention/dsa_backend.py +++ b/python/sglang/srt/layers/attention/dsa_backend.py @@ -136,16 +136,6 @@ def _to_2d_context_lens(seqlens_32: torch.Tensor, batch_size: int) -> torch.Tens return seqlens_32.contiguous().view(-1, 1) -# Reuse this workspace buffer across all DSA backend instances - -# Control whether to use fused metadata copy kernel for cuda graph replay (default: enabled) -# Set SGLANG_USE_FUSED_METADATA_COPY=0 or false to disable -_USE_FUSED_METADATA_COPY = envs.SGLANG_USE_FUSED_METADATA_COPY.get() and not _is_hip -_USE_FUSED_METADATA_GENERATION = ( - envs.SGLANG_DSA_USE_FUSED_METADATA_GENERATION.get() and not _is_hip -) - - @dataclass(frozen=True) class DSAFlashMLAMetadata: """Metadata only needed by FlashMLA""" @@ -1381,7 +1371,7 @@ class DeepseekSparseAttnBackend( # Normal Decode max_len = self._graph_page_table_width(metadata) - if _USE_FUSED_METADATA_GENERATION and is_cuda() and not _is_hip: + if is_cuda() and not _is_hip: from sglang.kernels.ops.attention.dsa_metadata import ( fused_dsa_decode_metadata, ) @@ -1423,7 +1413,7 @@ class DeepseekSparseAttnBackend( elif forward_mode.is_target_verify(): max_seqlen_k = self._graph_page_table_width(metadata) - if _USE_FUSED_METADATA_GENERATION and is_cuda() and not _is_hip: + if is_cuda() and not _is_hip: from sglang.kernels.ops.attention.dsa_metadata import ( fused_dsa_target_verify_metadata, ) @@ -1521,7 +1511,7 @@ class DeepseekSparseAttnBackend( device=self.device, ) - if _USE_FUSED_METADATA_GENERATION and is_cuda() and not _is_hip: + if is_cuda() and not _is_hip: from sglang.kernels.ops.attention.dsa_metadata import ( fused_dsa_draft_extend_metadata, )