Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions modelopt/torch/quantization/plugins/megatron.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ def sync_moe_local_experts_amax(self):
This function is called to synchronize the amax values across local experts s.t. all localexperts will
share the same amax.
"""
torch.distributed.barrier()
# Collect amax from all local experts
amax_dict = {}
for expert in self.local_experts:
Expand Down Expand Up @@ -754,8 +753,11 @@ def _setup(self):

def forward(self, hidden_states):
if any(getattr(m, "_if_calib", False) for m in self.experts.modules()):
original_top_k = self.router.topk
self.router.topk = self.router.num_experts
super().forward(hidden_states)
self.router.topk = original_top_k
if self.config.moe_router_num_groups is None:
original_top_k = self.router.topk
self.router.topk = self.router.num_experts
super().forward(hidden_states)
self.router.topk = original_top_k
else:
super().forward(hidden_states)
return super().forward(hidden_states)