A New Perspective on Shampoo's Preconditioner

Depen Morwani, Itai Shapira, Nikhil Vyas, Eran Malach, Sham Kakade, Lucas Janson

Introduction

Second-order optimization is a rich research area within deep learning that has seen multiple influential works over the past few decades. Recently, these methods have seen success in practical large scale training runs such as Gemini 1.5 Flash (Gemini Team, 20024) and in academic benchmarks (Dahl et al., 2023). One of the primary challenges in this field arises from the substantial memory and computational demands of traditional second-order methods, such as Adagrad (Duchi et al., 2011b) and Newton’s method. In the context of neural networks, both of these methods require storing and inverting a ∣P∣×∣P∣|P|\times|P| dimensional matrix HH (either covariance of the gradients for Adagrad or the Gauss–Newton component of the Hessian for Newton’s method), where ∣P∣|P| represents the number of parameters of the neural network. With modern deep learning architecture scaling to billions of parameters, these requirements make the direct application of these methods impractical. To address this issue, various approaches have been proposed, including Hessian-free optimization (Martens et al., 2010) and efficient approximations of the matrix HH (Gupta et al., 2018b; Martens & Grosse, 2015b). These methods aim to leverage second-order information while mitigating the computational and memory overhead.

The class of methods for efficiently approximating the matrix HH predominantly involve either a diagonal or a layer-wise Kronecker product approximation of HH. These choices are motivated by the fact that, compared to maintaining the matrix HH, both diagonal and layer-wise Kronecker products are significantly more memory-efficient to store and computationally efficient to invert. Two of the most well-known methods that utilize a layer-wise Kronecker product approximation of HH are K-FAC (Martens & Grosse, 2015b) and Shampoo (Gupta et al., 2018b).

In this work, we primarily focus on the Shampoo optimizer (Gupta et al., 2018b), which has recently gained increasing attention from the research community. Notably, in a recent benchmark of optimization algorithms proposed for practical neural network training workloads (Dahl et al., 2023), Shampoo appears to outperform all other existing methods. Another recent study, elucidating the Google Ads recommendation search pipeline, revealed that the Google Ads CTR model is trained using the Shampoo optimizer (Anil et al., 2022). Additionally, a recent work (Shi et al., 2023) implemented a distributed data parallel version of Shampoo, demonstrating its superior speed in training ImageNet compared to other methods.

Previously, Shampoo’s approximation was shown to be an upper bound (in spectral norm) on the matrix HH (Gupta et al., 2018b). In this work, we make this connection much more precise. Prior research has established the notion of the optimal Kronecker product approximation (in Frobenius norm) of HH (Koroko et al., 2023b), which can be obtained numerically using a power iteration scheme. The primary contribution of this work is to theoretically and empirically demonstrate that the square of the approximation used by Shampoo is nearly equivalent to the optimal Kronecker factored approximation of HH.

The main contributions of the work are summarized below:

We empirically establish that the result of one round of power iteration is very close to the optimal Kronecker factored approximation (see Figure 1), and provide theoretical justification for the same.

For the Hessian based viewpoint of Shampoo (Section 2.1.2), we empirically demonstrate the impact on the Hessian approximation of various practical tricks implemented to make Shampoo more computationally efficient such as averaging gradients over batch (Section 4.1) and using empirical Fisher instead of the actual Fisher (Section 4.2).

Remark. Previous works (Balles et al., 2020; Lin et al., 2024) have explored the question of why Adagrad-based approaches like Adam and Shampoo have an extra square root compared to the Hessian inverse in their update. This alternative question is orthogonal to our contribution. For details, refer Appendix F.

Paper organization. In Section 2, we cover the technical background necessary for understanding this work. In Section 3, we provide a general power iteration scheme for obtaining the optimal Kronecker product approximation of the matrix HH, and establish the the connection between Shampoo’s approximation and the optimal Kronecker product approximation of HH. In Section 4, we explore the Hessian approximation viewpoint of Shampoo and empirically study how various practical tricks to make Shampoo more computationally efficient impact the quality of the Hessian approximation. In Section 5, we cover closely related works and conclude with discussing the limitations of the work in Section 6. In Appendix A, we include additional experiments on the ViT architecture and compare with the K-FAC approximation to the Hessian. Detailed related work, proofs, dataset and architecture details have been deferred to the Appendix.

Technical background

