Automatic differentiation for Riemannian optimization on low-rank matrix and tensor-train manifolds

Alexander Novikov, Maxim Rakhuba, Ivan Oseledets

Low-rank matrices and tensors are the unsung heroes of modern data science. Whether you're compressing a massive neural network or solving high-dimensional partial differential equations, representing data in a low-rank format is often the only way to make the math tractable. However, optimizing these objects is notoriously difficult because they live on complex, curved geometric spaces called Riemannian manifolds.

In their paper, "Automatic Differentiation for Riemannian Optimization on Low-Rank Matrix and Tensor-Train Manifolds," Alexander Novikov and his colleagues propose a clever way to bypass the grueling manual derivations usually required for these problems. By leveraging Automatic Differentiation (AD), they’ve created a framework that makes Riemannian optimization as easy to implement as standard deep learning.

What Problem Does This Paper Address?

When you optimize a standard function, you move in the direction of the steepest descent (the gradient). But if your solution must remain "low-rank," you can't just move anywhere; you have to stay on the "surface" of the low-rank manifold. This requires a Riemannian gradient—essentially a projection of the standard gradient onto the manifold's tangent space.

Historically, researchers had three bad options for computing these:

  1. Manual Derivation: Mathematically intense and highly prone to bugs, especially for complex formats like Tensor-Train (TT).
  2. Finite Differences: Easy to code but computationally expensive ($N$ times slower for $N$ parameters) and numerically unstable.
  3. Naive Projection: Computing a full, dense gradient and then projecting it. This often requires massive amounts of memory, defeating the whole purpose of using low-rank representations.

The authors set out to find a "fourth way": a method that is as easy as AD but as efficient as a hand-optimized manual implementation.

Methods

The core innovation is the use of an auxiliary function. Instead of trying to teach an AD engine (like TensorFlow) the rules of Riemannian geometry, the authors define a new function $g$ that maps from a simple, flat parameter space (the tangent space) to the manifold.

Figure 2: A simple computational graph illustrating how AD breaks down a function into elementary operations.

By differentiating this auxiliary function at a specific point, standard AD tools automatically produce the Riemannian gradient. They extended this logic to:

  • Fixed-rank matrices: Using SVD-based parametrizations.
  • Tensor-Train (TT) manifolds: A much more complex case involving d-dimensional arrays.
  • Approximate Hessians: They developed a way to compute Hessian-vector products (crucial for second-order optimization) while intentionally omitting "curvature terms" that often cause numerical crashes due to small singular values.

Datasets and Benchmarks

The authors evaluated their approach on several fundamental mathematical problems rather than standard image or text datasets:

  • Quadratic Forms: Essential for solving linear systems ($AX=B$).
  • Rayleigh Quotients: Used in eigenvalue problems.
  • Tensor Completion: Predicting missing values in high-dimensional data.
  • Exponential Machines: A specific type of machine learning model related to recurrent neural networks.

Key Insights and Ideas

  • The "Auxiliary Function" Trick: The most elegant insight is that you don't need to redefine differentiation. By wrapping the manifold's geometry into an auxiliary function, you can use off-the-shelf AD tools to get Riemannian derivatives for free.
  • Asymptotic Efficiency: They proved that their AD-based approach has the same asymptotic complexity as evaluating the function itself. If your function takes $F$ operations to calculate, the gradient also takes roughly $O(F)$ operations—a massive improvement over the $O(NF)$ cost of finite differences.
  • Stability through Omission: By skipping the curvature term in the Hessian, they effectively implemented a Riemannian Gauss-Newton method. This makes the optimization much more robust against the "numerical explosions" common when dealing with near-zero singular values.
  • Stop-Gradient for Preconditioning: They showed how the "stop-gradient" operator (common in deep learning) can be used to compute projections for non-gradient fields, such as preconditioned residuals.

Key Results

The results show that the AD approach isn't just easier—it's often faster and more memory-efficient than the alternatives.

  • Memory Wins: In tensor completion tasks, the "naive" approach ran out of memory, while the AD method handled large ranks easily.
  • Speed on CPU: The AD method consistently outperformed both naive and manually "improved" baselines on CPU across almost all tested functions.
  • GPU Performance: While highly optimized manual kernels (the "improved" version) can sometimes beat AD on GPUs due to lower overhead, the AD method remained competitive and vastly easier to implement for new, custom functions.
  • Library Integration: The algorithms are now part of the T3F library, allowing researchers to run Riemannian optimization on both CPUs and GPUs with minimal setup.

Limitations and Future Work

While the AD approach is powerful, it does carry a constant-factor overhead. For very simple functions where a hand-optimized kernel is possible, the manual approach might still win on raw speed.

Additionally, the authors chose to omit the curvature term of the Hessian for stability. While this is standard for many applications, some high-precision tasks might require it. Future work could involve hybrid methods that selectively include these terms when singular values are sufficiently large. Finally, while the current work focuses on TensorFlow, porting these concepts to JAX or PyTorch would likely see wide adoption in the broader ML community.

Summary updated

BibTeX
@article{novikov2021automatic,
  author = {Alexander Novikov and Maxim Rakhuba and Ivan Oseledets},
  title = {{Automatic differentiation for Riemannian optimization on low-rank matrix and tensor-train manifolds}},
  journal = {SIAM J. Sci. Comput.},
  year = {2021},
  doi = {10.1137/20m1356774},
}
Figure