From 3f9b441428c7e68051fc6e5b7e3334238fd46ee1 Mon Sep 17 00:00:00 2001 From: biondizzle Date: Sun, 31 May 2026 03:28:53 +0000 Subject: [PATCH] diag: fix n_layers reference in forward_layer, add late-layer diags --- single_shot_inference.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/single_shot_inference.py b/single_shot_inference.py index 6aeb0f9a..ecac4465 100644 --- a/single_shot_inference.py +++ b/single_shot_inference.py @@ -428,7 +428,7 @@ def forward_layer(X_l, w, li, cfg, rope_cos, rope_sin, # -- mHC pre_block (attention) -- x_in, attn_ctx = attn_mhc.pre_block(X_l) # x_in: (T, H) - if li < 3: + if li < 3 or li >= 58: A_l = None B_l, C_l = attn_ctx print(f" L{li} pre_attn: |X_l|={X_l.abs().max().item():.2f} |x_in|={x_in.abs().max().item():.2f}", flush=True) @@ -513,7 +513,7 @@ def forward_layer(X_l, w, li, cfg, rope_cos, rope_sin, # -- mHC post_block (attention) -- X_mid = attn_mhc.post_block(X_l, F_attn, attn_ctx) # (T, n_hc, H) # Diagnostic: check mHC is stabilizing the residual - if li < 3 or li >= n_layers - 3: + if li < 3 or li >= 58: B_l, C_l = attn_ctx print(f" L{li} attn: |X_l|={X_l.abs().max().item():.2f} |F_attn|={F_attn.abs().max().item():.2f} |B|={B_l.abs().max().item():.4f} |C|={C_l.abs().max().item():.4f} |X_mid|={X_mid.abs().max().item():.2f}", flush=True) @@ -532,7 +532,7 @@ def forward_layer(X_l, w, li, cfg, rope_cos, rope_sin, # -- mHC post_block (FFN) -- X_next = ffn_mhc.post_block(X_mid, F_ffn, ffn_ctx) # (T, n_hc, H) - if li < 3 or li >= n_layers - 3: + if li < 3 or li >= 58: B_l_ffn, C_l_ffn = ffn_ctx print(f" L{li} ffn: |X_mid|={X_mid.abs().max().item():.2f} |F_ffn|={F_ffn.abs().max().item():.2f} |B|={B_l_ffn.abs().max().item():.4f} |C|={C_l_ffn.abs().max().item():.4f} |X_next|={X_next.abs().max().item():.2f}", flush=True)