Following is a basic lemma about Kronecker products that will be used later

(A⊗B)vec⁡(G)=vec⁡(BGA⊤)(A\otimes B)\operatorname{vec}(G)=\operatorname{vec}(BGA^{\top}).

The original Shampoo (Gupta et al., 2018b) paper introduced its algorithm as an approximation of an online learning algorithm Adagrad (Duchi et al., 2011a). Shampoo can also be interpreted (Anil et al., 2020; Osawa et al., 2023a) as approximating the Gauss–Newton component of the Hessian. Both of these perspectives will be discussed in Section 2.1.1 and 2.1.2 respectively. .

Assume that G1,...,GTG_{1},...,G_{T} are matrices of rank at most rr. Let gt=vec⁡(Gt)g_{t}=\operatorname{vec}(G_{t}) for all tt. Then, with ≼\preccurlyeq representing the for any ϵ>0\epsilon>0,

In Lemma 2 the matrix HAda=∑t=1Tgtgt⊤H_{\text{Ada}}=\sum_{t=1}^{T}g_{t}g_{t}^{\top} is approximated (ignoring ϵ\epsilon and scalar factors) by the the Kronecker product (∑t=1TGtGt⊤)1/2⊗(∑t=1TGt⊤Gt)1/2\left(\sum_{t=1}^{T}G_{t}G_{t}^{\top}\right)^{1/2}\otimes\left(\sum_{t=1}^{T}G_{t}^{\top}G_{t}\right)^{1/2}. Our main focus will be to study the optimal Kronecker product approximation of the matrix HAdaH_{\text{Ada}} and its connection to Shampoo’s approximation (done in Section 3).

1.2 Hessian based perspective of Shampoo

In this section we describe the Hessian approximation viewpoint of Shampoo explored by previous works (Anil et al., 2020; Osawa et al., 2023a) as an alternative to the Adagrad viewpoint described above. Our theoretical and empirical results hold for both viewpoints.

The aim of algorithms such as K-FAC and Shampoo (when viewed from the Hessian perspective) is to do a layerwise Kronecker product approximation of the Fisher matrix HGNH_{\text{GN}}. The following lemma establishes the approximation made by Shampoo:

Assume that Gx,sG_{x,s} are matrices of rank at most rr. Let gx,s=vec⁡(Gx,s)g_{x,s}=\operatorname{vec}(G_{x,s}) . Then, for any ϵ>0\epsilon>0,

In Lemma 2 the matrix on the left hand side is equal to HGNH_{\text{GN}} and the right hand side represents the HGNH_{\text{GN}} approximation made by Shampoo. However, computing this approximation at every step is expensive. So, in practice, Shampoo makes two additional approximations on top.

Thus, if GjG_{j} and WjW_{j} represent the batch gradient and weight matrix at iteration jj, and λ\lambda is an exponential weighting parameter, then the update of Shampoo is given by

where LjL_{j} and RjR_{j} represent the left and right preconditioners maintained by Shampoo, respectively.

Our focus (when viewing Shampoo from the Hessian perspective) will be to study

The optimal Kronecker product approximation of the matrix HGNH_{\text{GN}} and its connection to Shampoo’s approximation (done in Section 3).

The effect of the aforementioned two approximations on the approximation quality (done in Section 4).

2 Optimal Kronecker product approximation

where ∥⋅∥F\|\cdot\|_{F} denotes the Frobenius norm.

Since the optimal rank-1 approximation of a matrix is given by its singular value decomposition (SVD), we conclude:

minimize the Frobenius norm ∥H−L⊗R∥F\|H-L\otimes R\|_{F}.

Cosine similarity. We will be using cosine similarity between matrices as a metric for approximation. For two matrices M1M_{1} and M2M_{2}, this refers to Tr(M1M2⊤)/(∣∣M1∣∣F⋅∣∣M2∣∣F)\text{Tr}(M_{1}M_{2}^{\top})/(||M_{1}||_{F}\cdot||M_{2}||_{F}). A value of 1 indicates perfect alignment, while a value of 0 indicates orthogonality.

Optimal Kronecker product approximation and Shampoo

Loan & Pitsianis (1993) describe an approach to find the optimal Kronecker product approximation of a matrix (with respect to the Frobenius norm). Koroko et al. (2023b) use this approach to find the optimal layer-wise Kronecker product approximation of the hessian matrix for networks without weight sharing. We will now do a general analysis which would also be applicable to neural networks with weight sharing.

