Crystalcareai
commited on
Update modeling_gemmoe.py
Browse files- modeling_gemmoe.py +10 -0
modeling_gemmoe.py
CHANGED
@@ -1234,6 +1234,16 @@ class GemmoeForCausalLM(GemmoePreTrainedModel):
|
|
1234 |
hidden_states = outputs[0]
|
1235 |
logits = self.lm_head(hidden_states)
|
1236 |
logits = logits.float()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1237 |
|
1238 |
loss = None
|
1239 |
if labels is not None:
|
|
|
1234 |
hidden_states = outputs[0]
|
1235 |
logits = self.lm_head(hidden_states)
|
1236 |
logits = logits.float()
|
1237 |
+
|
1238 |
+
# Handle unused parameters
|
1239 |
+
if self.training:
|
1240 |
+
for expert in self.model.block_sparse_moe.experts:
|
1241 |
+
for param in expert.parameters():
|
1242 |
+
if param.requires_grad and param.grad is None:
|
1243 |
+
param.grad = torch.zeros_like(param)
|
1244 |
+
|
1245 |
+
loss = None
|
1246 |
+
if labels is not None:
|
1247 |
|
1248 |
loss = None
|
1249 |
if labels is not None:
|