LoKO: Low-Rank Kalman Optimizer for Online Fine-Tuning of Large Models

Hossein Abdi, Mingfei Sun, Andi Zhang, Samuel Kaski, Wei Pan · DOI

Introduction

Fine-tuning large-scale models, such as Transformers and deep Convolutional Neural Networks (CNNs), is a resource-intensive process. While Parameter-Efficient Fine-Tuning (PEFT) techniques like Low-Rank Adaptation (LoRA) have significantly reduced the number of trainable parameters, they still predominantly rely on first-order gradient-based optimizers like AdamW. These optimizers often suffer from slow convergence and require extensive hyperparameter tuning in online learning scenarios.

The Extended Kalman Filter (EKF) offers a theoretically superior alternative, functioning essentially as an online natural gradient descent method. However, its $O(n^2)$ computational complexity relative to the number of parameters $n$ has historically made it impractical for deep learning. This paper introduces LoKO (Low-Rank Kalman Optimizer), a framework that adapts the EKF for modern large-scale models by combining the efficiency of LoRA with a linear-complexity diagonal approximation.

Methodology

LoKO reformulates the fine-tuning process as an optimal filtering problem. To overcome the computational hurdles of the standard EKF, the authors implement several key innovations:

  1. LoRA Integration: By restricting the Kalman filter updates to the low-rank adapter weights (matrices A and B in LoRA), the state space is drastically reduced.
  2. Diagonal Covariance Approximation: LoKO assumes a diagonal covariance matrix ($P$), reducing complexity from $O(n^2)$ to $O(n)$. This makes the optimizer's resource requirements comparable to standard first-order methods.
  3. Advanced Noise Estimation: The performance of Kalman filters is sensitive to the observation noise covariance ($R$). LoKO employs an Exponential Moving Average (EMA) approach combined with a first-order Taylor expansion to estimate $R$ dynamically without extra computational cost.
  4. Efficient Implementation: Utilizing transposed Khatri-Rao products and einsum operations in PyTorch, the algorithm ensures that matrix inversions depend only on the model's output dimension, which is typically small, rather than the total parameter count.

Experimental Setup

The researchers evaluated LoKO across diverse architectures and tasks:

  • Computer Vision: MNIST (DenseNet-121), CIFAR-10/100 (ResNet-18/50, ViT-B16), and ImageNet100 (ViT-L16).
  • Natural Language Processing: SST-2, CoLA, and MRPC using RoBERTa-base and RoBERTa-large.

The models tested ranged from 7 million to 355 million parameters, demonstrating the scalability of the approach across different scales and modalities.

Results and Discussion

LoKO consistently outperformed standard optimizers in terms of convergence speed and final accuracy across various benchmarks.

Comparison of LoKO against AdamW and AdaGrad across multiple vision datasets and architectures. LoKO (blue) shows faster convergence and higher online accuracy.

Key Performance Metrics

  • Convergence Speed: On MNIST with DenseNet-121, LoKO reached target accuracy in approximately 4,000 steps, whereas AdamW required 20,000 steps.
  • Accuracy Gains: For ImageNet100 with a ViT-L16, LoKO achieved an online accuracy of 97.71%, significantly higher than the 95.13% achieved by LoRA/AdamW.
  • Stability: LoKO exhibited lower standard deviation across multiple runs compared to AdaGrad and AdamW, indicating higher stability for streaming data applications.

Theoretical and Practical Insights

The study highlights that LoKO is scale-invariant regarding hidden layer size because the most expensive computational step (matrix inversion) depends on the output dimension rather than the parameter count. Furthermore, the initialization of the covariance diagonal ($p_0$) was identified as the most critical hyperparameter, representing the initial uncertainty of the model. The authors also demonstrated that LoKO is compatible with other PEFT variants like DoRA (Weight-Decomposed LoRA), often yielding even better results.

Limitations and Future Work

Despite its advantages, LoKO currently lacks a direct equivalent to the decoupled weight decay used in AdamW, which led to slightly lower performance on certain NLP tasks like SST-2. Additionally, while robust, the optimizer requires careful selection of initial bounds for the covariance matrix and the EMA forgetting factor. Future research will explore LoKO's performance in generative tasks (LLMs) and Reinforcement Learning, as well as its handling of sudden out-of-distribution (OOD) data shifts.

Conclusion

LoKO successfully bridges the gap between classical state estimation and modern deep learning. By making the precision of Kalman filtering computationally feasible for large models, it provides a powerful tool for efficient, high-performance online fine-tuning.

Summary updated

BibTeX
@misc{abdi2024loko,
  author = {Hossein Abdi and Mingfei Sun and Andi Zhang and Samuel Kaski and Wei Pan},
  title = {{LoKO: Low-Rank Kalman Optimizer for Online Fine-Tuning of Large Models}},
  year = {2024},
  eprint = {2410.11551},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.11551},
}
Figure