Torch-Uncertainty: A Deep Learning Framework for Uncertainty Quantification

Adrien Lafage, Olivier Laurent, Firas Gabetni, Gianni FranchiarXiv 2025 · DOI

Introduction

Deep Neural Networks (DNNs) are often notoriously overconfident, leading to "confidently wrong" predictions that can be catastrophic in safety-critical domains like autonomous driving or medical imaging. While Uncertainty Quantification (UQ) techniques exist, the field remains fragmented, often requiring researchers to implement complex methods from scratch. Torch-Uncertainty is an open-source, PyTorch-based framework designed to make UQ a first-class citizen in deep learning workflows, providing a unified, modular environment to train, evaluate, and benchmark reliable models.

System Architecture and Methods

Torch-Uncertainty is built on three foundational pillars: domain generality, modular UQ design, and evaluation-centric routines. It integrates seamlessly with the PyTorch Lightning ecosystem, allowing for scalable and reproducible experiments.

The modular architecture of Torch-Uncertainty, illustrating the flow from user configuration to uncertainty-aware evaluation.

The framework provides "TU Layers" (e.g., Bayesian layers, Masksembles) and "Wrappers" that enable the composition of various UQ techniques. A standout feature is the support for Packed-Ensembles, which offer the benefits of traditional ensembling with significantly lower computational overhead. The library's "Task-Specific Routines" (e.g., ClassificationRoutine) automate the computation of 26 different UQ metrics, including Expected Calibration Error (ECE) and Area Under the Risk-Coverage curve (AURC).

Comprehensive Benchmarking Datasets

The framework is "batteries-included," supporting 37 datasets across various domains:

  • Corrupted Vision: Variants like CIFAR-10-C and ImageNet-C for testing robustness to noise and blur.
  • OOD Detection: Benchmarks such as SVHN and iNaturalist to evaluate a model's ability to flag unknown data.
  • Dense Prediction: The MUAD (Multiple Uncertainties for Autonomous Driving) dataset for complex road scene UQ.
  • Tabular & Time-Series: Standard UCI and UCR/UEA datasets.

Defining the "Rational" Model

A core philosophy of Torch-Uncertainty is that robustness is multi-dimensional. The authors propose the concept of a "rational" model, which extends beyond simple accuracy.

The multi-dimensional view of robustness, defining the characteristics of a 'rational' model.

As shown in Figure 1, a rational model must possess calibrated predictions, predictable failures, and a correct ranking of its own uncertainty. To support this, the framework allows for automated checkpointing based on UQ metrics (like NLL or ECE) rather than just accuracy, acknowledging that the most accurate model isn't always the most reliable one.

Key Results

Benchmarking across architectures like ViT, UNet, and BERT revealed several insights:

  • Classification: On ImageNet-1k, Deep Ensembles achieved the highest accuracy (82.19%). However, post-hoc Temperature Scaling was shown to drastically improve calibration, reducing ECE to 0.01% even for single models.
  • Segmentation: In autonomous driving tasks, Packed-Ensembles emerged as a highly efficient alternative to full ensembles, maintaining competitive performance with fewer parameters.
  • OOD Detection: The choice of OOD criteria (e.g., maximum logit vs. entropy) significantly impacts a model's detection capabilities, a factor easily explored within the framework's modular structure.

Limitations and Future Outlook

While Torch-Uncertainty covers six of the seven major UQ families, Gaussian Processes (GPs) are currently omitted due to scaling challenges in large-scale deep learning. Future development aims to expand pixel-wise regression capabilities and further optimize "TU Layers" to bridge the performance gap with standard layers. The project remains open-source, encouraging community contributions to advance the state of reliable AI.

Source: Lafage et al., "Torch-Uncertainty: A Deep Learning Framework for Uncertainty Quantification," NeurIPS 2025.

Summary updated

BibTeX
@misc{lafage2025torch,
  author = {Adrien Lafage and Olivier Laurent and Firas Gabetni and Gianni Franchi},
  title = {{Torch-Uncertainty: A Deep Learning Framework for Uncertainty Quantification}},
  year = {2025},
  eprint = {2511.10282},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.10282},
}
Figure