Google DeepMind’s training infrastructure team owns the reliability of hundred-GPU pretraining runs, where a single NaN spike can cost a day of cluster time. In an ML infrastructure debugging interview styled on that postmortem work, you are on call for a 7B-parameter Transformer pretraining run on 256 H100 GPUs. The run uses BF16 mixed precision, FSDP, and FlashAttention-2. Training is smooth for 14,200 steps and the loss reaches 2.18. At step 14,203 the training loss spikes to 19.4, and at step 14,204 it turns into NaN.
Two experiments are already done. Rolling back to the step-14,000 checkpoint and resuming with the exact same configuration reproduces the spike at exactly step 14,203. Skipping data steps 14,200–14,205 delays the crash by only 60 steps before another spike occurs. Every hour spent debating leaves the full cluster idle.
Walk through your 30-minute incident triage. Formulate the candidate root-cause buckets: a corrupted data shard, BF16 attention logit or activation overflow, optimizer second-moment underflow, or a hardware bit-flip. Then inspect the five diagnostic telemetry clues in order, isolate the combined root cause, and specify the exact code and configuration fixes plus automated regression guards.

Figure 1: the spike lands on the same step after a rollback, and it returns 60 steps after the suspect batches are skipped. Something in the run is primed to fail, and something in the data pulls the trigger.
Available Telemetry Clues (Inspect & Rank Before Opening the Answer):
Clue #1: Deterministic Replay & Hardware ECC Check
Triage question before viewing the log: Given that rolling back to step 14,000 reproduces the spike at the exact same step 14,203, what would a replay on a disjoint node pool plus ECC/Xid counters confirm or rule out in under five minutes?
Clue #2: Data Shard Inspection at Step 14,203
Triage question: Skipping batches 14,200-14,205 still crashed 60 steps later. When you decode token statistics at step 14,203 and step 14,263, what pattern distinguishes a trigger batch from a corrupted shard?
Clue #3: Per-Layer Activation & QK Logit Max-Norm Telemetry
Triage question: BF16 has FP32’s exponent range () yet only 8 significant bits. Which forward quantity can grow silently over 4,000 steps and destroy softmax resolution without overflowing?
Clue #4: Optimizer State Inspection (Dtype,
, Clipping)
Triage question: Why would a single spiky batch turn the very next step into NaN instead of a recoverable bump? Check what happens to AdamW’s second moment when stored in BF16 with
.
Clue #5: Stabilization Patch Replay & Ablations
Triage question: From which checkpoint step must you replay an architectural norm change so existing attention heads do not suffer a sudden distribution shock?
1Inspection Checklist (Where to Look)
(1) Hardware & Determinism: Random bit-flips do not fire on the identical step across replays; verify node independence and ECC counters first.
(2) Trigger vs Vulnerability: A crash that returns 60 steps after skipping suspect batches proves the batch is only a trigger acting on a primed model state.
(3) BF16 Resolution vs Range: Track per-layer QK logit maxima; BF16 loses unit precision long before it overflows.
(4) Optimizer Amplification: Check moment buffer dtypes, spike ceiling, gradient clipping, and update-to-weight ratios.
2Visual Review Map (Figure 2)

Figure 2: The triage map. The final diagnosis must explain every symptom, and each candidate bucket has one telemetry clue that can falsify it.
3Interviewer Nudge (Quantitative Triage Prompts)
Use these four quantitative back-of-the-envelope checks while classifying Clues #1-#5 in the Incident Console:
65,536 its unit-in-last-place step is 2^16 * 2^-7 = 512. Even though 68,400 is nowhere near 3.4e38 overflow, rounding Q/K jitters logits by hundreds and collapses softmax to one-hot.v_t by beta2 = 0.999 decays it by 0.1%, which is smaller than half a BF16 ULP (~0.39%) and rounds away to zero! When one huge gradient hits a frozen v_t, compute the single-step Adam bound (1 - beta1) / sqrt(1 - beta2) at 0.999 vs 0.95.1.6 and d = 128 caps logits near sqrt(128) * 1.6^2 ~ 29. Compare that target scale against ckpt_10000 (28.1) versus ckpt_14000 (61,200) to avoid distribution shock on resume.+Patch Lab Nudges (Optional Coding Step)
These map onto the patch_starter skeleton in the workbench: each chip jumps to the blank's region in the Patch Sandbox editor:
nn.RMSNorm(self.d, eps=1e-6) with weight initialized to qk_gain_init. Why per-head rather than one shared norm, and what does the gain scale vs the eps stabilize?
F.normalize(t, p=2, dim=-1) acts on the LAST axis before transposing to (B, H, T, D). Which argument to F.scaled_dot_product_attention replaces the manual causal mask, and does SDPA want is_causal=True during decode?
p.dtype == torch.float32, then split weight decay by tensor rank (0.1 for dim >= 2, 0.0 below). From Clue #4's ULP math, why does betas=(0.9, 0.95) keep second moments alive in BF16?
clip_grad_norm_ returns the pre-clip total norm; gate opt.step() on torch.isfinite(norm) so an Inf/NaN batch is skipped, then zero_grad(set_to_none=True). What breaks if you clip-then-step unconditionally?
exp() the logits directly: torch.logsumexp(logits, dim=-1) computes log Z in the log domain. Return ce + z_coef * log_z.pow(2).mean(): what does the quadratic penalty do to a +1000-logit tail?
Leave a Reply