Reshaping vectors on both sides into matrices results in:

Our first and main approximation involves replacing the iterative power iteration scheme (Equation 4) with just a single iteration. This leads to the main contribution of our work:

One step of power iteration, starting from the identity, for obtaining the optimal Kronecker product approximation of HH is precisely equal to the square of the Shampoo’s approximation of HH

The initialization for the single iteration will use the identity matrix, i.e., ImI_{m} and InI_{n} for LL and RR, respectively. Thus, we transition from the iterative update equations:

to the simplified single-step expressions:

With the above expression for LL and RR, L⊗RL\otimes R is precisely equal to the square of the Shampoo’s approximation of HH given by the right hand side of Equation 1. ∎

As shown in Figure 1, for various datasets and architectures, this single step of power iteration is very close to the optimal Kronecker product approximation for both H=HGNH=H_{\text{GN}} (top) and H=HAdaH=H_{\text{Ada}} (bottom). However, we can see that the upper bound proposed by the original Shampoo work (Gupta et al., 2018b) is significantly worse.

One reason why the cosine similarity might be large is that H^\hat{H} is nearly rank-1 (σ1\sigma_{1} is large); that is, HH is closely approximated by a Kronecker product. As illustrated in Figure 1, this assumption does not universally hold. Instead, we propose an alternative explanation for why a single step of power iteration is typically sufficient: the coefficient α1\alpha_{1} is usually larger than αi\alpha_{i} for all i≥2i\geq 2. We begin by providing a theoretical justification for this, followed by empirical evidence from our experiments.

We start by noting that αi=vec⁡(In)Tvi=Tr(Vi)\alpha_{i}=\operatorname{vec}\left(I_{n}\right)^{T}v_{i}=\text{Tr}(V_{i}). Now, we will show that using the identity matrix as initialization is a good choice since a) shows it has the maximal dot product with possible top components i.e., PSD matrices (Proposition 2), and b) we expect it to have a small dot product with later components.

V1V_{1} is a Positive Semi-Definite (PSD) matrix.

Since V1V_{1} is a PSD matrix we would like to initialize our power iteration with a matrix which is close to all PSD matrices. Now, we will show that identity is the matrix which achieves this, specifically it maximizes the minimum dot product across the set of PSD matrices of unit Frobenius norm.

Consider the set of PSD matrices of unit Frobenius norm of dimension mm denoted by SmS_{m}. Then

The previous proposition argues that ImI_{m} maximizes the worst-case dot product with possible top singular vectors. Now, we argue that its dot product with other singular vectors should be lower.

If V1V_{1} is positive-definite, then ViV_{i} for i≥2i\geq 2 are not PSD.

Therefore, the diagonal elements of ViV_{i} for i≥2i\geq 2 need not be positive, and this might lead to cancellations (for i≥2i\geq 2) in the trace of ViV_{i} which is equal to αi\alpha_{i}. Hence we expect αi\alpha_{i}’s for i≥2i\geq 2 to be smaller than α1\alpha_{1}. We now show experiments to demonstrate this in practice. To quantify the benefit of α1\alpha_{1} usually being larger than αi\alpha_{i} for i≥2i\geq 2, we will compare α1σ1∑iαi2σi2\frac{\alpha_{1}\sigma_{1}}{\sqrt{\sum_{i}\alpha_{i}^{2}\sigma_{i}^{2}}} (for both left and right singular vectors) and σ1∑iσi2\frac{\sigma_{1}}{\sqrt{\sum_{i}\sigma_{i}^{2}}}. The latter can be interpreted as the cosine similarity if all α\alpha’s were equal or as a measure of how close H^\hat{H} is to being rank 1 since it is equal to the cosine similarity between u1v1Tu_{1}v_{1}^{T} and H^\hat{H}. Thus σ1∑iσi2\frac{\sigma_{1}}{\sqrt{\sum_{i}\sigma_{i}^{2}}} is equal to the “Optimal Kronecker” cosine similarity used in Figure 1. In Figure 2 we track both of these quantities through training and indeed observe that α1σ1∑iαi2σi2\frac{\alpha_{1}\sigma_{1}}{\sqrt{\sum_{i}\alpha_{i}^{2}\sigma_{i}^{2}}} are significantly closer to 1 than σ1∑iσi2\frac{\sigma_{1}}{\sqrt{\sum_{i}\sigma_{i}^{2}}} for both H=HGNH=H_{\text{GN}} (top) and H=HAdaH=H_{\text{Ada}} (bottom).

