diag: check SE weight integrity

This commit is contained in:
2026-06-01 03:02:44 +00:00
parent 22d7cc9b7a
commit fba1c06cad

View File

@@ -428,6 +428,10 @@ def moe_forward(x, li, moe_runner, se_runner, router, token_id):
cuda_ok = False
print(f" L{li} SE CUDA ERROR: {e}", flush=True)
print(f" L{li} MoE shared: |out|={shared_out.abs().max().item():.4f} has_nan={torch.isnan(shared_out).any().item()} cuda_ok={cuda_ok}", flush=True)
# Check SE weight integrity
if hasattr(se_runner, 'l1_mat_b') and se_runner.l1_mat_b is not None:
w = se_runner.l1_mat_b
print(f" L{li} SE l1_mat_b: |max|={w.abs().max().item():.4f} has_nan={torch.isnan(w.view(torch.float16)).any().item()} shape={w.shape}", flush=True)
print(f" L{li} SE gsa: l1={se_runner._l1_activation_global_scale:.6f} l2={se_runner._l2_activation_global_scale:.6f} gsb: l1={se_runner._l1_gsb[0].item():.6f} l2={se_runner._l2_gsb[0].item():.6f}", flush=True)
return routed_out + shared_out