[WideEP] Integrate DeepEP v2 (#41183)
Signed-off-by: Tyler Michael Smith <tlrmchlsmth@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
05cb606cad
commit
e2f993dc41
@@ -566,7 +566,7 @@ class DeepseekV4MoE(nn.Module):
|
||||
if self.use_mega_moe:
|
||||
self._init_mega_moe_experts(vllm_config, config, prefix)
|
||||
else:
|
||||
self._init_fused_moe_experts(config, quant_config, prefix)
|
||||
self._init_fused_moe_experts(vllm_config, config, quant_config, prefix)
|
||||
|
||||
def _init_mega_moe_experts(
|
||||
self,
|
||||
@@ -612,22 +612,27 @@ class DeepseekV4MoE(nn.Module):
|
||||
|
||||
def _init_fused_moe_experts(
|
||||
self,
|
||||
vllm_config: VllmConfig,
|
||||
config,
|
||||
quant_config,
|
||||
prefix: str,
|
||||
) -> None:
|
||||
parallel_config = vllm_config.parallel_config
|
||||
self.tp_rank = get_tensor_model_parallel_rank()
|
||||
assert config.n_routed_experts % self.tp_size == 0
|
||||
|
||||
self.n_local_experts = config.n_routed_experts // self.tp_size
|
||||
self.experts_start_idx = self.tp_rank * self.n_local_experts
|
||||
self.experts_end_idx = self.experts_start_idx + self.n_local_experts
|
||||
|
||||
self.n_redundant_experts = 0
|
||||
eplb_config = parallel_config.eplb_config
|
||||
self.n_redundant_experts = eplb_config.num_redundant_experts
|
||||
self.n_shared_experts = config.n_shared_experts or 0
|
||||
self.n_logical_experts = self.n_routed_experts
|
||||
self.n_physical_experts = self.n_logical_experts
|
||||
self.n_local_physical_experts = self.n_local_experts
|
||||
self.n_physical_experts = self.n_logical_experts + self.n_redundant_experts
|
||||
assert self.n_physical_experts % self.tp_size == 0, (
|
||||
f"n_physical_experts={self.n_physical_experts} must be divisible by "
|
||||
f"tp_size={self.tp_size}. Adjust num_redundant_experts."
|
||||
)
|
||||
self.n_local_physical_experts = self.n_physical_experts // self.tp_size
|
||||
self.n_local_experts = self.n_local_physical_experts
|
||||
self.experts_start_idx = self.tp_rank * self.n_local_experts
|
||||
self.experts_end_idx = self.experts_start_idx + self.n_local_experts
|
||||
self.physical_expert_start = self.experts_start_idx
|
||||
self.physical_expert_end = self.experts_end_idx
|
||||
|
||||
@@ -647,6 +652,8 @@ class DeepseekV4MoE(nn.Module):
|
||||
hash_indices_table=self.gate.tid2eid,
|
||||
swiglu_limit=self.swiglu_limit,
|
||||
router_logits_dtype=torch.float32,
|
||||
enable_eplb=parallel_config.enable_eplb,
|
||||
num_redundant_experts=eplb_config.num_redundant_experts,
|
||||
)
|
||||
|
||||
def forward(
|
||||
|
||||
Reference in New Issue
Block a user