Mixed Precision Training of Neural ODEs

Elena Celledoni, Brynjulf Owren, Lars Ruthotto, Tianjiao Nicole Yang

TL;DR

Neural Ordinary Differential Equations (Neural ODEs) are powerful but notoriously expensive to train due to high memory demands and repeated network evaluations. This paper introduces a robust mixed-precision training framework that cuts memory usage by roughly 50% and delivers up to a 2× speedup. By strategically combining low-precision network evaluations with high-precision tracking and a novel dynamic scaling trick, the authors make training continuous-time models faster and lighter without sacrificing accuracy.

What Problem Does This Paper Address?

Deep learning has widely adopted Mixed Precision Training (MPT)—usually keeping master weights in 32-bit floating-point (float32) while running heavy matrix multiplications in 16-bit (float16 or bfloat16)—to save memory and accelerate training on modern GPUs.

However, naively applying MPT to Neural ODEs completely breaks down. Unlike standard discrete networks, Neural ODEs model data as a continuous system, requiring numerical solvers to step through time. Doing all calculations in low precision causes roundoff errors to compound drastically over these time steps. Furthermore, the restricted dynamic range of float16 frequently triggers underflow or overflow when calculating gradients via the adjoint method. As a result, researchers have been stuck using slower, memory-heavy single-precision training for continuous-time architectures.

Methods

The authors introduce rampde (Robust Automatic Mixed Precision for Differential Equations), a discretize-then-optimize framework built on three main pillars:

  1. Mixed-Precision Forward Pass: The computationally expensive velocity field (parameterized by the neural network) is evaluated in low precision (float16 or bfloat16). Crucially, the solver accumulates the actual state trajectory in high precision (float32) to prevent roundoff errors from exploding over time. Intermediate states are stored in low precision to save memory.
  2. Custom Mixed-Precision Backpropagation: Gradients are computed using a custom discrete adjoint pass. Weights, states, and adjoint variables are maintained in high precision, while the network's internal Jacobians are evaluated in low precision.
  3. Dynamic Adjoint Scaling: To combat float16's narrow dynamic range, the authors developed an adaptive scaling heuristic. It automatically scales the adjoint variables to maximize the available bit-range, halving the scale factor if an overflow occurs and doubling it when safe, completely removing the need for manual hyperparameter tuning.

Datasets

The framework was evaluated across three distinct types of tasks:

  • 2D Toy Benchmarks: 2-spirals, 8-Gaussians, and checkerboard datasets, used to test Continuous Normalizing Flows (CNFs).
  • BSDS300: A 63-dimensional feature dataset derived from natural image patches, used to evaluate high-dimensional Optimal Transport Flows (OT-Flow).
  • STL-10: A challenging image classification dataset containing 13,000 labeled natural images (96×96 pixels, upscaled to 128×128 for tensor core efficiency) used to test a large-scale parabolic CNN architecture with 12.6M weights.

Key Insights and Ideas

  • The Accumulation Safe-Haven: The "aha!" moment of the paper is that you don't need high precision everywhere to keep an ODE solver stable. As long as the accumulation step (adding the velocity increment to the current state) happens in float32, the underlying neural network evaluations can safely run in cheap 16-bit precision.
  • Error Growth is Bounded: Through rigorous roundoff error analysis, the authors prove that their mixed-precision scheme keeps errors bounded to the order of the low-precision unit roundoff. The errors do not grow uncontrollably with the number of integration time steps.
  • Standard MPT is Insufficient: The experiments show that standard deep learning toolkits (like torchdiffeq coupled with PyTorch's default GradScaler) fail completely or suffer massive accuracy drops when forced into float16 without the paper's custom dynamic adjoint scaling.

Key Results

  • Massive Memory Savings: In the large-scale STL-10 image classification task, rampde reduced peak memory consumption from 21.5 GB (in standard float32) down to just 2.2 GB (using bfloat16), representing an approximate 5× to 10× reduction depending on the exact configuration.
  • Up to 2× Speedup: On hardware with tensor core support (NVIDIA RTX A6000), the mixed-precision variants achieved up to a 1.8× speedup compared to tfloat32 modes during the forward pass.
  • Preserved Accuracy: Across all successful configurations, the models trained with rampde matched or slightly exceeded the validation accuracy and generative sample quality of pure float32 baselines (e.g., maintaining >77% test accuracy on STL-10).

Limitations and Future Work

  • Fixed Time Steps Only: The current implementation is strictly limited to discretize-then-optimize schemes using fixed time steps (like fixed Euler or RK4). It does not yet support adaptive step-size solvers.
  • PyTorch Interoperability Quirks: Due to limitations in how PyTorch's autocast interacts with custom autograd functions, the current package forces all operations in the custom backward pass to low precision, requiring users to manually cast certain blacklisted operations.
  • Future Directions: The authors point toward extending this framework to 8-bit quantization for even more extreme compression, as well as adapting it to Neural Stochastic Differential Equations (Neural SDEs) and PDE-constrained optimization problems.

Summary updated

Abstract

Exploiting low-precision computations has become a standard strategy in deep learning to address the growing computational costs imposed by ever larger models and datasets. However, naively performing all computations in low precision can lead to roundoff errors and instabilities. Therefore, mixed precision training schemes usually store the weights in high precision and use low-precision computations only for whitelisted operations. Despite their success, these principles are currently not reliable for training continuous-time architectures such as neural ordinary differential equations (Neural ODEs). This paper presents a mixed precision training framework for neural ODEs consisting of explicit ODE solvers and a custom backpropagation scheme and shows their effectiveness in a range of learning tasks. Our scheme uses low-precision computations for evaluating the velocity, parameterized by the neural network, and for storing intermediate states, while numerical reliability is provided by custom dynamic adjoint scaling and by accumulating the solution and gradients in higher precision. These contributions address two key challenges in training neural ODEs: the computational cost of repeated network evaluations and the growth of memory requirements with the number of time steps or layers. Along with the paper we publish our extendable, open-source PyTorch package \texttt{rampde}, whose syntax resembles that of leading packages to provide a drop-in replacement in existing codes. We demonstrate the reliability and effectiveness of our scheme using challenging test cases and on neural ODE applications in image classification and generative models, achieving approximately 50\% memory reduction and up to 2x speedup while maintaining accuracy comparable to single-precision training.
BibTeX
@misc{celledoni2025mixed,
  author = {Elena Celledoni and Brynjulf Owren and Lars Ruthotto and Tianjiao Nicole Yang},
  title = {{Mixed Precision Training of Neural ODEs}},
  year = {2025},
  eprint = {2510.23498},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.23498},
}
Figure