From 345d2acb19d7248abe41e9e7feeb8a1ffb4d1afd Mon Sep 17 00:00:00 2001 From: SolitaryThinker Date: Tue, 12 May 2026 14:09:55 -0700 Subject: [PATCH] [fix]: init PackedExpertLinear params with zeros, not empty (review) Addresses review thread on fastvideo/models/dits/magi_human.py:263. torch.empty leaves memory uninitialized; if a future caller skips load_state_dict or strict=False loses entries silently, the network would output NaNs. zero-init costs nothing at runtime (overwritten by load) and matches sibling MultiModalityRMSNorm which also uses torch.zeros. --- fastvideo/models/dits/magi_human.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastvideo/models/dits/magi_human.py b/fastvideo/models/dits/magi_human.py index 4682326bf..dec18d798 100644 --- a/fastvideo/models/dits/magi_human.py +++ b/fastvideo/models/dits/magi_human.py @@ -259,11 +259,11 @@ class PackedExpertLinear(nn.Module): self.num_experts = num_experts self.use_bias = bias self.weight = nn.Parameter( - torch.empty(out_features * num_experts, in_features, dtype=dtype) + torch.zeros(out_features * num_experts, in_features, dtype=dtype) ) if bias: self.bias = nn.Parameter( - torch.empty(out_features * num_experts, dtype=dtype) + torch.zeros(out_features * num_experts, dtype=dtype) ) else: self.register_parameter("bias", None)