1.2 Exact Kronecker product structure in H𝐻H

Under the assumption that H^\hat{H} is rank-1,

Let H^=σuv⊤\hat{H}=\sigma uv^{\top}, i.e, H=σU⊗VH=\sigma U\otimes V. Let Im=Tr(U)U+RmI_{m}=\text{Tr}(U)U+R_{m} and In=Tr(V)V+RnI_{n}=\text{Tr}(V)V+R_{n}, where RmR_{m} and RnR_{n} are the residual matrices. Now, after one round of power iteration, the left and right estimates provided by Shampoo are given by

Since H=H^GNH=\hat{H}_{\text{GN}} is an m2×1m^{2}\times 1 matrix for binomial logistic regression, it is rank-1, so the equality in the corollary holds. In other words, the square of Shampoo’s HGNH_{\text{GN}} estimate perfectly correlates with HGNH_{\text{GN}} for binomial logistic regression. This is demonstrated in the first plot of Figure 1.

1.3 Discussion about optimization

Hessian Approximation of Shampoo

From the Hessian approximation viewpoint, the previous section covers the case of using batch size 11 and sampled labels, as described in Section 2.1.2. To be precise, in Figure 1 top, we consider how well HGNH_{\text{GN}} is correlated with Ex,s[Gx,sGx,sT]⊗Ex,s[Gx,sTGx,s]E_{x,s}[G_{x,s}G_{x,s}^{T}]\otimes E_{x,s}[G_{x,s}^{T}G_{x,s}], where ss represents that the labels are sampled from the model’s output distribution. On the other hand, as discussed in Section 2.1.2, Shampoo in practice is generally used with arbitrary batch sizes and real labels. We now investigate the effect of these two factors on the Hessian approximation.

The next approximation towards Shampoo is to average the gradient across the batch, i.e., we go from

where BB denotes the batch, s\bf{s} is the concatenation of s∼f(x)s\sim f(x) for all x∈Bx\in B and GB,s=1∣B∣∑x∈B,s=s[x]Gx,sG_{B,\bf{s}}=\frac{1}{|B|}\sum_{x\in B,s=\mathbf{s}[x]}G_{x,s} is the batch gradient, with s[x]\mathbf{s}[x] representing the sampled label corresponding to x∈Bx\in B.

However, this does lead to a significant improvement in computational complexity by saving up to a factor of batch size.

2 Using real labels instead of sampled labels

As our final approximation we replace using sampled labels s∼f(x)s\sim f(x) to using real labels yy. This approximation, denoted in the literature by empirical Fisher when batch size is 1, has been discussed at length by prior works (Osawa et al., 2023a; Kunstner et al., 2019). The main theoretical argument for why this approximation may work well is that, as we move towards optima, the two quantities converge in the presence of label noise (Grosse, 2021).

In Figure 3 (top), when evaluating HGNH_{\text{GN}} approximation with batch size 11, we surprisingly find that the approximation quality is good throughout the training. However, unlike the case of sampled labels, the approximation starts to degrade at large batch sizes because the gradients with real labels are not mean 0. The lemma below (Grosse, 2021) shows how this estimator changes with batch size.

Let BB denote the batch and GB=1∣B∣∑(x,y)∈BGx,yG_{B}=\frac{1}{|B|}\sum_{(x,y)\in B}G_{x,y} denote the batch gradient. Then

We note that this approximation has the computational benefit of not requiring another backpropagation with sampled labels; instead, these computations can be done alongside usual training.

Related work

We discuss the related works in detail in Appendix E. Here, we discuss two closely related works: Ren & Goldfarb (2021) and Koroko et al. (2023a).

Ren & Goldfarb (2021) study the Hessian perspective of Shampoo and show that, under the assumption that sampled gradients follow a tensor-normal distribution, the square of the Hessian estimate of Shampoo is perfectly correlated with HGNH_{\text{GN}}. We also show the same result under much weaker conditions in Corollary 2. Moreover, in Proposition 1 we show that, in general, the square of the Hessian estimate of Shampoo is closely related to the optimal Kronecker product approximation of HGNH_{\text{GN}}. We additionally also study the approximations used by Shampoo to make it computationally efficient (Section 4) and the Adagrad perspective of Shampoo’s preconditioner.

