add debugs and attempt fix
Browse files- modeling_myolmoe.py +3 -2
modeling_myolmoe.py
CHANGED
|
@@ -311,12 +311,13 @@ class MyOLMoESparseMoeBlock(nn.Module):
|
|
| 311 |
self.experts = nn.ModuleList([OlmoeMLP(config) for _ in range(self.num_experts)])
|
| 312 |
|
| 313 |
def forward(self, hidden_states: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
| 314 |
-
|
|
|
|
| 315 |
hidden_states = hidden_states.view(-1, self.hidden_size)
|
| 316 |
|
| 317 |
# Get routing weights and selected experts
|
| 318 |
routing_weights, selected_experts, router_logits = self.router(hidden_states)
|
| 319 |
-
print(f"DEBUG: MoE forward - routing_weights shape: {routing_weights.shape}, selected_experts shape: {selected_experts.shape}")
|
| 320 |
|
| 321 |
if self.norm_topk_prob:
|
| 322 |
routing_weights = routing_weights / routing_weights.sum(dim=-1, keepdim=True)
|
|
|
|
| 311 |
self.experts = nn.ModuleList([OlmoeMLP(config) for _ in range(self.num_experts)])
|
| 312 |
|
| 313 |
def forward(self, hidden_states: torch.Tensor) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
|
| 314 |
+
print(f"DEBUG: MoE forward start - routing_weights shape: {routing_weights.shape}, selected_experts shape: {selected_experts.shape}")
|
| 315 |
+
batch_size, seq_len = hidden_states.shape
|
| 316 |
hidden_states = hidden_states.view(-1, self.hidden_size)
|
| 317 |
|
| 318 |
# Get routing weights and selected experts
|
| 319 |
routing_weights, selected_experts, router_logits = self.router(hidden_states)
|
| 320 |
+
print(f"DEBUG: MoE forward mid - routing_weights shape: {routing_weights.shape}, selected_experts shape: {selected_experts.shape}")
|
| 321 |
|
| 322 |
if self.norm_topk_prob:
|
| 323 |
routing_weights = routing_weights / routing_weights.sum(dim=-1, keepdim=True)
|