Fix dpsk-r1-fp4 tp8 by reverting two commits (#13162 and #13341) (#13348)

Co-authored-by: Kangyan-Zhou <zky314343421@gmail.com>
This commit is contained in:
Qiaolin Yu
2025-11-15 21:31:36 -08:00
committed by GitHub
parent f969664172
commit 78a4b446c6
5 changed files with 14 additions and 17 deletions

View File

@@ -284,17 +284,9 @@ class ExpertLocationMetadata:
# -------------------------------- usage ------------------------------------
def logical_to_all_physical(
self,
layer_id: int,
logical_expert_id: int,
require_global_experts: bool = False,
self, layer_id: int, logical_expert_id: int
) -> List[int]:
# Use CPU copy to avoid GPU→CPU sync on every call, which is expensive in update weights scenario
if require_global_experts:
num_physical_experts = self.logical_to_all_physical_map_cpu[layer_id].shape[
-1
]
return list(torch.arange(0, num_physical_experts))
return [
physical_expert_id
for physical_expert_id in self.logical_to_all_physical_map_cpu[
@@ -363,10 +355,14 @@ def _compute_logical_to_all_physical_map(
)
# Replace by the nearest physical expert
if nearest_expert != -1:
logical_to_all_physical_map[layer_id][logical_expert_id] = [
nearest_expert
]
mapped_physical_experts = logical_to_all_physical_map[layer_id][
logical_expert_id
]
if (
nearest_expert != -1
and nearest_expert not in mapped_physical_experts
):
mapped_physical_experts[0] = nearest_expert
logical_to_all_physical_map = _pad_nested_array(
logical_to_all_physical_map, pad_value=-1

View File

@@ -539,12 +539,9 @@ class FusedMoE(torch.nn.Module):
# This is a shared expert.
physical_expert_ids = [expert_id]
else:
require_global_experts = getattr(
param, "_sglang_require_global_experts", False
)
physical_expert_ids = (
global_expert_location_metadata.logical_to_all_physical(
self.layer_id, expert_id, require_global_experts
self.layer_id, expert_id
)
)
@@ -1129,6 +1126,7 @@ class FlashInferFP4MoE(FusedMoE):
local_expert_offset=self.moe_ep_rank * self.num_local_experts,
local_num_experts=self.num_local_experts,
routed_scaling_factor=self.moe_runner_config.routed_scaling_factor,
tile_tokens_dim=None,
routing_method_type=RoutingMethodType.DeepSeekV3,
do_finalize=True,
output=symm_output,

View File

@@ -1245,6 +1245,7 @@ class Fp8MoEMethod(FusedMoEMethodBase):
routed_scaling_factor=(
routed_scaling_factor if routed_scaling_factor is not None else 1.0
),
tile_tokens_dim=None,
routing_method_type=routing_method_type,
use_shuffled_weight=False,
)

View File

@@ -739,6 +739,7 @@ class ModelOptFp8MoEMethod(FusedMoEMethodBase):
else 1.0
),
use_routing_scales_on_input=use_routing_scales_on_input,
tile_tokens_dim=None,
routing_method_type=routing_method_type,
)

View File

@@ -681,6 +681,7 @@ class Mxfp4MoEMethod(FusedMoEMethodBase):
layer.moe_ep_rank * layer.num_local_experts, # local_expert_offset
layer.num_local_experts, # local num experts
None,
None, # tile_tokens_dim
1, # routing_method_type, renormalize
True, # do finalize
output=symm_output,