@@ -146,7 +146,11 @@ def setUp(self):
146146 self .hier_comm_patch = patch (
147147 "vllm_ascend.ops.fused_moe.token_dispatcher.is_hierarchical_communication_enabled" , return_value = False
148148 )
149- self .mock_hier_comm = self .hier_comm_patch .start ()
149+ self .hier_comm_patch .start ()
150+ self .skip_allreduce_patch = patch (
151+ "vllm_ascend.ops.fused_moe.token_dispatcher.should_skip_allreduce_across_dp_group" , return_value = False
152+ )
153+ self .mock_skip_allreduce = self .skip_allreduce_patch .start ()
150154
151155 kwargs = {"with_quant" : False , "top_k" : 8 , "num_experts" : 128 }
152156 self .dispatcher = TokenDispatcherWithMC2 (** kwargs )
@@ -161,24 +165,26 @@ def tearDown(self):
161165 self .ascend_config_patch .stop ()
162166 self .ascend_config_utils_patch .stop ()
163167 self .hier_comm_patch .stop ()
168+ self .skip_allreduce_patch .stop ()
164169
165170 def test_init (self ):
166171 self .assertEqual (self .dispatcher .ep_rank_id , 0 )
167172 self .assertEqual (self .dispatcher .ep_world_size , 8 )
168173 self .assertTrue (self .dispatcher .enable_dispatch_v2 )
169174 self .assertTrue (self .dispatcher .need_extra_args )
170- self .assertEqual (self .dispatcher .global_bs , 1024 )
175+ self .assertEqual (self .dispatcher .global_bs , 0 )
171176
172177 def test_init_uses_mc2_capacity_for_non_uniform_global_bs (self ):
173178 self .mock_get_config .return_value .parallel_config .tensor_parallel_size = 4
179+ self .mock_skip_allreduce .return_value = True
174180
175181 dispatcher = TokenDispatcherWithMC2 (with_quant = False , top_k = 8 , num_experts = 128 )
176182
177183 self .assertEqual (dispatcher .global_bs , 256 )
178184
179- def test_get_dispatch_mc2_kwargs_without_hier_comm_omits_mc2_mask (self ):
185+ def test_get_dispatch_mc2_kwargs_with_skip_allreduce_omits_mc2_mask (self ):
180186 self .mock_get_config .return_value .parallel_config .tensor_parallel_size = 4
181- self .mock_hier_comm .return_value = False
187+ self .mock_skip_allreduce .return_value = True
182188 dispatcher = TokenDispatcherWithMC2 (with_quant = False , top_k = 8 , num_experts = 128 )
183189
184190 hidden_states = torch .randn (10 , 128 )
@@ -199,9 +205,7 @@ def test_get_dispatch_mc2_kwargs_without_hier_comm_omits_mc2_mask(self):
199205 self .assertEqual (kwargs ["global_bs" ], 256 )
200206 self .assertNotIn ("x_active_mask" , kwargs )
201207
202- def test_get_dispatch_mc2_kwargs_with_hier_comm_keeps_mc2_mask (self ):
203- self .mock_hier_comm .return_value = True
204- dispatcher = TokenDispatcherWithMC2 (with_quant = False , top_k = 8 , num_experts = 128 )
208+ def test_get_dispatch_mc2_kwargs_without_skip_allreduce_keeps_mc2_mask (self ):
205209 hidden_states = torch .randn (10 , 128 )
206210 topk_ids = torch .randint (0 , 8 , (10 , 1 ))
207211 topk_weights = torch .randn (10 , 1 )
@@ -215,7 +219,7 @@ def test_get_dispatch_mc2_kwargs_with_hier_comm_keeps_mc2_mask(self):
215219 mc2_mask = mc2_mask ,
216220 )
217221
218- kwargs = dispatcher .get_dispatch_mc2_kwargs (token_dispatch_input )
222+ kwargs = self . dispatcher .get_dispatch_mc2_kwargs (token_dispatch_input )
219223
220224 self .assertEqual (kwargs ["global_bs" ], 0 )
221225 self .assertIs (kwargs ["x_active_mask" ], mc2_mask )
0 commit comments