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:
- Mixed-Precision Forward Pass: The computationally expensive velocity field (parameterized by the neural network) is evaluated in low precision (
float16orbfloat16). 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. - 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.
- 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
torchdiffeqcoupled with PyTorch's defaultGradScaler) fail completely or suffer massive accuracy drops when forced intofloat16without the paper's custom dynamic adjoint scaling.
Key Results
- Massive Memory Savings: In the large-scale STL-10 image classification task,
rampdereduced peak memory consumption from 21.5 GB (in standardfloat32) down to just 2.2 GB (usingbfloat16), 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
tfloat32modes during the forward pass. - Preserved Accuracy: Across all successful configurations, the models trained with
rampdematched or slightly exceeded the validation accuracy and generative sample quality of purefloat32baselines (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
autocastinteracts with customautogradfunctions, 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