Loan & Pitsianis (1993) develop the theory of optimal Kronecker product approximation of a matrix (in Frobenius norm). Koroko et al. (2023a) use it for finding layer-wise optimal Kronecker product approximation of HGNH_{\text{GN}} for a network without weight sharing. We extend their technique to networks with weight-sharing, and show that the square of the Hessian estimate of Shampoo is nearly equivalent to the optimal Kronecker product approximation of HGNH_{\text{GN}}.

Limitations

The main contribution of our work is to show that the square of the Shampoo’s approximation of HH (where HH refers to either HAdaH_{\text{Ada}} or HGNH_{\text{GN}}) is nearly equivalent to the optimal Kronecker approximation of HH. Although we verify this empirically on various datasets and provide theoretical arguments, the gap between them depends on the problem structure. In some of our experiments with ViT architecture (Appendix A), we find that the gap is relatively larger compared to other architectures. Moreover, it remains an open question to understand the conditions (beyond those described in K-FAC Martens & Grosse (2015b)) under which HH is expected to be close to a Kronecker product. Again, in some of the experiments with ViTs (Appendix A), we find that the optimal Kronecker product approximation to HH is much worse as compared to other architectures.

Acknowledgements

NV and DM are supported by a Simons Investigator Fellowship, NSF grant DMS-2134157, DARPA grant W911NF2010021, and DOE grant DE-SC0022199. This work has been made possible in part by a gift from the Chan Zuckerberg Initiative Foundation to establish the Kempner Institute for the Study of Natural and Artificial Intelligence. SK and DM acknowledge funding from the Office of Naval Research under award N00014-22-1-2377 and the National Science Foundation Grant under award #IIS 2229881. LJ acknowledges funding from the National Science Foundation DMS-2134157.

References

Appendix A Additional experimental results

In this subsection, we present the results for a Vision Transformer (ViT) architecture trained on the CIFAR-5m dataset. This architecture features a patch size of 4, a hidden dimension of 512, an MLP dimension of 512, 6 layers, and 8 attention heads.

For these experiments, we utilize three layers from the fourth transformer block: two layers from the MLP (referred to as ’FFN Linear Layer 1’ and ’FFN Linear Layer 2’) and the QK layerThe QK layer is separated from the V part of the layer, following similar decomposition method described by Duvvuri et al. (2024) (referred to as ’Q-K Projection Layer’).

Appendix B Experiments

Datasets and Architectures. We conducted experiments on three datasets: MNIST (LeCun et al., 1998), CIFAR-5M (Nakkiran et al., 2020), and ImageNet (Deng et al., 2009), using logistic regression, ResNet18 (He et al., 2016), and ConvNeXt-T (Liu et al., 2022) architectures, respectively. For MNIST, we subsampled two digits ({0,1}\{0,1\}) and trained a binary classifier.

