Skip to content

Commit f12c16f

Browse files
cjluo-nvCopilot
andauthored
Update modelopt/torch/quantization/plugins/huggingface.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Chenjie Luo <108829653+cjluo-nv@users.noreply.github.com>
1 parent 777fcaf commit f12c16f

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

modelopt/torch/quantization/plugins/huggingface.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,10 @@ def _setup(self):
458458
elif hasattr(self, "experts") and hasattr(self.experts, "num_experts"):
459459
num_experts = self.experts.num_experts
460460

461-
self.expert_token_count = torch.zeros(
462-
num_experts, dtype=torch.long, device=next(self.parameters()).device
461+
self.register_buffer(
462+
"expert_token_count",
463+
torch.zeros(num_experts, dtype=torch.long, device=next(self.parameters()).device),
464+
persistent=False,
463465
)
464466
self._count_expert_tokens = False
465467
self._moe_calib_experts_ratio = None

0 commit comments

Comments
 (0)