Make sure we always disable symm memory without dp padding (#18129)
This commit is contained in:
@@ -320,9 +320,11 @@ class GroupCoordinator:
|
||||
from sglang.srt.distributed.device_communicators.torch_symm_mem import (
|
||||
TorchSymmMemCommunicator,
|
||||
)
|
||||
from sglang.srt.layers.dp_attention import is_allocation_symmetric
|
||||
|
||||
self.is_symmetric_memory_enabled = is_symmetric_memory_enabled
|
||||
self.use_symmetric_memory = use_symmetric_memory
|
||||
self.is_allocation_symmetric = is_allocation_symmetric
|
||||
if is_hip():
|
||||
from sglang.srt.distributed.device_communicators.quick_all_reduce import (
|
||||
QuickAllReduce,
|
||||
@@ -807,7 +809,9 @@ class GroupCoordinator:
|
||||
# torch.compile . see https://github.com/pytorch/pytorch/issues/138795
|
||||
output_size = (input_size[0] * world_size,) + input_size[1:]
|
||||
# Allocate output tensor.
|
||||
with self.use_symmetric_memory(self):
|
||||
with self.use_symmetric_memory(
|
||||
self, disabled=not self.is_allocation_symmetric()
|
||||
):
|
||||
output_tensor = torch.empty(
|
||||
output_size, dtype=input_.dtype, device=input_.device
|
||||
)
|
||||
|
||||
@@ -114,7 +114,7 @@ class _DpGatheredBufferWrapper:
|
||||
|
||||
@classmethod
|
||||
def get_global_dp_buffer(cls) -> torch.Tensor:
|
||||
with use_symmetric_memory(get_tp_group()):
|
||||
with use_symmetric_memory(get_tp_group(), disabled=not cls._dp_max_padding):
|
||||
buffer = torch.empty(
|
||||
(cls._global_dp_buffer_len, cls._hidden_size),
|
||||
dtype=cls._dtype,
|
||||
|
||||
@@ -23,6 +23,7 @@ from sglang.srt.layers.dp_attention import (
|
||||
attn_tp_all_reduce,
|
||||
get_attention_tp_rank,
|
||||
get_attention_tp_size,
|
||||
is_allocation_symmetric,
|
||||
)
|
||||
from sglang.srt.layers.parameter import BasevLLMParameter
|
||||
from sglang.srt.layers.quantization.base_config import (
|
||||
@@ -482,7 +483,9 @@ class VocabParallelEmbedding(torch.nn.Module):
|
||||
masked_input = input_
|
||||
|
||||
# Get the embeddings.
|
||||
with use_symmetric_memory(get_tp_group(), disabled=not self.enable_tp):
|
||||
with use_symmetric_memory(
|
||||
get_tp_group(), disabled=not is_allocation_symmetric()
|
||||
):
|
||||
output_parallel = self.quant_method.embedding(self, masked_input.long())
|
||||
|
||||
if self.tp_size > 1:
|
||||
|
||||
Reference in New Issue
Block a user