torchtest2: One-Call Sanity Checks for PyTorch Models,Evaluated on Real and Unseen Architectures
Abstract
Many bugs in deep learning code are silent: a layer that is never called, an optimizer created before the classification head was replaced, a recurrent layer that treats the batch as time, or an ignored attention mask. The code runs, the loss decreases somewhat, and the defect surfaces, if ever, after days of GPU time. We present torchtest2, an open-source library that runs 18 sanity checks on a single batch with one call, restores the PyTorch state it touches, and adapts to model families through plugins. We evaluate it by mutation analysis with 17 classes of silent bugs on 103 models from torchvision, timm and Hugging Face transformers, on 600 random architectures and on 20 hand-written realistic bugs, against the checks of the original torchtest, overfitting a single batch, a smoke test and a training monitor in the style of AUTOTRAINER and DeepDiagnosis. Every mutant is compared with its healthy counterpart, and intervals come from a bootstrap over models. After freezing the tool, we ran it on 191 models of architecture families it had never seen: counting, for every tool alike, a failing report where the healthy model's report does not fail, it detected 78% of the injected bugs (95% CI 75-80), against 40% for the original torchtest checks and 48% for the training monitor. On real models its batch-independence check found a bug in timm's GCViT that couples the images of a batch. Real models also exposed false alarms that neither the tool's own test suite nor random architectures had revealed. Two independent collections of real silent bugs mark the limits of the approach: only 3 of 28 reproduced PyTorch bugs from Stack Overflow and 3 of the 18 silent training errors released with TrainCheck are within reach of a pre-training model tester. A median check takes 1.0 s. We release the library, the benchmark and all raw results.
Create a lesson
Metadata
- Categories
- cs.SE, cs.CV
Related papers
SCCGBench: Executability-Oriented Evaluation for Real-World Web Service-Call Code Generation
Shared title terminologycs.SEShuo Wang, Guodong Fan, Ming Zhu et al.
Agents as Architecture Evaluators: Automating ATAM and SAAM for Continuous Assessment
Shared title terminologycs.SEAdyansh Kakran, Sathvika Miryala, Karthik Vaidhyanathan
Multi-agent LLMs on the Cloud-Edge-IoT Continuum: A Systematic Mapping Study on Architectures, Deployment, and Evaluation
Shared title terminologycs.SEMahyar Tourchi Moghaddam, Tiziano Santilli, Leo Wilhelm Lierse et al.
Schema-Validated LLM Workflows: A Benchmark Protocol and Comparative Evaluation Across Six Python Implementations
Shared title terminologycs.SESidney Shapiro, Sanad Al-Khatib, Aurora Pinzón Arzola et al.
How Far Can LLMs Go in Generating Android Lint Checks from Natural Language?
Shared title terminologycs.SEMoshood A. Fakorede, A. B. Siddique, Manu Sridharan et al.
Verify the Verifier: Specification-Grounded LLM Cross-Checking for Bugs That Escape UVM Scoreboards
Shared title terminologycs.SEAna E. Sanchez Villalobos, Michael D. Quinn, Aakash Tyagi et al.