debug statements
Browse files- modeling_myolmoe.py +5 -1
modeling_myolmoe.py
CHANGED
|
@@ -316,7 +316,8 @@ class MyOLMoESparseMoeBlock(nn.Module):
|
|
| 316 |
|
| 317 |
# Get routing weights and selected experts
|
| 318 |
routing_weights, selected_experts, router_logits = self.router(hidden_states)
|
| 319 |
-
|
|
|
|
| 320 |
if self.norm_topk_prob:
|
| 321 |
routing_weights = routing_weights / routing_weights.sum(dim=-1, keepdim=True)
|
| 322 |
|
|
@@ -347,6 +348,7 @@ class MyOLMoESparseMoeBlock(nn.Module):
|
|
| 347 |
# Return 3 values: (hidden_states, router_logits, aux_loss)
|
| 348 |
# For now, we'll return None for aux_loss - you can compute it here if needed
|
| 349 |
aux_loss = None
|
|
|
|
| 350 |
return final_hidden_states, router_logits, aux_loss
|
| 351 |
|
| 352 |
class MyOLMoEDecoderLayer(nn.Module):
|
|
@@ -382,6 +384,7 @@ class MyOLMoEDecoderLayer(nn.Module):
|
|
| 382 |
|
| 383 |
# Self-attention
|
| 384 |
hidden_states = self.input_layernorm(hidden_states)
|
|
|
|
| 385 |
hidden_states, self_attn_weights, present_key_value = self.self_attn(
|
| 386 |
hidden_states=hidden_states,
|
| 387 |
attention_mask=attention_mask,
|
|
@@ -392,6 +395,7 @@ class MyOLMoEDecoderLayer(nn.Module):
|
|
| 392 |
cache_position=cache_position,
|
| 393 |
position_embeddings=position_embeddings,
|
| 394 |
)
|
|
|
|
| 395 |
hidden_states = residual + hidden_states
|
| 396 |
|
| 397 |
# MoE layer
|
|
|
|
| 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)
|
| 323 |
|
|
|
|
| 348 |
# Return 3 values: (hidden_states, router_logits, aux_loss)
|
| 349 |
# For now, we'll return None for aux_loss - you can compute it here if needed
|
| 350 |
aux_loss = None
|
| 351 |
+
print(f"DEBUG: MoE forward returning - final_hidden_states shape: {final_hidden_states.shape}, router_logits shape: {router_logits.shape}, aux_loss: {aux_loss}")
|
| 352 |
return final_hidden_states, router_logits, aux_loss
|
| 353 |
|
| 354 |
class MyOLMoEDecoderLayer(nn.Module):
|
|
|
|
| 384 |
|
| 385 |
# Self-attention
|
| 386 |
hidden_states = self.input_layernorm(hidden_states)
|
| 387 |
+
print(f"DEBUG: Before MoE call - hidden_states shape: {hidden_states.shape}")
|
| 388 |
hidden_states, self_attn_weights, present_key_value = self.self_attn(
|
| 389 |
hidden_states=hidden_states,
|
| 390 |
attention_mask=attention_mask,
|
|
|
|
| 395 |
cache_position=cache_position,
|
| 396 |
position_embeddings=position_embeddings,
|
| 397 |
)
|
| 398 |
+
print(f"DEBUG: After MoE call - hidden_states shape: {hidden_states.shape}")
|
| 399 |
hidden_states = residual + hidden_states
|
| 400 |
|
| 401 |
# MoE layer
|