[NPU] bug fix for multi stream (#15048)

This commit is contained in:
liupeng374
2025-12-14 16:38:12 +08:00
committed by GitHub
parent f50af32d8b
commit 4ea3642250
3 changed files with 12 additions and 2 deletions

View File

@@ -239,6 +239,7 @@ class Envs:
# NPU
SGLANG_NPU_DISABLE_ACL_FORMAT_WEIGHT = EnvBool(False)
SGLANG_NPU_USE_MULTI_STREAM = EnvBool(False)
# Quantization
SGLANG_INT4_WEIGHT = EnvBool(False)

View File

@@ -22,6 +22,7 @@ from transformers import PretrainedConfig
from sglang.srt.configs.model_config import is_deepseek_nsa
from sglang.srt.distributed import get_pp_group, get_tensor_model_parallel_world_size
from sglang.srt.environ import envs
from sglang.srt.eplb.expert_distribution import get_global_expert_distribution_recorder
from sglang.srt.layers.attention.nsa.utils import (
can_cp_split,
@@ -97,7 +98,11 @@ class DeepseekModelNextN(nn.Module):
self.eh_proj = nn.Linear(2 * config.hidden_size, config.hidden_size, bias=False)
self.alt_stream = torch.cuda.Stream() if _is_cuda or _is_npu else None
self.alt_stream = (
torch.cuda.Stream()
if _is_cuda or envs.SGLANG_NPU_USE_MULTI_STREAM.get()
else None
)
layer_name = "decoder"
if _is_npu and (

View File

@@ -3020,7 +3020,11 @@ class DeepseekV2Model(nn.Module):
else:
self.embed_tokens = PPMissingLayer()
self.alt_stream = torch.cuda.Stream() if _is_cuda or _is_npu else None
self.alt_stream = (
torch.cuda.Stream()
if _is_cuda or envs.SGLANG_NPU_USE_MULTI_STREAM.get()
else None
)
self.layers, self.start_layer, self.end_layer = make_layers(
config.num_hidden_layers,