TL;DR
Training massive AI models across thousands of GPUs is notorious for "silent bugs"—subtle errors that don't crash the system, yet quietly sabotage model quality and waste massive compute budgets. nnTrace is a new differential testing system that catches and pinpoints these invisible culprits in just one training iteration rather than thousands. Better yet, it solves the classic headache of floating-point noise, cleanly separating harmless rounding differences from actual bugs—even in noisy, low-precision formats like FP8.
What Problem Does This Paper Address?
When you slice a neural network across hundreds of GPUs using complex strategies like tensor, pipeline, and context parallelism, the underlying code gets extraordinarily intricate. A slightly wrong communication group or an unaligned memory layout won't necessarily throw an exception. Instead, the run continues smoothly, burning thousands of GPU hours to produce a degraded model.
Currently, engineers hunt for these silent bugs by running a smaller version of their distributed setup alongside a trusted single-GPU reference, staring at training loss curves until they diverge. This is painfully slow and offers zero clues about where the bug actually lives.
Why not just compare every intermediate tensor after step one? Two reasons:
- Fragmented Tensors: Distributed frameworks chop, reorder, and scatter tensors across GPUs, making them hard to match up against a single-device reference.
- Floating-Point Chaos: Floating-point math is non-associative: $(a + b) + c$ does not strictly equal $a + (b + c)$. Because distributed setups sum numbers in different orders, benign numerical differences naturally accumulate—especially in low-precision formats like BF16 and FP8. Static thresholds (like
torch.allclose) either trigger constant false alarms or let real bugs slip right through.
Methods
nnTrace turns a multi-hour guessing game into a fast, single-iteration diagnostic workflow:
- Canonical Mapping: Using lightweight user annotations about how layers are parallelized, nnTrace reassembles scattered physical GPU shards back into "logical full tensors" that map 1-to-1 with the reference run.
- Perturbation-Based Tolerance Estimation (The Secret Sauce): Instead of guessing an error threshold, nnTrace measures how sensitive each specific tensor is to rounding noise. It injects tiny, machine-epsilon-scale nudges—mimicking natural floating-point roundoff—into the reference model's inputs and backward pass. By observing how much each intermediate tensor shifts in response, nnTrace dynamically calculates a custom numerical tolerance for every single tensor in the network.
- Single-Iteration Check & Module-Wise Rewrite: nnTrace feeds identical inputs into both implementations for one training step (forward, backward, and optimizer update) and flags anything exceeding its dynamic tolerance (scaled by a safety margin $k=3.5$). Once a bug is spotted, nnTrace isolates the exact faulty PyTorch module by overriding every module's inputs with clean reference tensors—stopping early errors from cascading downstream. This same trick forces Mixture-of-Experts (MoE) routers to pick identical experts across runs so benign noise doesn't cause divergent token routing.
Datasets
Rather than evaluating on text or image corpora, nnTrace's "datasets" are codebases and bug suites:
- Real-World Production Bugs: Tested on NVIDIA’s Megatron-LM and TransformerEngine across GPT, Llama, Mamba, and MoE architectures (using consistent generated inputs). The authors reproduced 11 historical silent bugs and swept 4D parallelism configurations to hunt for new ones.
- Synthetic Fault Benchmark: A newly constructed suite of 96 simulated bugs across those four architectures, created by injecting controlled perturbations ($10\times$, $50\times$, and $100\times$ BF16 machine epsilon) into forward activations or backward gradients to benchmark against
torch.allclose.
Key Insights and Ideas
- Use the model as its own calculus engine: Analytically computing how rounding errors compound across dozens of transformer layers is practically impossible. Injecting tiny noise into the reference run empirically probes local sensitivity (essentially measuring Jacobian effects for free), adapting automatically to model depth, layer type, and precision.
- Numerical errors have distinct depth signatures: Forward activation errors naturally climb as data flows deeper into the network, while backward gradient errors grow in reverse—accumulating more noise closer to the first layer. Static tolerances are fundamentally blind to this geometry.
- Testing at native precision is non-negotiable: Prior tools often dodge floating-point noise by upcasting tests to FP32. However, several real bugs only trigger inside custom low-precision FP8 kernels or casts. Testing natively in BF16/FP8 catches bugs that higher-precision tests never execute.
Key Results
- 14 Real Bugs Caught: nnTrace detected all 11 reproduced historical bugs and uncovered 3 brand-new silent bugs in Megatron-LM and TransformerEngine (all confirmed by NVIDIA; 2 already fixed). One new bug involved passing a non-contiguous tensor into an opaque custom C++/CUDA attention kernel—invisible to Python graph analyzers, yet caught immediately by nnTrace.
- 440x Faster Detection: For a representative embedding mask bug, waiting for a 3% loss curve divergence took 6 hours and 40 minutes (>4,000 iterations). nnTrace caught and localized it in 54 seconds (1 iteration).
- Crushing Static Thresholds: On the 96-fault benchmark,
torch.allclosefaced an ugly trade-off: strict settings yielded a 98.3% false-positive rate on healthy distributed code, while loose settings still had a 19.5% false-positive rate and missed 37/96 bugs. nnTrace achieved 0.0% false positives while catching 92/96 injected faults. - Real-World Adoption: Megatron-LM maintainers have already integrated nnTrace’s methodology into their development and testing workflow.
Limitations and Future Work
- Sub-noise Floor Bugs: nnTrace missed 4 out of 96 synthetic faults—specifically, tiny $10\times \varepsilon_{\text{mch}}$ perturbations in FP8 runs, where coarse quantization naturally generates $5\times$ to $13\times \varepsilon_{\text{mch}}$ of baseline noise, drowning out the fault in a single step.
- Non-determinism & Hardware: Because it relies on a single iteration, nnTrace can miss intermittent race conditions, and hardware-level silent data corruption (like cosmic-ray bit flips on a GPU) is out of scope.
- Coverage: Like all differential testing, it only catches bugs on code paths actually exercised by the scaled-down test configuration. (Future directions are not explicitly discussed in the main text.)
Summary updated