Manuscript Offprint

arXiv:2610.22925

Scalable Levenberg-Marquardt Training Framework for Deep Learning

Xianghao Wang, Johan Barthélemy, John Taylor

Xianghao Wang

School of Computing

Australian National University

Canberra, Australia

xianghao.wang@anu.edu.au

Johan Barthélemy

NVIDIA

CA, United States

jbarthelemy@nvidia.com

John Taylor

School of Computing

Australian National University

Canberra, Australia

john.taylor@anu.edu.au

Abstract—The Levenberg-Marquardt (LMA) algorithm is a widely used nonlinear least-squares solver in scientific computing, known for its rapid convergence. Recent studies show that for small-scale neural networks, LMA provides better convergence and architectural robustness than first-order optimizers like Adam. However, as a second-order method, LMA imposes prohibitive memory and computational costs. These costs are primarily from the Jacobian matrix, whose dimensions scale with both the number of samples and parameters. This bottleneck limits LMA in its traditional applications and prevents its use in large-scale neural networks.

Recent efforts scale LMA using preconditioned conjugate gradient (PCG) solvers to avoid materializing the Jacobian. However, PCG only approximates the solution, and an accurate approximation requires many network propagations and a task-specific preconditioner. Other studies optimize LMA to reduce costs, but they restrict their methods to specific tasks or network architectures. As a result, LMA remains impractical for training general large-scale neural networks.

In this paper, we propose LeMA, a distributed LMA algorithm for large-scale neural network training on multi-GPU platforms. The contributions of LeMA are twofold. First, an exact dual formulation of LMA removes the memory dependence on the parameter dimension. Second, a Jacobian sharding strategy computes Jacobian shards on the fly and in parallel to avoid materializing the full Jacobian.

For large-scale neural networks, LeMA reduces the memory footprint of LMA from quadratic in the number of parameters to quadratic in the batch size. This advancement makes exact LMA steps feasible for billion-parameter models without approximate PCG solves. Furthermore, for a convolutional neural network with 1,000,022,632 parameters on an 8-GPU node, LeMA achieves a 7.97×7.97\times speedup over a single GPU, corresponding to a 99.7% strong scaling efficiency.

Index Terms—Levenberg-Marquardt algorithm, distributed training, deep learning, multi-GPU

I. INTRODUCTION

The Levenberg-Marquardt (LMA) algorithm [1], [2] is a standard solver for nonlinear least-squares problems in scientific computing [3], [4]. Each LMA step solves a damped Gauss-Newton system. A damping factor λ\lambda moves the step between the Gauss-Newton method and gradient descent, allowing LMA to converge quickly near a minimum while remaining robust far from it. Since Hagan and Menhaj [5] applied LMA to neural networks, many studies have used it to train small models containing up to several thousand parameters [6]–[13].

Despite its fast convergence, LMA is difficult to scale to large neural networks. The bottleneck lies in the linear system solved at each step, which involves an M×MM \times M coefficient matrix JTJ+λdiag(JTJ)\mathbf{J}^T \mathbf{J} + \lambda \text{diag}(\mathbf{J}^T \mathbf{J}) and an N×MN \times M Jacobian matrix J\mathbf{J}, where NN is the batch size and MM is the number of parameters. This formulation creates an O(MN+M2)\mathcal{O}(MN + M^2) memory footprint. For a model with only one million parameters, the coefficient matrix alone contains a trillion elements. The computational cost is equally high. Evaluating J\mathbf{J} requires NN backward propagations, computing the coefficient matrix takes O(M2N)\mathcal{O}(M^2 N) time, and solving the linear system takes O(M3)\mathcal{O}(M^3) time. These extreme memory and computation demands prevent the extension of LMA to large-scale training.

To address these memory bottlenecks, several studies and libraries [14]–[18] use preconditioned conjugate gradient (PCG) solvers [19] to avoid materializing the large matrices. PCG computes an approximate solution to the linear system Ax=bAx = b using only matrix-vector products Av, without explicitly constructing A. For instance, both the optimization toolkit PETSc [17] and the Python library JAXopt [14] provide LMA implementations with a PCG option. However, applying PCG to LMA requires numerous network propagations to ensure a robust approximation. Additionally, PCG relies on a suitable preconditioner matrix, and selecting an effective one is highly task-specific [20].

As an exact alternative to PCG, Bilski et al. [21] decompose LMA into independent tasks where each neuron computes its own Jacobian and weight updates. However, this approach assumes each neuron produces a single output. It is therefore incompatible with convolutional layers, which share parameters to generate multiple spatial outputs.

Our goal is to design an exact LMA framework for general deep learning tasks, without relying on PCG approximations or specific network architectures. We focus strictly on the systems engineering challenges to make each exact LMA step feasible and fast at scale, as the numerical convergence properties of LMA fall beyond the scope of this work. Di Marco [12], [13] utilizes a dual form of the simpler Levenberg method, which applies λI\lambda I as the damping term. This approach successfully reduces the memory footprint from O(MN+M2)\mathcal{O}(MN + M^2) to O(MN+N2)\mathcal{O}(MN + N^2), making it feasible to train large neural networks where M≫NM \gg N. Inspired by this, we derive and implement an exact dual formulation specifically for LMA. To further reduce memory consumption, we design a partitioning strategy that avoids storing the full Jacobian J. This design allows us to parallelize LMA and accelerate training across multiple GPUs.

We present LeMA, a multi-GPU Levenberg-Marquardt training framework for neural networks. We summarize our main contributions as follows:

• We derive an exact dual formulation for LMA, which shifts the linear system from the parameter dimension to the batch dimension (Section III-A).

• We provide guidelines for designing robust residual functions tailored for LMA (Section III-B).

• We design a partitioning and parallelization strategy to further reduce the memory footprint and accelerate computation (Sections IV-B and IV-C).

In addition to these core contributions, we introduce several supplementary optimizations detailed in Sections III and IV.

We evaluate LeMA on image classification tasks across various neural networks. LeMA scales LMA to models with up to 1,000,022,632 parameters and achieves a 99.7% strong scaling efficiency on 8 GPUs. For LeNet-5, which is small enough for the standard LMA form to fit in GPU memory, LeMA achieves an 8.3×8.3\times speedup and a 33×33\times reduction in memory footprint on a single GPU compared to a standard LMA implementation. When running on 8 GPUs, it delivers a 37.8×37.8\times speedup and a 41×41\times memory reduction over a standard multi-GPU LMA baseline.

The rest of this paper is organized as follows. Section II reviews LMA and Jacobian computation within deep learning frameworks. Section III derives the exact dual formulation and provides residual representations for common loss functions. Section IV details the distributed implementation of LeMA and analyzes its associated costs. Finally, Section V evaluates the performance of LeMA.

References (30)