[Perf] Fix moe reduce_scatter perf regression by removing additional comm, 5% E2E throughput gain back. (#48763)
Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
@@ -8,7 +8,10 @@ import torch.nn as nn
|
||||
|
||||
from vllm._aiter_ops import rocm_aiter_ops
|
||||
from vllm.config import VllmConfig
|
||||
from vllm.distributed import tensor_model_parallel_all_reduce
|
||||
from vllm.distributed import (
|
||||
tensor_model_parallel_all_gather,
|
||||
tensor_model_parallel_all_reduce,
|
||||
)
|
||||
from vllm.model_executor.layers.fused_moe import (
|
||||
fused_moe_make_expert_params_mapping,
|
||||
)
|
||||
@@ -24,10 +27,7 @@ from vllm.model_executor.model_loader.weight_utils import (
|
||||
default_weight_loader,
|
||||
maybe_remap_kv_scale_name,
|
||||
)
|
||||
from vllm.model_executor.models.deepseek_mtp import (
|
||||
SharedHead,
|
||||
_restore_full_token_layout_if_needed,
|
||||
)
|
||||
from vllm.model_executor.models.deepseek_mtp import SharedHead
|
||||
from vllm.model_executor.models.deepseek_v2 import (
|
||||
DeepseekV2MixtureOfExperts,
|
||||
DeepseekV2MoE,
|
||||
@@ -95,13 +95,8 @@ class DeepseekV32MultiTokenPredictorLayer(nn.Module):
|
||||
hidden_states, residual = self.mtp_block(
|
||||
positions=positions, hidden_states=hidden_states, residual=None
|
||||
)
|
||||
hidden_states, residual = _restore_full_token_layout_if_needed(
|
||||
hidden_states,
|
||||
residual,
|
||||
positions.shape[0],
|
||||
is_sequence_parallel=self.mtp_block.use_sequence_parallel_moe,
|
||||
)
|
||||
if not self.mtp_block.use_sequence_parallel_moe:
|
||||
is_sequence_parallel = self.mtp_block.use_sequence_parallel_moe
|
||||
if not is_sequence_parallel:
|
||||
# Without sequence parallelism, the MoE output is left un-reduced.
|
||||
hidden_states = tensor_model_parallel_all_reduce(hidden_states)
|
||||
# Recycle the POST-final-norm hidden into the next draft step. The
|
||||
@@ -115,6 +110,9 @@ class DeepseekV32MultiTokenPredictorLayer(nn.Module):
|
||||
# the legacy proposer (model_returns_tuple is True for the
|
||||
# DeepSeekMTPModel architecture).
|
||||
hidden_states, _ = self.shared_head.norm(hidden_states, residual)
|
||||
if is_sequence_parallel:
|
||||
hidden_states = tensor_model_parallel_all_gather(hidden_states, 0)
|
||||
hidden_states = hidden_states[: positions.shape[0]]
|
||||
return hidden_states, hidden_states
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user