Robust First and Second-Order Differentiation for Regularized Optimal Transport

Xingjie Li, Fei Lu, Felix X.-f. Ye, Molei Tao

TL;DR

This paper introduces a robust analytical framework for computing the first and second-order derivatives (gradients and Hessians) of regularized Optimal Transport (OT) distances. By performing a deep dive into the spectral properties of the underlying linear systems, the authors resolve long-standing numerical instability issues, enabling the use of fast second-order "Newton" optimizers that outperform standard gradient descent by orders of magnitude in speed and accuracy.

What Problem Does This Paper Address?

Optimal Transport is a mathematical framework for comparing probability distributions, widely used in tasks like "shuffled regression" (where you have data points but don't know which input matches which output) and 3D point cloud alignment. To solve these problems, researchers typically minimize an OT-based loss function.

However, optimizing these functions is notoriously difficult. First-order methods (like Gradient Descent) are slow to converge. Second-order methods (like Newton’s method) are much faster but require the Hessian (the matrix of second derivatives). Computing the Hessian for OT is a nightmare:

  1. Memory Consumption: Standard automatic differentiation (autodiff) requires massive memory to store computational graphs for large datasets.
  2. Numerical Instability: As the regularization parameter ($\epsilon$) gets smaller—which is necessary for high accuracy—the underlying linear systems become "ill-conditioned" or singular, causing standard solvers to crash or produce garbage results.

Methods

The authors move away from "black-box" differentiation and toward a principled analytical approach:

  • Analytical Derivation: They derive exact formulas for the gradients of Entropic OT (EOT) and Sinkhorn distances, and the Hessian for EOT. This bypasses the need for memory-heavy autodiff.
  • Spectral Analysis of the "H-Matrix": They identify a specific block matrix, $H$, that governs the system. They prove that $H$ is always singular (it has a zero eigenvalue) and show that its condition number explodes exponentially as regularization decreases.
  • Truncated SVD (TSVD): To handle the ill-conditioned nature of $H$, they use Truncated Singular Value Decomposition. By "cutting off" the problematic small eigenvalues, they achieve stable and accurate computations where previous methods failed.
  • Two-Stage SGD-Newton Optimizer: They propose a hybrid strategy: start with Stochastic Gradient Descent (SGD) to get into the right neighborhood, then switch to a "relaxed Newton" method using their robust Hessian to sprint to the finish line.

Datasets

The authors evaluated their approach on several benchmarks:

  • Synthetic Geometry: Equally spaced points on a circle and uniformly distributed points in a unit square to test spectral decay and numerical limits.
  • Shuffled Regression: Synthetic Gaussian mixture models with 500 data points in 5 dimensions.
  • ModelNet10: A standard 3D CAD dataset. They specifically used point clouds of chairs (500 points), desks (1500 points), and sofas (1500 points) to test 3D registration/alignment.

Key Insights and Ideas

  • The Singularity is Structural: The paper proves that the $H$-matrix used in OT differentiation is guaranteed to be singular for any positive coupling matrix. This means standard matrix inversion will always be unstable without specific regularization like TSVD.
  • The "Sharpness" Penalty: They quantify the trade-off between accuracy and stability. The smallest positive eigenvalue of the system decays at a rate of $O(e^{-1/\epsilon})$. This explains why researchers previously struggled to use small regularization values in second-order optimization.
  • Bypassing the Graph: By using analytical formulas, the method's memory footprint is significantly lower than JAX or PyTorch's "unrolling" methods, allowing it to scale to much larger datasets ($N > 5000$) where other methods hit "Out of Memory" errors at $N \approx 400$.

Key Results

  • Speedup: In shuffled regression tasks, the SGD-Newton method converged 27 times faster than standard Gradient Descent (2.35 seconds vs. 64.77 seconds).
  • Accuracy: The analytical approach provided results that were 3 to 8 orders of magnitude more accurate than implicit differentiation or unrolling methods.
  • Robustness: In highly singular settings (small $N$, small $\epsilon$), their method maintained a 100% success rate, while implicit differentiation failed 97% of the time due to numerical instability.
  • Scalability: The method successfully handled 3D point cloud registration for objects with 1500 points, reaching a solution in 17 seconds, whereas GD took over 5 minutes to reach a comparable loss.

Limitations and Future Work

  • Computational Complexity: While more efficient than autodiff, computing the full Hessian still involves $O((M+N)^3)$ operations for the SVD/linear solve. For extremely high-dimensional data (millions of points), this remains a bottleneck.
  • Sparse Approximations: The authors suggest that future work could involve "sparse approximations" of the Hessian to further accelerate the computation for massive datasets.
  • Generalization of Spectral Bounds: The current spectral analysis is most detailed for uniform distributions; extending these sharp bounds to arbitrary, non-uniform distributions is an open theoretical challenge.

Summary updated

BibTeX
@article{li2025robust,
  author = {Xingjie Li and Fei Lu and Felix X.-F. Ye and Molei Tao},
  title = {{Robust First and Second-Order Differentiation for Regularized Optimal Transport}},
  journal = {SIAM Journal on Scientific Computing},
  year = {2025},
  url = {https://openreview.net/forum?id=NFaLUqi4fP},
}
Figure