TL;DR: This paper introduces Collapsed Taylor Mode, a graph-optimization technique that significantly accelerates the computation of high-order derivatives (like Laplacians) used in scientific machine learning. By exploiting linearity to sum derivative coefficients during propagation rather than after, the authors achieve up to a 2x speedup over standard backpropagation and substantial memory savings, all through automated graph rewrites.
The Bottleneck in Scientific Machine Learning
In fields like Scientific Machine Learning (SciML), researchers often train neural networks to satisfy physical laws expressed as Partial Differential Equations (PDEs). This requires computing high-order derivatives—such as the Laplacian (trace of the Hessian) for Schrödinger equations or fourth-order derivatives for elasticity problems.
The standard tool, backpropagation, is highly optimized but scales poorly; nesting first-order automatic differentiation (AD) to get higher orders leads to exponential growth in time and memory. Taylor Mode AD offers better theoretical polynomial scaling. However, in practice, "vanilla" Taylor mode is often slower than highly optimized nested backpropagation in frameworks like JAX or PyTorch. The challenge is making Taylor mode efficient enough to be the default choice for complex PDE operators.
The "Collapse" Optimization
The authors propose an optimization called Collapsing to address the inefficiencies of vanilla Taylor mode.
- Taylor Mode Basics: Instead of scalar values, Taylor mode propagates "jets"—vectors of Taylor coefficients representing derivatives of different orders.
- The "Collapse" Insight: Many PDE operators are linear (e.g., the sum of second derivatives). The authors observe that in the mathematical rules for propagating these coefficients (Faà di Bruno’s formula), the highest-order coefficient depends linearly on the highest-order input coefficients.
- Summing Early: Instead of propagating multiple different derivative directions through the entire network and summing them at the end, "Collapsed" Taylor mode sums the directions at the input and propagates only the summed coefficient. This drastically reduces the number of vectors being moved through the computational graph.
- Automated Graph Rewriting: They implement this in PyTorch using
torch.fx. The system captures a standard Taylor mode graph and automatically rewrites it into a "collapsed" version. Users can write standard code, and the "compiler" handles the optimization. - Generalization: For complex mixed partial derivatives (like the biharmonic operator), they use an interpolation technique to reconstruct the required terms from a small family of collapsed jets.
Benchmarks and Key Results
The authors evaluate their approach on synthetic benchmarks designed to mimic real-world SciML workloads, using a 5-layer Multi-Layer Perceptron (MLP) with tanh activations. They benchmarked the Laplacian (2nd order), Weighted Laplacian, and the Biharmonic operator (4th order).
The results demonstrate that linearity is a "free" optimization. Because the highest-order derivative propagation is linear, swapping the order of "summing" and "propagating" is mathematically equivalent but computationally much cheaper. The paper shows that while vanilla Taylor mode is actually slower than nested backpropagation in many cases, the "collapsing" step makes Taylor mode the clear winner.
- Speed: Collapsed Taylor mode is roughly 2x faster than nested first-order AD for computing Laplacians. For the 4th-order biharmonic operator, the collapsed mode outperformed nested AD by up to 9x in runtime (in the stochastic case).
- Memory: It uses only 40-50% of the memory required by nested backpropagation, and up to 5x less memory for higher-order stochastic operators.
- Stochastic Advantage: The method works seamlessly with stochastic approximations (like Hutchinson’s trace estimator), providing even larger relative gains when estimating high-dimensional operators.
Limitations and Future Directions
While highly effective, the current PyTorch implementation supports a limited set of "primitives" (basic operations like addition, multiplication, and specific activations). Expanding this to the full suite of deep learning operations is a significant engineering task, as Taylor arithmetic for new operations must currently be implemented case-by-case.
Furthermore, while the authors demonstrated the potential for compilers, the optimization is not yet natively integrated into the core JIT compilers of JAX or PyTorch. Future work will likely focus on exploring more complex graph optimizations and broadening the library to support a wider array of scientific computing primitives natively.
Summary updated