KL-SOAP: Hybrid Shampoo Optimizer
- KL-SOAP is a hybrid optimizer that integrates KL-Shampoo’s Kronecker factor updates with SOAP’s second-moment vector preconditioning for enhanced scaling and coupling.
- Its reparametrization supports BFloat16 storage by storing combined factor matrices and using efficient subspace QR decompositions to cut computational overhead.
- KL-SOAP improves memory efficiency and runtime while mitigating performance degradation, making it robust for high-dimensional deep learning tasks.
KL-SOAP is a Shampoo-based optimizer that combines Kronecker-factored metric learning, as in KL-Shampoo, with the “second-moment-vector” preconditioning of SOAP. In the formulation reported in "Reparametrizing Shampoo and SOAP for Subspace Basis Updates and BFloat16 Storage" (Milligan et al., 25 May 2026), KL-SOAP tracks Kronecker factors exactly as in KL-Shampoo while also maintaining a vector second moment in the Kronecker eigenbasis, and it uses a reparametrization that supports BFloat16 storage and forms a complete basis by combining updated basis vectors with unchanged ones. The same work places KL-SOAP within a broader family of Shampoo-based methods that employ QR decomposition and argues that reparametrized, subspace-based basis updates reduce computational overhead while mitigating the performance degradation caused by BFloat16 storage.
1. Position within the Shampoo family
The paper situates KL-SOAP among three closely related Shampoo-based methods (Milligan et al., 25 May 2026). Shampoo and KL-Shampoo maintain two Kronecker factors and , and form the preconditioner
SOAP instead works in the eigenbasis of , tracks the elementwise “Adam” second moment
and forms
KL-SOAP merges these two ideas. It keeps KL-Shampoo’s update mechanism for , but also tracks SOAP’s vector moment 0. The preconditioner at time 1 is
2
and the parameter update is
3
The paper’s stated motivation is that KL-SOAP often improves on pure-Shampoo through better scaling in “long-tail” coordinates and on pure-SOAP through better Kronecker-coupling. A plausible implication is that KL-SOAP is intended as a hybrid preconditioner that preserves the structural coupling of Kronecker factors while retaining elementwise adaptation in the learned basis.
2. Full mathematical formulation
In the full-basis formulation, KL-SOAP tracks two matrix factors and a vector moment (Milligan et al., 25 May 2026). Let
4
Then
5
and the factor updates are
6
Using 7, KL-SOAP updates the vector moment as
8
then defines
9
This formulation makes explicit that KL-SOAP uses two distinct state types. The first is the Kronecker-factored curvature state 0, inherited from KL-Shampoo. The second is the coordinatewise second moment 1 in the time-varying basis 2, inherited from SOAP. The optimizer therefore combines curvature adaptation induced by the Kronecker factors with diagonal rescaling in the learned eigenspace.
3. Reparametrization for BFloat16 storage
The paper identifies two practical issues for Shampoo-based methods: existing QR implementations require single-precision arithmetic and remain computationally expensive, and using BFloat16 storage to reduce memory usage can degrade performance (Milligan et al., 25 May 2026). Its proposed remedy is a reparametrization of the preconditioner.
Instead of storing 3 and 4 in FP32, the method stores the combined factor
5
together with the orthogonal basis 6. Algebraically,
7
and then
8
The exposition states that storing 9, described as nearly diagonal, and 0 in BFloat16 is safe, while QR is performed in FP32 only on small subspaces. It also states that the vector 1 is updated as before but can also be stored in BFloat16 without measurable loss. This suggests that the reparametrization is not merely a memory layout change; it is designed to preserve the numerical role of the basis while relocating the precision-sensitive computation to a reduced-dimensional QR step.
4. Subspace basis updates
A central feature of the reparametrized method is the subspace basis update (Milligan et al., 25 May 2026). Rather than performing a full 2 QR, the method chooses an index set 3 of size 4, for example 5 with 6, and partitions
7
It then performs
8
and updates only those rows and columns of 9 that touch 0: 1 while 2 and 3 are rotated similarly.
The cost is given explicitly as 4 for QR plus 5 for the two block updates, versus 6 for a full QR. The paper also describes the resulting basis as complete because updated basis vectors are combined with unchanged ones. In operational terms, the algorithm updates only a subspace of the basis at each scheduled QR step while leaving the complement intact.
A typical loop includes the following elements. 7, 8, and 9 are stored in BFloat16; gradients and small QR computations remain in FP32. The algorithm computes 0 in FP32, projects it into the current basis via 1, updates 2, periodically performs the subspace QR step every 3 iterations, applies the basis transforms implicitly through two matrix multiplications rather than materializing 4, updates 5, rescales by 6, and maps the preconditioned direction back to parameter space.
5. Computational and memory characteristics
The paper gives a cost analysis in terms of 7 (Milligan et al., 25 May 2026). A full QR costs 8 per factor, for a total of 9. With subspace QR and block size 0,
- QR on the 1 block costs 2.
- Rotating the two touched blocks costs 3.
- The combined per-factor cost is 4.
- The total across both factors is 5.
The exposition adds that with 6, for example 7 or 8, the subspace approach can be 9 or 0 faster than full QR. This is a direct consequence of replacing cubic dependence on the full dimension by cubic and quadratic dependence on a smaller block.
The memory accounting is also explicit. Per factor, the method stores 1 and 2, each with 3 numbers. In FP32 this is
4
whereas in BFloat16 it is
5
which yields 50% savings. The vector 6 is also stored in BFloat16 for 7 savings versus FP32. The paper’s broader claim is that the reparametrization makes Shampoo-based methods more memory- and time-efficient, and KL-SOAP is presented as a concrete beneficiary of that redesign.
6. Empirical behavior and implementation parameters
The reported empirical results focus on BFloat16 storage and subspace-QR runtime behavior (Milligan et al., 25 May 2026). Under the new reparametrization, KL-SOAP, KL-Shampoo, and SOAP can be stored entirely in BFloat16 without measurable loss in test loss; the same section also states that subspace-QR steps cut wall-clock runtime by approximately 8 with at most 0.001 degradation in loss.
| Method | Parametrization | FP32 loss 9 BFP16 loss (0) |
|---|---|---|
| KL-SOAP | old | 3.351 1 3.362 (+0.011) |
| KL-SOAP | new | 3.346 2 3.346 (+0.000) ★ |
| KL-Shampoo | old | 3.345 3 3.345 (+0.000) |
| KL-Shampoo | new | 3.345 4 3.344 (−0.001) ★ |
| SOAP | old | 3.358 5 3.372 (+0.014) |
| SOAP | new | 3.353 6 3.359 (+0.006) |
The mark ★ is identified in the source as best under BFloat16. For KL-SOAP specifically, the new parametrization changes the reported transition from 7 to 8. This suggests that, in the reported setting, the BFloat16 penalty is removed for KL-SOAP.
The paper further reports that for 9 and 0, subspace QR is 1 faster than full-basis QR on an NVIDIA H100, yielding overall optimizer speedups of approximately 30%. In the implementation notes, the recommended block fraction is 2, the subspace frequency is 5–10 steps, the inner loop usually uses 3 subspace QR per update, the damping for vector 4 is 5, the Shampoo damping for 6 is 7, and the optimizer coefficients are 8 and 9. For block selection, the recommended strategy is the two-phase “greedy Jacobi,” described as picking the largest off-diagonal and growing a block, implementable via top-k in PyTorch; random sampling also works but is slightly less robust. The work states that the method can be implemented in modern deep-learning frameworks such as JAX and PyTorch using standard operations including matmul, top-k, and small-scale QR.
In this presentation, KL-SOAP is therefore not only a hybrid preconditioner but also a precision-aware and basis-update-aware optimizer design. Its defining technical characteristics are the combination of KL-Shampoo factor updates with SOAP-style vector moments, the reparametrized storage of basis and factor information, and the restriction of QR operations to selected subspaces rather than the full basis.