For MNIST, we used the only layer, i.e, the first layer of the linear classifier for computing the cosine similarities. For Resnet18 and Imagenet, we picked arbitrary layers. In particular, for Resnet 18, we used one of the convolution layers within the first block (’layer1.1.conv1’ in https://pytorch.org/vision/master/_modules/torchvision/models/resnet.html#resnet18). For Imagenet, we used the 1x1 convolutional layer within the 2nd block of convnext-T (’stages.2.1.pwconv1’ in https://pytorch.org/vision/main/models/generated/torchvision.models.convnext_tiny.html#torchvision.models.convnext_tiny).

Cosine similarity estimation for HGNH_{\text{GN}}. For estimating the Frobenius norm of HGNH_{\text{GN}}, we used the identity:

Hessian-vector products with the Gauss–Newton component were performed using the DeepNetHessian library provided by Papyan (2019).

For estimating the cosine similarity between HGNH_{\text{GN}} and its estimator H~GN\widetilde{H}_{\text{GN}}, we used the following procedure:

Estimate ∥HGN∥F\|H_{\text{GN}}\|_{F}, and calculate ∥H~GN∥F\|\widetilde{H}_{\text{GN}}\|_{F}.

Define scaled H~GN\widetilde{H}_{\text{GN}} as S~GN=∥HGN∥F∥H~GN∥FH~GN\widetilde{S}_{\text{GN}}=\frac{\|H_{\text{GN}}\|_{F}}{\|\widetilde{H}_{\text{GN}}\|_{F}}\widetilde{H}_{\text{GN}}.

Cos-sim(HGN,H~GN)=1−∥HGN−S~GN∥F22∥HGN∥F2\text{Cos-sim}(H_{\text{GN}},\widetilde{H}_{\text{GN}})=1-\frac{\|H_{\text{GN}}-\widetilde{S}_{\text{GN}}\|_{F}^{2}}{2\|H_{\text{GN}}\|_{F}^{2}}, where the numerator is again estimated via Hessian-vector products.

Note that in the above procedure, we can exactly calculate ∥H~GN∥F\|\widetilde{H}_{\text{GN}}\|_{F} as it is generally of a Kronecker product form with both terms of size m×mm\times m or n×nn\times n, where m×nm\times n is the size of a weight matrix.

Cosine similarity estimation for HAdaH_{\text{Ada}}. We follow a similar recipe as before, but using a difference method for computing the product HAdavH_{\text{Ada}}v. For a given time TT, HAda=∑t=1Tgtgt⊤H_{\text{Ada}}=\sum_{t=1}^{T}g_{t}g_{t}^{\top}. Thus, HAdav=∑t=1T(gt⊤v)gtH_{\text{Ada}}v=\sum_{t=1}^{T}(g_{t}^{\top}v)g_{t}. We maintain this by keeping a running estimate of the quantity for multiple random vectors vv during a training run, and use it for estimating the product HAdavH_{\text{Ada}}v.

Optimal Kronecker method, wherever used was computed with five rounds of power iteration, starting from the identity. For H=HGNH=H_{\text{GN}}, the Hessian approximations Shampoo2\textit{Shampoo}^{2}, Shampoo, and K-FAC were done using sampled labels and a batch size of 11. For H=HAdaH=H_{\text{Ada}} and step tt, we used gradient enocoutered during the training run in steps ≤t\leq t.

K-FAC was computed with the “reduce” variant from Eschenhagen et al. (2023).

In Figure 2, the Optimal Kronecker legend represents the cosine similarity between the optimal Kronecker approximation of HGNH_{\text{GN}} and HGNH_{\text{GN}}. This is precisely equal to σ1∑iσi2\frac{\sigma_{1}}{\sqrt{\sum_{i}\sigma_{i}^{2}}}. Similarly, the label L (resp. R) represents the cosine similarity between the top left (resp. right) singular vector of H^GN\hat{H}_{\text{GN}} and the estimate obtained after one round of power iteration starting from InI_{n} (resp. ImI_{m}). This is precisely equal to α1σ1∑iαi2σi2\frac{\alpha_{1}\sigma_{1}}{\sqrt{\sum_{i}\alpha_{i}^{2}\sigma_{i}^{2}}}.

In Figure 3 (top), the Hessian approximation is calculated with batch size 11, i.e, ∣B∣=1|B|=1 in Section 4.2. Similarly, in Figure 3 (bottom), ∣B∣=256|B|=256.

Appendix C Deferred proofs

Consider two PSD matrices M1M_{1} and M2M_{2} having the eigenvalue decomposition M1=∑λ1iq1iq1i⊤M_{1}=\sum\lambda_{1i}q_{1i}q_{1i}^{\top} and M2=∑λ2iq2iq2i⊤M_{2}=\sum\lambda_{2i}q_{2i}q_{2i}^{\top}. Then

Thus, if M1M_{1} and M2M_{2} have unit frobenius norm and M1M_{1} is positive definite, then Tr(M1M2)>0\text{Tr}(M_{1}M_{2})>0.

Thus, if V1V_{1} is positive definite, then by orthogonality of successive singular vectors, ViV_{i} for i≥2i\geq 2 cannot be positive semi-definite. ∎

Consider the eigendecomposition of any M∈SqM\in S_{q} given by ∑i=1qλivivi⊤\sum_{i=1}^{q}\lambda_{i}v_{i}v_{i}^{\top}. Denote L={i:λi≤1q}L=\{i:\lambda_{i}\leq\frac{1}{\sqrt{q}}\}. As ∑λi2=1\sum\lambda_{i}^{2}=1, therefore, ∣A∣≥1|A|\geq 1. Consider any j∈Aj\in A. Then

As vjv_{j} is orthogonal to the other eigenvectors. Thus, we can see

Moreover, for the matrix 1qIq\frac{1}{\sqrt{q}}I_{q}, for any matrix M′M^{\prime},

where tr(M′)\text{tr}(M^{\prime}) denotes the trace of the matrix M′M^{\prime}. However, we know tr(M′)=∑λi≥1\text{tr}(M^{\prime})=\sum\lambda_{i}\geq 1 as ∑λi2=1\sum\lambda_{i}^{2}=1. Thus

Note that this is the only matrix with this property as any other matrix will at least have one eigenvalue less than 1q\frac{1}{\sqrt{q}}. Thus

Evaluating GB,sGB,sTG_{B,\bf{s}}G_{B,\bf{s}}^{T}, we get

Now taking an expectation over batches, we get

Taking the expectation over BB on both the sides, we get

Appendix D Technical Background on Hessian

Appendix E Related work

The literature related to second order optimization within deep learning is very rich, with methods that can be broadly classified as Hessian-free and methods based on estimating the preconditioner HH (which could refer to either HAdaH_{\text{Ada}} or HGNH_{\text{GN}}). Hessian-free methods (Martens, 2010) generally tend to approximate the preconditioned step (for Newton’s method) using Hessian vector products, but do not maintain an explicit form of the Hessian. Estimating HH (Martens & Grosse, 2015a; Gupta et al., 2018a) methods maintain an explicit form of the preconditioner that could be efficiently stored as well as estimated.

One of the seminal works related to second order optimization within deep learning was the introduction of Hessian-free optimization (Martens, 2010). The work demonstrated the effectiveness of using conjugate gradient (CG) for approximately solving the Newton step on multiple auto-encoder and classifications tasks. Multiple works (Martens & Sutskever, 2011; Cho et al., 2015) have extended this algorithm to other architectures such as recurrent networks and multidimensional neural nets. One of the recent works (Garcia et al., 2023) also takes motivation from this line of work, by approximately using single step CG for every update, along with maintaining a closed form for the inverse of the Hessian, for the single step to be effective.

E.2 Estimating Preconditioner

Given that it is costly to store the entire matrix HH, various works have tried to estimate layer-wise HH. KFAC (Martens & Grosse, 2015a) was one of the first work, that went beyond diagonal approximation and made a Kronecker product approximation to layer-wise HGNH_{\text{GN}}. It showed that this structure approximately captures the per layer Hessian for MLPs. This approximation was extended to convolutional (Osawa et al., 2019) and recurrent (Martens et al., 2018) architectures. Subsequent works also improved the Hessian approximation, by further fixing the trace (Gao et al., 2021) as well as the diagonal estimates (George et al., 2018; Gao et al., 2020) of the approximation. A recent work (Eschenhagen et al., 2023) also demonstrated that K-FAC can be extended to large-scale training.

From the viewpoint of approximating Adagrad (Duchi et al., 2011b), Gupta et al. (2018a) introduced Shampoo, that also makes a Kronecker product approximation to HAdaH_{\text{Ada}}. One of the subsequent work (Ren & Goldfarb, 2021) introduced a modification of Shampoo, that was precisely estimating the layer-wise HGNH_{\text{GN}} under certain distributional assumptions. Other works (Anil et al., 2021) introduced a distributed implementation of Shampoo, that has recently shown impressive performance for training large scale networks (Shi et al., 2023). Recently, another paper (Duvvuri et al., 2024) proposed a modification of Shampoo, empirically and theoretically demonstrating that the new estimator approximates HAdaH_{\text{Ada}} better than Shampoo’s approximation. Our work shows that the square of Shampoo’s approximation of HAdaH_{\text{Ada}} is nearly equivalent to the optimal Kronecker approximation.

Appendix F Comparison with extra square root in Adagrad based approaches

Multiple previous works (Balles et al., 2020; Lin et al., 2024) have tried to address the question of why Adagrad-based approaches like Adam and Shampoo, have an extra square root in their update compared to Hessian inverse in their updates. This question is primarily concerned with the final update to the weights being used in the optimization procedure, once we have approximated the Hessian.

The primary contribution of this work is completely orthogonal to this question. We are addressing the question of optimal Kronecker approximation of the Hessian, and its connection to Shampoo’s Hessian approximation. This is orthogonal to the Hessian power used in the final update.