MKOR: Momentum-Enabled Kronecker-Factor-Based Optimizer Using Rank-1 Updates

M. Hamed Mozaffari, Sikan Li, Zhao Zhang, Maryam Mehri Dehnavi · DOI

TL;DR

MKOR (Momentum-Enabled Kronecker-Factor-Based Optimizer) is a new optimization framework that slashes the computational and communication overhead of second-order methods. By using rank-1 updates and the Sherman-Morrison identity, it reduces complexity from cubic to quadratic, enabling training speedups of up to 2.57× over standard optimizers like LAMB for large-scale models like BERT.

What Problem Does This Paper Address?

In the world of deep learning, first-order optimizers like SGD, Adam, and LAMB are the workhorses. They are computationally "cheap" but often require many iterations to converge because they only look at the gradient's slope.

Second-order methods (like Natural Gradient Descent) are theoretically superior because they look at the "curvature" of the loss landscape, allowing them to take much smarter, larger steps toward the optimum. However, they have a massive catch: they require computing and inverting large matrices (the Hessian or Fisher Information Matrix). For a layer with dimension $d$, this inversion usually costs $O(d^3)$—a death sentence for scalability in the era of Large Language Models (LLMs). Furthermore, synchronizing these large matrices across multiple GPUs creates a communication bottleneck ($O(d^2)$).

The authors aim to bridge this gap, making the fast convergence of second-order methods practical for massive Transformer models.

Methods

The core innovation of MKOR lies in how it approximates and updates the inverse of the curvature information:

  1. Rank-1 Approximations: Instead of computing full covariance matrices for every batch, MKOR uses a rank-1 approximation based on the average of samples.
  2. Sherman-Morrison (SM) Based Inversion: This is the mathematical "cheat code." Because the update is rank-1, the authors use the Sherman-Morrison identity to update the inverse of the matrix directly. This transforms a cubic $O(d^3)$ matrix inversion into a quadratic $O(d^2)$ matrix-vector multiplication.
  3. Linear Communication: Because only rank-1 vectors need to be synchronized across workers, communication costs drop from $O(d^2)$ to $O(d)$.
  4. Momentum Integration: Unlike previous low-rank attempts, MKOR successfully integrates momentum into the Kronecker factors, which is vital for stable training in deep networks.
  5. MKOR-H (Hybrid): The authors observed that second-order gains are highest early in training. MKOR-H automatically switches to a first-order optimizer (like LAMB) once the curvature updates no longer provide a significant "boost," saving even more time.
  6. Stability Mechanisms: To prevent the "exploding gradient" issues common in second-order methods, MKOR includes a norm-based stabilizer and a gradient rescaling mechanism.

Datasets

The authors evaluated MKOR across a variety of standard benchmarks to prove its versatility:

  • BERT-Large-Uncased: Pre-trained on English Wikipedia and the Toronto BookCorpus.
  • SQuAD v1.1: For fine-tuning on question-answering tasks.
  • GLUE Benchmark: A suite of nine diverse natural language understanding tasks.
  • ImageNet: Used with ResNet-50 to test performance on computer vision.
  • CIFAR-100: Used with AlexNet for smaller-scale validation.

Key Insights and Ideas

  • Curvature is Low-Rank: A major "aha moment" is the empirical evidence that covariance matrices in deep learning are often low-rank. This justifies using rank-1 updates without losing the essential "shape" of the loss landscape.
  • Freshness Over Precision: Because MKOR is so computationally cheap, it can update its second-order information much more frequently (e.g., every 10 iterations) than traditional KFAC (which might wait 100–1000 iterations). "Fresher" approximate info turns out to be better than "stale" exact info.
  • FP16 Compatibility: Most second-order methods are numerically unstable with half-precision (FP16) math. MKOR’s simpler scalar divisions make it robust enough to use FP16, further doubling the communication speed.

Key Results

The results on BERT-Large-Uncased using 64 A100 GPUs are particularly striking:

  • Speedup: MKOR-H achieved a 2.57× speedup over the LAMB optimizer and a 1.85× speedup over KAISA (a state-of-the-art KFAC implementation).
  • Training Time: It reduced the training time for BERT-Large from roughly 8 hours down to 3 hours.
  • Convergence: On the GLUE dataset, MKOR achieved new state-of-the-art metrics, whereas other second-order methods like KFAC sometimes failed to reach the baseline accuracy.
  • Scalability: MKOR showed near-linear scaling up to 64 GPUs, proving that its reduced communication complexity works in practice.

Limitations and Future Work

  • Memory Overhead: While MKOR is more efficient than KFAC, it still requires storing the inverse factors ($O(d^2)$), which is more memory-intensive than simple first-order methods ($O(d)$).
  • Higher-Rank Potential: The authors mention that while rank-1 works well, extending this to "rank-$r$" updates (using SVD) could potentially capture even more curvature info, though it currently introduces too much overhead to be worth it.
  • Switching Heuristics: The hybrid version (MKOR-H) relies on a loss-reduction-rate heuristic to decide when to switch to first-order. The authors suggest that more sophisticated, automated switching logic could be a fruitful area for future research.

Summary updated

Abstract

This work proposes a Momentum-Enabled Kronecker-Factor-Based Optimizer Using Rank-1 updates, called MKOR, that improves the training time and convergence properties of deep neural networks (DNNs). Second-order techniques, while enjoying higher convergence rates vs first-order counterparts, have cubic complexity with respect to either the model size and/or the training batch size. Hence they exhibit poor scalability and performance in transformer models, e.g. large language models (LLMs), because the batch sizes in these models scale by the attention mechanism sequence length, leading to large model size and batch sizes. MKOR's complexity is quadratic with respect to the model size, alleviating the computation bottlenecks in second-order methods. Because of their high computation complexity, state-of-the-art implementations of second-order methods can only afford to update the second order information infrequently, and thus do not fully exploit the promise of better convergence from these updates. By reducing the communication complexity of the second-order updates as well as achieving a linear communication complexity, MKOR increases the frequency of second order updates. We also propose a hybrid version of MKOR (called MKOR-H) that mid-training falls backs to a first order optimizer if the second order updates no longer accelerate convergence. Our experiments show that MKOR outperforms state -of-the-art first order methods, e.g. the LAMB optimizer, and best implementations of second-order methods, i.e. KAISA/KFAC, up to 2.57x and 1.85x respectively on BERT-Large-Uncased on 64 GPUs.
BibTeX
@inproceedings{mozaffari2023mkor,
  author = {M. Hamed Mozaffari and Sikan Li and Zhao Zhang and Maryam Mehri Dehnavi},
  title = {{MKOR: Momentum-Enabled Kronecker-Factor-Based Optimizer Using Rank-1 Updates}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=jcnvDO96N5},
}
Figure