Start by framing the problem as a systematic debugging exercise: reproduce the issues, isolate each component, and verify fixes with targeted tests. Prioritize root causes that explain multiple symptoms (e.g., masking bug causing divergence and stuck validation), then address AMP and determinism separately. Structure your answer around a clear debugging plan and concrete fixes with assertions.
Pro tip: Demonstrate production maturity by emphasizing reproducibility first: set all seeds, enable deterministic algorithms, and log everything. Then, use a minimal synthetic dataset to quickly validate fixes before scaling up.
Create a minimal reproducible script with fixed seeds, small synthetic data, and logging of loss, gradients, and AMP scale. Confirm the reported symptoms (divergence, stuck validation, AMP crashes, nondeterminism).
Systematically inspect each component: data preprocessing, masking, positional encodings, loss computation, optimizer state, AMP/GradScaler, seed control, and DDP config. For each bug, explain the failure mode and propose a minimal fix.
For each identified bug, write a unit test or runtime assertion that would catch it (e.g., check mask shapes, verify loss decreases on a tiny batch, assert deterministic outputs across runs).
Outline a step-by-step plan: validate data pipeline (shapes, tokenization, padding), check masking logic (causal and padding masks), verify positional encoding implementation, inspect loss (ignore_index, reduction), review optimizer and scheduler states, test AMP with/without GradScaler, enforce seeds, and verify DDP setup.
Describe sanity checks: overfit a single batch, check gradient norms, monitor AMP scale factor, track loss and accuracy on a small validation set. Propose small experiments to verify each fix (e.g., disable AMP to see if crashes stop).
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.