Clean Some Environment Variables for DeepSeek V32 (#15938)

This commit is contained in:
Baizhou Zhang
2026-01-07 14:00:16 +08:00
committed by GitHub
parent 5c04088b3a
commit 7d757d6f17
8 changed files with 39 additions and 108 deletions
@@ -22,9 +22,6 @@ from sglang.srt.layers.attention.nsa.transform_index import (
transform_index_page_table_prefill,
)
from sglang.srt.layers.attention.nsa.utils import (
NSA_ENABLE_MTP_PRECOMPUTE_METADATA,
NSA_FLASHMLA_BACKEND_DECODE_COMPUTE_FP8,
NSA_FUSE_TOPK,
can_nsa_prefill_cp_round_robin_split,
compute_nsa_seqlens,
is_nsa_enable_prefill_cp,
@@ -230,7 +227,7 @@ class NSAIndexerMetadata(BaseIndexerMetadata):
else:
page_table_size_1 = self.attn_metadata.page_table_1
if not NSA_FUSE_TOPK:
if not envs.SGLANG_NSA_FUSE_TOPK.get():
return fast_topk_v2(logits, seq_lens_topk, topk, row_starts=ks)
elif self.topk_transform_method == TopkTransformMethod.PAGED:
# NOTE(dark): if fused, we return a transformed page table directly
@@ -1222,12 +1219,6 @@ class NativeSparseAttnBackend(
assert q_rope is not None
kv_cache = forward_batch.token_to_kv_pool.get_key_buffer(layer.layer_id)
# when store in fp8 and compute in fp8, no need to convert dtype
if not (
NSA_FLASHMLA_BACKEND_DECODE_COMPUTE_FP8 and self.nsa_kv_cache_store_fp8
):
kv_cache = kv_cache.to(q.dtype)
if q_rope is not None:
q_nope = q.view(-1, layer.tp_q_head_num, layer.v_head_dim)
q_rope = q_rope.view(
@@ -1245,7 +1236,7 @@ class NativeSparseAttnBackend(
# NOTE(dark): here, we use page size = 1
topk_transform_method = self.get_topk_transform_method()
if NSA_FUSE_TOPK:
if envs.SGLANG_NSA_FUSE_TOPK.get():
page_table_1 = topk_indices
else:
if topk_transform_method == TopkTransformMethod.RAGGED:
@@ -1283,8 +1274,6 @@ class NativeSparseAttnBackend(
if q_rope is not None:
q_all = _concat_mla_absorb_q_general(q_nope, q_rope)
# NSA_FLASHMLA_BACKEND_DECODE_COMPUTE_FP8 has no effect here,
# because the flashmla_sparse kernel doesn't support fp8 compute
if topk_transform_method == TopkTransformMethod.RAGGED:
if any(forward_batch.extend_prefix_lens_cpu):
page_table_1_flattened = (
@@ -1384,7 +1373,7 @@ class NativeSparseAttnBackend(
if topk_indices is not None:
topk_indices = self._pad_topk_indices(topk_indices, q_nope.shape[0])
if NSA_FUSE_TOPK:
if envs.SGLANG_NSA_FUSE_TOPK.get():
page_table_1 = topk_indices
else:
page_table_1 = transform_index_page_table_decode(
@@ -1562,7 +1551,7 @@ class NativeSparseAttnBackend(
kv_cache = kv_cache.view(-1, self.real_page_size, 1, self.kv_cache_dim)
assert self.real_page_size == 64, "only page size 64 is supported"
if NSA_FLASHMLA_BACKEND_DECODE_COMPUTE_FP8 and not self.nsa_kv_cache_store_fp8:
if not self.nsa_kv_cache_store_fp8:
# inefficiently quantize the whole cache
kv_cache = quantize_k_cache(kv_cache)
@@ -1584,7 +1573,7 @@ class NativeSparseAttnBackend(
block_table=torch.empty(
(q_all.shape[0], 0), dtype=torch.int32, device=q_all.device
),
is_fp8_kvcache=NSA_FLASHMLA_BACKEND_DECODE_COMPUTE_FP8,
is_fp8_kvcache=True,
)
return o
@@ -1787,7 +1776,7 @@ class NativeSparseAttnBackend(
def get_topk_transform_method(self) -> TopkTransformMethod:
"""
NSA_FUSE_TOPK controls whether to fuse the topk transform into the topk kernel.
SGLANG_NSA_FUSE_TOPK controls whether to fuse the topk transform into the topk kernel.
This method is used to select the topk transform method which can be fused or unfused.
"""
if (
@@ -1819,7 +1808,7 @@ class NativeSparseAttnBackend(
num_q_tokens_per_head_k=seq_len_q * self.num_q_heads // 1,
num_heads_k=1,
num_heads_q=self.num_q_heads,
is_fp8_kvcache=NSA_FLASHMLA_BACKEND_DECODE_COMPUTE_FP8,
is_fp8_kvcache=True,
topk=self.nsa_index_topk,
)
@@ -1871,7 +1860,7 @@ class NativeSparseAttnMultiStepBackend:
def init_forward_metadata_replay_cuda_graph(
self, forward_batch: ForwardBatch, bs: int
):
if NSA_ENABLE_MTP_PRECOMPUTE_METADATA:
if envs.SGLANG_NSA_ENABLE_MTP_PRECOMPUTE_METADATA.get():
# Precompute metadata once (shared across all backends)
precomputed = self.attn_backends[0]._precompute_replay_metadata(
bs=bs,