-
Notifications
You must be signed in to change notification settings - Fork 687
Fix qwen35 dp #4535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix qwen35 dp #4535
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -319,3 +319,37 @@ def forward(self, hidden_states: torch.Tensor, topk_weights: torch.Tensor, topk_ | |||||||||||
| def renormalize(self, topk_weights): | ||||||||||||
| """renormalize.""" | ||||||||||||
| return _renormalize(topk_weights, self.do_renormalize) | ||||||||||||
|
|
||||||||||||
| def build_moe_all_reduce(self): | ||||||||||||
| """Build moe all reduce. | ||||||||||||
|
|
||||||||||||
| This is only used when dp==1 and tp>1, and fused moe module does not perform all_reduce | ||||||||||||
| """ | ||||||||||||
| return MoEAllReduce(not self.all_reduce, self.tp, self.tp_mode) | ||||||||||||
|
||||||||||||
| return MoEAllReduce(not self.all_reduce, self.tp, self.tp_mode) | |
| dist_ctx = get_dist_manager().current_context() | |
| dp = dist_ctx.dist_config.dp | |
| enable = (dp == 1) and (not self.all_reduce) | |
| return MoEAllReduce(enable, self.tp, self.tp_mode) |
Copilot
AI
Apr 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MoEAllReduce.forward() calls dist.all_reduce(x) without specifying a group. In lmdeploy.pytorch.distributed.all_reduce, the default group is 'tp' which maps to the attention TP group, not the MoE TP group, so this can reduce across the wrong ranks when attn_tp != moe_tp. Please pass the correct MoE TP process group (e.g., from DistContext.moe_tp_group.gpu_group) into MoEAllReduce and use it in the all-reduce call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The div-by-zero guard was added in
_reduce_split_kernel, but_fused_reduce_hadamard_kernelin the same file still doesacc = acc / l_sumand can hit the samel_sum==0case (e.g., when all splits are masked out). Consider applying a consistent safeguard (e.g., clampl_sumto an epsilon or conditional divide) to the fused kernel as well to avoid NaN/Inf in TURBO_QUANT paths.