AGI Daily
资讯日报词条论文人物新创
返回论文列表
摘要1 引言目录1.1 Muon 方法1.2 计算极因子Newton-Schulz 方法。Jordan 方法与 You 方法。1.3 贡献记号。2 相关工作Newton-Schulz 与多项式 Padé 方法。Newton 方法与有理 Padé。由最优逼近得到的自适应有理方法。自适应多项式方法。在 Muon 中的应用。3 用多项式复合做逼近4 Polar Express4.1 贪心就是最优定理 4.1。证明。4.2为何固定次数?定理 4.3。证明。4.2 为每一步寻找最优多项式4.3 奇异值的上界与下界4.4 有限精度下的考虑4.5 算法5 数值实验5.1 Polar Express 的收敛5.2 训练 GPT-2参考文献附录 A 定理 4.1 的证明A.1。证明。A.2。证明。证明。附录 B 定理 4.3 的证明证明。附录 C (6) 与 (7) 等价性的证明附录 D Remez 算法附录 E 大谱间隙矩阵的初始化附录 F 矩形矩阵的快速多项式迭代附录 G 构造 Polar Express 多项式的代码
返回论文列表
目录

The Polar Express: Optimal Matrix Sign Methods and Their Application to the Muon Algorithm

收录于 ICLR 2026 Outstanding Paper Honorable Mention被引 88 次
打开论文来源

The Polar Express: Optimal Matrix Sign Methods and Their Application to the Muon Algorithm

Polar Express:最优矩阵符号方法及其在 Muon 算法中的应用

Noah Amsel Thanks:  New York University. noah.amsel@nyu.edu    David Persson Thanks:  New York University and Flatiron Institute. dup210@nyu.edu , dpersson@flatironinstitute.org    Christopher Musco Thanks:  New York University. cmusco@nyu.edu    Robert M. Gower Thanks:  Flatiron Institute. rgower@flatironinstitute.org

Abstract

摘要

Computing the polar decomposition and the related matrix sign function has been a well-studied problem in numerical analysis for decades. Recently, it has emerged as an important subroutine within the Muon algorithm for training deep neural networks. However, the requirements of this application differ sharply from classical settings: deep learning demands GPU-friendly algorithms that prioritize high throughput over high precision. We introduce Polar Express, a new method for computing the polar decomposition. Like Newton–Schulz and other classical polynomial methods, our approach uses only matrix-matrix multiplications, making it very efficient on GPUs. Inspired by earlier work of Chen & Chow and Nakatsukasa & Freund, Polar Express adapts the update rule at each iteration by solving a minimax optimization problem. We prove that this strategy minimizes error in a worst-case sense, allowing Polar Express to converge as rapidly as possible both in the early iterations and asymptotically. We also address finite-precision issues, making it practical to use in bfloat16. When integrated into the Muon training framework, our method leads to consistent improvements in validation loss when training a GPT-2 model on one billion tokens from the FineWeb dataset, outperforming recent alternatives across a range of learning rates.

计算极分解以及与之相关的矩阵符号函数,是数值分析里研究了数十年的老问题。最近它又成了训练深度网络的 Muon 算法里的关键子程序。不过,这一应用提出的要求与经典场景差得很远:深度学习需要照顾 GPU 的算法,更看重吞吐,而不是极高的精度。我们提出 Polar Express,一种新的极分解算法。它和 Newton–Schulz 以及其他经典多项式方法一样,只用矩阵-矩阵乘法,因而在 GPU 上很高效。受 Chen & Chow 以及 Nakatsukasa & Freund 较早工作的启发,Polar Express 在每一步都通过求解一个 minimax 优化问题来调整更新规则。我们证明这一策略能在最坏情形下把误差压到最小,从而让 Polar Express 无论在前期迭代还是在渐近阶段都能尽快收敛。我们还处理了有限精度下的问题,使其能切实用于 bfloat16。把该方法嵌进 Muon 训练框架后,在 FineWeb 数据集的 10 亿 token 上训练 GPT-2 时,验证损失得到了稳定的改善,并在一系列学习率下都优于近期的替代方法。

1  Introduction

1 引言

Contents

Advanced linear algebra is making its way into deep learning. Efficient algorithms for computing matrix functions have found exciting new applications in training neural networks. In particular, approximations to the matrix-inverse are used in the full Adagrad method [13], the matrix square-root and quarter-root appear as subroutines in the Shampoo and Soap optimizers [17, 43, 47], and most recently, the matrix sign function has become a key ingredient of the Muon optimizer [5, 4, 22].

目录

高等线性代数正在进入深度学习。计算矩阵函数的高效算法,已经在神经网络训练里找到了令人兴奋的新用途。具体来说,矩阵求逆的近似出现在完整的 Adagrad 方法中 [13],矩阵平方根和四分之一次根是 Shampoo 与 Soap 优化器的子程序 [17, 43, 47],而最近,矩阵符号函数又成了 Muon 优化器的关键构件 [5, 4, 22]。

While the problem of computing these matrix functions has been studied by numerical analysts for decades, applications in deep learning come with different requirements than those in computational science. For deep learning, it is critical to take maximum advantage of GPU-friendly operations like matrix-matrix products and to avoid less parallel operations. Moreover, memory overhead must be small to handle large models. On the other hand, high accuracy is typically less important; the gold standard of sixteen digits of accuracy is overkill in deep learning.

尽管计算这些矩阵函数的问题已被数值分析学家研究了数十年,深度学习应用提出的要求与计算科学并不相同。对深度学习来说,关键是尽量用满 GPU 友好的操作(例如矩阵-矩阵乘法),并避开并行度较差的运算。内存开销也必须很小,才能撑住大模型。另一方面,高精度通常并不那么重要;科学计算里追求的十六位有效数字,对深度学习来说过头了。

Given these considerations, there is a need to develop new matrix function methods that are tailor-made for deep learning applications. We take on this challenge by designing a state-of-the-art, GPU-friendly algorithm for computing the matrix sign function, or more generally, for computing the polar decomposition of a rectangular matrix. We apply our new Polar Express method (Algorithm 1) to compute the descent direction in the increasingly popular Muon optimizer. In Figure 1, we show that using Polar Express within Muon consistently results in lower validation loss across all learning rates when training a GPT-2 model, as compared to other matrix sign methods [9, 44, 22].

基于这些考虑,有必要专门为深度学习设计新的矩阵函数方法。我们接受这一挑战,设计了一种面向 GPU、用于计算矩阵符号函数——更一般地说,用于计算矩形矩阵极分解——的先进算法。我们把新的 Polar Express 方法(算法 1)用到日益流行的 Muon 优化器里,去计算下降方向。图 1 表明,在训练 GPT-2 时,把 Polar Express 放进 Muon,在所有学习率下都能得到更低的验证损失,优于其他矩阵符号方法 [9, 44, 22]。

from itertools import repeat
import torch

coeffs_list = [
(8.28721201814563, -23.595886519098837, 17.300387312530933),
(4.107059111542203, -2.9478499167379106, 0.5448431082926601),
(3.9486908534822946, -2.908902115962949, 0.5518191394370137),
(3.3184196573706015, -2.488488024314874, 0.51004894012372),
(2.300652019954817, -1.6689039845747493, 0.4188073119525673),
(1.891301407787398, -1.2679958271945868, 0.37680408948524835),
(1.8750014808534479, -1.2500016453999487, 0.3750001645474248),
(1.875, -1.25, 0.375), # subsequent coeffs equal this numerically
]

safety factor for numerical stability (but exclude last polynomial)

coeffs_list = [(a / 1.01, b / 1.013, c / 1.015)
for (a, b, c) in coeffs_list[:-1]] + [coeffs_list[-1]]

@torch.compile
def PolarExpress(G: torch.Tensor, steps: int) -> torch.Tensor:
assert G.ndim >= 2
X = G.bfloat16() # for speed
if G.size(-2) > G.size(-1): X = X.mT # this reduces FLOPs
X = X / (X.norm(dim=(-2, -1), keepdim=True) * 1.01)
hs = coeffs_list[:steps] + list(
repeat(coeffs_list[-1], steps - len(coeffs_list)))
for a, b, c in hs:
A = X @ X.mT
B = b * A + c * A @ A
X = a * X + B @ X # X <- aX + bX^3 + cX^5
if G.size(-2) > G.size(-1): X = X.mT
return X

Algorithm 1 Python code for the Polar Express of degree = 5.

from itertools import repeat
import torch

coeffs_list = [
(8.28721201814563, -23.595886519098837, 17.300387312530933),
(4.107059111542203, -2.9478499167379106, 0.5448431082926601),
(3.9486908534822946, -2.908902115962949, 0.5518191394370137),
(3.3184196573706015, -2.488488024314874, 0.51004894012372),
(2.300652019954817, -1.6689039845747493, 0.4188073119525673),
(1.891301407787398, -1.2679958271945868, 0.37680408948524835),
(1.8750014808534479, -1.2500016453999487, 0.3750001645474248),
(1.875, -1.25, 0.375), # subsequent coeffs equal this numerically
]

safety factor for numerical stability (but exclude last polynomial)

coeffs_list = [(a / 1.01, b / 1.013, c / 1.015)
for (a, b, c) in coeffs_list[:-1]] + [coeffs_list[-1]]

@torch.compile
def PolarExpress(G: torch.Tensor, steps: int) -> torch.Tensor:
assert G.ndim >= 2
X = G.bfloat16() # for speed
if G.size(-2) > G.size(-1): X = X.mT # this reduces FLOPs
X = X / (X.norm(dim=(-2, -1), keepdim=True) * 1.01)
hs = coeffs_list[:steps] + list(
repeat(coeffs_list[-1], steps - len(coeffs_list)))
for a, b, c in hs:
A = X @ X.mT
B = b * A + c * A @ A
X = a * X + B @ X # X <- aX + bX^3 + cX^5
if G.size(-2) > G.size(-1): X = X.mT
return X

算法 1 次数 d=5d=5d=5 的 Polar Express 的 Python 代码。

GPT-2-Large 在 FineWeb 上用不同矩阵符号方法训练 Muon

Figure 1: Training a GPT-2-Large model (774M params) on 1 billion tokens from the FineWeb dataset [2]. The label muon- refers to implementing Muon using to compute the polar factor. Left: final validation loss across learning rates. Right: validation loss across epochs using the best learning rate. The best learning rate (lrlrlr) and final validation loss for each method was adamw (lr=0.0001)(lr=0.0001)(lr=0.0001): 4.1724.1724.172, muon-You (lr=0.02)(lr=0.02)(lr=0.02): 3.4003.4003.400, muon-Jordan (lr=0.02)(lr=0.02)(lr=0.02): 3.3983.3983.398 and muon-PolarExp (lr=0.02)(lr=0.02)(lr=0.02): 3.3403.3403.340.

图 1:在 FineWeb 数据集 [2] 的 10 亿 token 上训练 GPT-2-Large 模型(774M 参数)。标签 muon- 表示用 来计算极因子,以实现 Muon。左:各学习率下的最终验证损失。右:采用各自最优学习率时,验证损失随 epoch 的变化。各方法的最优学习率(lrlrlr)和最终验证损失分别为:adamw (lr=0.0001)(lr=0.0001)(lr=0.0001):4.1724.1724.172,muon-You (lr=0.02)(lr=0.02)(lr=0.02):3.4003.4003.400,muon-Jordan (lr=0.02)(lr=0.02)(lr=0.02):3.3983.3983.398,muon-PolarExp (lr=0.02)(lr=0.02)(lr=0.02):3.3403.3403.340。

1.1  The Muon Method

1.1 Muon 方法

The Muon optimizer has recently gained popularity for training large language models, often outperforming state-of-the-art adaptive gradient methods like Adam and AdamW [26, 31]. Muon has been used to set records for the NanoGPT speedrun [22] and to expand the Pareto frontier of performance versus training FLOPs for large language models [30, 42].

Muon 优化器最近在训练大语言模型时颇受欢迎,常常超过 Adam 和 AdamW 这类先进的自适应梯度方法 [26, 31]。Muon 曾用来刷新 NanoGPT speedrun 纪录 [22],也把大语言模型在性能与训练 FLOPs 之间的帕累托前沿往外推了一截 [30, 42]。

The Muon update rule [5] is defined as follows. Let λ,β>0\lambda,\beta>0λ,β>0 be the learning rate and momentum coefficient hyperparameters. (By default, β=0.9\beta=0.9β=0.9.) Let Wt∈Rm×n\bm{W}_{t}\in\mathbb{R}^{m\times n}Wt​∈Rm×n be the weight matrix of a given neural network layer at iteration ttt, and let Gt∈Rm×n\bm{G}_{t}\in\mathbb{R}^{m\times n}Gt​∈Rm×n be its (stochastic) gradient. Let Mt∈Rm×n\bm{M}_{t}\in\mathbb{R}^{m\times n}Mt​∈Rm×n be the running momentum estimate of the gradient, where M0=0\bm{M}_{0}=\bm{0}M0​=0. The Muon update is given by

Muon 的更新规则 [5] 如下。设 λ,β>0\lambda,\beta>0λ,β>0 为学习率和动量系数超参数(默认 β=0.9\beta=0.9β=0.9)。设 Wt∈Rm×n\bm{W}_{t}\in\mathbb{R}^{m\times n}Wt​∈Rm×n 为某层网络在第 ttt 步的权重矩阵,Gt∈Rm×n\bm{G}_{t}\in\mathbb{R}^{m\times n}Gt​∈Rm×n 为其(随机)梯度。设 Mt∈Rm×n\bm{M}_{t}\in\mathbb{R}^{m\times n}Mt​∈Rm×n 为梯度的滑动动量估计,且 M0=0\bm{M}_{0}=\bm{0}M0​=0。Muon 更新由下式给出

Mt=βMt−1+(1−β)GtWt+1=Wt−λ\polar(Mt).\displaystyle\bm{M}_{t} \\ \displaystyle=\beta\bm{M}_{t-1}+(1-\beta)\bm{G}_{t} \\ \displaystyle\bm{W}_{t+1} \\ \displaystyle=\bm{W}_{t}-\lambda\polar(\bm{M}_{t}).Mt​=βMt−1​+(1−β)Gt​Wt+1​=Wt​−λ\polar(Mt​).

Whereas standard stochastic gradient descent (SGD) with momentum updates the weight matrix by taking a step in the direction −Mt-\bm{M}_{t}−Mt​, the Muon method steps in the direction −\polar(Mt)-\polar(\bm{M}_{t})−\polar(Mt​), where \polar(M)\polar(\bm{M})\polar(M) denotes the closest semi-orthogonal matrix to M\bm{M}M [19, Chapter 8]. Concretely, if M=UΣVT\bm{M}=\bm{U}\bm{\Sigma}\bm{V}^{\mathsf{T}}M=UΣVT is the singular value decomposition (SVD) of M\bm{M}M, then

标准的带动量随机梯度下降(SGD)沿 −Mt-\bm{M}_{t}−Mt​ 方向更新权重;Muon 则沿 −\polar(Mt)-\polar(\bm{M}_{t})−\polar(Mt​) 迈步,其中 \polar(M)\polar(\bm{M})\polar(M) 表示离 M\bm{M}M 最近的半正交矩阵 [19, 第 8 章]。具体来说,若 M=UΣVT\bm{M}=\bm{U}\bm{\Sigma}\bm{V}^{\mathsf{T}}M=UΣVT 是 M\bm{M}M 的奇异值分解(SVD),则

\polar(M):=UVT.(1)\polar(\bm{M}):=\bm{U}\bm{V}^{\mathsf{T}}. \tag{1}\polar(M):=UVT.(1)

The matrix \polar(M)\polar(\bm{M})\polar(M) can be seen as a generalization of the matrix sign function to rectangular matrices [3]. Indeed, when M\bm{M}M is square symmetric with eigendecomposition M=VΛVT\bm{M}=\bm{V}\bm{\Lambda}\bm{V}^{\mathsf{T}}M=VΛVT, \polar(M)\polar(\bm{M})\polar(M) exactly coincides with the matrix sign function \sign(M)=V\sign(Λ)VT\sign(\bm{M})=\bm{V}\sign(\bm{\Lambda})\bm{V}^{\mathsf{T}}\sign(M)=V\sign(Λ)VT [19, Chapter 5]. Equivalently, \polar(M)\polar(\bm{M})\polar(M) is the left orthogonal factor of the polar decomposition of M\bm{M}M [19, Chapter 8]. The motivation for Muon is that −\polar(M)-\polar(\bm{M})−\polar(M) gives the steepest-descent direction with respect to the spectral norm (instead of the Frobenius norm, as in standard SGD).

矩阵 \polar(M)\polar(\bm{M})\polar(M) 可以看成矩阵符号函数向矩形矩阵的推广 [3]。确实,当 M\bm{M}M 为方阵且对称、特征分解为 M=VΛVT\bm{M}=\bm{V}\bm{\Lambda}\bm{V}^{\mathsf{T}}M=VΛVT 时,\polar(M)\polar(\bm{M})\polar(M) 恰好等于矩阵符号函数 \sign(M)=V\sign(Λ)VT\sign(\bm{M})=\bm{V}\sign(\bm{\Lambda})\bm{V}^{\mathsf{T}}\sign(M)=V\sign(Λ)VT [19, 第 5 章]。等价地说,\polar(M)\polar(\bm{M})\polar(M) 就是 M\bm{M}M 的极分解中左侧的正交因子 [19, 第 8 章]。Muon 的动机是:−\polar(M)-\polar(\bm{M})−\polar(M) 给出的是关于谱范数的最速下降方向(而标准 SGD 用的是 Frobenius 范数)。

Recent work [40] shows that Muon can be viewed as a conditional gradient (Frank-Wolfe) method with a trust region defined by the spectral norm. In the same work, the authors also provide a convergence theory for the smooth and non-convex setting, as well as for the stochastic non-convex case. The analysis of Muon was further refined in [41], which proves convergence under a layerwise (L0,L1)(L_{0},L_{1})(L0​,L1​)-smoothness assumption, in both the stochastic non-convex and stochastic Polyak–Łojasiewicz settings. We refer the reader to [22] and [5] for further background. In this paper, we take the Muon update rule as given and focus on the problem of efficiently computing the polar decomposition \polar(M)\polar(\bm{M})\polar(M).

近期工作 [40] 表明,Muon 可以看成一种条件梯度(Frank-Wolfe)方法,其信赖域由谱范数划定。同一工作还给出了光滑非凸情形以及随机非凸情形下的收敛理论。[41] 进一步细化了分析,在逐层 (L0,L1)(L_{0},L_{1})(L0​,L1​)-光滑假设下,证明了随机非凸和随机 Polyak–Łojasiewicz 两种设定中的收敛性。更多背景见 [22] 和 [5]。本文把 Muon 的更新规则当作给定,集中讨论如何高效计算极分解 \polar(M)\polar(\bm{M})\polar(M)。

1.2  Computing the Polar Factor

1.2 计算极因子

Although \polar(M)\polar(\bm{M})\polar(M) can be computed directly via an SVD in O(min⁡(mn2,nm2))O(\min(mn^{2},nm^{2}))O(min(mn2,nm2)) time, doing so is prohibitively expensive in deep learning applications, especially as standard SVD algorithms fail to take full advantage of the parallelism available on GPUs. There has been significant work on highly-parallel methods for the SVD, but the most common approaches actually require computing the matrix-sign function as a subroutine [33, 35]. Numerical analysts have spent decades developing iterative methods for computing \polar(M)\polar(\bm{M})\polar(M). This rich line of work includes Newton–Schulz [19, Chapter 8], Padé iteration [25, 18], the Newton and scaled Newton iterations [19, Chapter 8], the QWHD iteration [32, 35], and Zolo-pd (Zolotarev polar decomposition) [33]. Unfortunately, as discussed in Section 2, most of these methods are based on rational approximations to the function \sign(x)\sign(x)\sign(x) and require computing matrix inverses or QR decompositions. Such methods are ill-suited to GPU acceleration and deep learning applications. In contrast, the older Newton-Schulz method is based on polynomial approximation of \sign(x)\sign(x)\sign(x) and uses only matrix-matrix products. Thus, Muon initially used Newton-Schulz [4]. Indeed, Muon stands for “MomentUm Orthogonalized by Newton-Schulz” [22].

虽然可以直接用 SVD 在 O(min⁡(mn2,nm2))O(\min(mn^{2},nm^{2}))O(min(mn2,nm2)) 时间内算出 \polar(M)\polar(\bm{M})\polar(M),这在深度学习里贵得难以承受,尤其是标准 SVD 算法没法充分利用 GPU 上的并行能力。高度并行的 SVD 方法也有不少研究,但最常见的路线其实还是把计算矩阵符号函数当作子程序 [33, 35]。数值分析学家花了数十年发展计算 \polar(M)\polar(\bm{M})\polar(M) 的迭代法。这条丰富的脉络包括 Newton–Schulz [19, 第 8 章]、Padé 迭代 [25, 18]、Newton 迭代及其缩放版本 [19, 第 8 章]、QWHD 迭代 [32, 35],以及 Zolo-pd(Zolotarev 极分解)[33]。可惜,如第 2 节所讨论的,这些方法大多基于对函数 \sign(x)\sign(x)\sign(x) 的有理逼近,需要计算矩阵逆或 QR 分解。这类方法既不适合 GPU 加速,也不适合深度学习。相比之下,更早的 Newton-Schulz 方法基于对 \sign(x)\sign(x)\sign(x) 的多项式逼近,只用矩阵-矩阵乘法。因此 Muon 起初采用的就是 Newton-Schulz [4]。Muon 这个名字正是 “MomentUm Orthogonalized by Newton-Schulz” 的缩写 [22]。

The Newton-Schulz methods.

Newton-Schulz constructs a sequence of approximations Xt≈\polar(M)\bm{X}_{t}\approx\polar(\bm{M})Xt​≈\polar(M) as follows:

Newton-Schulz 方法。

Newton-Schulz 按如下方式构造一列近似 Xt≈\polar(M)\bm{X}_{t}\approx\polar(\bm{M})Xt​≈\polar(M):

X0=M/∥M∥FXt+1=32Xt−12XtXt⊤Xt(2)\displaystyle\bm{X}_{0}=\bm{M}/\|\bm{M}\|_{\text{F}} \\ \displaystyle\bm{X}_{t+1}=\frac{3}{2}\bm{X}_{t}-\frac{1}{2}\bm{X}_{t}\bm{X}_{t}^{\top}\bm{X}_{t} \tag{2}X0​=M/∥M∥F​Xt+1​=23​Xt​−21​Xt​Xt⊤​Xt​(2)

At each iteration, this rule effectively applies the cubic polynomial p(x)=32x−12x3p(x)=\frac{3}{2}x-\frac{1}{2}x^{3}p(x)=23​x−21​x3 to each singular value of Xt\bm{X}_{t}Xt​. The scalar fixed-point iteration xt+1=p(xt)x_{t+1}=p(x_{t})xt+1​=p(xt​) converges to \sign(x0)\sign(x_{0})\sign(x0​) as t→∞t\to\inftyt→∞, provided ∣x0∣≤1|x_{0}|\leq 1∣x0​∣≤1. As a result, the matrix iteration satisfies lim⁡t→∞Xt=UV⊤=\polar(X0)\lim\limits_{t\to\infty}\bm{X}_{t}=\bm{U}\bm{V}^{\top}=\polar(\bm{X}_{0})t→∞lim​Xt​=UV⊤=\polar(X0​). Higher-degree versions of Newton-Schulz follow the same principle. For example, the degree-5 polynomial p(x)=(15x−10x3+3x5)/8p(x)=(15x-10x^{3}+3x^{5})/8p(x)=(15x−10x3+3x5)/8 converges even faster. The Newton-Schulz iterations converge super-exponentially when Xt\bm{X}_{t}Xt​ is sufficiently close to \polar(M)\polar(\bm{M})\polar(M), but they suffer from slow initial convergence; when X0\bm{X}_{0}X0​ is far from \polar(M)\polar(\bm{M})\polar(M), the approximation improves slowly over the first few iterations.

每一步迭代,这条规则实际上是把三次多项式 p(x)=32x−12x3p(x)=\frac{3}{2}x-\frac{1}{2}x^{3}p(x)=23​x−21​x3 作用到 Xt\bm{X}_{t}Xt​ 的每一个奇异值上。标量不动点迭代 xt+1=p(xt)x_{t+1}=p(x_{t})xt+1​=p(xt​) 在 ∣x0∣≤1|x_{0}|\leq 1∣x0​∣≤1 时会收敛到 \sign(x0)\sign(x_{0})\sign(x0​)(当 t→∞t\to\inftyt→∞)。因此矩阵迭代满足 lim⁡t→∞Xt=UV⊤=\polar(X0)\lim\limits_{t\to\infty}\bm{X}_{t}=\bm{U}\bm{V}^{\top}=\polar(\bm{X}_{0})t→∞lim​Xt​=UV⊤=\polar(X0​)。更高次数的 Newton-Schulz 遵循同一原理。例如五次多项式 p(x)=(15x−10x3+3x5)/8p(x)=(15x-10x^{3}+3x^{5})/8p(x)=(15x−10x3+3x5)/8 收敛得更快。当 Xt\bm{X}_{t}Xt​ 已经足够接近 \polar(M)\polar(\bm{M})\polar(M) 时,Newton-Schulz 迭代超指数收敛;但起步很慢:当 X0\bm{X}_{0}X0​ 离 \polar(M)\polar(\bm{M})\polar(M) 还远时,前几步近似改善得很有限。

The Jordan and You methods.

In Muon, high accuracy approximations to \polar(M)\polar(\bm{M})\polar(M) are usually not necessary. The primary goal is instead to compute a coarse approximation in as few iterations as possible. To accelerate convergence in the low-accuracy regime, Jordan recently proposed a fixed-point iteration based on the polynomial p(x)=3.4445x−4.7750x3+2.0315x5p(x)=3.4445x-4.7750x^{3}+2.0315x^{5}p(x)=3.4445x−4.7750x3+2.0315x5 [22], which was found using a heuristic numerical search. Unlike Newton-Schulz, the scheme that Jordan proposed does not converge to \polar(M)\polar(\bm{M})\polar(M). Instead, it plateaus at an error of ≈0.3\approx 0.3≈0.3. However, it reaches this level of accuracy rapidly. As a result, when the number of iterations is smaller than about 101010, Jordan’s method outperforms the Newton-Schulz iteration. Building on this idea, You [9] proposed a method that applies six different polynomial updates in succession, which were again found by heuristic search. This method achieves better accuracy than Jordan’s but still fails to converge.

Jordan 方法与 You 方法。

在 Muon 里,通常并不需要高精度地逼近 \polar(M)\polar(\bm{M})\polar(M)。首要目标是用尽量少的迭代算出一个粗糙近似。为了加快低精度区间里的收敛,Jordan 最近提出了一种基于多项式 p(x)=3.4445x−4.7750x3+2.0315x5p(x)=3.4445x-4.7750x^{3}+2.0315x^{5}p(x)=3.4445x−4.7750x3+2.0315x5 的不动点迭代 [22],系数来自启发式数值搜索。与 Newton-Schulz 不同,Jordan 提出的格式并不会收敛到 \polar(M)\polar(\bm{M})\polar(M),而是在误差约 0.30.30.3 处停下。不过它达到这一精度的速度很快。因此当迭代次数大约小于 101010 时,Jordan 的方法会超过 Newton-Schulz 迭代。顺着这一思路,You [9] 提出连续使用六种不同的多项式更新,同样由启发式搜索得到。该方法精度优于 Jordan,但仍然不会真正收敛。

We introduce a new method. In particular, we derive polynomial update rules that are optimal at every iteration, outperforming all previous polynomial methods in our setting.

我们提出一种新方法。具体来说,我们导出在每一步都最优的多项式更新规则,在我们所关心的设定下超过此前所有多项式方法。

1.3  Contributions

1.3 贡献

We present Polar Express, an iterative method for approximating \polar(M)\polar(\bm{M})\polar(M). Our method dynamically adapts the polynomial update rule at each iteration, prioritizing rapid progress in the initial stage and high accuracy in the later stage. Polar Express constructs polynomials p1,…,pTp_{1},\ldots,p_{T}p1​,…,pT​ so that the resulting composition is the optimal approximation to the sign function with respect to the supremum (L∞L^{\infty}L∞) norm (Theorem 4.1). By iteratively applying these polynomials to M\bm{M}M, Polar Express computes an approximation to \polar(M)\polar(\bm{M})\polar(M) that is optimal in the worst-case at every iteration. Our method converges to \polar(M)\polar(\bm{M})\polar(M) super-exponentially (Theorem 4.3), and it quickly reaches a good approximation within just five to ten iterations. This early-stage acceleration is especially valuable in deep learning applications, where runtime efficiency takes precedence over high accuracy. In contrast, classical methods like Newton-Schulz suffer from a slow initial convergence, while recent heuristic proposals [22, 9] fail to converge. Our method is efficient to run on GPUs, using only a few matrix-matrix products per iteration.[^1]

我们提出 Polar Express,一种逼近 \polar(M)\polar(\bm{M})\polar(M) 的迭代法。该方法会动态调整每一步的多项式更新规则,前期优先快速推进,后期再追求高精度。Polar Express 构造多项式 p1,…,pTp_{1},\ldots,p_{T}p1​,…,pT​,使得所得复合是关于上确界(L∞L^{\infty}L∞)范数对符号函数的最优逼近(定理 4.1)。把这些多项式迭代作用到 M\bm{M}M 上,Polar Express 就能在每一步都得到最坏情形下最优的 \polar(M)\polar(\bm{M})\polar(M) 近似。我们的方法超指数收敛到 \polar(M)\polar(\bm{M})\polar(M)(定理 4.3),并且只需五到十步就能得到不错的近似。这种前期加速对深度学习尤其有价值,因为那里更看重运行效率而不是高精度。相比之下,Newton-Schulz 这类经典方法起步很慢,而近期的启发式方案 [22, 9] 又无法真正收敛。我们的方法在 GPU 上很高效,每步只用几次矩阵-矩阵乘法。[^1]

We give an explicit instantiation of Polar Express in Algorithm 1, which incorporates minor modifications to make it compatible with half-precision arithmetic (see Section 4.4). Algorithm 1 can be used as a drop-in replacement for previous methods. In numerical experiments, Polar Express outperforms previous methods on synthetic matrices and gradient matrices from a GPT-2 transformer (Figure 4). We demonstrate the effectiveness of using Polar Express within the Muon optimizer in Figure 1, showing that it consistently improves the training of GPT-2 language models on 1 billion tokens of the FineWeb dataset [2].

我们在算法 1 中给出 Polar Express 的一个显式实例,其中加入了少许改动,使之能兼容半精度算术(见第 4.4 节)。算法 1 可以当作此前方法的即插即用替换。数值实验中,Polar Express 在合成矩阵以及来自 GPT-2 Transformer 的梯度矩阵上都超过了以往方法(图 4)。图 1 展示了把 Polar Express 放进 Muon 优化器后的效果:在 FineWeb 数据集 [2] 的 10 亿 token 上训练 GPT-2 语言模型时,它稳定地改善了训练表现。

Notation.

We let ∥M∥F\|\bm{M}\|_{\text{F}}∥M∥F​ and ∥M∥2\|\bm{M}\|_{2}∥M∥2​ denote the Frobenius norm and spectral norm (largest singular value) of a matrix M\bm{M}M, respectively. We denote the spectrum (set of singular values) by σ(M)\sigma(\bm{M})σ(M).

记号。

我们分别用 ∥M∥F\|\bm{M}\|_{\text{F}}∥M∥F​ 和 ∥M∥2\|\bm{M}\|_{2}∥M∥2​ 表示矩阵 M\bm{M}M 的 Frobenius 范数和谱范数(最大奇异值)。用 σ(M)\sigma(\bm{M})σ(M) 表示谱(奇异值集合)。

Let Pd\mathbb{P}_{d}Pd​ be the set of polynomials of degree at most ddd. For odd ddd, Pd\odd\mathbb{P}_{d}^{\odd}Pd\odd​ denotes the set of polynomials of degree at most ddd containing only odd-degree monomials. For a polynomial ppp, deg⁡(p)\deg(p)deg(p) is its degree. Let \sign(x)\sign(x)\sign(x) be the scalar sign function, which satisfies \sign(0)=0\sign(0)=0\sign(0)=0, \sign(x)=1\sign(x)=1\sign(x)=1 if x>0x>0x>0 and \sign(x)=−1\sign(x)=-1\sign(x)=−1 if x<0x<0x<0.

设 Pd\mathbb{P}_{d}Pd​ 为次数至多为 ddd 的多项式集合。对奇数 ddd,Pd\odd\mathbb{P}_{d}^{\odd}Pd\odd​ 表示次数至多为 ddd、且只含奇次单项式的多项式集合。对多项式 ppp,deg⁡(p)\deg(p)deg(p) 为其次数。设 \sign(x)\sign(x)\sign(x) 为标量符号函数,满足 \sign(0)=0\sign(0)=0\sign(0)=0,x>0x>0x>0 时 \sign(x)=1\sign(x)=1\sign(x)=1,x<0x<0x<0 时 \sign(x)=−1\sign(x)=-1\sign(x)=−1。

For a polynomial p∈Pd\oddp\in\mathbb{P}_{d}^{\odd}p∈Pd\odd​ and a matrix M\bm{M}M with rank reduced SVD given by M=UΣVT\bm{M}=\bm{U}\bm{\Sigma}\bm{V}^{\mathsf{T}}M=UΣVT and positive singular values σ1≥⋯≥σ\rank(M)>0\sigma_{1}\geq\cdots\geq\sigma_{\rank(\bm{M})}>0σ1​≥⋯≥σ\rank(M)​>0, we define p(M):=Up(Σ)VTp(\bm{M}):=\bm{U}p(\bm{\Sigma})\bm{V}^{\mathsf{T}}p(M):=Up(Σ)VT, where p(Σ)p(\bm{\Sigma})p(Σ) is the diagonal matrix with diagonal entries p(σi)p(\sigma_{i})p(σi​) for i=1,…,\rank(M)i=1,\ldots,\rank(\bm{M})i=1,…,\rank(M).

对多项式 p∈Pd\oddp\in\mathbb{P}_{d}^{\odd}p∈Pd\odd​,以及具有降秩 SVD M=UΣVT\bm{M}=\bm{U}\bm{\Sigma}\bm{V}^{\mathsf{T}}M=UΣVT、正奇异值为 σ1≥⋯≥σ\rank(M)>0\sigma_{1}\geq\cdots\geq\sigma_{\rank(\bm{M})}>0σ1​≥⋯≥σ\rank(M)​>0 的矩阵 M\bm{M}M,我们定义 p(M):=Up(Σ)VTp(\bm{M}):=\bm{U}p(\bm{\Sigma})\bm{V}^{\mathsf{T}}p(M):=Up(Σ)VT,其中 p(Σ)p(\bm{\Sigma})p(Σ) 是对角元为 p(σi)p(\sigma_{i})p(σi​)(i=1,…,\rank(M)i=1,\ldots,\rank(\bm{M})i=1,…,\rank(M))的对角矩阵。

2  Related Work

2 相关工作

Computing \polar(M)\polar(\bm{M})\polar(M) is an important and longstanding problem in numerical linear algebra, with applications spanning electronic structure calculations, lattice quantum chromodynamics, orthogonal Procrustes analysis, parallel algorithms for computing the SVD, and beyond; see e.g. [18, 23, 8, 16, 36, 45].

计算 \polar(M)\polar(\bm{M})\polar(M) 是数值线性代数里一个重要而悠久的问题,应用涵盖电子结构计算、格点量子色动力学、正交 Procrustes 分析、并行 SVD 算法等等;参见 [18, 23, 8, 16, 36, 45]。

Newton-Schulz and polynomial Padé methods.

The earliest methods in the literature are polynomial iterations like (2). Several nearly simultaneous papers introduced the family of polynomial Padé iterations, comprising Newton-Schulz and its higher-degree analogues [27, 6, 18, 29]. These higher-degree methods are also sometimes called “Newton-Schulz”; when doing so, we will specify the degree for clarity. In these methods, each iteration refines the current approximation Xt\bm{X}_{t}Xt​ by applying a low-degree odd matrix polynomial, where any odd monomial x↦x2q+1x\mapsto x^{2q+1}x↦x2q+1 is defined for rectangular matrices by the formula Xt↦Xt(Xt⊤Xt)q\bm{X}_{t}\mapsto\bm{X}_{t}\left(\bm{X}_{t}^{\top}\bm{X}_{t}\right)^{q}Xt​↦Xt​(Xt⊤​Xt​)q. Our Polar Express method also takes this form, though unlike Newton-Schulz, it changes the polynomial at each iteration.

Newton-Schulz 与多项式 Padé 方法。

文献中最早的方法是形如 (2) 的多项式迭代。几篇几乎同时出现的论文引入了多项式 Padé 迭代族,其中包括 Newton-Schulz 及其更高次数的同类方法 [27, 6, 18, 29]。这些更高次数的方法有时也被称作 “Newton-Schulz”;这样称呼时我们会标明次数以免混淆。在这些方法里,每一步都用一个低次奇次矩阵多项式来改进当前近似 Xt\bm{X}_{t}Xt​,其中任意奇次单项式 x↦x2q+1x\mapsto x^{2q+1}x↦x2q+1 对矩形矩阵由公式 Xt↦Xt(Xt⊤Xt)q\bm{X}_{t}\mapsto\bm{X}_{t}\left(\bm{X}_{t}^{\top}\bm{X}_{t}\right)^{q}Xt​↦Xt​(Xt⊤​Xt​)q 定义。我们的 Polar Express 也取这一形式,不过与 Newton-Schulz 不同,它在每一步都会更换多项式。

The polynomials used in Padé methods are chosen to match the value and first few derivatives of \sign(x)\sign(x)\sign(x) at the points x=±1x=\pm 1x=±1. For instance, the update rule of the third method in this family is defined by p(x)=116(35x−35x3+21x5−5x7)p(x)=\frac{1}{16}\left(35x-35x^{3}+21x^{5}-5x^{7}\right)p(x)=161​(35x−35x3+21x5−5x7), which is the unique degree-7 polynomial satisfying p(±1)=±1p(\pm 1)=\pm 1p(±1)=±1 and p′(±1)=p′′(±1)=p′′′(±1)=0p^{\prime}(\pm 1)=p^{\prime\prime}(\pm 1)=p^{\prime\prime\prime}(\pm 1)=0p′(±1)=p′′(±1)=p′′′(±1)=0. These methods converge so long as all singular values of X0\bm{X}_{0}X0​ lie in (0,1](0,1](0,1], a condition guaranteed by the initialization of (2). Furthermore, the order of convergence of the degree 2q+12q+12q+1 method is q+1q+1q+1 [6]. In particular, the Newton-Schulz method (q=1q=1q=1) converges quadratically.

Padé 方法所用的多项式,是为了在 x=±1x=\pm 1x=±1 处匹配 \sign(x)\sign(x)\sign(x) 的函数值及其前若干阶导数。例如该族中第三种方法的更新规则由 p(x)=116(35x−35x3+21x5−5x7)p(x)=\frac{1}{16}\left(35x-35x^{3}+21x^{5}-5x^{7}\right)p(x)=161​(35x−35x3+21x5−5x7) 给出,这是满足 p(±1)=±1p(\pm 1)=\pm 1p(±1)=±1 且 p′(±1)=p′′(±1)=p′′′(±1)=0p^{\prime}(\pm 1)=p^{\prime\prime}(\pm 1)=p^{\prime\prime\prime}(\pm 1)=0p′(±1)=p′′(±1)=p′′′(±1)=0 的唯一七次多项式。只要 X0\bm{X}_{0}X0​ 的全部奇异值落在 (0,1](0,1](0,1] 内——(2) 的初始化就保证了这一点——这些方法就会收敛。此外,次数为 2q+12q+12q+1 的方法收敛阶为 q+1q+1q+1 [6]。特别地,Newton-Schulz 方法(q=1q=1q=1)二次收敛。

Newton’s method and rational Padé.

In the numerical analysis literature, polynomial methods were succeeded by rational iterations like Newton’s method [18], defined as follows[^2]:

Newton 方法与有理 Padé。

在数值分析文献中,多项式方法之后出现的是像 Newton 方法这样的有理迭代 [18],定义如下[^2]:

X0=MXt+1=12(Xt+Xt−⊤)(3)\displaystyle\bm{X}_{0}=\bm{M} \\ \displaystyle\bm{X}_{t+1}=\frac{1}{2}\left(\bm{X}_{t}+\bm{X}_{t}^{-\top}\right) \tag{3}X0​=MXt+1​=21​(Xt​+Xt−⊤​)(3)

Newton’s method also converges quadratically. Like Newton-Schulz, it works because the rational function r(x)=12(x+x−1)r(x)=\frac{1}{2}(x+x^{-1})r(x)=21​(x+x−1) has a stable fixed point at 111; unlike for Newton-Schulz, this point is a global attractor for the whole positive real line. At first glance, Newton’s method has nothing to do with the Padé iterations discussed above. However, after a change of variables Yt=Xt−1\bm{Y}_{t}=\bm{X}_{t}^{-1}Yt​=Xt−1​, it can be reinterpreted as Yt+1=2Yt(I+Yt⊤Yt)−1\bm{Y}_{t+1}=2\bm{Y}_{t}(\bm{I}+\bm{Y}_{t}^{\top}\bm{Y}_{t})^{-1}Yt+1​=2Yt​(I+Yt⊤​Yt​)−1, which is sometimes called inverse Newton. Observing that r(x)=2x1+x2r(x)=\frac{2x}{1+x^{2}}r(x)=1+x22x​ satisfies r(±1)=±1r(\pm 1)=\pm 1r(±1)=±1 and r′(±1)=0r^{\prime}(\pm 1)=0r′(±1)=0, we see that (inverse) Newton is also a Padé method, though a rational rather than polynomial one. In fact, given a odd degree 2qn+12q_{n}+12qn​+1 for the numerator and an even degree 2qd2q_{d}2qd​ for the denominator, there is a unique rational function that matches the value and first qn+qdq_{n}+q_{d}qn​+qd​ derivatives of \sign(x)\sign(x)\sign(x) at x=±1x=\pm 1x=±1. This directly yields a Padé method for computing \polar(M)\polar(\bm{M})\polar(M) whose order of convergence is qn+qd+1q_{n}+q_{d}+1qn​+qd​+1. For instance, r(x)=3x+x31+3x2r(x)=\frac{3x+x^{3}}{1+3x^{2}}r(x)=1+3x23x+x3​ is called Halley’s method, which converges cubically. When qd=0q_{d}=0qd​=0, we recover the polynomial Padé methods.

Newton 方法同样二次收敛。和 Newton-Schulz 一样,它之所以有效,是因为有理函数 r(x)=12(x+x−1)r(x)=\frac{1}{2}(x+x^{-1})r(x)=21​(x+x−1) 在 111 处有一个稳定不动点;与 Newton-Schulz 不同的是,这个点是整条正实轴的全局吸引子。乍看之下,Newton 方法与上面讨论的 Padé 迭代毫无关系。不过做变量替换 Yt=Xt−1\bm{Y}_{t}=\bm{X}_{t}^{-1}Yt​=Xt−1​ 之后,它可以改写成 Yt+1=2Yt(I+Yt⊤Yt)−1\bm{Y}_{t+1}=2\bm{Y}_{t}(\bm{I}+\bm{Y}_{t}^{\top}\bm{Y}_{t})^{-1}Yt+1​=2Yt​(I+Yt⊤​Yt​)−1,有时称作逆 Newton。注意到 r(x)=2x1+x2r(x)=\frac{2x}{1+x^{2}}r(x)=1+x22x​ 满足 r(±1)=±1r(\pm 1)=\pm 1r(±1)=±1 且 r′(±1)=0r^{\prime}(\pm 1)=0r′(±1)=0,可见(逆)Newton 其实也是一种 Padé 方法,只不过是有理的而非多项式的。事实上,给定分子的奇次数 2qn+12q_{n}+12qn​+1 和分母的偶次数 2qd2q_{d}2qd​,存在唯一的有理函数能在 x=±1x=\pm 1x=±1 处匹配 \sign(x)\sign(x)\sign(x) 的函数值及其前 qn+qdq_{n}+q_{d}qn​+qd​ 阶导数。这直接给出一种计算 \polar(M)\polar(\bm{M})\polar(M) 的 Padé 方法,收敛阶为 qn+qd+1q_{n}+q_{d}+1qn​+qd​+1。例如 r(x)=3x+x31+3x2r(x)=\frac{3x+x^{3}}{1+3x^{2}}r(x)=1+3x23x+x3​ 称为 Halley 方法,三次收敛。当 qd=0q_{d}=0qd​=0 时,就回到多项式 Padé 方法。

There are two main weakness of Newton’s method and the Padé iterations: slow convergence in the initial phase and the need to compute explicit inverses. To accelerate initial convergence, Higham popularized the technique of rescaling the matrix after every Newton iteration [18]. Intuitively, rescaling Xt\bm{X}_{t}Xt​ so that σmax⁡=1/σmin⁡\sigma_{\max}=1/\sigma_{\min}σmax​=1/σmin​ centers the spectrum around 111, where convergence is fastest. Several easily-computable choices of scaling factor exist to accomplish this approximately. Note that this rescaling scheme would fail for Newton-Schulz, which likewise suffers from slow initial convergence but which would diverge if σmax⁡≫1\sigma_{\max}\gg 1σmax​≫1.

Newton 方法与 Padé 迭代有两个主要弱点:初期收敛慢,以及需要显式求逆。为加快初期收敛,Higham 推广了每步 Newton 迭代后重新缩放矩阵的技巧 [18]。直观上,把 Xt\bm{X}_{t}Xt​ 缩放到 σmax⁡=1/σmin⁡\sigma_{\max}=1/\sigma_{\min}σmax​=1/σmin​,就能把谱居中到 111 附近,而那里收敛最快。有若干易于计算的缩放因子可以近似做到这一点。需要注意,这种缩放方案对 Newton-Schulz 行不通:后者同样受初期收敛慢的困扰,但如果 σmax⁡≫1\sigma_{\max}\gg 1σmax​≫1 它还会发散。

Computing matrix inverses is difficult to parallelize and to implement stably in low precision arithmetic. However, a trick was developed for stably computing many rational methods without explicit inverses; QR decompositions can be used instead [32, 49]. Applying this trick to Halley’s method and combining with a special rescaling scheme yields the QDWH (QR-based dynamically weighted Halley) method, which converges in just six iterations for any reasonably conditioned matrix [32].

计算矩阵逆既难并行,也难在低精度算术里稳定实现。不过人们找到了一个窍门,可以在不显式求逆的情况下稳定地计算许多有理方法:改用 QR 分解 [32, 49]。把这一窍门用到 Halley 方法上,再配上一种特殊的缩放方案,就得到 QDWH(基于 QR、动态加权的 Halley)方法,对任何条件数不太离谱的矩阵都能在六步内收敛 [32]。

Adaptive rational methods from optimal approximations.

A landmark 2016 paper introduced a new paradigm to design iterative methods for computing \polar(M)\polar(\bm{M})\polar(M) [33]. We describe this paradigm in more detail in Section 4, but the main insight is as follows. Padé methods choose the update rule to be an approximation to \sign(x)\sign(x)\sign(x) of a given degree that is optimally accurate in the neighborhood of x=1x=1x=1. Instead, we should choose the approximation to \sign(x)\sign(x)\sign(x) that is optimal over an interval [ℓ,1]⊂R≥0[\ell,1]\subset\mathbb{R}_{\geq 0}[ℓ,1]⊂R≥0​ that contains the singular values. Moreover, after each step of the algorithm, the range of the singular values changes; therefore, we adapt the update rule at each iteration to match the new interval. When the range of the singular values is large, this approach ensures that the update rule shrinks it as quickly as possible. As the algorithm proceeds and the interval shrinks to a small neighborhood of 111, the update rule approaches that of a Padé method, maintaining the same high order of convergence as it has.

由最优逼近得到的自适应有理方法。

2016 年一篇标志性论文引入了一种设计 \polar(M)\polar(\bm{M})\polar(M) 迭代法的新范式 [33]。我们在第 4 节更详细地描述这一范式,其核心洞见如下。Padé 方法把更新规则选成在 x=1x=1x=1 邻域内、给定次数下对 \sign(x)\sign(x)\sign(x) 最优精确的逼近。相反,我们应当选择在包含奇异值的区间 [ℓ,1]⊂R≥0[\ell,1]\subset\mathbb{R}_{\geq 0}[ℓ,1]⊂R≥0​ 上最优的 \sign(x)\sign(x)\sign(x) 逼近。而且每走一步,奇异值的取值范围都会变;因此我们在每一步都按新区间调整更新规则。当奇异值范围很大时,这种方法能尽快把它缩小。随着算法推进、区间收缩到 111 的一个小邻域,更新规则会逼近 Padé 方法,从而保持同样高的收敛阶。

Within the class of odd rational functions whose numerators and denominators have degree 2q+12q+12q+1 and 2q2q2q, respectively, an explicit formula for this optimal approximation to \sign(x)\sign(x)\sign(x) on any interval [ℓ,1][\ell,1][ℓ,1] was found by Zolotarev. It was shown that these rationals have remarkable convergence properties for any qqq [33]. For q=1q=1q=1, this optimal approximation coincides exactly with the dynamically weighted Halley’s method (QDWH) referenced above. For even faster convergence than QDWH, [33] proposed the zolo-pd method, which uses q=17q=17q=17. Finally, these methods all admit the same QR-based implementation trick as QDWH.

在分子、分母次数分别为 2q+12q+12q+1 和 2q2q2q 的奇次有理函数类中,Zolotarev 给出了任意区间 [ℓ,1][\ell,1][ℓ,1] 上对 \sign(x)\sign(x)\sign(x) 最优逼近的显式公式。已经证明,这些有理函数对任意 qqq 都有出色的收敛性质 [33]。当 q=1q=1q=1 时,这一最优逼近恰好就是上面提到的动态加权 Halley 方法(QDWH)。为了比 QDWH 收敛得更快,[33] 提出了取 q=17q=17q=17 的 zolo-pd 方法。这些方法都可以沿用 QDWH 那套基于 QR 的实现技巧。

Adaptive polynomial methods.

In this paper, we adopt the paradigm of zolo-pd [33] but with polynomials rather than rationals of degree (2q+1,2q)(2q+1,2q)(2q+1,2q). This choice avoids the need for QR factorizations, relying solely on GPU-friendly matrix-matrix multiplications in low-precision arithmetic. While this class of methods has not been fully developed in the numerical analysis literature, similar ideas have been rediscovered in different guises. In an unpublished manuscript that predates zolo-pd, Chen and Chow [11] describe a rescaling strategy for Newton-Schulz. Though motivated differently, their method is equivalent to ours for degree-3 polynomials. They also observe numerical instability that prevents the method from converging to all the way to machine precision. Using the insights of [34], they propose a simple mitigation for this issue that we adopt in Section 4.4. Our work gives this method a theoretical foundation that connects it to the paradigm of zolo-pd, and we prove its optimality in the sense of (6). In addition, we study odd polynomials of arbitrary degree and focus particularly on the degree-5 case. Independently, a group of cryptographers developed a similar method for approximating the scalar function \sign(x)\sign(x)\sign(x) in the context of homomorphic encryption schemes [28]. Their focus is mainly on tuning the analogues in their setting of the polynomial degree and number of iterations, whereas we focus on demonstrating optimality and efficiently constructing the update polynomials for degree 333 and 555. In addition, we consider matrix-valued inputs in low-precision arithmetic—not scalars in exact arithmetic—and we demonstrate our method’s effectiveness within the Muon algorithm for training deep neural networks.

自适应多项式方法。

本文沿用 zolo-pd [33] 的范式,但把次数为 (2q+1,2q)(2q+1,2q)(2q+1,2q) 的有理函数换成多项式。这一选择避免了 QR 分解,只依赖在低精度算术下对 GPU 友好的矩阵-矩阵乘法。这类方法在数值分析文献中尚未得到充分发展,但类似想法以不同面貌被重新发现过。在早于 zolo-pd 的一份未发表手稿中,Chen 和 Chow [11] 描述了一种针对 Newton-Schulz 的缩放策略。尽管动机不同,他们的方法在三次多项式时与我们等价。他们还观察到数值不稳定性会阻止方法一直收敛到机器精度。借助 [34] 的见解,他们提出了一种简单的缓解办法,我们在第 4.4 节加以采用。我们的工作为这一方法提供了理论根基,把它连接到 zolo-pd 的范式,并在 (6) 的意义下证明了最优性。此外,我们研究任意次数的奇次多项式,并特别关注五次情形。独立地,一组密码学家在同态加密方案的语境下,为逼近标量函数 \sign(x)\sign(x)\sign(x) 发展了类似方法 [28]。他们主要调节各自设定中与多项式次数和迭代步数对应的量,而我们侧重于证明最优性,并高效构造三次和五次的更新多项式。此外,我们考虑低精度算术下的矩阵值输入——而不是精确算术下的标量——并展示该方法在用于训练深度网络的 Muon 算法中的效果。

Application within Muon.

The designers of Muon realized that, due to the extreme efficiency requirements and lax accuracy requirements of their setting, rational-based methods from the numerical analysis literature are inapplicable. However, polynomial-based iteration schemes can take full advantage of GPUs because they use only matrix-matrix products in half-precision arithmetic, not inverses or QR decompositions. The preference for speed over accuracy motivates methods that aim to quickly produce coarse approximations, even at the cost of asymptotic convergence. Examples include the proposals of Jordan [22] and You [44, 9], as discussed in Section 1.2. Like Chen and Chow [11], Jordan found that convergence in the initial phase can be accelerated by choosing update rules that have a large derivative near zero, so as to increase the small singular values as much as possible at each iteration. You furthermore chose to use different update rules at each iteration, allowing extra flexibility to tune the trade-off between speed and accuracy. Both used degree-5 polynomials that were found through gradient descent on heuristic objective functions. These proposals were previously compared to Newton-Schultz[^3], but never to Chen and Chow’s method. We find that our method outperforms them all.

在 Muon 中的应用。

Muon 的设计者意识到,由于该设定对效率要求极高、对精度要求却很宽松,数值分析文献中的有理方法并不适用。但基于多项式的迭代格式可以充分利用 GPU,因为它们在半精度算术下只用矩阵-矩阵乘法,不要求逆或 QR 分解。对速度优先、精度其次的偏好,促使人们去设计能尽快给出粗糙近似的方法,哪怕牺牲渐近收敛。例子包括第 1.2 节讨论的 Jordan [22] 和 You [44, 9] 的方案。与 Chen 和 Chow [11] 类似,Jordan 发现:若选择在零点附近导数很大的更新规则,以便每一步尽可能抬升较小的奇异值,就能加快初期收敛。You 更进一步,在每一步使用不同的更新规则,从而有更大的灵活性来权衡速度与精度。两者都使用通过启发式目标函数上的梯度下降找到的五次多项式。这些方案此前曾与 Newton-Schultz[^3] 比较过,但从未与 Chen 和 Chow 的方法比较。我们发现我们的方法超过了它们全部。

3  Approximations by Compositions of Polynomials

3 用多项式复合做逼近

To design a GPU-friendly method for computing \polar(M)\polar(\bm{M})\polar(M), we limit ourselves to the following GPU-friendly operations:

为了设计一种对 GPU 友好的 \polar(M)\polar(\bm{M})\polar(M) 计算方法,我们把自己限制在下列对 GPU 友好的操作上:

i) Linear combinations: given scalars β,γ∈R\beta,\gamma\in\mathbb{R}β,γ∈R and matrices B\bm{B}B and C\bm{C}C, compute βB+γC\beta\bm{B}+\gamma\bm{C}βB+γC,

i) 线性组合:给定标量 β,γ∈R\beta,\gamma\in\mathbb{R}β,γ∈R 以及矩阵 B\bm{B}B 和 C\bm{C}C,计算 βB+γC\beta\bm{B}+\gamma\bm{C}βB+γC,

ii) Matrix-matrix products: compute BC\bm{B}\bm{C}BC.

ii) 矩阵-矩阵乘法:计算 BC\bm{B}\bm{C}BC。

While both these computational primitives are well-suited for parallel computing environments, matrix-matrix products come at a higher computational cost than linear combinations. Therefore, our method attempts to minimize the number of matrix-matrix products. A key observation is that we can compute odd monomials of M=UΣVT\bm{M}=\bm{U}\bm{\Sigma}\bm{V}^{\mathsf{T}}M=UΣVT using the following formula:

这两种计算原语都适合并行计算环境,但矩阵-矩阵乘法的计算代价高于线性组合。因此我们的方法尽量减少矩阵-矩阵乘法的次数。一个关键观察是,对 M=UΣVT\bm{M}=\bm{U}\bm{\Sigma}\bm{V}^{\mathsf{T}}M=UΣVT 的奇次单项式可以用下面的公式计算:

M2q+1:=UΣ2q+1VT=M(MTM)q.\bm{M}^{2q+1}:=\bm{U}\bm{\Sigma}^{2q+1}\bm{V}^{\mathsf{T}}=\bm{M}(\bm{M}^{\mathsf{T}}\bm{M})^{q}.M2q+1:=UΣ2q+1VT=M(MTM)q.

Hence, for an odd polynomial p(x)=a0x+a1x3+⋯+aqx2q+1p(x)=a_{0}x+a_{1}x^{3}+\cdots+a_{q}x^{2q+1}p(x)=a0​x+a1​x3+⋯+aq​x2q+1 we can compute

因此,对奇次多项式 p(x)=a0x+a1x3+⋯+aqx2q+1p(x)=a_{0}x+a_{1}x^{3}+\cdots+a_{q}x^{2q+1}p(x)=a0​x+a1​x3+⋯+aq​x2q+1,我们可以计算

p(M):=a0M+a1M(MTM)+⋯+aqM(MTM)q.p(\bm{M}):=a_{0}\bm{M}+a_{1}\bm{M}(\bm{M}^{\mathsf{T}}\bm{M})+\cdots+a_{q}\bm{M}(\bm{M}^{\mathsf{T}}\bm{M})^{q}.p(M):=a0​M+a1​M(MTM)+⋯+aq​M(MTM)q.

It has been shown that for an arbitrary polynomial ppp, one requires Θ(deg⁡(p)1/2)\Theta(\deg(p)^{1/2})Θ(deg(p)1/2) products to compute p(M)p(\bm{M})p(M) [39]; see also [20] for related work. This compares favorably to the naive approach that forms all monomials in ppp and then sums them together, which requires Ω(deg⁡(p))\Omega(\deg(p))Ω(deg(p)) products. However, if ppp can be expressed as a composition of TTT polynomials, each of degree ddd

已经证明,对任意多项式 ppp,计算 p(M)p(\bm{M})p(M) 需要 Θ(deg⁡(p)1/2)\Theta(\deg(p)^{1/2})Θ(deg(p)1/2) 次乘法 [39];相关工作另见 [20]。这比先形成 ppp 中所有单项式再相加的朴素做法要好,后者需要 Ω(deg⁡(p))\Omega(\deg(p))Ω(deg(p)) 次乘法。不过,如果 ppp 能写成 TTT 个次数均为 ddd 的多项式的复合

p=pT∘pT−1∘⋯∘p1,(4)p=p_{T}\circ p_{T-1}\circ\cdots\circ p_{1}, \tag{4}p=pT​∘pT−1​∘⋯∘p1​,(4)

then the degree of ppp is dTd^{T}dT, and p(M)p(\bm{M})p(M) can be efficiently computed recursively by

那么 ppp 的次数就是 dTd^{T}dT,并且 p(M)p(\bm{M})p(M) 可以高效地递归计算:

X0=M,Xt=pt(Xt−1) for t=1,2,…,T.(5)\bm{X}_{0}=\bm{M},\quad\bm{X}_{t}=p_{t}(\bm{X}_{t-1})\text{ for }t=1,2,\ldots,T. \tag{5}X0​=M,Xt​=pt​(Xt−1​) for t=1,2,…,T.(5)

The final iterate is XT=p(M)\bm{X}_{T}=p(\bm{M})XT​=p(M), which we compute with just O(Td)O(Td)O(Td) matrix-matrix products.

最后一次迭代是 XT=p(M)\bm{X}_{T}=p(\bm{M})XT​=p(M),我们只用 O(Td)O(Td)O(Td) 次矩阵-矩阵乘法就能算出它。

Iterative methods for \polar(M)\polar(\bm{M})\polar(M) can be seen in this light. For instance, the degree-5 Newton-Schulz method uses the polynomial update pt(x)=158x−108x3+38x5p_{t}(x)=\frac{15}{8}x-\frac{10}{8}x^{3}+\frac{3}{8}x^{5}pt​(x)=815​x−810​x3+83​x5 for each t=1,…,Tt=1,\ldots,Tt=1,…,T. The composition p=pT∘⋯∘p1p=p_{T}\circ\cdots\circ p_{1}p=pT​∘⋯∘p1​ approximates \sign(x)\sign(x)\sign(x), and the approximation error goes to 000 as TTT grows. In this paper, we ask the following question: what choice of pT∘⋯∘p1p_{T}\circ\cdots\circ p_{1}pT​∘⋯∘p1​ gives the best approximation to \sign(x)\sign(x)\sign(x)?

计算 \polar(M)\polar(\bm{M})\polar(M) 的迭代法都可以从这个角度看。例如,五次 Newton-Schulz 方法对每个 t=1,…,Tt=1,\ldots,Tt=1,…,T 都使用多项式更新 pt(x)=158x−108x3+38x5p_{t}(x)=\frac{15}{8}x-\frac{10}{8}x^{3}+\frac{3}{8}x^{5}pt​(x)=815​x−810​x3+83​x5。复合 p=pT∘⋯∘p1p=p_{T}\circ\cdots\circ p_{1}p=pT​∘⋯∘p1​ 逼近 \sign(x)\sign(x)\sign(x),逼近误差随 TTT 增大而趋于 000。本文要问的是:怎样选择 pT∘⋯∘p1p_{T}\circ\cdots\circ p_{1}pT​∘⋯∘p1​,才能给出对 \sign(x)\sign(x)\sign(x) 的最好逼近?

The method we will present is optimal in the following sense: given lower and upper bounds ℓ\ellℓ and uuu on the singular values of M\bm{M}M, an odd degree d∈Nd\in\mathbb{N}d∈N, and the number of iterations T∈NT\in\mathbb{N}T∈N, our method computes the composition p⋆(M)p^{\star}(\bm{M})p⋆(M) that minimizes the worst-case error in the spectral norm. That is,

我们将给出的方法在下述意义上是最优的:给定 M\bm{M}M 的奇异值的下界 ℓ\ellℓ 和上界 uuu、一个奇次数 d∈Nd\in\mathbb{N}d∈N,以及迭代次数 T∈NT\in\mathbb{N}T∈N,该方法算出的复合 p⋆(M)p^{\star}(\bm{M})p⋆(M) 能把谱范数下的最坏情形误差降到最小。也就是说,

$$p^{\star}=\argmin_{\begin{subarray}{c}p=p_{T}\circ p_{T-1}\circ\cdots\circ p_{1}\
p_{t}\in\mathbb{P}{d}^{\odd}\end{subarray}}\max{\begin{subarray}{c}\bm{M}\in\mathbb{R}^{m\times n}\
\sigma(\bm{M})\subset[\ell,u]\end{subarray}}\left|\polar(\bm{M})-p(\bm{M})\right|_{2}. \tag{6}$$

Given that \polar(M)−p(M)=U(I−p(Σ))VT\polar(\bm{M})-p(\bm{M})=\bm{U}(\bm{I}-p(\bm{\Sigma}))\bm{V}^{\mathsf{T}}\polar(M)−p(M)=U(I−p(Σ))VT, and by the unitary invariance of the spectral norm, we have that (6) is equivalent to

鉴于 \polar(M)−p(M)=U(I−p(Σ))VT\polar(\bm{M})-p(\bm{M})=\bm{U}(\bm{I}-p(\bm{\Sigma}))\bm{V}^{\mathsf{T}}\polar(M)−p(M)=U(I−p(Σ))VT,再由谱范数的酉不变性,(6) 等价于

$$p^{\star};=;\argmin_{\begin{subarray}{c}p=p_{T}\circ p_{T-1}\circ\cdots\circ p_{1}\
p_{t}\in\mathbb{P}{d}^{\odd}\end{subarray}},\max{x\in[\ell,u]}\left|1-p(x)\right|. \tag{7}$$

For completeness, the equivalence between (6) and (7) is proven in Appendix C.

为完整起见,(6) 与 (7) 的等价性在附录 C 中证明。

(a) The left figure compares the composition (for T=6T=6T=6 and d=5d=5d=5) of polynomials given by Polar Express (ℓ=0.001\ell=0.001ℓ=0.001), You’s method (which is defined up to 6 iterations), Newton-Schulz, and Jordan’s method for approximating \sign(x)\sign(x)\sign(x). The right figure demonstrates the convergence of the methods on [0.001,1][0.001,1][0.001,1]. Note the slow initial convergence of Newton-Schulz.

(a) 左图比较 Polar Express(ℓ=0.001\ell=0.001ℓ=0.001)、You 的方法(定义到 6 步)、Newton-Schulz 以及 Jordan 的方法在逼近 \sign(x)\sign(x)\sign(x) 时所用多项式的复合(T=6T=6T=6,d=5d=5d=5)。右图展示这些方法在 [0.001,1][0.001,1][0.001,1] 上的收敛情况。注意 Newton-Schulz 初期收敛很慢。

In other words, the problem given in (6) reduces to that of finding a “uniform” or “minimax” approximation to the constant function x↦1x\mapsto 1x↦1 over the interval [ℓ,u][\ell,u][ℓ,u], as given in (7). Uniform approximation on an interval by polynomials or rational functions of a given degree is a central topic in approximation theory; see e.g. [46]. Here, we seek an approximation of a particular form—a composition of odd polynomials of fixed degrees. In the next section, we solve the optimization problem of (7) and use the solution to create Polar Express. Figure 2 (a) shows the resulting p∗p^{*}p∗ polynomial labeled as PolarExp, as compared to the Jordan’s method in [22], and the six iterations of You’s method in [9].

换句话说,(6) 中的问题归结为在区间 [ℓ,u][\ell,u][ℓ,u] 上寻找对常值函数 x↦1x\mapsto 1x↦1 的“一致”或“minimax”逼近,即 (7)。用给定次数的多项式或有理函数在区间上做一致逼近,是逼近论的中心课题;参见 [46]。这里我们要找的是一种特殊形式的逼近——固定次数的奇次多项式的复合。下一节我们求解 (7) 的优化问题,并用其解来构造 Polar Express。图 2 (a) 给出所得的 p∗p^{*}p∗ 多项式(标记为 PolarExp),并与 [22] 中 Jordan 的方法以及 [9] 中 You 方法的六步迭代相比较。

4  The Polar Express

4 Polar Express

4.1  Greedy is optimal

4.1 贪心就是最优

The key observation is that the polynomial used in each iteration can be chosen greedily, given the choice of polynomials from the previous iterations. For the first iteration, we choose p1p_{1}p1​ so as to map the interval [ℓ,u][\ell,u][ℓ,u] as close to 111 as possible. That is, it minimizes max⁡x∈[ℓ,u]∣1−p1(x)∣\max_{x\in[\ell,u]}|1-p_{1}(x)|maxx∈[ℓ,u]​∣1−p1​(x)∣. The image of p1p_{1}p1​ will be a new interval [ℓ2,u2][\ell_{2},u_{2}][ℓ2​,u2​], where

关键观察是:每一步所用的多项式都可以在给定此前各步选择的前提下贪心地确定。对第一步,我们选择 p1p_{1}p1​,使区间 [ℓ,u][\ell,u][ℓ,u] 被映射到尽可能靠近 111 的地方。也就是说,它最小化 max⁡x∈[ℓ,u]∣1−p1(x)∣\max_{x\in[\ell,u]}|1-p_{1}(x)|maxx∈[ℓ,u]​∣1−p1​(x)∣。p1p_{1}p1​ 的像会是一个新区间 [ℓ2,u2][\ell_{2},u_{2}][ℓ2​,u2​],其中

ℓ2=min⁡x∈[ℓ,u]p1(x)u2=max⁡x∈[ℓ,u]p1(x)(8)\ell_{2}=\min_{x\in[\ell,u]}p_{1}(x)\qquad\qquad u_{2}=\max_{x\in[\ell,u]}p_{1}(x) \tag{8}ℓ2​=x∈[ℓ,u]min​p1​(x)u2​=x∈[ℓ,u]max​p1​(x)(8)

We now pick p2p_{2}p2​ to map the interval [ℓ2,u2][\ell_{2},u_{2}][ℓ2​,u2​] as close to 111 as possible, obtaining a new interval [ℓ3,u3][\ell_{3},u_{3}][ℓ3​,u3​] that is the image of [ℓ,u][\ell,u][ℓ,u] through p2∘p1p_{2}\circ p_{1}p2​∘p1​. We continue this process for as many iterations as desired.

接着我们选择 p2p_{2}p2​,使区间 [ℓ2,u2][\ell_{2},u_{2}][ℓ2​,u2​] 被映射到尽可能靠近 111 的地方,得到新区间 [ℓ3,u3][\ell_{3},u_{3}][ℓ3​,u3​],它是 [ℓ,u][\ell,u][ℓ,u] 经过 p2∘p1p_{2}\circ p_{1}p2​∘p1​ 的像。我们按需要的步数继续这一过程。

The following theorem guarantees that this process finds the solution to (7), and thereby also (6). The scheme is also outlined in Figure 2 (b), which demonstrates the evolution of the lower bounds ℓt\ell_{t}ℓt​, the upper bounds utu_{t}ut​, and the polynomials ptp_{t}pt​ across iterations.

下面的定理保证这一过程能找到 (7) 的解,从而也找到 (6) 的解。该方案也在图 2 (b) 中示意,展示了下界 ℓt\ell_{t}ℓt​、上界 utu_{t}ut​ 以及多项式 ptp_{t}pt​ 随迭代的演变。

Theorem 4.1.

Let ddd be odd and define ℓ1=ℓ\ell_{1}=\ellℓ1​=ℓ and u1=uu_{1}=uu1​=u. For t=1,…,Tt=1,\ldots,Tt=1,…,T define

定理 4.1。

设 ddd 为奇数,并定义 ℓ1=ℓ\ell_{1}=\ellℓ1​=ℓ、u1=uu_{1}=uu1​=u。对 t=1,…,Tt=1,\ldots,Tt=1,…,T 定义

pt=  arg min⁡p∈Pd\odd max⁡x∈[ℓt,ut]∣1−p(x)∣ℓt+1=  min⁡x∈[ℓt,ut]pt(x)ut+1=  max⁡x∈[ℓt,ut]pt(x)(9)\displaystyle p_{t} \\ \displaystyle=\;\argmin_{\begin{subarray}{c}p\in\mathbb{P}_{d}^{\odd}\end{subarray}}\,\max_{x\in[\ell_{t},u_{t}]}|1-p(x)| \\ \displaystyle\ell_{t+1} \\ \displaystyle=\;\min_{x\in[\ell_{t},u_{t}]}p_{t}(x) \\ \displaystyle u_{t+1} \\ \displaystyle=\;\max_{x\in[\ell_{t},u_{t}]}p_{t}(x) \tag{9}pt​=p∈Pd\odd​​argmin​x∈[ℓt​,ut​]max​∣1−p(x)∣ℓt+1​=x∈[ℓt​,ut​]min​pt​(x)ut+1​=x∈[ℓt​,ut​]max​pt​(x)(9)

Then the new error, lower and upper bounds can be computed through

那么新的误差以及新的下界、上界可以通过下式计算

ℓt+1=pt(ℓt),ut+1=2−ℓt+1, and max⁡x∈[ℓt,ut]∣1−pt(x)∣=1−ℓt+1.(10)\ell_{t+1}=p_{t}(\ell_{t}),\quad u_{t+1}=2-\ell_{t+1},\quad\text{ and }\quad\max\limits_{x\in[\ell_{t},u_{t}]}|1-p_{t}(x)|=1-\ell_{t+1}. \tag{10}ℓt+1​=pt​(ℓt​),ut+1​=2−ℓt+1​, and x∈[ℓt​,ut​]max​∣1−pt​(x)∣=1−ℓt+1​.(10)

Furthermore, the composition p⋆:=pT∘pT−1∘⋯∘p1p^{\star}:=p_{T}\circ p_{T-1}\circ\cdots\circ p_{1}p⋆:=pT​∘pT−1​∘⋯∘p1​ is optimal and the error is given by:

此外,复合 p⋆:=pT∘pT−1∘⋯∘p1p^{\star}:=p_{T}\circ p_{T-1}\circ\cdots\circ p_{1}p⋆:=pT​∘pT−1​∘⋯∘p1​ 是最优的,误差由下式给出:

$$\max\limits_{x\in[\ell,u]}|1-p^{\star}(x)|\quad=\quad\min_{\begin{subarray}{c}p=p_{T}\circ p_{T-1}\circ\cdots\circ p_{1}\
p_{t}\in\mathbb{P}{d}^{\odd}\end{subarray}},\max{x\in[\ell,u]}\left|1-p(x)\right|=1-\ell_{T+1}. \tag{11}$$

Proof.

See Appendix A. ∎

证明。

见附录 A。∎

4.2****Why a fixed degree?.

We note that choice of the degree of each p1,p2,…,pTp_{1},p_{2},\ldots,p_{T}p1​,p2​,…,pT​ need not be the same for Theorem 4.1 to hold. More generally, one may specify a sequence of degrees d1,…,dTd_{1},\ldots,d_{T}d1​,…,dT​ and define each ptp_{t}pt​ as

4.2****为何固定次数?

我们指出,定理 4.1 并不要求每个 p1,p2,…,pTp_{1},p_{2},\ldots,p_{T}p1​,p2​,…,pT​ 的次数相同。更一般地,可以指定一列次数 d1,…,dTd_{1},\ldots,d_{T}d1​,…,dT​,并把每个 ptp_{t}pt​ 定义为

pt=arg min⁡p∈Pdt\odd max⁡x∈[ℓt,ut]∣p(x)−1∣,\mboxfort=1,…,T.p_{t}=\argmin_{\begin{subarray}{c}p\in\mathbb{P}_{d_{t}}^{\odd}\end{subarray}}\,\max_{x\in[\ell_{t},u_{t}]}|p(x)-1|,\qquad\mbox{for }t=1,\ldots,T.pt​=p∈Pdt​\odd​​argmin​x∈[ℓt​,ut​]max​∣p(x)−1∣,\mboxfort=1,…,T.

Our theory translates entirely to this more general case. However, for simplicity we assume d=dtd=d_{t}d=dt​ for all t=1,…,Tt=1,\ldots,Tt=1,…,T. Our setting is similar to that of [28], which considers the closely related problem of choosing the depth TTT and degrees d1,…,dTd_{1},\ldots,d_{T}d1​,…,dT​ such that ppp approximates \sign\sign\sign up to a prescribed error tolerance while minimizing the number of scalar multiplications. Interestingly, from [28, Table 2] the optimal choice of degrees is dt=5d_{t}=5dt​=5 for almost all iterations. This justifies choosing ddd to be a constant and our use of d=5d=5d=5 in particular.

我们的理论完全适用于这一更一般的情形。不过为简单起见,我们假定对所有 t=1,…,Tt=1,\ldots,Tt=1,…,T 都有 d=dtd=d_{t}d=dt​。我们的设定与 [28] 相近,后者考虑的相关问题是:选择深度 TTT 和次数 d1,…,dTd_{1},\ldots,d_{T}d1​,…,dT​,使 ppp 在达到指定误差容限的同时尽量减少标量乘法次数。有趣的是,从 [28, 表 2] 来看,几乎每一步的最优次数都是 dt=5d_{t}=5dt​=5。这为把 ddd 取成常数、尤其是取 d=5d=5d=5 提供了理由。

Fortunately, (10) shows that once ptp_{t}pt​ has been found, we can compute the new lower and upper bounds ℓt+1\ell_{t+1}ℓt+1​ and ut+1u_{t+1}ut+1​ and the approximation error simply by evaluating pt(ℓt)p_{t}(\ell_{t})pt​(ℓt​). Hence, for any fixed upper and lower bounds on the singular values of M\bm{M}M, we can precompute the polynomials p1,…,pTp_{1},\ldots,p_{T}p1​,…,pT​ and the bounds [ℓ1,u1],…,[ℓT+1,uT+1][\ell_{1},u_{1}],\ldots,[\ell_{T+1},u_{T+1}][ℓ1​,u1​],…,[ℓT+1​,uT+1​]. Then, applying the iterative procedure of (5), the final iterate XT\bm{X}_{T}XT​ will satisfy the following error bound

幸运的是,(10) 表明一旦找到 ptp_{t}pt​,只需计算 pt(ℓt)p_{t}(\ell_{t})pt​(ℓt​) 就能得到新的下界 ℓt+1\ell_{t+1}ℓt+1​、上界 ut+1u_{t+1}ut+1​ 以及逼近误差。因此,对 M\bm{M}M 的奇异值的任意固定上、下界,我们可以预先计算多项式 p1,…,pTp_{1},\ldots,p_{T}p1​,…,pT​ 以及区间 [ℓ1,u1],…,[ℓT+1,uT+1][\ell_{1},u_{1}],\ldots,[\ell_{T+1},u_{T+1}][ℓ1​,u1​],…,[ℓT+1​,uT+1​]。然后执行 (5) 的迭代过程,最终迭代 XT\bm{X}_{T}XT​ 将满足如下误差界

∥\polar(M)−XT∥2=∥\polar(M)−p⋆(M)∥2≤1−ℓT+1.(12)\|\polar(\bm{M})-\bm{X}_{T}\|_{2}=\|\polar(\bm{M})-p^{\star}(\bm{M})\|_{2}\leq 1-\ell_{T+1}. \tag{12}∥\polar(M)−XT​∥2​=∥\polar(M)−p⋆(M)∥2​≤1−ℓT+1​.(12)

From the optimality guarantee of Theorem 4.1, we know that our method converges at least as fast as the Newton-Schulz iteration of the same degree. Combining this fact with an existing analysis of Newton-Schulz, we immediately get the following convergence guarantee showing that our method enjoys faster than exponential convergence.

由定理 4.1 的最优性保证,我们知道该方法的收敛速度至少不慢于同次数的 Newton-Schulz 迭代。把这一事实与已有的 Newton-Schulz 分析结合起来,立刻得到下面的收敛保证,表明我们的方法具有快于指数的收敛。

Theorem 4.3.

Let M\bm{M}M be a matrix normalized so that σ(M)⊂[ℓ,1]\sigma(\bm{M})\subset[\ell,1]σ(M)⊂[ℓ,1]. Let XT=p⋆(M)\bm{X}_{T}=p^{\star}(\bm{M})XT​=p⋆(M), where p⋆p^{\star}p⋆ is the polynomial from Theorem 4.1 with d=2q+1d=2q+1d=2q+1. Then, we have

定理 4.3。

设 M\bm{M}M 已归一化,使得 σ(M)⊂[ℓ,1]\sigma(\bm{M})\subset[\ell,1]σ(M)⊂[ℓ,1]。设 XT=p⋆(M)\bm{X}_{T}=p^{\star}(\bm{M})XT​=p⋆(M),其中 p⋆p^{\star}p⋆ 是定理 4.1 中取 d=2q+1d=2q+1d=2q+1 时的多项式。则有

∥\polar(M)−XT∥2≤∣1−ℓ2∣(q+1)T.(13)\|\polar(\bm{M})-\bm{X}_{T}\|_{2}\leq|1-\ell^{2}|^{(q+1)^{T}}. \tag{13}∥\polar(M)−XT​∥2​≤∣1−ℓ2∣(q+1)T.(13)

Hence, for d=3d=3d=3 the method converges quadratically and for d=5d=5d=5 the method converges cubically.

因此,当 d=3d=3d=3 时方法二次收敛,当 d=5d=5d=5 时方法三次收敛。

Proof.

See Appendix B. ∎

证明。

见附录 B。∎

In fact, Theorem 4.3 underestimates how fast our method converges. For degree d=5d=5d=5, our method converges about twice as fast as Newton-Schulz (compare with [11, Section 3.1]). Furthermore, the same analysis applies even if p∗p^{*}p∗ is constructed using a “lower bound” ℓ\ellℓ that was too high. That is, replacing ℓ\ellℓ on the right-hand side of (13) by σmin⁡\sigma_{\min}σmin​, the theorem holds even if p∗p^{*}p∗ is constructed to be optimal on the interval [ℓ,1][\ell,1][ℓ,1] for ℓ>σmin⁡\ell>\sigma_{\min}ℓ>σmin​. Intuitively, when ℓ=u=1\ell=u=1ℓ=u=1, the polynomial p∗p^{*}p∗ coincides exactly with the Newton-Schulz method. Mistakenly setting ℓ>σmin⁡\ell>\sigma_{\min}ℓ>σmin​, we obtain a polynomial that converges slower than the optimal polynomial but faster than Newton-Schulz, so the guarantee of Theorem 4.3 still holds (cf. [11, Theorem 3.3]).

事实上,定理 4.3 低估了我们方法的收敛速度。对次数 d=5d=5d=5,我们的方法大约比 Newton-Schulz 快一倍(可与 [11, 第 3.1 节] 比较)。而且,即便构造 p∗p^{*}p∗ 时所用的“下界”ℓ\ellℓ 偏高,同样的分析仍然成立。也就是说,把 (13) 右边的 ℓ\ellℓ 换成 σmin⁡\sigma_{\min}σmin​ 之后,即使 p∗p^{*}p∗ 是针对某个 ℓ>σmin⁡\ell>\sigma_{\min}ℓ>σmin​ 的区间 [ℓ,1][\ell,1][ℓ,1] 最优构造的,定理依然成立。直观上,当 ℓ=u=1\ell=u=1ℓ=u=1 时,多项式 p∗p^{*}p∗ 恰好就是 Newton-Schulz 方法。若误把 ℓ\ellℓ 设得大于 σmin⁡\sigma_{\min}σmin​,得到的多项式会比最优多项式慢,但比 Newton-Schulz 快,因此定理 4.3 的保证仍然成立(参见 [11, 定理 3.3])。

4.2  Finding the optimal polynomial for each iteration

4.2 为每一步寻找最优多项式

Theorem 4.1 shows that we can solve (7) by greedily choosing the optimal approximation pt∈Pd\oddp_{t}\in\mathbb{P}_{d}^{\odd}pt​∈Pd\odd​ for each interval [ℓt,ut][\ell_{t},u_{t}][ℓt​,ut​] for t=1,…,Tt=1,\ldots,Tt=1,…,T. In this section, we show how to find each ptp_{t}pt​. Since we are now focused on just one iteration, we drop the subscripts. Given ℓ\ellℓ and uuu, we wish to solve the following optimization problem:

定理 4.1 表明,只要对每个区间 [ℓt,ut][\ell_{t},u_{t}][ℓt​,ut​](t=1,…,Tt=1,\ldots,Tt=1,…,T)贪心地选择最优逼近 pt∈Pd\oddp_{t}\in\mathbb{P}_{d}^{\odd}pt​∈Pd\odd​,就能求解 (7)。本节说明如何找出每个 ptp_{t}pt​。既然现在只关注单步,我们省去下标。给定 ℓ\ellℓ 和 uuu,我们希望求解如下优化问题:

arg min⁡p∈Pd\odd max⁡x∈[ℓ,u]∣1−p(x)∣(14)\argmin_{\begin{subarray}{c}p\in\mathbb{P}_{d}^{\odd}\end{subarray}}\,\max_{x\in[\ell,u]}|1-p(x)| \tag{14}p∈Pd\odd​​argmin​x∈[ℓ,u]max​∣1−p(x)∣(14)

That is, we seek a minimax or uniform approximation of the function x↦1x\mapsto 1x↦1 on [ℓ,u][\ell,u][ℓ,u] from the set of odd polynomials. (Equivalently, we seek a minimax optimal approximation to \sign(x)\sign(x)\sign(x) on [−u,−ℓ]∪[ℓ,u][-u,-\ell]\cup[\ell,u][−u,−ℓ]∪[ℓ,u].)

也就是说,我们要在奇次多项式集合中,寻找对区间 [ℓ,u][\ell,u][ℓ,u] 上函数 x↦1x\mapsto 1x↦1 的 minimax 或一致逼近。(等价地,我们要寻找 [−u,−ℓ]∪[ℓ,u][-u,-\ell]\cup[\ell,u][−u,−ℓ]∪[ℓ,u] 上对 \sign(x)\sign(x)\sign(x) 的 minimax 最优逼近。)

Problems of the form (14) are well-studied in approximation theory and numerical analysis. The key mathematical insight underlying the solution is the Equioscillation Theorem, which we state formally for our setting in Lemma A.1. This theorem gives a surprising characterization of the optimal solution of (14): an odd ppp is optimal for degree 2q+12q+12q+1 if and only if there is a set of q+2q+2q+2 equioscillating points. This is a set of points at which ppp achieves its maximum approximation error ±E\pm E±E, and for which the sign of the error alternates. Even if the optimal approximation error EEE is not known in advance, finding a set of q+2q+2q+2 equioscillating points for a given EEE serves as a certificate that no better approximation error is achievable. The Equioscillation Theorem is the basis of the Remez algorithm [37, 38], a general tool that can be used to find (nearly) optimal polynomial approximations of a given degree to any function on any interval. With very minor modifications to handle the constraint that ppp be odd, Remez can be used to directly solve (14).

形如 (14) 的问题在逼近论和数值分析中已被充分研究。求解的关键数学洞见是等振荡定理,我们在引理 A.1 中针对本设定给出正式陈述。该定理给出了 (14) 最优解的一个出人意料的刻画:一个次数为 2q+12q+12q+1 的奇次 ppp 最优,当且仅当存在一组 q+2q+2q+2 个等振荡点。这是一组使 ppp 达到最大逼近误差 ±E\pm E±E、且误差符号交替的点。即便事先不知道最优逼近误差 EEE,对给定的 EEE 找到一组 q+2q+2q+2 个等振荡点,也可以作为“不可能再有更好逼近误差”的证书。等振荡定理是 Remez 算法 [37, 38] 的基础;Remez 是一种通用工具,可用于寻找任意函数在任意区间上、给定次数的(近乎)最优多项式逼近。只需稍加修改以处理 ppp 必须为奇次的约束,就可以直接用 Remez 求解 (14)。

However, the Remez algorithm is opaque, complex, and difficult to implement correctly. Fortunately, we do not need the Remez algorithm in its full generality to solve our problem. We seek only low degree polynomials, and the function we wish to approximate is the constant function f(x)≡1f(x)\equiv 1f(x)≡1. For d=3d=3d=3, we can derive an explicit, closed form solution to (14) using the Equioscillation Theorem. Up to rescaling, the optimal polynomial turns out to be the same one derived in Chen and Chow by different means [11]. For degree d=5d=5d=5, we present Algorithm 3, a much simpler way of solving (14) that is mathematically equivalent to Remez in our setting. This algorithm is implemented in its entirety in Appendix G.

不过 Remez 算法晦涩、复杂,也很难正确实现。幸运的是,求解我们的问题并不需要完整的一般 Remez 算法。我们只要低次多项式,而要逼近的函数是常值函数 f(x)≡1f(x)\equiv 1f(x)≡1。对 d=3d=3d=3,我们可以用等振荡定理导出 (14) 的显式闭式解。除去缩放之外,最优多项式恰好就是 Chen 和 Chow 用不同手段导出的那一个 [11]。对次数 d=5d=5d=5,我们给出算法 3,这是一种在本设定下与 Remez 数学等价、但简单得多的求解 (14) 的办法。该算法的完整实现见附录 G。

We briefly describe the solution for d=3d=3d=3. We seek a polynomial of the form p(x)=ax+bx3p(x)=ax+bx^{3}p(x)=ax+bx3. The Equioscillation Theorem stipulates that ppp must have an equioscillating set of size 3. For ppp to achieve its maximum error at a point xxx, xxx must be a local extremum of p(x)−1p(x)-1p(x)−1 on the interval [ℓ,u][\ell,u][ℓ,u]. Thus, for xxx to be eligible for membership in the equioscillating set, it must either be a true local extremum of p(x)−1p(x)-1p(x)−1 that happens to lie in [ℓ,u][\ell,u][ℓ,u], or else one of the endpoints ℓ,u\ell,uℓ,u. However, because ppp is an odd cubic, it has at most one true local extremum on R≥0\mathbb{R}_{\geq 0}R≥0​. Thus, to build an equioscillating set of three points, we must include ppp’s unique positive local extremum and both endpoints. This local extremum of ppp occurs at −a3b\sqrt{\frac{-a}{3b}}3b−a​​. Therefore, we seek a,ba,ba,b such that

我们简要描述 d=3d=3d=3 时的解。我们寻找形如 p(x)=ax+bx3p(x)=ax+bx^{3}p(x)=ax+bx3 的多项式。等振荡定理要求 ppp 必须有一个大小为 3 的等振荡集。若 ppp 在某点 xxx 达到最大误差,则 xxx 必须是 p(x)−1p(x)-1p(x)−1 在区间 [ℓ,u][\ell,u][ℓ,u] 上的局部极值。因此,要使 xxx 有资格进入等振荡集,它要么是恰好落在 [ℓ,u][\ell,u][ℓ,u] 内的 p(x)−1p(x)-1p(x)−1 的真正局部极值,要么是端点 ℓ,u\ell,uℓ,u 之一。但由于 ppp 是奇次三次多项式,它在 R≥0\mathbb{R}_{\geq 0}R≥0​ 上至多有一个真正的局部极值。因此,要构造三个点的等振荡集,必须同时纳入 ppp 唯一的正局部极值以及两个端点。这一局部极值出现在 −a3b\sqrt{\frac{-a}{3b}}3b−a​​。于是我们寻找满足下式的 a,ba,ba,b

p(ℓ)=1−E,p(−a3b)=1+E,p(u)=1−E(15)p(\ell)=1-E,\qquad\qquad p\left(\sqrt{\frac{-a}{3b}}\right)=1+E,\qquad\qquad p(u)=1-E \tag{15}p(ℓ)=1−E,p(3b−a​​)=1+E,p(u)=1−E(15)

for some EEE. This is a system of three equations in three variables. The solution p(x)=ax+bx3p(x)=ax+bx^{3}p(x)=ax+bx3 is most easily expressed as follows. Let p\NS(x)=32x−12x3p_{\NS}(x)=\frac{3}{2}x-\frac{1}{2}x^{3}p\NS​(x)=23​x−21​x3. Then

对某个 EEE。这是三个未知数的三个方程。解 p(x)=ax+bx3p(x)=ax+bx^{3}p(x)=ax+bx3 最容易按如下方式写出。设 p\NS(x)=32x−12x3p_{\NS}(x)=\frac{3}{2}x-\frac{1}{2}x^{3}p\NS​(x)=23​x−21​x3。则

p(x)=βp\NS(αx), where α=3u2+lu+ℓ2 and β=42+ℓu(ℓ+u)α3.p(x)=\beta p_{\NS}(\alpha x),\quad\text{ where }\alpha=\sqrt{\frac{3}{u^{2}+lu+\ell^{2}}}\quad\text{ and }\quad\beta=\frac{4}{2+\ell u(\ell+u)\alpha^{3}}.p(x)=βp\NS​(αx), where α=u2+lu+ℓ23​​ and β=2+ℓu(ℓ+u)α34​.

We now turn to the degree-5 case. The intuition of Algorithm 3 is as follows. For any fixed set of four points ℓ<q<r<u\ell<q<r<uℓ<q<r<u, we can find an degree-5 odd polynomial p(x)=ax+bx3+cx5p(x)=ax+bx^{3}+cx^{5}p(x)=ax+bx3+cx5 that satisfies

现在转向五次情形。算法 3 的直觉如下。对任意固定的四个点 ℓ<q<r<u\ell<q<r<uℓ<q<r<u,我们可以找到一个满足下式的五次奇次多项式 p(x)=ax+bx3+cx5p(x)=ax+bx^{3}+cx^{5}p(x)=ax+bx3+cx5

p(ℓ)=1−E,p(q)=1+E,p(r)=1−E,p(u)=1+Ep(\ell)=1-E,\qquad p(q)=1+E,\qquad p(r)=1-E,\qquad p(u)=1+Ep(ℓ)=1−E,p(q)=1+E,p(r)=1−E,p(u)=1+E

for some EEE by solving a 4×44\times 44×4 linear system in a,b,ca,b,ca,b,c and EEE. Likewise, for any fixed degree-5 odd ppp, we can find its four (or fewer) local extrema on [ℓ,u][\ell,u][ℓ,u] as follows: they occur at ℓ,u\ell,uℓ,u and the roots of p′p^{\prime}p′, which is an even degree-4 polynomial whose roots can easily be found by the quadratic formula. Algorithm 3 simply alternates between these two steps (solving for a,b,c,Ea,b,c,Ea,b,c,E and solving for q,rq,rq,r) until the points q,rq,rq,r converge. Once they have converged, {ℓ,q,r,u}\{\ell,q,r,u\}{ℓ,q,r,u} forms an equioscillating set, so ppp is the optimal polynomial. For more details, please see Appendix D.

对某个 EEE,只需求解关于 a,b,ca,b,ca,b,c 和 EEE 的 4×44\times 44×4 线性方程组。同样,对任意固定的五次奇次 ppp,可以如下找到它在 [ℓ,u][\ell,u][ℓ,u] 上的四个(或更少)局部极值:它们出现在 ℓ\ellℓ、uuu 以及 p′p^{\prime}p′ 的根处;p′p^{\prime}p′ 是一个偶的四次多项式,其根很容易用二次公式求出。算法 3 只是在这两步(求解 a,b,c,Ea,b,c,Ea,b,c,E 与求解 q,rq,rq,r)之间交替,直到点 q,rq,rq,r 收敛。一旦收敛,{ℓ,q,r,u}\{\ell,q,r,u\}{ℓ,q,r,u} 就构成等振荡集,因而 ppp 就是最优多项式。更多细节见附录 D。

4.3  Upper and lower bounds on the singular values

4.3 奇异值的上界与下界

To instantiate our method, we need upper and lower bounds uuu and ℓ\ellℓ on the singular values of the input matrix M\bm{M}M. A trivial upper bound is given by ∥M∥F\|\bm{M}\|_{\text{F}}∥M∥F​. For M∈Rm×n\bm{M}\in\mathbb{R}^{m\times n}M∈Rm×n with n≤mn\leq mn≤m, this can overestimate σmax⁡(M)\sigma_{\max}(\bm{M})σmax​(M) by a factor of n\sqrt{n}n​ in the worst case. However in practice, the gradient matrices of the weights of dense linear layers in neural networks tend to have small effective rank [48]. Consequently, the Frobenius norm tends to be a reasonably good bound on the spectral norm that is loose only by a small constant factor. We rescale the input matrix by setting X0=M/∥M∥F\bm{X}_{0}=\bm{M}/\|\bm{M}\|_{\text{F}}X0​=M/∥M∥F​ so that u=1u=1u=1.

要实例化我们的方法,需要输入矩阵 M\bm{M}M 的奇异值上界 uuu 和下界 ℓ\ellℓ。一个平凡的上界是 ∥M∥F\|\bm{M}\|_{\text{F}}∥M∥F​。对 n≤mn\leq mn≤m 的 M∈Rm×n\bm{M}\in\mathbb{R}^{m\times n}M∈Rm×n,这在最坏情形下可能把 σmax⁡(M)\sigma_{\max}(\bm{M})σmax​(M) 高估 n\sqrt{n}n​ 倍。但在实践中,神经网络稠密线性层权重的梯度矩阵往往有效秩较小 [48]。因此 Frobenius 范数往往是谱范数一个相当不错的界,松弛程度只是一个不大的常数因子。我们令 X0=M/∥M∥F\bm{X}_{0}=\bm{M}/\|\bm{M}\|_{\text{F}}X0​=M/∥M∥F​ 来缩放输入矩阵,从而使 u=1u=1u=1。

It is difficult to efficiently find a good lower bound on the smallest singular value, so we are forced to guess. Fortunately, the consequences of a bad guess are not severe. As discussed above, the method will eventually converge for any ℓ∈(0,u]\ell\in(0,u]ℓ∈(0,u], and even an order of magnitude error in our guess of ℓ\ellℓ only delays convergence by a few iterations. For matrices stored in floating point arithmetic, the singular values are usually larger than machine precision ϵmach\epsilon_{\text{mach}}ϵmach​ [7], so a good guess is to set ℓ≈ϵmach\ell\approx\epsilon_{\text{mach}}ℓ≈ϵmach​. In our numerical experiments we work in bfloat16 where ϵmach=2−7=0.0078125.\epsilon_{\text{mach}}=2^{-7}=0.0078125.ϵmach​=2−7=0.0078125. Hence we set ℓ=10−3\ell=10^{-3}ℓ=10−3 and u=1u=1u=1. Since we use these bounds for all input matrices, we can precompute the optimal polynomials once and apply them to as many inputs as we want.

要高效地找到最小奇异值的好下界并不容易,因此只好去猜。幸运的是,猜错的后果并不严重。如上所述,对任意 ℓ∈(0,u]\ell\in(0,u]ℓ∈(0,u] 方法最终都会收敛,即便对 ℓ\ellℓ 的猜测偏差一个数量级,也只会让收敛晚几步。对浮点存储的矩阵,奇异值通常大于机器精度 ϵmach\epsilon_{\text{mach}}ϵmach​ [7],因此一个好的猜测是取 ℓ≈ϵmach\ell\approx\epsilon_{\text{mach}}ℓ≈ϵmach​。我们的数值实验在 bfloat16 下进行,其中 ϵmach=2−7=0.0078125\epsilon_{\text{mach}}=2^{-7}=0.0078125ϵmach​=2−7=0.0078125。因此我们取 ℓ=10−3\ell=10^{-3}ℓ=10−3、u=1u=1u=1。既然对所有输入矩阵都使用这些界,我们可以预先把最优多项式算好一次,再把它们用到任意多的输入上。

4.4  Finite precision considerations

4.4 有限精度下的考虑

用安全因子和缓冲稳定更新规则的效果

Figure 3: Effects of stabilizing the update rules with a safety factor and cushioning, as described in Section 4.4. The blue curve is the optimal degree-5 polynomial for the interval [0.005,1][0.005,1][0.005,1]. It is has numerical issues because it maps singular values near 0.80.80.8 down to almost zero and maps 1+ϵ1+\epsilon1+ϵ to ≈ut+1+25ϵ\approx u_{t+1}+25\epsilon≈ut+1​+25ϵ. The stabilized version is better because it ensures pt(x)x≥0.236\frac{p_{t}(x)}{x}\geq 0.236xpt​(x)​≥0.236 and maps all x≤1.01x\leq 1.01x≤1.01 to at most ut+1u_{t+1}ut+1​.

图 3:如第 4.4 节所述,用安全因子和缓冲来稳定更新规则的效果。蓝线是区间 [0.005,1][0.005,1][0.005,1] 上最优的五次多项式。它有数值问题,因为会把接近 0.80.80.8 的奇异值映射到几乎为零,并把 1+ϵ1+\epsilon1+ϵ 映射到约 ut+1+25ϵu_{t+1}+25\epsilonut+1​+25ϵ。稳定后的版本更好,因为它保证 pt(x)x≥0.236\frac{p_{t}(x)}{x}\geq 0.236xpt​(x)​≥0.236,并把所有 x≤1.01x\leq 1.01x≤1.01 映射到至多 ut+1u_{t+1}ut+1​。

When working in finite-precision arithmetic, especially the half-precision bfloat16 format used in deep learning, we must take some care to avoid blowups and other problems due to numerical error. To this end, we make three small changes to the method. These adjustments stabilize the algorithm with a negligible effect on accuracy. Furthermore, these adjustments can be made in the offline stage by modifying the coefficients of our optimal polynomials.

在有限精度算术中,尤其是深度学习使用的半精度 bfloat16 格式下,必须稍加小心,以免因数值误差出现爆炸或其他问题。为此我们对方法做了三处小改动。这些调整能稳定算法,对精度的影响可以忽略。而且这些调整可以在离线阶段完成,只需修改最优多项式的系数。

The first issue arises when numerical round-off creates singular values that are slightly larger than our current upper bound utu_{t}ut​. Our optimal polynomials converge only when the singular values of Xt\bm{X}_{t}Xt​ are less than utu_{t}ut​. In some cases we have

第一个问题出现在数值舍入制造出略大于当前上界 utu_{t}ut​ 的奇异值时。我们的最优多项式只有在 Xt\bm{X}_{t}Xt​ 的奇异值小于 utu_{t}ut​ 时才会收敛。有些情况下我们有

pt(ut+ϵ)>ut+1+ϵ,p_{t}(u_{t}+\epsilon)>u_{t+1}+\epsilon,pt​(ut​+ϵ)>ut+1​+ϵ,

so over many iterations, a singular value that is slightly larger than utu_{t}ut​ large could grow to ∞\infty∞ instead of converging to 111.

于是经过许多步之后,一个略大于 utu_{t}ut​ 的奇异值可能会增长到 ∞\infty∞,而不是收敛到 111。

To fix this issue, we simply replace each polynomial x↦pt(x)x\mapsto p_{t}(x)x↦pt​(x) by x↦pt(x/1.01)x\mapsto p_{t}(x/1.01)x↦pt​(x/1.01). This safety factor corrects for round-off errors in previous iterations while only slightly changing the behavior of the polynomial on the interval [ℓt,ut][\ell_{t},u_{t}][ℓt​,ut​], though it does cause the singular values to converge to 0.9999980.9999980.999998 instead of to 111. To correct for this, the safety factor can be omitted in the final iteration.

为修复这一问题,我们只需把每个多项式 x↦pt(x)x\mapsto p_{t}(x)x↦pt​(x) 换成 x↦pt(x/1.01)x\mapsto p_{t}(x/1.01)x↦pt​(x/1.01)。这一安全因子能纠正此前各步的舍入误差,同时只轻微改变多项式在区间 [ℓt,ut][\ell_{t},u_{t}][ℓt​,ut​] 上的行为,不过它会让奇异值收敛到 0.9999980.9999980.999998 而不是 111。为纠正这一点,最后一步可以省去安全因子。

The second issue was identified in [34] and addressed in the context of polynomial iterations by Chen and Chow [11]. In general, iterative methods for \polar(M)\polar(\bm{M})\polar(M) aim to increase each singular value relative to the largest singular value; while σmin⁡(X0)≪σmax⁡(X0)\sigma_{\min}(\bm{X}_{0})\ll\sigma_{\max}(\bm{X}_{0})σmin​(X0​)≪σmax​(X0​), after enough iterations, σmin⁡(Xt)≈σmax⁡(Xt)≈1\sigma_{\min}(\bm{X}_{t})\approx\sigma_{\max}(\bm{X}_{t})\approx 1σmin​(Xt​)≈σmax​(Xt​)≈1. However, the convergence of each singular value to σmax⁡\sigma_{\max}σmax​ may not be monotonic. Over the domain [ℓt,ut][\ell_{t},u_{t}][ℓt​,ut​], our optimal polynomial ptp_{t}pt​ oscillates repeatedly between ℓt+1\ell_{t+1}ℓt+1​ and ut+1u_{t+1}ut+1​, so some singular values that are near utu_{t}ut​ may get mapped down to ℓt+1\ell_{t+1}ℓt+1​. It so happens that this non-monotonicity—even at a single iteration—can cause loss of precision. That is, problems occur if

第二个问题由 [34] 指出,并由 Chen 和 Chow [11] 在多项式迭代的语境下加以处理。一般而言,计算 \polar(M)\polar(\bm{M})\polar(M) 的迭代法旨在相对于最大奇异值抬升每一个奇异值;虽然 σmin⁡(X0)≪σmax⁡(X0)\sigma_{\min}(\bm{X}_{0})\ll\sigma_{\max}(\bm{X}_{0})σmin​(X0​)≪σmax​(X0​),足够多步之后会有 σmin⁡(Xt)≈σmax⁡(Xt)≈1\sigma_{\min}(\bm{X}_{t})\approx\sigma_{\max}(\bm{X}_{t})\approx 1σmin​(Xt​)≈σmax​(Xt​)≈1。不过每个奇异值向 σmax⁡\sigma_{\max}σmax​ 的收敛未必是单调的。在定义域 [ℓt,ut][\ell_{t},u_{t}][ℓt​,ut​] 上,我们的最优多项式 ptp_{t}pt​ 会在 ℓt+1\ell_{t+1}ℓt+1​ 与 ut+1u_{t+1}ut+1​ 之间反复振荡,因此某些接近 utu_{t}ut​ 的奇异值可能被映射到 ℓt+1\ell_{t+1}ℓt+1​。偏偏这种非单调性——哪怕只出现在单步——就会造成精度损失。也就是说,若

pt(σi)σi≪max⁡x∈[σmin⁡,σmax⁡]pt(x)σmax⁡,\frac{p_{t}(\sigma_{i})}{\sigma_{i}}\ll\frac{\max\limits_{x\in[\sigma_{\min},\sigma_{\max}]}p_{t}(x)}{\sigma_{\max}},σi​pt​(σi​)​≪σmax​x∈[σmin​,σmax​]max​pt​(x)​,

where 0≤σmin⁡≤σi≤σmax⁡0\leq\sigma_{\min}\leq\sigma_{i}\leq\sigma_{\max}0≤σmin​≤σi​≤σmax​ are singular values of Xt\bm{X}_{t}Xt​ [34]. In the extreme case pt(σi)<0p_{t}(\sigma_{i})<0pt​(σi​)<0, the iiith singular vector will change sign, casuing the method to converge to the polar factor of the wrong matrix. Unlike Newton-Schulz, unscaled Newton, or QDWH, our method is affected by this loss of precision.

就会出问题,其中 0≤σmin⁡≤σi≤σmax⁡0\leq\sigma_{\min}\leq\sigma_{i}\leq\sigma_{\max}0≤σmin​≤σi​≤σmax​ 是 Xt\bm{X}_{t}Xt​ 的奇异值 [34]。在极端情形 pt(σi)<0p_{t}(\sigma_{i})<0pt​(σi​)<0 时,第 iii 个奇异向量会变号,导致方法收敛到错误矩阵的极因子。与 Newton-Schulz、未缩放的 Newton 或 QDWH 不同,我们的方法会受到这种精度损失的影响。

To mitigate this issue, [11] propose modifying their update polynomials to enforce a lower bound on the ratio pt(σi)σi\frac{p_{t}(\sigma_{i})}{\sigma_{i}}σi​pt​(σi​)​. This issue only occurs when ℓt≪ut\ell_{t}\ll u_{t}ℓt​≪ut​; as ℓt→ut\ell_{t}\to u_{t}ℓt​→ut​, our optimal polynomial approaches the Padé approximant and so pt(x)x≥1\frac{p_{t}(x)}{x}\geq 1xpt​(x)​≥1 for all x∈[0,ut]x\in[0,u_{t}]x∈[0,ut​]. We could fully solve the problem by using the Padé approximant instead of our optimal polynomial, but this would significantly slow down convergence. Instead we compromise. When ℓt≥ut/10\ell_{t}\geq u_{t}/10ℓt​≥ut​/10, we find that pt(x)x≥0.236\frac{p_{t}(x)}{x}\geq 0.236xpt​(x)​≥0.236. Therefore, whenever ℓt<ut/10\ell_{t}<u_{t}/10ℓt​<ut​/10 we select the update rule as though ℓt=ut/10\ell_{t}=u_{t}/10ℓt​=ut​/10. This change slows convergence, but only very slightly. (The choice of 10 is somewhat arbitrary. In Appendix G, we use a different factor.)

为缓解这一问题,[11] 建议修改更新多项式,给比值 pt(σi)σi\frac{p_{t}(\sigma_{i})}{\sigma_{i}}σi​pt​(σi​)​ 加上一个下界。这一问题只在 ℓt≪ut\ell_{t}\ll u_{t}ℓt​≪ut​ 时出现;当 ℓt→ut\ell_{t}\to u_{t}ℓt​→ut​ 时,我们的最优多项式会逼近 Padé 逼近,从而对所有 x∈[0,ut]x\in[0,u_{t}]x∈[0,ut​] 都有 pt(x)x≥1\frac{p_{t}(x)}{x}\geq 1xpt​(x)​≥1。我们可以干脆改用 Padé 逼近而不是最优多项式来彻底解决问题,但这会显著拖慢收敛。我们采取折中。当 ℓt≥ut/10\ell_{t}\geq u_{t}/10ℓt​≥ut​/10 时,我们发现 pt(x)x≥0.236\frac{p_{t}(x)}{x}\geq 0.236xpt​(x)​≥0.236。因此只要 ℓt<ut/10\ell_{t}<u_{t}/10ℓt​<ut​/10,我们就按 ℓt=ut/10\ell_{t}=u_{t}/10ℓt​=ut​/10 来选择更新规则。这一改动会减慢收敛,但幅度很小。(取 10 多少有些任意。附录 G 中我们使用了不同的因子。)

The third change is copied from the original Muon implementation: normalize M\bm{M}M by ∥M∥F+10−2\|\bm{M}\|_{\text{F}}+10^{-2}∥M∥F​+10−2 instead of by ∥M∥F\|\bm{M}\|_{\text{F}}∥M∥F​. As before, we set u1=1u_{1}=1u1​=1.

第三处改动照搬自原先的 Muon 实现:用 ∥M∥F+10−2\|\bm{M}\|_{\text{F}}+10^{-2}∥M∥F​+10−2 而不是 ∥M∥F\|\bm{M}\|_{\text{F}}∥M∥F​ 来归一化 M\bm{M}M。和前面一样,我们设 u1=1u_{1}=1u1​=1。

4.5  The algorithm

4.5 算法

We give the complete pseudocode for our proposed method for any degree in Algorithm 2. We give the specfic version of the Polar Express with degree d=5d=5d=5 and ℓ=10−3\ell=10^{-3}ℓ=10−3 used in our GPT experiments in Algorithm 1. Our algorithm first computes the polynomials p1,…,pTp_{1},\ldots,p_{T}p1​,…,pT​ of Theorem 4.1 in full precision using the results of Section 4.2 (or the Remez algorithm for d>5d>5d>5). This stage is offline because the coefficients of the polynomials are only computed and stored once. For every subsequent call to the algorithm, these coefficients are reused and the offline stage is skipped. For instance, in Algorithm 1 these polynomials have been precomputed and stored in the variable coeffs_list.

我们在算法 2 中给出任意次数下所提方法的完整伪代码。算法 1 给出我们在 GPT 实验中使用的、次数 d=5d=5d=5 且 ℓ=10−3\ell=10^{-3}ℓ=10−3 的 Polar Express 具体版本。算法首先用第 4.2 节的结果(或当 d>5d>5d>5 时用 Remez 算法)在全精度下计算定理 4.1 中的多项式 p1,…,pTp_{1},\ldots,p_{T}p1​,…,pT​。这一阶段是离线的,因为多项式系数只需计算并存储一次。此后每次调用算法都会复用这些系数,并跳过离线阶段。例如在算法 1 中,这些多项式已被预先算好并存放在变量 coeffs_list 里。

1: Offline stage: ▹\triangleright▹ In float64
2: ℓ1=ℓ\ell_{1}=\ellℓ1​=ℓ, u1=1u_{1}=1u1​=1.
3: for t=1,2,…,Tt=1,2,\ldots,Tt=1,2,…,T do
4:   Solve using Remez Appendix D:
5:   pt=arg min⁡p∈Pd\oddmax⁡x∈[max⁡(ℓt,ut/10), ut]∣1−p(x)∣p_{t}=\argmin\limits_{p\in\mathbb{P}_{d}^{\odd}}\max\limits_{x\in\left[\max(\ell_{t},u_{t}/10),\,u_{t}\right]}|1-p(x)|pt​=p∈Pd\odd​argmin​x∈[max(ℓt​,ut​/10),ut​]max​∣1−p(x)∣.
6:   pt←pt(⋅/1.01)p_{t}\leftarrow p_{t}(\cdot/1.01)pt​←pt​(⋅/1.01).
7:   ℓt+1=pt(ℓt),ut+1=2−ℓt+1\ell_{t+1}=p_{t}(\ell_{t}),u_{t+1}=2-\ell_{t+1}ℓt+1​=pt​(ℓt​),ut+1​=2−ℓt+1​.
8: end for
9: Online stage: ▹\triangleright▹ In float16
10: Let X0=M/(∥M∥F+10−7)\bm{X}_{0}=\bm{M}/(\|\bm{M}\|_{\text{F}}+10^{-7})X0​=M/(∥M∥F​+10−7).
11: for t=1,2,…,Tt=1,2,\ldots,Tt=1,2,…,T do
12:   Xt=pt(Xt−1)\bm{X}_{t}=p_{t}(\bm{X}_{t-1})Xt​=pt​(Xt−1​).
13: end for
14: return XT\bm{X}_{T}XT​.

Algorithm 2 The General Polar Express

1: 离线阶段: ▹\triangleright▹ 使用 float64
2: ℓ1=ℓ\ell_{1}=\ellℓ1​=ℓ,u1=1u_{1}=1u1​=1。
3: for t=1,2,…,Tt=1,2,\ldots,Tt=1,2,…,T do
4:   用附录 D 的 Remez 求解:
5:   pt=arg min⁡p∈Pd\oddmax⁡x∈[max⁡(ℓt,ut/10), ut]∣1−p(x)∣p_{t}=\argmin\limits_{p\in\mathbb{P}_{d}^{\odd}}\max\limits_{x\in\left[\max(\ell_{t},u_{t}/10),\,u_{t}\right]}|1-p(x)|pt​=p∈Pd\odd​argmin​x∈[max(ℓt​,ut​/10),ut​]max​∣1−p(x)∣。
6:   pt←pt(⋅/1.01)p_{t}\leftarrow p_{t}(\cdot/1.01)pt​←pt​(⋅/1.01)。
7:   ℓt+1=pt(ℓt)\ell_{t+1}=p_{t}(\ell_{t})ℓt+1​=pt​(ℓt​),ut+1=2−ℓt+1u_{t+1}=2-\ell_{t+1}ut+1​=2−ℓt+1​。
8: end for
9: 在线阶段: ▹\triangleright▹ 使用 float16
10: 令 X0=M/(∥M∥F+10−7)\bm{X}_{0}=\bm{M}/(\|\bm{M}\|_{\text{F}}+10^{-7})X0​=M/(∥M∥F​+10−7)。
11: for t=1,2,…,Tt=1,2,\ldots,Tt=1,2,…,T do
12:   Xt=pt(Xt−1)\bm{X}_{t}=p_{t}(\bm{X}_{t-1})Xt​=pt​(Xt−1​)。
13: end for
14: return XT\bm{X}_{T}XT​。

算法 2 一般形式的 Polar Express

The polynomial p⋆:=pT∘⋯∘p1p^{\star}:=p_{T}\circ\cdots\circ p_{1}p⋆:=pT​∘⋯∘p1​ is then applied to the input matrix M\bm{M}M in the online stage. The online stage can be performed in lower precision (bfloat16) for greater speed on a GPU. Horner’s rule can be used to carry out each iteration. For instance, if pt=ax+bx3+cx5p_{t}=ax+bx^{3}+cx^{5}pt​=ax+bx3+cx5, then

多项式 p⋆:=pT∘⋯∘p1p^{\star}:=p_{T}\circ\cdots\circ p_{1}p⋆:=pT​∘⋯∘p1​ 随后在在线阶段作用于输入矩阵 M\bm{M}M。在线阶段可以在更低精度(bfloat16)下进行,以便在 GPU 上跑得更快。每一步可以用 Horner 法则来执行。例如,若 pt=ax+bx3+cx5p_{t}=ax+bx^{3}+cx^{5}pt​=ax+bx3+cx5,则

Xt=Xt−1(aI+Yt−1(bI+cYt−1))\bm{X}_{t}=\bm{X}_{t-1}\left(a\bm{I}+\bm{Y}_{t-1}\left(b\bm{I}+c\bm{Y}_{t-1}\right)\right)Xt​=Xt−1​(aI+Yt−1​(bI+cYt−1​))

where Yt−1=Xt−1⊤Xt−1\bm{Y}_{t-1}=\bm{X}_{t-1}^{\top}\bm{X}_{t-1}Yt−1​=Xt−1⊤​Xt−1​.

其中 Yt−1=Xt−1⊤Xt−1\bm{Y}_{t-1}=\bm{X}_{t-1}^{\top}\bm{X}_{t-1}Yt−1​=Xt−1⊤​Xt−1​。

A simple implementation of the offline stage of Algorithm 2 is given in Appendix G. For deep learning applications, we recommend using d=5d=5d=5 and T=5T=5T=5 or 666 with ℓ1=10−3\ell_{1}=10^{-3}ℓ1​=10−3. With these parameters, the offline stage as implemented in Appendix G gives the polynomials encoded in coeffs_list in Algorithm 1. All told, our proposal for Muon is to apply the composition of these polynomials to M/(∥M∥F+10−2)\bm{M}/(\|\bm{M}\|_{F}+10^{-2})M/(∥M∥F​+10−2).

算法 2 离线阶段的一个简单实现见附录 G。对深度学习应用,我们建议取 d=5d=5d=5、T=5T=5T=5 或 666,并取 ℓ1=10−3\ell_{1}=10^{-3}ℓ1​=10−3。在这些参数下,附录 G 中实现的离线阶段会给出算法 1 里 coeffs_list 所编码的那些多项式。总的来说,我们对 Muon 的建议是:把这些多项式的复合作用到 M/(∥M∥F+10−2)\bm{M}/(\|\bm{M}\|_{F}+10^{-2})M/(∥M∥F​+10−2) 上。

5  Numerical Experiments

5 数值实验

5.1  Convergence of Polar Express

5.1 Polar Express 的收敛

五次多项式方法在谱范数下的收敛

Figure 4: Convergence of various degree-5 polynomial methods in the spectral norm. When tuned properly, Polar Express attains outperforms the other methods at every iteration. Left panel: synthetic matrix with σmax⁡=1\sigma_{\max}=1σmax​=1, σmin⁡=10−6\sigma_{\min}=10^{-6}σmin​=10−6. Right panel: gradient of a certain weight matrix of a randomly-initialized GPT-2 architecture on a batch of language modeling data, normalized by the Frobenius norm.

图 4:多种五次多项式方法在谱范数下的收敛。调得恰当时,Polar Express 在每一步都超过其他方法。左图:合成矩阵,σmax⁡=1\sigma_{\max}=1σmax​=1,σmin⁡=10−6\sigma_{\min}=10^{-6}σmin​=10−6。右图:随机初始化的 GPT-2 架构中某一权重矩阵、在一批语言建模数据上的梯度,并按 Frobenius 范数归一化。

We compare the performance of Polar Express against degree-5 Newton-Schulz and the methods of Chen and Chow [11], Jordan [22], and You [9].

我们将 Polar Express 与五次 Newton-Schulz,以及 Chen 和 Chow [11]、Jordan [22]、You [9] 的方法进行比较。

We first study an idealized scenario where the spectrum of the input matrix is known exactly. We generate a random matrix whose singular values are evenly spaced on a logarithmic scale between 10−610^{-6}10−6 and 111. The right and left singular vectors are chosen at random. The left panel of Figure 4 shows the results. Since all the methods in this plot use degree-5 polynomials, their computational and runtime costs are all proportional to the number of iterations. As expected, Newton-Schulz converges but makes almost no progress for the first 17 iterations. Jordan’s method rapidly achieves an error of ≈0.3\approx 0.3≈0.3 after just 11 iterations, but ceases to converge further. You’s method, which is difficult to see on the plot because it is only defined for six iterations, converges at a similar rate as Jordan’s method. When Polar Express is instantiated with ℓ=σmin⁡\ell=\sigma_{\min}ℓ=σmin​, it dominates the other methods at every iteration, achieving excellent accuracy after just 11 iterations and converging about twice as fast as Newton-Schulz to any given error. Even when the lower bound on σmin⁡\sigma_{\min}σmin​ is wrong by two orders of magnitude in either direction, the method remains competitive, though it does not actually outperform Keller until iteration 13 or 14.

我们首先研究输入矩阵的谱已知的理想情形。我们生成一个随机矩阵,其奇异值在 10−610^{-6}10−6 与 111 之间按对数均匀间隔排列。左、右奇异向量随机选取。图 4 左图给出结果。由于图中所有方法都使用五次多项式,它们的计算量和运行时间都与迭代次数成正比。如所预期,Newton-Schulz 会收敛,但前 17 步几乎没有进展。Jordan 的方法只需 11 步就能迅速把误差降到约 0.30.30.3,但之后不再继续收敛。You 的方法在图上不容易看清,因为它只定义了六步,收敛速度与 Jordan 的方法相近。当 Polar Express 取 ℓ=σmin⁡\ell=\sigma_{\min}ℓ=σmin​ 时,它在每一步都压过其他方法,只需 11 步就能达到很高的精度,并且收敛到任意给定误差的速度大约是 Newton-Schulz 的两倍。即便对 σmin⁡\sigma_{\min}σmin​ 下界的猜测在任一方向偏了两个数量级,该方法仍然具有竞争力,不过要到第 13 或 14 步才真正超过 Keller。

多项式方法在 GPT-2 梯度矩阵上的 Frobenius 范数收敛

Figure 5: Convergence of polynomial methods in the Frobenius norm on GPT-2 gradient matrices. The number of matrix-matrix products is T(d+1)/2T(d+1)/2T(d+1)/2, where ddd is the degree (333 for Chen & Chow; 555 for all others) and TTT is the number of iterations.

图 5:多项式方法在 GPT-2 梯度矩阵上、按 Frobenius 范数衡量的收敛。矩阵-矩阵乘法次数为 T(d+1)/2T(d+1)/2T(d+1)/2,其中 ddd 为次数(Chen & Chow 为 333,其余均为 555),TTT 为迭代次数。

Next we test the methods’ performance on a matrix from a real-world application, namely, the gradient of a weight matrix from the fourth transformer block of a GPT-2 architecture with respect to a language modeling objective on a batch of text from the Tiny Shakespeare dataset [24]. The right panel of Figure 4 shows the results. Once again, the best-tuned version of Polar Express outperforms the other methods. This time, we see that setting ℓ\ellℓ to be many orders of magnitude too small can delay convergence significantly, and make Polar Express less competitive as compared to Jordan’s method.

接下来我们在一个真实应用中的矩阵上测试这些方法的表现,即某个 GPT-2 架构第四个 Transformer 块中一个权重矩阵、相对于 Tiny Shakespeare 数据集 [24] 一批文本上的语言建模目标的梯度。图 4 右图给出结果。再一次,调得最好的 Polar Express 超过了其他方法。这一次我们看到,若把 ℓ\ellℓ 设得比真实值小许多个数量级,会显著推迟收敛,并使 Polar Express 相对 Jordan 方法的竞争力下降。

For most other weight matrices in this GPT-2 model, the methods all take more than 10 iterations to converge in the spectral norm. The spectral error is large if there is even one outlying singular value that is far from 111. However, for some applications, we may be satisfied with a weaker notion of convergence, like the relative Frobenius norm. Figure 5 shows the performance of various methods on this metric. We use gradient matrices of the same model, but from two different layers. In addition, we compare the degree-5 methods to Chen and Chow’s degree-3 method. To make this comparison fair, we measure the number of matrix-matrix products performed by each method instead the number of iterations. We find that Polar Express can once again dominate the other methods across iterations. Chen and Chow’s method is also quite competitive, and the remaining methods behave much as in Figure 4.

对该 GPT-2 模型中的大多数其他权重矩阵,这些方法都需要超过 10 步才能在谱范数下收敛。哪怕只有一个远离 111 的离群奇异值,谱误差也会很大。不过对某些应用,我们也许满足于更弱的收敛概念,例如相对 Frobenius 范数。图 5 展示了各方法在这一度量上的表现。我们使用同一模型、但来自两个不同层的梯度矩阵。此外,我们把五次方法与 Chen 和 Chow 的三次方法相比较。为使比较公平,我们统计每种方法执行的矩阵-矩阵乘法次数,而不是迭代次数。我们发现 Polar Express 可以再次在各步都压过其他方法。Chen 和 Chow 的方法也相当有竞争力,其余方法的表现则与图 4 大致相同。

5.2  Training GPT-2

5.2 训练 GPT-2

In our final experiment, we compare the performance of using our Polar Express method given in Algorithm 1 inside the Muon algorithm versus Jordan’s [22] and You’s [9] methods.

在最后一组实验中,我们比较把算法 1 给出的 Polar Express 方法放进 Muon 算法,与使用 Jordan [22] 和 You [9] 的方法时的表现。

Our experimental setup is based on the modified nanogpt code of Jordan [21]. We train two different GPT-2 models:

实验设置基于 Jordan 修改过的 nanogpt 代码 [21]。我们训练两种不同的 GPT-2 模型:

GPT-Small:nembd=768,nlayer=12,nhead=12GPT-Large:nembd=1280,nlayer=36,nhead=20\displaystyle\texttt{GPT-Small}: \\ \displaystyle\quad n_{\text{embd}}=768,\quad n_{\text{layer}}=12,\quad n_{\text{head}}=12 \\ \displaystyle\texttt{GPT-Large}: \\ \displaystyle\quad n_{\text{embd}}=1280,\quad n_{\text{layer}}=36,\quad n_{\text{head}}=20GPT-Small:nembd​=768,nlayer​=12,nhead​=12GPT-Large:nembd​=1280,nlayer​=36,nhead​=20

and a vocabulary size of 50,25750{,}25750,257, using a context length of 102410241024. Training is performed on 1B tokens from the FineWeb dataset [2], using a batch size of 32 and a single epoch. All models are trained with mixed precision (bfloat16) on 4 H100 GPUs. For all methods we use the learning rate schedule proposed in [21], consisting of a constant phase for the first 40% of training steps followed by a linear decay. All methods for the matrix sign computations are performed in float16b precision and use five iterations.

词表大小为 50,25750{,}25750,257,上下文长度为 102410241024。训练在 FineWeb 数据集 [2] 的 10 亿 token 上进行,批大小为 32,训练一个 epoch。所有模型都在 4 张 H100 GPU 上以混合精度(bfloat16)训练。对所有方法我们都采用 [21] 提出的学习率日程:前 40% 训练步保持恒定,随后线性衰减。所有矩阵符号计算都在 float16b 精度下进行,并使用五步迭代。

We apply Muon selectively to certain layers of the model. Following the nano-gpt implementation [21], we assign Muon to all parameters with at least two dimensions (typically weight matrices, and excluding RMS norm parameters), excluding the embeddings, unembeddings, and the attention head. These excluded parameters are instead optimized with AdamW.

我们对模型的某些层有选择地使用 Muon。沿用 nano-gpt 的实现 [21],我们把 Muon 分配给所有至少两维的参数(通常是权重矩阵,并排除 RMS 归一化参数),同时排除嵌入、反嵌入以及注意力头。这些被排除的参数改用 AdamW 优化。

GPT-2(124M)在 FineWeb 10 亿 token 上的训练

Figure 6: Training a GPT-2 (124M) model on 1 Billion tokens of the Fineweb data set [2]. The Legend muon- refers to using muon with the method for computing \polar(M)\polar(\bm{M})\polar(M). Top Left: The final validation loss vs. the learning rate. The final best validation losses for each method were, in reverse order, adamw: 4.1974.1974.197, muon-Jordan: 3.6393.6393.639, muon-You: 3.6293.6293.629 and muon-PolarExp: 3.5883.5883.588. Bottom Left: The final training loss vs the learning rate. Top Right: Validation loss vs. number of iterations. Bottom Left: validation loss vs. time, plotting each method with its best learning rate.

图 6:在 Fineweb 数据集 [2] 的 10 亿 token 上训练 GPT-2(124M)模型。图例 muon- 表示用 方法计算 \polar(M)\polar(\bm{M})\polar(M) 来实现 muon。左上:最终验证损失与学习率。各方法最终最好的验证损失从差到好依次为 adamw:4.1974.1974.197,muon-Jordan:3.6393.6393.639,muon-You:3.6293.6293.629,muon-PolarExp:3.5883.5883.588。左下:最终训练损失与学习率。右上:验证损失与迭代次数。左下:验证损失与时间,每种方法取其最优学习率作图。

Figure 1 and Figure 6 shows the resulting runs of each method in terms of validation loss and training loss on the GPT-Large and GPT-Small models, respectively. In both figures we can see that muon-PolarExp achieves a better validation and training loss than muon-Jordan or muon-You for every learning rate. Since each iteration of the different matrix sign methods are equally expensive (since they all apply a degree 5 polynomial), improved validation loss in terms of epochs also translates to an improved loss in terms of wall clock time (see bottom right of Figure 6). The advantage is remarkably consistent across all learning rates and epochs.

图 1 和图 6 分别给出各方法在 GPT-Large 和 GPT-Small 模型上、按验证损失和训练损失衡量的运行结果。两图都可以看到,对每一个学习率,muon-PolarExp 的验证损失和训练损失都优于 muon-Jordan 或 muon-You。由于不同矩阵符号方法的每一步代价相同(它们都作用一个五次多项式),按 epoch 衡量的验证损失改进,也会转化成按墙钟时间衡量的损失改进(见图 6 右下)。这一优势在所有学习率和所有 epoch 上都非常稳定。

References

参考文献

[1] N. I. Achieser. Theory of approximation . Dover Publications, Inc., New York, 1992. Translated from the Russian and with a preface by Charles J. Hyman, Reprint of the 1956 English translation.

[2] Samuel Aroca-Ouellette, Philippe Beaudoin, Guillaume Lajoie, Liam Paull, Joelle Pineau, Pascal Vincent, and Anirudh Goyal. Fineweb: Learning language models with high quality web data. In NeurIPS Datasets and Benchmarks Track , 2023. URL: https://arxiv.org/abs/2306.03061 .

[3] Michele Benzi and Ru Huang. Some matrix properties preserved by generalized matrix functions. Spec. Matrices , 7:27–37, 2019. doi:10.1515/spma-2019-0003 .

[4] Jeremy Bernstein and Laker Newhouse. Modular duality in deep learning. arXiv preprint arXiv:2410.21265 , 2024. URL: https://arxiv.org/abs/2410.21265 .

[5] Jeremy Bernstein and Laker Newhouse. Old optimizer, new norm: An anthology. arXiv preprint arXiv:2409.20325 , 2024. URL: https://arxiv.org/abs/2409.20325 .

[6] Ȧ. Björck and C. Bowie. An iterative algorithm for computing the best estimate of an orthogonal matrix. SIAM J. Numer. Anal. , 8:358–364, 1971. doi:10.1137/0708036 .

[7] Christos Boutsikas, Petros Drineas, and Ilse C. F. Ipsen. Small singular values can increase in lower precision. SIAM J. Matrix Anal. Appl. , 45(3):1518–1540, 2024. doi:10.1137/23M1557209 .

[8] J Douglas Carroll and Phipps Arabie. Multidimensional scaling. pages 179–250, 1998. URL: https://www.sciencedirect.com/science/article/pii/B9780120999750500051 , doi:10.1016/B978-012099975-0.50005-1 .

[9] Franz Louis Cesista, You Jiacheng, and Keller Jordan. Squeezing 1-2% efficiency gains out of muon by optimizing the newton-schulz coefficients, 2025. URL: http://leloykun.github.io/ponder/muon-opt-coeffs/ .

[10] PL Chebyshev. Questions on smallest quantities connected with the approximate representation of functions (1859). Collected works , 2:151–235, 1947.

[11] Jie Chen and Edmond Chow. A stable scaling of newton-schulz for improving the sign function computation of a hermitian matrix. Preprint ANL/MCS-P5059-0114 , 2014. URL: https://www.mcs.anl.gov/papers/P5059-0114.pdf .

[12] E. W. Cheney. Introduction to approximation theory . McGraw-Hill Book Co., New York-Toronto-London, 1966.

[13] John Duchi, Elad Hazan, and Yoram Singer. Adaptive subgradient methods for online learning and stochastic optimization. J. Mach. Learn. Res. , 12:2121–2159, 2011.

[14] Alexandre Eremenko and Peter Yuditskii. Uniform approximation of sgn ​ x {\rm sgn},x by polynomials and entire functions. J. Anal. Math. , 101:313–324, 2007. doi:10.1007/s11854-007-0011-3 .

[15] Gene H. Golub and Charles F. Van Loan. Matrix computations . Johns Hopkins Studies in the Mathematical Sciences. Johns Hopkins University Press, Baltimore, MD, fourth edition, 2013.

[16] J. C. Gower and G. B. Dijksterhuis. Procrustes problems , volume 30 of Oxford Statistical Science Series . Oxford University Press, Oxford, 2004. doi:10.1093/acprof:oso/9780198510581.001.0001 .

[17] Vineet Gupta, Tomer Koren, and Yoram Singer. Shampoo: Preconditioned stochastic tensor optimization. In Jennifer Dy and Andreas Krause, editors, Proceedings of the 35th International Conference on Machine Learning , volume 80 of Proceedings of Machine Learning Research , pages 1842–1850. PMLR, 10–15 Jul 2018. URL: https://proceedings.mlr.press/v80/gupta18a.html .

[18] Nicholas J. Higham. Computing the polar decomposition—with applications. SIAM J. Sci. Statist. Comput. , 7(4):1160–1174, 1986. doi:10.1137/0907079 .

[19] Nicholas J. Higham. Functions of matrices . SIAM, Philadelphia, PA, 2008. doi:10.1137/1.9780898717778 .

[20] Elias Jarlebring and Gustaf Lorentzon. The polynomial set associated with a fixed number of matrix-matrix multiplications. arXiv preprint arXiv:2504.01500 , 2025. URL: https://arxiv.org/abs/2504.01500 .

[21] Keller Jordan, Jeremy Bernstein, Brendan Rappazzo, @fernbear.bsky.social, Boza Vlado, You Jiacheng, Franz Cesista, Braden Koszarsky, and @Grad62304977. modded-nanogpt: Speedrunning the nanogpt baseline, 2024. URL: https://github.com/KellerJordan/modded-nanogpt .

[22] Keller Jordan, Yuchen Jin, Vlado Boza, Jiacheng You, Franz Cesista, Laker Newhouse, and Jeremy Bernstein. Muon: An optimizer for hidden layers in neural networks, 2024. URL: https://kellerjordan.github.io/posts/muon/ .

[23] Tetsuya Kaneko, Simone Fiori, and Toshihisa Tanaka. Empirical arithmetic averaging over the compact Stiefel manifold. IEEE Trans. Signal Process. , 61(4):883–894, 2013. doi:10.1109/TSP.2012.2226167 .

[24] Andrej Karpathy. char-rnn. https://github.com/karpathy/char-rnn , 2015.

[25] Charles Kenney and Alan J. Laub. Rational iterative methods for the matrix sign function. SIAM J. Matrix Anal. Appl. , 12(2):273–291, 1991. doi:10.1137/0612020 .

[26] Diederik P. Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In International Conference on Learning Representations , 2015. URL: http://arxiv.org/abs/1412.6980 .

[27] Zdislav Kovářík. Some iterative methods for improving orthonormality. SIAM J. Numer. Anal. , 7:386–389, 1970. doi:10.1137/0707031 .

[28] Eunsang Lee, Joon-Woo Lee, Jong-Seon No, and Young-Sik Kim. Minimax approximation of sign function by composite polynomial for homomorphic comparison. IEEE Transactions on Dependable and Secure Computing , 19(6):3711–3727, 2022. doi:10.1109/TDSC.2021.3105111 .

[29] R. B. Leipnik. Rapidly convergent recursive solution of quadratic operator equations. Numer. Math. , 17:1–16, 1971. doi:10.1007/BF01395861 .

[30] Jingyuan Liu, Jianlin Su, Xingcheng Yao, Zhejun Jiang, Guokun Lai, Yulun Du, Yidao Qin, Weixin Xu, Enzhe Lu, Junjie Yan, et al. Muon is scalable for LLM training. arXiv preprint arXiv:2502.16982 , 2025. URL: https://arxiv.org/abs/2502.16982 .

[31] Ilya Loshchilov and Frank Hutter. Decoupled weight decay regularization. In International Conference on Learning Representations , 2019. URL: https://openreview.net/forum?id=Bkg6RiCqY7 .

[32] Yuji Nakatsukasa, Zhaojun Bai, and François Gygi. Optimizing Halley’s iteration for computing the matrix polar decomposition. SIAM J. Matrix Anal. Appl. , 31(5):2700–2720, 2010. doi:10.1137/090774999 .

[33] Yuji Nakatsukasa and Roland W. Freund. Computing fundamental matrix decompositions accurately via the matrix sign function in two iterations: the power of Zolotarev’s functions. SIAM Rev. , 58(3):461–493, 2016. doi:10.1137/140990334 .

[34] Yuji Nakatsukasa and Nicholas J. Higham. Backward stability of iterations for computing the polar decomposition. SIAM J. Matrix Anal. Appl. , 33(2):460–479, 2012. doi:10.1137/110857544 .

[35] Yuji Nakatsukasa and Nicholas J. Higham. Stable and efficient spectral divide and conquer algorithms for the symmetric eigenvalue decomposition and the SVD. SIAM J. Sci. Comput. , 35(3):A1325–A1349, 2013. doi:10.1137/120876605 .

[36] Herbert Neuberger. Exactly massless quarks on the lattice. Phys. Lett. B , 417(1-2):141–144, 1998. doi:10.1016/S0370-2693(97)01368-3 .

[37] Ricardo Pachón and Lloyd N. Trefethen. Barycentric-Remez algorithms for best polynomial approximation in the chebfun system. BIT , 49(4):721–741, 2009. doi:10.1007/s10543-009-0240-1 .

[38] T Parks and James McClellan. Chebyshev approximation for nonrecursive digital filters with linear phase. IEEE Transactions on circuit theory , 19(2):189–194, 1972. doi:10.1109/TCT.1972.1083419 .

[39] Michael S. Paterson and Larry J. Stockmeyer. On the number of nonscalar multiplications necessary to evaluate polynomials. SIAM J. Comput. , 2:60–66, 1973. doi:10.1137/0202007 .

[40] Thomas Pethick, Wanyun Xie, Kimon Antonakopoulos, Zhenyu Zhu, Antonio Silveti-Falls, and Volkan Cevher. Training deep learning models with norm-constrained lmos, 2025. URL: https://arxiv.org/abs/2502.07529 , arXiv:2502.07529 .

[41] Artem Riabinin, Egor Shulgin, Kaja Gruntkowska, and Peter Richtárik. Gluon: Making muon & scion great again! (bridging theory and practice of lmo-based optimizers for llms), 2025. URL: https://arxiv.org/abs/2505.13416 , arXiv:2505.13416 .

[42] Ishaan Shah, Anthony M Polloreno, Karl Stratos, Philip Monk, Adarsh Chaluvaraju, Andrew Hojel, Andrew Ma, Anil Thomas, Ashish Tanwer, Darsh J Shah, et al. Practical efficiency of muon for pretraining. arXiv preprint arXiv:2505.02222 , 2025. URL: https://arxiv.org/abs/2505.02222 .

[43] Hao-Jun Michael Shi, Tsung-Hsien Lee, Shintaro Iwasaki, Jose Gallego-Posada, Zhijing Li, Kaushik Rangadurai, Dheevatsa Mudigere, and Michael Rabbat. A distributed data-parallel PyTorch implementation of the distributed Shampoo optimizer for training neural networks at-scale. arXiv preprint arXiv:2309.06497 , 2023. URL: https://arxiv.org/abs/2309.06497 .

[44] Modula Systems. Newton-schulz algorithm — jiacheng’s six-step method. https://docs.modula.systems/algorithms/newton-schulz/#jiacheng-s-six-step , 2024. Accessed: 2025-05-19.

[45] Attila Szabo and Neil S Ostlund. Modern quantum chemistry: introduction to advanced electronic structure theory . Courier Corporation, 1996.

[46] Lloyd N. Trefethen. Approximation theory and approximation practice . Society for Industrial and Applied Mathematics (SIAM), Philadelphia, PA, extended edition, 2020.

[47] Nikhil Vyas, Depen Morwani, Rosie Zhao, Itai Shapira, David Brandfonbrener, Lucas Janson, and Sham M. Kakade. SOAP: Improving and stabilizing shampoo using adam for language modeling. In The Thirteenth International Conference on Learning Representations , 2025. URL: https://openreview.net/forum?id=IDxZhXrpNf .

[48] Greg Yang, James B. Simon, and Jeremy Bernstein. A spectral condition for feature learning, 2024. URL: https://arxiv.org/abs/2310.17813 , arXiv:2310.17813 .

[49] Zhenyue Zhang, Hongyuan Zha, and Wenlong Ying. Fast parallelizable methods for computing invariant subspaces of Hermitian matrices. J. Comput. Math. , 25(5):583–594, 2007. URL: http://www.jstor.org/stable/43693395 .

Appendix A Proof of Theorem 4.1

附录 A 定理 4.1 的证明

The aim of this section is to prove Theorem 4.1. We begin with a result that provides a few essential properties for the the polynomial solving (7) when T=1T=1T=1. This result is known as Chebyshev’s theorem [10] or the equioscillation theorem [46, Chapter 10].

本节旨在证明定理 4.1。我们先给出一个结果,它提供当 T=1T=1T=1 时求解 (7) 的多项式的若干基本性质。该结果称为 Chebyshev 定理 [10],或等振荡定理 [46, 第 10 章]。

A.1.

Let d=2q+1d=2q+1d=2q+1 and u,ℓ>0u,\ell>0u,ℓ>0. Consider the problem

A.1。

设 d=2q+1d=2q+1d=2q+1 且 u,ℓ>0u,\ell>0u,ℓ>0。考虑问题

min⁡p∈Pd\oddmax⁡x∈[ℓ,u]∣1−p(x)∣.(16)\min\limits_{p\in\mathbb{P}_{d}^{\odd}}\max\limits_{x\in[\ell,u]}|1-p(x)|. \tag{16}p∈Pd\odd​min​x∈[ℓ,u]max​∣1−p(x)∣.(16)

There exists a unique polynomial p⋆∈Pd\oddp^{\star}\in\mathbb{P}_{d}^{\odd}p⋆∈Pd\odd​ solving (16). Furthermore, p⋆p^{\star}p⋆ is the unique solution to the above problem if and only if there exist q+2q+2q+2 distinct points {x0,…,xq+1}⊂[ℓ,u]\{x_{0},\ldots,x_{q+1}\}\subset[\ell,u]{x0​,…,xq+1​}⊂[ℓ,u] such that

存在唯一的多项式 p⋆∈Pd\oddp^{\star}\in\mathbb{P}_{d}^{\odd}p⋆∈Pd\odd​ 求解 (16)。此外,p⋆p^{\star}p⋆ 是上述问题的唯一解,当且仅当存在 q+2q+2q+2 个互异的点 {x0,…,xq+1}⊂[ℓ,u]\{x_{0},\ldots,x_{q+1}\}\subset[\ell,u]{x0​,…,xq+1​}⊂[ℓ,u] 使得

1−p⋆(xi)  =  η(−1)imax⁡x∈[ℓ,u]∣1−p⋆(x)∣,\mboxfor  i=0,…,q+1,1-p^{\star}(x_{i})\;=\;\eta(-1)^{i}\max\limits_{x\in[\ell,u]}|1-p^{\star}(x)|,\quad\mbox{for}\;i=0,\ldots,q+1,1−p⋆(xi​)=η(−1)ix∈[ℓ,u]max​∣1−p⋆(x)∣,\mboxfori=0,…,q+1,

for η=1\eta=1η=1 or η=−1\eta=-1η=−1.

其中 η=1\eta=1η=1 或 η=−1\eta=-1η=−1。

Proof.

A discussion can be found in [14]. Here we include a formal proof for completeness.

证明。

相关讨论见 [14]。这里为完整起见给出一个形式证明。

By Chebyshev’s Theorem [1, 10, 12] it is sufficient to show that Pd\odd\mathbb{P}_{d}^{\odd}Pd\odd​ satisfies the Haar condition: any non-zero p∈Pd\odd=\mboxspan{x,…,x3,…,x2q+1}p\in\mathbb{P}_{d}^{\odd}=\mbox{span}\{x,\ldots,x^{3},\ldots,x^{2q+1}\}p∈Pd\odd​=\mboxspan{x,…,x3,…,x2q+1} can have at most qqq roots in [ℓ,u][\ell,u][ℓ,u].

由 Chebyshev 定理 [1, 10, 12],只需证明 Pd\odd\mathbb{P}_{d}^{\odd}Pd\odd​ 满足 Haar 条件:任意非零 p∈Pd\odd=\mboxspan{x,…,x3,…,x2q+1}p\in\mathbb{P}_{d}^{\odd}=\mbox{span}\{x,\ldots,x^{3},\ldots,x^{2q+1}\}p∈Pd\odd​=\mboxspan{x,…,x3,…,x2q+1} 在 [ℓ,u][\ell,u][ℓ,u] 内至多有 qqq 个根。

Since deg⁡(p)=d=2q+1\deg(p)=d=2q+1deg(p)=d=2q+1 we know that ppp can have at most 2q+12q+12q+1 roots in R\mathbb{R}R. However, since p(0)=0p(0)=0p(0)=0 and p(x)=−p(−x)p(x)=-p(-x)p(x)=−p(−x) we know that ppp has one root at zero, and the remaining roots come in symmetric pairs (x,−x)(x,-x)(x,−x). Because of this, ppp can have at most qqq roots in the positive orthant, and thus it can have at most qqq roots in [ℓ,u]⊂(0,∞)[\ell,u]\subset(0,\infty)[ℓ,u]⊂(0,∞). Hence, Pd\odd\mathbb{P}_{d}^{\odd}Pd\odd​ satisfies the Haar condition, which yields the desired result.

由于 deg⁡(p)=d=2q+1\deg(p)=d=2q+1deg(p)=d=2q+1,我们知道 ppp 在 R\mathbb{R}R 上至多有 2q+12q+12q+1 个根。不过,由于 p(0)=0p(0)=0p(0)=0 且 p(x)=−p(−x)p(x)=-p(-x)p(x)=−p(−x),我们知道 ppp 在零点有一个根,其余根成对称对 (x,−x)(x,-x)(x,−x) 出现。因此,ppp 在正半轴上至多有 qqq 个根,从而在 [ℓ,u]⊂(0,∞)[\ell,u]\subset(0,\infty)[ℓ,u]⊂(0,∞) 内至多有 qqq 个根。于是 Pd\odd\mathbb{P}_{d}^{\odd}Pd\odd​ 满足 Haar 条件,这就给出了所需结果。

∎

The proof of Theorem 4.1 will be by induction on TTT. We begin by establishing the base case, T=1T=1T=1, which is handled by the following result.

定理 4.1 的证明将对 TTT 做归纳。我们先建立基础情形 T=1T=1T=1,由下面的结果处理。

A.2.

Let u,ℓ>0u,\ell>0u,ℓ>0 and define

A.2。

设 u,ℓ>0u,\ell>0u,ℓ>0 并定义

p⋆:=arg min⁡p∈Pd∗max⁡x∈[ℓ,u]∣1−p(x)∣.p^{\star}:=\argmin\limits_{p\in\mathbb{P}_{d}^{*}}\max\limits_{x\in[\ell,u]}|1-p(x)|.p⋆:=p∈Pd∗​argmin​x∈[ℓ,u]max​∣1−p(x)∣.

Then

则

p⋆(ℓ)=min⁡x∈[ℓ,u]p⋆(x),max⁡x∈[ℓ,u]p⋆(x)=2−p⋆(ℓ), and max⁡x∈[ℓ,u]∣1−p⋆(x)∣=1−p⋆(ℓ).p^{\star}(\ell)=\min\limits_{x\in[\ell,u]}p^{\star}(x),\quad\max\limits_{x\in[\ell,u]}p^{\star}(x)=2-p^{\star}(\ell),\text{ and }\max\limits_{x\in[\ell,u]}|1-p^{\star}(x)|=1-p^{\star}(\ell).p⋆(ℓ)=x∈[ℓ,u]min​p⋆(x),x∈[ℓ,u]max​p⋆(x)=2−p⋆(ℓ), and x∈[ℓ,u]max​∣1−p⋆(x)∣=1−p⋆(ℓ).

Proof.

Throughout the proof we assume d=2q+1d=2q+1d=2q+1. We begin with proving

证明。

整个证明中我们假定 d=2q+1d=2q+1d=2q+1。我们先证明

p⋆(ℓ)=min⁡x∈[ℓ,u]p⋆(x).p^{\star}(\ell)=\min\limits_{x\in[\ell,u]}p^{\star}(x).p⋆(ℓ)=x∈[ℓ,u]min​p⋆(x).

Consider the polynomial e(x):=1−p⋆(x)e(x):=1-p^{\star}(x)e(x):=1−p⋆(x). The proof will contain three steps. We first rule out the trivial case that p⋆≠0p^{\star}\neq 0p⋆=0, since p(x)=2ℓ+uxp(x)=\frac{2}{\ell+u}xp(x)=ℓ+u2​x would then be a better approximation. Hence, p⋆p^{\star}p⋆ cannot be the zero polynomial.

考虑多项式 e(x):=1−p⋆(x)e(x):=1-p^{\star}(x)e(x):=1−p⋆(x)。证明分三步。我们先排除 p⋆p^{\star}p⋆ 为零多项式这一平凡情形,因为否则 p(x)=2ℓ+uxp(x)=\frac{2}{\ell+u}xp(x)=ℓ+u2​x 会是更好的逼近。因此 p⋆p^{\star}p⋆ 不可能是零多项式。

Step 1: e(x)e(x)e(x) has exactly qqq stationary points inside the open interval (ℓ,u)(\ell,u)(ℓ,u).

第一步:e(x)e(x)e(x) 在开区间 (ℓ,u)(\ell,u)(ℓ,u) 内恰好有 qqq 个驻点。

Note that e(x)e(x)e(x) has at most 2q2q2q stationary points in R\mathbb{R}R, since its derivative e′(x)e^{\prime}(x)e′(x) is a polynomial of degree 2q2q2q. Furthermore, since p⋆p^{\star}p⋆ is odd, we have that e′(x)=−p′(x)e^{\prime}(x)=-p^{\prime}(x)e′(x)=−p′(x) is even of degree 2q2q2q, and thus can have at most qqq stationary points contained in (0,+∞)(0,+\infty)(0,+∞). Hence, there can be at most qqq stationary points of e(x)e(x)e(x) inside the interval [ℓ,u][\ell,u][ℓ,u].

注意 e(x)e(x)e(x) 在 R\mathbb{R}R 上至多有 2q2q2q 个驻点,因为它的导数 e′(x)e^{\prime}(x)e′(x) 是次数为 2q2q2q 的多项式。此外,由于 p⋆p^{\star}p⋆ 是奇函数,我们有 e′(x)=−p′(x)e^{\prime}(x)=-p^{\prime}(x)e′(x)=−p′(x) 是次数为 2q2q2q 的偶函数,因而在 (0,+∞)(0,+\infty)(0,+∞) 内至多有 qqq 个驻点。因此 e(x)e(x)e(x) 在区间 [ℓ,u][\ell,u][ℓ,u] 内至多有 qqq 个驻点。

By Lemma A.1 there are q+2q+2q+2 points x0,…,xq+1∈[ℓ,u]x_{0},\ldots,x_{q+1}\in[\ell,u]x0​,…,xq+1​∈[ℓ,u] where e(x)e(x)e(x) is maximized or minimized in [ℓ,u][\ell,u][ℓ,u]. These points are either stationary points or they are endpoints of the interval [ℓ,u][\ell,u][ℓ,u]. Let nextn_{\text{ext}}next​ be the number of stationary points and nstatn_{\text{stat}}nstat​ be the number of endpoints in the set {x0,…,xq+1}\{x_{0},\ldots,x_{q+1}\}{x0​,…,xq+1​}. Since a point can be both a stationary point and an endpoint we have q+2≤nend+nstatq+2\leq n_{\text{end}}+n_{\text{stat}}q+2≤nend​+nstat​. However, nend≤2n_{\text{end}}\leq 2nend​≤2 and nstat≤qn_{\text{stat}}\leq qnstat​≤q, which follows from the previous paragraph where we showed that there are at most qqq stationary points of e(x)e(x)e(x) in [ℓ,u][\ell,u][ℓ,u]. So nend+nstat≤q+2n_{\text{end}}+n_{\text{stat}}\leq q+2nend​+nstat​≤q+2, and consequently we must have nend=2n_{\text{end}}=2nend​=2 and nstat=qn_{\text{stat}}=qnstat​=q, as required.

由引理 A.1,存在 q+2q+2q+2 个点 x0,…,xq+1∈[ℓ,u]x_{0},\ldots,x_{q+1}\in[\ell,u]x0​,…,xq+1​∈[ℓ,u],使 e(x)e(x)e(x) 在 [ℓ,u][\ell,u][ℓ,u] 上在这些点取到极大或极小。这些点要么是驻点,要么是区间 [ℓ,u][\ell,u][ℓ,u] 的端点。设 nextn_{\text{ext}}next​ 为驻点个数,nstatn_{\text{stat}}nstat​ 为集合 {x0,…,xq+1}\{x_{0},\ldots,x_{q+1}\}{x0​,…,xq+1​} 中端点的个数。由于一个点可以既是驻点又是端点,我们有 q+2≤nend+nstatq+2\leq n_{\text{end}}+n_{\text{stat}}q+2≤nend​+nstat​。不过 nend≤2n_{\text{end}}\leq 2nend​≤2 且 nstat≤qn_{\text{stat}}\leq qnstat​≤q,这来自上一段我们证明的、e(x)e(x)e(x) 在 [ℓ,u][\ell,u][ℓ,u] 内至多有 qqq 个驻点。于是 nend+nstat≤q+2n_{\text{end}}+n_{\text{stat}}\leq q+2nend​+nstat​≤q+2,因而必须有 nend=2n_{\text{end}}=2nend​=2 且 nstat=qn_{\text{stat}}=qnstat​=q,此即所需。

Step 2: x=ℓx=\ellx=ℓ is a maximum of e(x)e(x)e(x) on the interval [ℓ,u][\ell,u][ℓ,u]

第二步:x=ℓx=\ellx=ℓ 是 e(x)e(x)e(x) 在区间 [ℓ,u][\ell,u][ℓ,u] 上的一个极大点

By Lemma A.1 and the discussion from Step 1, we know that ∣e(x)∣|e(x)|∣e(x)∣ is maximized at q+2q+2q+2 points inside [ℓ,u][\ell,u][ℓ,u] and qqq of these points are contained inside the open interval (ℓ,u)(\ell,u)(ℓ,u). Hence, x=ℓx=\ellx=ℓ must either be a maximum or a minimum of e(x)e(x)e(x). We will show that x=ℓx=\ellx=ℓ must be a maximum by contradiction.

由引理 A.1 以及第一步的讨论,我们知道 ∣e(x)∣|e(x)|∣e(x)∣ 在 [ℓ,u][\ell,u][ℓ,u] 内的 q+2q+2q+2 个点上取到最大值,且其中 qqq 个点落在开区间 (ℓ,u)(\ell,u)(ℓ,u) 内。因此 x=ℓx=\ellx=ℓ 必须是 e(x)e(x)e(x) 的一个极大或极小。我们将用反证法证明 x=ℓx=\ellx=ℓ 必须是极大。

Suppose x=ℓx=\ellx=ℓ was a minimum of e(x)e(x)e(x) on [ℓ,u][\ell,u][ℓ,u]. First note that p⋆p^{\star}p⋆ is trivially non-negative on [ℓ,u][\ell,u][ℓ,u], or else p(x)=0p(x)=0p(x)=0 would be a better polynomial. Hence, since p⋆(0)=0p^{\star}(0)=0p⋆(0)=0 we must have p∗′(δ)>0{p^{*}}^{\prime}(\delta)>0p∗′(δ)>0 for some δ∈[0,ℓ]\delta\in[0,\ell]δ∈[0,ℓ], or else the zero polynomial p(x)=0p(x)=0p(x)=0 would be a better approximation. Hence, for some δ∈[0,ℓ]\delta\in[0,\ell]δ∈[0,ℓ] we have e′(δ)<0e^{\prime}(\delta)<0e′(δ)<0.

假设 x=ℓx=\ellx=ℓ 是 e(x)e(x)e(x) 在 [ℓ,u][\ell,u][ℓ,u] 上的一个极小。首先注意 p⋆p^{\star}p⋆ 在 [ℓ,u][\ell,u][ℓ,u] 上显然非负,否则 p(x)=0p(x)=0p(x)=0 会是更好的多项式。因此,由于 p⋆(0)=0p^{\star}(0)=0p⋆(0)=0,对某个 δ∈[0,ℓ]\delta\in[0,\ell]δ∈[0,ℓ] 必须有 p∗′(δ)>0{p^{*}}^{\prime}(\delta)>0p∗′(δ)>0,否则零多项式 p(x)=0p(x)=0p(x)=0 会是更好的逼近。于是对某个 δ∈[0,ℓ]\delta\in[0,\ell]δ∈[0,ℓ] 有 e′(δ)<0e^{\prime}(\delta)<0e′(δ)<0。

We must also have e′(ℓ)≥0e^{\prime}(\ell)\geq 0e′(ℓ)≥0 or else x=ℓx=\ellx=ℓ is not a minimum of e(x)e(x)e(x). Since e′(δ)<0e^{\prime}(\delta)<0e′(δ)<0 for some δ∈[0,ℓ]\delta\in[0,\ell]δ∈[0,ℓ] and e′(ℓ)≥0e^{\prime}(\ell)\geq 0e′(ℓ)≥0, by the intermediate value theorem there exists a point x∗∈[0,ℓ]x^{*}\in[0,\ell]x∗∈[0,ℓ] such that e′(x∗)=0e^{\prime}(x^{*})=0e′(x∗)=0. However, by the discussion above we know that all stationary points of eee are contained inside the open interval (ℓ,u)(\ell,u)(ℓ,u). Hence, x=ℓx=\ellx=ℓ cannot be a minimum of e(x)e(x)e(x) on [ℓ,u][\ell,u][ℓ,u]. However, by Step 1 we know that the endpoints of [ℓ,u][\ell,u][ℓ,u] must be either minima or maxima of e(x)e(x)e(x). Hence, x=ℓx=\ellx=ℓ is a maximum of e(x)e(x)e(x) on [ℓ,u][\ell,u][ℓ,u].

我们还必须有 e′(ℓ)≥0e^{\prime}(\ell)\geq 0e′(ℓ)≥0,否则 x=ℓx=\ellx=ℓ 就不是 e(x)e(x)e(x) 的极小。既然对某个 δ∈[0,ℓ]\delta\in[0,\ell]δ∈[0,ℓ] 有 e′(δ)<0e^{\prime}(\delta)<0e′(δ)<0 且 e′(ℓ)≥0e^{\prime}(\ell)\geq 0e′(ℓ)≥0,由介值定理存在一点 x∗∈[0,ℓ]x^{*}\in[0,\ell]x∗∈[0,ℓ] 使得 e′(x∗)=0e^{\prime}(x^{*})=0e′(x∗)=0。但由上面的讨论,我们知道 eee 的所有驻点都落在开区间 (ℓ,u)(\ell,u)(ℓ,u) 内。因此 x=ℓx=\ellx=ℓ 不可能是 e(x)e(x)e(x) 在 [ℓ,u][\ell,u][ℓ,u] 上的极小。然而由第一步我们知道 [ℓ,u][\ell,u][ℓ,u] 的端点必须是 e(x)e(x)e(x) 的极小或极大。因此 x=ℓx=\ellx=ℓ 是 e(x)e(x)e(x) 在 [ℓ,u][\ell,u][ℓ,u] 上的一个极大。

Step 3: Obtaining the desired equalities

第三步:得到所需的等式

Since e(x)e(x)e(x) has a maximum in [ℓ,u][\ell,u][ℓ,u] at x=ℓx=\ellx=ℓ, we have p⋆(ℓ)=min⁡x∈[ℓ,u]p⋆(x)p^{\star}(\ell)=\min\limits_{x\in[\ell,u]}p^{\star}(x)p⋆(ℓ)=x∈[ℓ,u]min​p⋆(x). The other two equalities are immediate consequences of the equioscillation property of p⋆p^{\star}p⋆ Lemma A.1 and that x=ℓx=\ellx=ℓ is a minimum of p⋆p^{\star}p⋆ over the set [ℓ,u][\ell,u][ℓ,u]. ∎

由于 e(x)e(x)e(x) 在 [ℓ,u][\ell,u][ℓ,u] 上于 x=ℓx=\ellx=ℓ 取到极大,我们有 p⋆(ℓ)=min⁡x∈[ℓ,u]p⋆(x)p^{\star}(\ell)=\min\limits_{x\in[\ell,u]}p^{\star}(x)p⋆(ℓ)=x∈[ℓ,u]min​p⋆(x)。另外两个等式是 p⋆p^{\star}p⋆ 的等振荡性质(引理 A.1)以及 x=ℓx=\ellx=ℓ 是 p⋆p^{\star}p⋆ 在集合 [ℓ,u][\ell,u][ℓ,u] 上的极小这一事实的直接推论。∎

With the above-mentioned result in hand, we are ready to prove Theorem 4.1.

有了上述结果,我们就可以证明定理 4.1。

See 4.1

见 4.1

Proof.

The proof of (10) is an immediate consequence of Lemma A.2, since for each t=1,…,Tt=1,\ldots,Tt=1,…,T, ptp_{t}pt​ is the optimal approximation in Pd\odd\mathbb{P}_{d}^{\odd}Pd\odd​ to x↦1x\mapsto 1x↦1.

证明。

(10) 的证明是引理 A.2 的直接推论,因为对每个 t=1,…,Tt=1,\ldots,Tt=1,…,T,ptp_{t}pt​ 都是 Pd\odd\mathbb{P}_{d}^{\odd}Pd\odd​ 中对 x↦1x\mapsto 1x↦1 的最优逼近。

We now proceed with the proof of (11), which will be by induction. The proof for T=1T=1T=1 is an immediate consequence of Lemma A.2 and we also have p⋆(ℓ)=ℓ2p^{\star}(\ell)=\ell_{2}p⋆(ℓ)=ℓ2​ by (10). Now suppose the result is true for all t≤T−1t\leq T-1t≤T−1. For t=1,…,T−1t=1,\ldots,T-1t=1,…,T−1, note that the image of ptp_{t}pt​ on [ℓt,ut][\ell_{t},u_{t}][ℓt​,ut​] is exactly [ℓt+1,ut+1][\ell_{t+1},u_{t+1}][ℓt+1​,ut+1​] by i). Hence, if we define g(x):=pT−1∘⋯∘p1(x)g(x):=p_{T-1}\circ\cdots\circ p_{1}(x)g(x):=pT−1​∘⋯∘p1​(x), then the image of ggg on [ℓ,u][\ell,u][ℓ,u] is [ℓT,uT][\ell_{T},u_{T}][ℓT​,uT​]. Furthermore, by i) we also have g(ℓ)=ℓTg(\ell)=\ell_{T}g(ℓ)=ℓT​. Pick any fff such that f≠gf\neq gf=g and

我们接着用归纳法证明 (11)。T=1T=1T=1 时的证明是引理 A.2 的直接推论,并且由 (10) 还有 p⋆(ℓ)=ℓ2p^{\star}(\ell)=\ell_{2}p⋆(ℓ)=ℓ2​。现在假设结果对所有 t≤T−1t\leq T-1t≤T−1 成立。对 t=1,…,T−1t=1,\ldots,T-1t=1,…,T−1,注意 ptp_{t}pt​ 在 [ℓt,ut][\ell_{t},u_{t}][ℓt​,ut​] 上的像恰好是 [ℓt+1,ut+1][\ell_{t+1},u_{t+1}][ℓt+1​,ut+1​],这由 i) 得出。因此,若定义 g(x):=pT−1∘⋯∘p1(x)g(x):=p_{T-1}\circ\cdots\circ p_{1}(x)g(x):=pT−1​∘⋯∘p1​(x),则 ggg 在 [ℓ,u][\ell,u][ℓ,u] 上的像是 [ℓT,uT][\ell_{T},u_{T}][ℓT​,uT​]。此外,由 i) 还有 g(ℓ)=ℓTg(\ell)=\ell_{T}g(ℓ)=ℓT​。任取满足 f≠gf\neq gf=g 且

f=p~T−1∘⋯∘p~1,f=\widetilde{p}_{T-1}\circ\cdots\circ\widetilde{p}_{1},f=p​T−1​∘⋯∘p​1​,

for some p~1,…,p~T−1∈Pd\odd\widetilde{p}_{1},\ldots,\widetilde{p}_{T-1}\in\mathbb{P}_{d}^{\odd}p​1​,…,p​T−1​∈Pd\odd​. Let the image of fff on [ℓ,u][\ell,u][ℓ,u] be [a,b][a,b][a,b]. We will prove that ab≤ℓTuT\frac{a}{b}\leq\frac{\ell_{T}}{u_{T}}ba​≤uT​ℓT​​ by contradiction.

的 fff,其中 p~1,…,p~T−1∈Pd\odd\widetilde{p}_{1},\ldots,\widetilde{p}_{T-1}\in\mathbb{P}_{d}^{\odd}p​1​,…,p​T−1​∈Pd\odd​。设 fff 在 [ℓ,u][\ell,u][ℓ,u] 上的像为 [a,b][a,b][a,b]。我们将用反证法证明 ab≤ℓTuT\frac{a}{b}\leq\frac{\ell_{T}}{u_{T}}ba​≤uT​ℓT​​。

Suppose ab>ℓTuT\frac{a}{b}>\frac{\ell_{T}}{u_{T}}ba​>uT​ℓT​​. Define c=2a+bc=\frac{2}{a+b}c=a+b2​. Then, the image of the scaled function cfcfcf on [ℓ,u][\ell,u][ℓ,u] is [ca,cb][ca,cb][ca,cb] and cfcfcf satisfies

假设 ab>ℓTuT\frac{a}{b}>\frac{\ell_{T}}{u_{T}}ba​>uT​ℓT​​。定义 c=2a+bc=\frac{2}{a+b}c=a+b2​。则缩放后的函数 cfcfcf 在 [ℓ,u][\ell,u][ℓ,u] 上的像是 [ca,cb][ca,cb][ca,cb],并且 cfcfcf 满足

max⁡x∈[ℓ,u]∣1−cf(x)∣=max⁡{1−ca,cb−1}=b−aa+b.\max\limits_{x\in[\ell,u]}|1-cf(x)|=\max\left\{1-ca,cb-1\right\}=\frac{b-a}{a+b}.x∈[ℓ,u]max​∣1−cf(x)∣=max{1−ca,cb−1}=a+bb−a​.

Recall by our inductive hypothesis, we have max⁡x∈[ℓ,u]∣1−g(x)∣=1−ℓT=uT−1\max\limits_{x\in[\ell,u]}|1-g(x)|=1-\ell_{T}=u_{T}-1x∈[ℓ,u]max​∣1−g(x)∣=1−ℓT​=uT​−1 where the second equality holds by (10). It follows that

回忆由归纳假设,我们有 max⁡x∈[ℓ,u]∣1−g(x)∣=1−ℓT=uT−1\max\limits_{x\in[\ell,u]}|1-g(x)|=1-\ell_{T}=u_{T}-1x∈[ℓ,u]max​∣1−g(x)∣=1−ℓT​=uT​−1,其中第二个等号由 (10) 成立。于是

ab>ℓTuT⇔ab>ℓT2−ℓT⇔ℓT<2aa+b⇔1−ℓT>b−aa+b⇔max⁡x∈[ℓ,u]∣1−g(x)∣>max⁡x∈[ℓ,u]∣1−cf(x)∣,\displaystyle\frac{a}{b} \\ \displaystyle>\frac{\ell_{T}}{u_{T}} \\ \displaystyle\Leftrightarrow\frac{a}{b} \\ \displaystyle>\frac{\ell_{T}}{2-\ell_{T}} \\ \displaystyle\Leftrightarrow\ell_{T} \\ \displaystyle<\frac{2a}{a+b} \\ \displaystyle\Leftrightarrow 1-\ell_{T} \\ \displaystyle>\frac{b-a}{a+b} \\ \displaystyle\Leftrightarrow\max\limits_{x\in[\ell,u]}|1-g(x)| \\ \displaystyle>\max\limits_{x\in[\ell,u]}|1-cf(x)|,ba​>uT​ℓT​​⇔ba​>2−ℓT​ℓT​​⇔ℓT​<a+b2a​⇔1−ℓT​>a+bb−a​⇔x∈[ℓ,u]max​∣1−g(x)∣>x∈[ℓ,u]max​∣1−cf(x)∣,

which leads to a contradiction to our inductive hypothesis that ggg is optimal. Hence, we must have ab≤ℓTuT\frac{a}{b}\leq\frac{\ell_{T}}{u_{T}}ba​≤uT​ℓT​​.

这与归纳假设中 ggg 为最优相矛盾。因此必须有 ab≤ℓTuT\frac{a}{b}\leq\frac{\ell_{T}}{u_{T}}ba​≤uT​ℓT​​。

Consequently, using that ab≤ℓTuT\frac{a}{b}\leq\frac{\ell_{T}}{u_{T}}ba​≤uT​ℓT​​, we will show that for any p~T∈Pd\odd\widetilde{p}_{T}\in\mathbb{P}_{d}^{\odd}p​T​∈Pd\odd​ and for any f=p~T−1∘⋯∘p~1f=\widetilde{p}_{T-1}\circ\cdots\circ\widetilde{p}_{1}f=p​T−1​∘⋯∘p​1​ p~T∘f\widetilde{p}_{T}\circ fp​T​∘f cannot be a better approximation than pT∘gp_{T}\circ gpT​∘g. In particular, we have

于是,利用 ab≤ℓTuT\frac{a}{b}\leq\frac{\ell_{T}}{u_{T}}ba​≤uT​ℓT​​,我们将证明对任意 p~T∈Pd\odd\widetilde{p}_{T}\in\mathbb{P}_{d}^{\odd}p​T​∈Pd\odd​ 以及任意 f=p~T−1∘⋯∘p~1f=\widetilde{p}_{T-1}\circ\cdots\circ\widetilde{p}_{1}f=p​T−1​∘⋯∘p​1​,p~T∘f\widetilde{p}_{T}\circ fp​T​∘f 都不可能比 pT∘gp_{T}\circ gpT​∘g 更好。具体来说,我们有

max⁡x∈[ℓ,u]∣1−p~T(f(x))∣≥min⁡p∈Pd∗max⁡x∈[ℓ,u]∣1−p(f(x))∣=min⁡p∈Pd∗max⁡x∈[a,b]∣1−p(x)∣=min⁡p∈Pd∗max⁡x∈[a/b,1]∣1−p(x)∣≥min⁡p∈Pd∗max⁡x∈[ℓT/uT,1]∣1−p(x)∣=min⁡p∈Pd∗max⁡x∈[ℓT,uT]∣1−p(x)∣=min⁡p∈Pd∗max⁡x∈[ℓ,u]∣1−p(g(x))∣=max⁡x∈[ℓT,uT]∣1−pT(g(x))∣=1−pT(ℓT)=1−ℓT+1,\displaystyle\max\limits_{x\in[\ell,u]}|1-\widetilde{p}_{T}(f(x))| \\ \displaystyle\geq\min\limits_{p\in\mathbb{P}_{d}^{*}}\max\limits_{x\in[\ell,u]}|1-p(f(x))| \\ \displaystyle=\min\limits_{p\in\mathbb{P}_{d}^{*}}\max\limits_{x\in[a,b]}|1-p(x)| \\ \displaystyle=\min\limits_{p\in\mathbb{P}_{d}^{*}}\max\limits_{x\in[a/b,1]}|1-p(x)| \\ \displaystyle\geq\min\limits_{p\in\mathbb{P}_{d}^{*}}\max\limits_{x\in[\ell_{T}/u_{T},1]}|1-p(x)| \\ \displaystyle=\min\limits_{p\in\mathbb{P}_{d}^{*}}\max\limits_{x\in[\ell_{T},u_{T}]}|1-p(x)| \\ \displaystyle=\min\limits_{p\in\mathbb{P}_{d}^{*}}\max\limits_{x\in[\ell,u]}|1-p(g(x))| \\ \displaystyle=\max\limits_{x\in[\ell_{T},u_{T}]}|1-p_{T}(g(x))|=1-p_{T}(\ell_{T})=1-\ell_{T+1},x∈[ℓ,u]max​∣1−p​T​(f(x))∣≥p∈Pd∗​min​x∈[ℓ,u]max​∣1−p(f(x))∣=p∈Pd∗​min​x∈[a,b]max​∣1−p(x)∣=p∈Pd∗​min​x∈[a/b,1]max​∣1−p(x)∣≥p∈Pd∗​min​x∈[ℓT​/uT​,1]max​∣1−p(x)∣=p∈Pd∗​min​x∈[ℓT​,uT​]max​∣1−p(x)∣=p∈Pd∗​min​x∈[ℓ,u]max​∣1−p(g(x))∣=x∈[ℓT​,uT​]max​∣1−pT​(g(x))∣=1−pT​(ℓT​)=1−ℓT+1​,

where the second and third equality follow by changing variables y=x/by=x/by=x/b so that

其中第二、第三个等号来自变量替换 y=x/by=x/by=x/b,从而

min⁡p∈Pd∗max⁡x∈[a,b]∣1−p(x)∣=min⁡p∈Pd∗max⁡y∈[a/b,1]∣1−p(by)∣=min⁡p∈Pd∗max⁡y∈[a/b,1]∣1−p(y)∣\min\limits_{p\in\mathbb{P}_{d}^{*}}\max\limits_{x\in[a,b]}|1-p(x)|=\min\limits_{p\in\mathbb{P}_{d}^{*}}\max\limits_{y\in[a/b,1]}|1-p(by)|=\min\limits_{p\in\mathbb{P}_{d}^{*}}\max\limits_{y\in[a/b,1]}|1-p(y)|p∈Pd∗​min​x∈[a,b]max​∣1−p(x)∣=p∈Pd∗​min​y∈[a/b,1]max​∣1−p(by)∣=p∈Pd∗​min​y∈[a/b,1]max​∣1−p(y)∣

and this last equality follows because the space Pd∗\mathbb{P}_{d}^{*}Pd∗​ is invariant under input rescaling; that is, for any b≠0b\neq 0b=0, the map x↦bxx\mapsto bxx↦bx preserves the space span{x,x3,…,xd}\mathrm{span}\{x,x^{3},\dots,x^{d}\}span{x,x3,…,xd}. This concludes the proof. ∎

而最后一个等号成立,是因为空间 Pd∗\mathbb{P}_{d}^{*}Pd∗​ 在输入缩放下不变;也就是说,对任意 b≠0b\neq 0b=0,映射 x↦bxx\mapsto bxx↦bx 保持空间 span{x,x3,…,xd}\mathrm{span}\{x,x^{3},\dots,x^{d}\}span{x,x3,…,xd}。这就完成了证明。∎

Appendix B Proof of Theorem 4.3

附录 B 定理 4.3 的证明

In this section we provide the proof of the convergence guarantee stated in Theorem 4.3.

本节给出定理 4.3 中所述收敛保证的证明。

See 4.3

见 4.3

Proof.

Define

证明。

定义

$$p^{\star}=\argmin_{\begin{subarray}{c}p=p_{T}\circ p_{T-1}\circ\cdots\circ p_{1}\
p_{t}\in\mathbb{P}{d}^{*}\end{subarray}},\max{x\in[\ell,u]}\left|1-p(x)\right|.$$

Then Algorithm 2 returns XT=p⋆(M)\bm{X}_{T}=p^{\star}(\bm{M})XT​=p⋆(M). Let h∈Pqh\in\mathbb{P}_{q}h∈Pq​ be [q/0][q/0][q/0] Padé-approximant to (1−x)−1/2(1-x)^{-1/2}(1−x)−1/2 [25, Section 3] and define p(x)=xh(1−x2)∈Pd\oddp(x)=xh(1-x^{2})\in\mathbb{P}_{d}^{\odd}p(x)=xh(1−x2)∈Pd\odd​. Define f=p∘⋯∘pf=p\circ\cdots\circ pf=p∘⋯∘p as the composition of ppp with itself TTT times. Then, by Theorem 4.1 and [25, Theorem 3.1] we have

则算法 2 返回 XT=p⋆(M)\bm{X}_{T}=p^{\star}(\bm{M})XT​=p⋆(M)。设 h∈Pqh\in\mathbb{P}_{q}h∈Pq​ 为对 (1−x)−1/2(1-x)^{-1/2}(1−x)−1/2 的 [q/0][q/0][q/0] Padé 逼近 [25, 第 3 节],并定义 p(x)=xh(1−x2)∈Pd\oddp(x)=xh(1-x^{2})\in\mathbb{P}_{d}^{\odd}p(x)=xh(1−x2)∈Pd\odd​。定义 f=p∘⋯∘pf=p\circ\cdots\circ pf=p∘⋯∘p 为 ppp 与自身复合 TTT 次。则由定理 4.1 和 [25, 定理 3.1] 我们有

∥\sign(M)−XT∥2≤max⁡x∈[ℓ,1]∣1−p⋆(x)∣≤max⁡x∈[ℓ,1]∣1−f(x)∣≤max⁡x∈[ℓ,1][∣1−x2∣(d+1)T1+f(x)]≤∣1−ℓ2∣(d+1)T,\displaystyle\|\sign(\bm{M})-\bm{X}_{T}\|_{2} \\ \displaystyle\leq\max\limits_{x\in[\ell,1]}|1-p^{\star}(x)| \\ \displaystyle\leq\max\limits_{x\in[\ell,1]}|1-f(x)| \\ \displaystyle\leq\max\limits_{x\in[\ell,1]}\left[\frac{|1-x^{2}|^{(d+1)^{T}}}{1+f(x)}\right] \\ \displaystyle\leq|1-\ell^{2}|^{(d+1)^{T}},∥\sign(M)−XT​∥2​≤x∈[ℓ,1]max​∣1−p⋆(x)∣≤x∈[ℓ,1]max​∣1−f(x)∣≤x∈[ℓ,1]max​[1+f(x)∣1−x2∣(d+1)T​]≤∣1−ℓ2∣(d+1)T,

as required. ∎

此即所需。∎

Appendix C Proof of equivalence between (6) and (7)

附录 C (6) 与 (7) 等价性的证明

In this section we provide a proof for the equivalence between (6) and (7). It is sufficient to show that for any fixed polynomial ppp we have

本节给出 (6) 与 (7) 等价性的证明。只需证明对任意固定的多项式 ppp 都有

$$\varepsilon_{1}:=\max_{\begin{subarray}{c}\bm{M}\in\mathbb{R}^{m\times n}\
\sigma(\bm{M})\subset[\ell,u]\end{subarray}}\left|\polar(\bm{M})-p(\bm{M})\right|{2}=\max{x\in[\ell,u]}\left|1-p(x)\right|:=\varepsilon_{2}.$$

For any fixed M\bm{M}M, by the unitary invariance of the spectral norm we immediately have

对任意固定的 M\bm{M}M,由谱范数的酉不变性我们立刻有

∥\polar(M)−p(M)∥2=max⁡σi∈σ(M)∣1−p(σi)∣≤max⁡x∈[ℓ,u]∣1−p(x)∣.\left\|\polar(\bm{M})-p(\bm{M})\right\|_{2}=\max\limits_{\sigma_{i}\in\sigma(\bm{M})}|1-p(\sigma_{i})|\leq\max\limits_{x\in[\ell,u]}\left|1-p(x)\right|.∥\polar(M)−p(M)∥2​=σi​∈σ(M)max​∣1−p(σi​)∣≤x∈[ℓ,u]max​∣1−p(x)∣.

Consequently, ε1≤ε2\varepsilon_{1}\leq\varepsilon_{2}ε1​≤ε2​.

因此 ε1≤ε2\varepsilon_{1}\leq\varepsilon_{2}ε1​≤ε2​。

Suppose that x∗∈[ℓ,u]x^{*}\in[\ell,u]x∗∈[ℓ,u] is chosen so that ∣1−p(x∗)∣=max⁡x∈[ℓ,u]∣1−p(x)∣.|1-p(x^{*})|=\max_{x\in[\ell,u]}\left|1-p(x)\right|.∣1−p(x∗)∣=maxx∈[ℓ,u]​∣1−p(x)∣. Without loss of generality, assume m≥nm\geq nm≥n. Letting M=x∗UVT\bm{M}=x^{*}\bm{U}\bm{V}^{\mathsf{T}}M=x∗UVT, for any matrix U∈Rm×n\bm{U}\in\mathbb{R}^{m\times n}U∈Rm×n and V∈Rn×n\bm{V}\in\mathbb{R}^{n\times n}V∈Rn×n with orthonormal columns, and noting \polar(M)=UVT\polar(\bm{M})=\bm{U}\bm{V}^{\mathsf{T}}\polar(M)=UVT yields

设 x∗∈[ℓ,u]x^{*}\in[\ell,u]x∗∈[ℓ,u] 使得 ∣1−p(x∗)∣=max⁡x∈[ℓ,u]∣1−p(x)∣|1-p(x^{*})|=\max_{x\in[\ell,u]}\left|1-p(x)\right|∣1−p(x∗)∣=maxx∈[ℓ,u]​∣1−p(x)∣。不失一般性,假定 m≥nm\geq nm≥n。令 M=x∗UVT\bm{M}=x^{*}\bm{U}\bm{V}^{\mathsf{T}}M=x∗UVT,其中任意矩阵 U∈Rm×n\bm{U}\in\mathbb{R}^{m\times n}U∈Rm×n 和 V∈Rn×n\bm{V}\in\mathbb{R}^{n\times n}V∈Rn×n 具有标准正交列,并注意到 \polar(M)=UVT\polar(\bm{M})=\bm{U}\bm{V}^{\mathsf{T}}\polar(M)=UVT,便得到

ε1≥∥\polar(M)−p(M)∥2=∥In−p(x∗)In∥2=∣1−p(x∗)∣=max⁡x∈[ℓ,u]∣1−p(x)∣  =ε2\displaystyle\varepsilon_{1} \\ \displaystyle\geq\|\polar(\bm{M})-p(\bm{M})\|_{2} \\ \displaystyle=\|\bm{I}_{n}-p(x^{*})\bm{I}_{n}\|_{2} \\ \displaystyle=|1-p(x^{*})| \\ \displaystyle=\max_{x\in[\ell,u]}\left|1-p(x)\right|\;=\varepsilon_{2}ε1​≥∥\polar(M)−p(M)∥2​=∥In​−p(x∗)In​∥2​=∣1−p(x∗)∣=x∈[ℓ,u]max​∣1−p(x)∣=ε2​

Consequently, ε1≥ε2\varepsilon_{1}\geq\varepsilon_{2}ε1​≥ε2​. Hence, ε1=ε2\varepsilon_{1}=\varepsilon_{2}ε1​=ε2​, as desired.

因此 ε1≥ε2\varepsilon_{1}\geq\varepsilon_{2}ε1​≥ε2​。于是 ε1=ε2\varepsilon_{1}=\varepsilon_{2}ε1​=ε2​,此即所需。

Appendix D Remez algorithm

附录 D Remez 算法

Theorem 4.1 shows that we can solve (7) by greedily choosing the optimal approximation pt∈Pd\oddp_{t}\in\mathbb{P}_{d}^{\odd}pt​∈Pd\odd​ for each interval [ℓt,ut][\ell_{t},u_{t}][ℓt​,ut​] for t=1,…,Tt=1,\ldots,Tt=1,…,T. In this section, we outline how the Remez algorithm [37, 38] can be used to approximate ptp_{t}pt​.

定理 4.1 表明,只要对每个区间 [ℓt,ut][\ell_{t},u_{t}][ℓt​,ut​](t=1,…,Tt=1,\ldots,Tt=1,…,T)贪心地选择最优逼近 pt∈Pd\oddp_{t}\in\mathbb{P}_{d}^{\odd}pt​∈Pd\odd​,就能求解 (7)。本节概述如何用 Remez 算法 [37, 38] 来逼近 ptp_{t}pt​。

We begin with the case when d=3d=3d=3. In this case, there is a simple closed form for the optimal odd polynomial p⋆∈P3\oddp^{\star}\in\mathbb{P}_{3}^{\odd}p⋆∈P3\odd​; see [11]. On a given interval [ℓ,u][\ell,u][ℓ,u], the optimal approximation to the constant function x↦1x\mapsto 1x↦1 is given by the scaled and shifted Newton-Schulz polynomial p\NS(x)=32x−12x3p_{\NS}(x)=\frac{3}{2}x-\frac{1}{2}x^{3}p\NS​(x)=23​x−21​x3:

我们从 d=3d=3d=3 的情形开始。这时最优奇次多项式 p⋆∈P3\oddp^{\star}\in\mathbb{P}_{3}^{\odd}p⋆∈P3\odd​ 有简单的闭式;见 [11]。在给定区间 [ℓ,u][\ell,u][ℓ,u] 上,对常值函数 x↦1x\mapsto 1x↦1 的最优逼近由缩放并平移后的 Newton-Schulz 多项式 p\NS(x)=32x−12x3p_{\NS}(x)=\frac{3}{2}x-\frac{1}{2}x^{3}p\NS​(x)=23​x−21​x3 给出:

p⋆(x)=βp\NS(αx), where α=3u2+lu+ℓ2 and β=42+ℓu(ℓ+u)α3.p^{\star}(x)=\beta p_{\NS}(\alpha x),\text{ where }\alpha=\sqrt{\frac{3}{u^{2}+lu+\ell^{2}}}\text{ and }\beta=\frac{4}{2+\ell u(\ell+u)\alpha^{3}}.p⋆(x)=βp\NS​(αx), where α=u2+lu+ℓ23​​ and β=2+ℓu(ℓ+u)α34​.

One can verify that this polynomial satisfies the equioscillation condition from Lemma A.1 at x=ℓ,1α,ux=\ell,\frac{1}{\alpha},ux=ℓ,α1​,u and therefore necessarily has to be the optimal approximation from P3\odd\mathbb{P}_{3}^{\odd}P3\odd​. Unfortunately, for larger ddd finding closed form expressions for optimal approximations from Pd\odd\mathbb{P}_{d}^{\odd}Pd\odd​ becomes challenging. In fact, to the best of our knowledge the optimal approximation is not known for d≥5d\geq 5d≥5. However, we can approximate the optimal polynomial using the Remez algorithm.

可以验证该多项式在 x=ℓ,1α,ux=\ell,\frac{1}{\alpha},ux=ℓ,α1​,u 处满足引理 A.1 的等振荡条件,因而必然是来自 P3\odd\mathbb{P}_{3}^{\odd}P3\odd​ 的最优逼近。可惜对更大的 ddd,要为来自 Pd\odd\mathbb{P}_{d}^{\odd}Pd\odd​ 的最优逼近找到闭式变得困难。事实上,据我们所知,当 d≥5d\geq 5d≥5 时最优逼近并不已知。不过我们可以用 Remez 算法来逼近最优多项式。

Let d=2q+1d=2q+1d=2q+1. Recall that from Lemma A.1 the optimal polynomial must satisfy the equioscillation property q+2q+2q+2 times. The Remez algorithm is an iterative algorithm that finds the equioscillation points A={x0,…,xq+1}A=\{x_{0},\ldots,x_{q+1}\}A={x0​,…,xq+1​} from Lemma A.1 by iteratively refining a sequence of trial points A(k)={x0(k),…,xq+1(k)}A^{(k)}=\{x_{0}^{(k)},\ldots,x_{q+1}^{(k)}\}A(k)={x0(k)​,…,xq+1(k)​} so that A(k)A^{(k)}A(k) converges to AAA. From the sequence of trial points A(k)A^{(k)}A(k) the algorithm also finds a sequence of polynomials p(k)p^{(k)}p(k) so that p(k)p^{(k)}p(k) converges to the optimal polynomial. The convergence is extremely fast, and usually 10 iterations is sufficient to converge to the optimal polynomial up to double precision machine epsilon [37]. More commonly, the Remez algorithm is used to find optimal polynomial approximations to general continuous functions where d≈100d\approx 100d≈100 or even d≈1000d\approx 1000d≈1000. However, because the polynomial we build to approximate \sign(x)\sign(x)\sign(x) is a composition of polynomials, each of which has a low degree, in our setting the degree ddd is small, usually d=5d=5d=5. For d=5d=5d=5 the Remez algorithm simplifies significantly. We now describe this simplified algorithm.

设 d=2q+1d=2q+1d=2q+1。回忆引理 A.1,最优多项式必须满足 q+2q+2q+2 次等振荡性质。Remez 算法是一种迭代算法,它通过不断修正一列试验点 A(k)={x0(k),…,xq+1(k)}A^{(k)}=\{x_{0}^{(k)},\ldots,x_{q+1}^{(k)}\}A(k)={x0(k)​,…,xq+1(k)​},使其收敛到引理 A.1 中的等振荡点集 A={x0,…,xq+1}A=\{x_{0},\ldots,x_{q+1}\}A={x0​,…,xq+1​}。从试验点列 A(k)A^{(k)}A(k) 出发,算法同时找到一列多项式 p(k)p^{(k)}p(k),使其收敛到最优多项式。收敛极快,通常 10 步就足以收敛到双精度机器 epsilon 意义下的最优多项式 [37]。更常见的是,Remez 算法被用来寻找对一般连续函数的最优多项式逼近,其中 d≈100d\approx 100d≈100 甚至 d≈1000d\approx 1000d≈1000。不过,由于我们用来逼近 \sign(x)\sign(x)\sign(x) 的多项式是若干低次多项式的复合,在我们的设定中次数 ddd 很小,通常 d=5d=5d=5。对 d=5d=5d=5,Remez 算法会显著简化。我们接下来描述这一简化算法。

Recall that as stated in Lemma A.1, the unique optimal approximation p⋆∈P5\oddp^{\star}\in\mathbb{P}_{5}^{\odd}p⋆∈P5\odd​ satisfies the equioscillation property at four points. The Remez algorithm first starts with a trial set A(1)={x0(1),x1(1),x2(1),x3(1)}⊂[ℓ,u]A^{(1)}=\{x_{0}^{(1)},x_{1}^{(1)},x_{2}^{(1)},x_{3}^{(1)}\}\subset[\ell,u]A(1)={x0(1)​,x1(1)​,x2(1)​,x3(1)​}⊂[ℓ,u] which ideally should come close to satisfying the equioscillation property. Since we know that ℓ\ellℓ and uuu must be equioscillation points we always set x0(k)=ℓx_{0}^{(k)}=\ellx0(k)​=ℓ and x3(k)=ux_{3}^{(k)}=ux3(k)​=u for all kkk. x2(1)x_{2}^{(1)}x2(1)​ and x3(1)x_{3}^{(1)}x3(1)​ are chosen to be 14ℓ+34u\frac{1}{4}\ell+\frac{3}{4}u41​ℓ+43​u and 34ℓ+14u\frac{3}{4}\ell+\frac{1}{4}u43​ℓ+41​u, since we observe that as ℓ→u\ell\to uℓ→u these are approximately the other equioscillation points. Next, the algorithm solves the following system of equations

回忆引理 A.1 所述,唯一的最优逼近 p⋆∈P5\oddp^{\star}\in\mathbb{P}_{5}^{\odd}p⋆∈P5\odd​ 在四个点处满足等振荡性质。Remez 算法首先从一个试验集 A(1)={x0(1),x1(1),x2(1),x3(1)}⊂[ℓ,u]A^{(1)}=\{x_{0}^{(1)},x_{1}^{(1)},x_{2}^{(1)},x_{3}^{(1)}\}\subset[\ell,u]A(1)={x0(1)​,x1(1)​,x2(1)​,x3(1)​}⊂[ℓ,u] 出发,该集合理想情况下应接近满足等振荡性质。既然我们知道 ℓ\ellℓ 和 uuu 必须是等振荡点,我们始终令所有 kkk 都有 x0(k)=ℓx_{0}^{(k)}=\ellx0(k)​=ℓ 和 x3(k)=ux_{3}^{(k)}=ux3(k)​=u。x2(1)x_{2}^{(1)}x2(1)​ 和 x3(1)x_{3}^{(1)}x3(1)​ 取为 14ℓ+34u\frac{1}{4}\ell+\frac{3}{4}u41​ℓ+43​u 和 34ℓ+14u\frac{3}{4}\ell+\frac{1}{4}u43​ℓ+41​u,因为我们观察到当 ℓ→u\ell\to uℓ→u 时它们大致就是其余等振荡点。接下来,算法求解下列方程组

a1xi(1)+b1(xi(1))3+c1(xi(1))5+(−1)iE1=\sign(x)=1,i=0,1,2,3,(17)a_{1}x_{i}^{(1)}+b_{1}(x_{i}^{(1)})^{3}+c_{1}(x_{i}^{(1)})^{5}+(-1)^{i}E_{1}=\sign(x)=1,\quad i=0,1,2,3, \tag{17}a1​xi(1)​+b1​(xi(1)​)3+c1​(xi(1)​)5+(−1)iE1​=\sign(x)=1,i=0,1,2,3,(17)

for the unknowns a1,b1,c1,a_{1},b_{1},c_{1},a1​,b1​,c1​, and E1E_{1}E1​. Recalling that x0(1)=ℓx_{0}^{(1)}=\ellx0(1)​=ℓ and x3(1)=ux_{3}^{(1)}=ux3(1)​=u, (17) can equivalently be written as a system of linear equations

未知数为 a1,b1,c1a_{1},b_{1},c_{1}a1​,b1​,c1​ 和 E1E_{1}E1​。回忆 x0(1)=ℓx_{0}^{(1)}=\ellx0(1)​=ℓ 且 x3(1)=ux_{3}^{(1)}=ux3(1)​=u,(17) 可以等价地写成线性方程组

$$\begin{bmatrix}\ell&\ell^{3}&\ell^{5}&1\
x_{1}^{(1)}&(x_{1}^{(1)})^{3}&(x_{1}^{(1)})^{5}&-1\
x_{2}^{(1)}&(x_{2}^{(1)})^{3}&(x_{2}^{(1)})^{5}&1\
u&u^{3}&u^{5}&-1\end{bmatrix}\begin{bmatrix}a\
b\
c\
E\end{bmatrix}=\begin{bmatrix}1\
1\
1\
1\end{bmatrix}. \tag{18}$$

Once we have solved for a1,b1,c1,a_{1},b_{1},c_{1},a1​,b1​,c1​, and E1E_{1}E1​ we set p1(x)=a1x+b1x3+b1x5p_{1}(x)=a_{1}x+b_{1}x^{3}+b_{1}x^{5}p1​(x)=a1​x+b1​x3+b1​x5. Now we want to find the error in the L∞L^{\infty}L∞ norm of using p1p_{1}p1​ to approximate x↦1x\mapsto 1x↦1. We therefore find local maxima of the error function e1(x)=1−p1(x)e_{1}(x)=1-p_{1}(x)e1​(x)=1−p1​(x) on (ℓ,u)(\ell,u)(ℓ,u) by setting the derivative of e1(x)e_{1}(x)e1​(x) to zero and solving for xxx. This results in the quartic equation 5b1x4+3b1x2+a=05b_{1}x^{4}+3b_{1}x^{2}+a=05b1​x4+3b1​x2+a=0, which has closed form solutions given by the quadratic formula after the substitution y=x2y=x^{2}y=x2. We now let x1(2)x_{1}^{(2)}x1(2)​ and x2(2)x_{2}^{(2)}x2(2)​ be the solutions to this equation and let A(2)={ℓ,x1(2),x2(2),u}A^{(2)}=\{\ell,x_{1}^{(2)},x_{2}^{(2)},u\}A(2)={ℓ,x1(2)​,x2(2)​,u}. We repeat the procedure until ∣Ek∣:=max⁡x∈[ℓ,u]∣1−pk(x)∣≈max⁡x∈[ℓ,u]∣1−pk+1(x)∣:=∣Ek+1∣|E_{k}|:=\max\limits_{x\in[\ell,u]}|1-p_{k}(x)|\approx\max\limits_{x\in[\ell,u]}|1-p_{k+1}(x)|:=|E_{k+1}|∣Ek​∣:=x∈[ℓ,u]max​∣1−pk​(x)∣≈x∈[ℓ,u]max​∣1−pk+1​(x)∣:=∣Ek+1​∣.

一旦解出 a1,b1,c1a_{1},b_{1},c_{1}a1​,b1​,c1​ 和 E1E_{1}E1​,我们就令 p1(x)=a1x+b1x3+b1x5p_{1}(x)=a_{1}x+b_{1}x^{3}+b_{1}x^{5}p1​(x)=a1​x+b1​x3+b1​x5。现在我们要找出用 p1p_{1}p1​ 逼近 x↦1x\mapsto 1x↦1 时的 L∞L^{\infty}L∞ 范数误差。因此我们令误差函数 e1(x)=1−p1(x)e_{1}(x)=1-p_{1}(x)e1​(x)=1−p1​(x) 的导数为零并求解 xxx,以找出它在 (ℓ,u)(\ell,u)(ℓ,u) 上的局部极大。这给出四次方程 5b1x4+3b1x2+a=05b_{1}x^{4}+3b_{1}x^{2}+a=05b1​x4+3b1​x2+a=0,在替换 y=x2y=x^{2}y=x2 后可用二次公式给出闭式解。我们现在令 x1(2)x_{1}^{(2)}x1(2)​ 和 x2(2)x_{2}^{(2)}x2(2)​ 为该方程的解,并令 A(2)={ℓ,x1(2),x2(2),u}A^{(2)}=\{\ell,x_{1}^{(2)},x_{2}^{(2)},u\}A(2)={ℓ,x1(2)​,x2(2)​,u}。我们重复这一过程,直到 ∣Ek∣:=max⁡x∈[ℓ,u]∣1−pk(x)∣≈max⁡x∈[ℓ,u]∣1−pk+1(x)∣:=∣Ek+1∣|E_{k}|:=\max\limits_{x\in[\ell,u]}|1-p_{k}(x)|\approx\max\limits_{x\in[\ell,u]}|1-p_{k+1}(x)|:=|E_{k+1}|∣Ek​∣:=x∈[ℓ,u]max​∣1−pk​(x)∣≈x∈[ℓ,u]max​∣1−pk+1​(x)∣:=∣Ek+1​∣。

We note that the matrix appearing in (18) is a Vandermonde matrix. Vandermonde matrices become notoriously ill-conditioned as the degree grows large [15, Section 4.6]. However, since in our setting we choose ddd to be small, there is no ill-conditioning. Instead, we observe ill-conditioning when ℓ≈u\ell\approx uℓ≈u. However, as ℓ/u→1\ell/u\to 1ℓ/u→1 the optimal polynomial will converge to the polynomial x/u8(15−10(x/u)2+3(x/u)4)\frac{x/u}{8}\left(15-10(x/u)^{2}+3(x/u)^{4}\right)8x/u​(15−10(x/u)2+3(x/u)4), which can be verified by noting that as ℓ/u→1\ell/u\to 1ℓ/u→1 all equioscillation points x0,x1,x2,x3x_{0},x_{1},x_{2},x_{3}x0​,x1​,x2​,x3​ must converge to uuu. For general d=2q+1d=2q+1d=2q+1, the polynomial will converge to (x/ℓ)h(1−(x/ℓ)2)(x/\ell)h(1-(x/\ell)^{2})(x/ℓ)h(1−(x/ℓ)2) where h∈Pqh\in\mathbb{P}_{q}h∈Pq​ is the [q/0][q/0][q/0] Padé approximant to (1−x)1/2(1-x)^{1/2}(1−x)1/2 [25]. In fact, this polynomial is extremely close to the optimal polynomial for sufficiently large ℓ\ellℓ. To see this, let p⋆p^{\star}p⋆ be the optimal approximation from P5\odd\mathbb{P}_{5}^{\odd}P5\odd​ and let p(x)=x/u8(15−10(x/u)2+3(x/u)4)p(x)=\frac{x/u}{8}\left(15-10(x/u)^{2}+3(x/u)^{4}\right)p(x)=8x/u​(15−10(x/u)2+3(x/u)4). Then,

我们注意到 (18) 中出现的矩阵是 Vandermonde 矩阵。当次数变大时,Vandermonde 矩阵会变得出了名地病态 [15, 第 4.6 节]。不过在我们的设定中 ddd 取得很小,因此没有病态问题。相反,我们在 ℓ≈u\ell\approx uℓ≈u 时观察到病态。但当 ℓ/u→1\ell/u\to 1ℓ/u→1 时,最优多项式会收敛到多项式 x/u8(15−10(x/u)2+3(x/u)4)\frac{x/u}{8}\left(15-10(x/u)^{2}+3(x/u)^{4}\right)8x/u​(15−10(x/u)2+3(x/u)4),这一点可以通过注意到当 ℓ/u→1\ell/u\to 1ℓ/u→1 时所有等振荡点 x0,x1,x2,x3x_{0},x_{1},x_{2},x_{3}x0​,x1​,x2​,x3​ 都必须收敛到 uuu 来验证。对一般的 d=2q+1d=2q+1d=2q+1,多项式会收敛到 (x/ℓ)h(1−(x/ℓ)2)(x/\ell)h(1-(x/\ell)^{2})(x/ℓ)h(1−(x/ℓ)2),其中 h∈Pqh\in\mathbb{P}_{q}h∈Pq​ 是对 (1−x)1/2(1-x)^{1/2}(1−x)1/2 的 [q/0][q/0][q/0] Padé 逼近 [25]。事实上,当 ℓ\ellℓ 足够大时,这一多项式与最优多项式极为接近。为看清这一点,设 p⋆p^{\star}p⋆ 为来自 P5\odd\mathbb{P}_{5}^{\odd}P5\odd​ 的最优逼近,并设 p(x)=x/u8(15−10(x/u)2+3(x/u)4)p(x)=\frac{x/u}{8}\left(15-10(x/u)^{2}+3(x/u)^{4}\right)p(x)=8x/u​(15−10(x/u)2+3(x/u)4)。则

max⁡x∈[ℓ,u]∣p⋆(x)−p(x)∣≤max⁡x∈[ℓ,u]∣1−p(x)∣+max⁡x∈[ℓ,u]∣1−p⋆(x)∣≤2max⁡x∈[ℓ,u]∣1−p(x)∣≤2(1−ℓ/u)3.\displaystyle\max\limits_{x\in[\ell,u]}|p^{\star}(x)-p(x)| \\ \displaystyle\leq\max\limits_{x\in[\ell,u]}|1-p(x)|+\max\limits_{x\in[\ell,u]}|1-p^{\star}(x)| \\ \displaystyle\leq 2\max\limits_{x\in[\ell,u]}|1-p(x)| \\ \displaystyle\leq 2\left(1-\ell/u\right)^{3}.x∈[ℓ,u]max​∣p⋆(x)−p(x)∣≤x∈[ℓ,u]max​∣1−p(x)∣+x∈[ℓ,u]max​∣1−p⋆(x)∣≤2x∈[ℓ,u]max​∣1−p(x)∣≤2(1−ℓ/u)3.

where we invoked [25, Theorem 3.1] and the fact that p⋆p^{\star}p⋆ is the optimal approximation to x↦1x\mapsto 1x↦1 from P5\odd\mathbb{P}_{5}^{\odd}P5\odd​. Hence, when ℓ/u≥1−ϵd1/3\ell/u\geq 1-\epsilon_{d}^{1/3}ℓ/u≥1−ϵd1/3​, where ϵdouble≈1.1×10−16\epsilon_{\text{double}}\approx 1.1\times 10^{-16}ϵdouble​≈1.1×10−16 is the double precision machine epsilon, then ∣p⋆(x)−p(x)∣≤2ϵdouble|p^{\star}(x)-p(x)|\leq 2\epsilon_{\text{double}}∣p⋆(x)−p(x)∣≤2ϵdouble​. In other words, up to double precision machine epsilon, p⋆p^{\star}p⋆ is equal to ppp. Therefore, whenever ℓ/u≥1−ϵdouble1/3\ell/u\geq 1-\epsilon_{\text{double}}^{1/3}ℓ/u≥1−ϵdouble1/3​ the algorithm simply returns ppp as the optimal polynomial.

其中我们援引了 [25, 定理 3.1],以及 p⋆p^{\star}p⋆ 是来自 P5\odd\mathbb{P}_{5}^{\odd}P5\odd​ 的对 x↦1x\mapsto 1x↦1 的最优逼近这一事实。因此,当 ℓ/u≥1−ϵd1/3\ell/u\geq 1-\epsilon_{d}^{1/3}ℓ/u≥1−ϵd1/3​ 时——这里 ϵdouble≈1.1×10−16\epsilon_{\text{double}}\approx 1.1\times 10^{-16}ϵdouble​≈1.1×10−16 是双精度机器 epsilon——就有 ∣p⋆(x)−p(x)∣≤2ϵdouble|p^{\star}(x)-p(x)|\leq 2\epsilon_{\text{double}}∣p⋆(x)−p(x)∣≤2ϵdouble​。换句话说,在双精度机器 epsilon 的意义下,p⋆p^{\star}p⋆ 等于 ppp。因此,只要 ℓ/u≥1−ϵdouble1/3\ell/u\geq 1-\epsilon_{\text{double}}^{1/3}ℓ/u≥1−ϵdouble1/3​,算法就直接返回 ppp 作为最优多项式。

The algorithm is outlined in Algorithm 3. In our experiments, we never observed Algorithm 3 taking more than five iterations to converge.

算法概述于算法 3。在我们的实验中,从未观察到算法 3 需要超过五步才能收敛。

define ϵdouble=1.11×10−16\epsilon_{\text{double}}=1.11\times 10^{-16}ϵdouble​=1.11×10−16
if ℓ/u≥1−ϵdouble1/3\ell/u\geq 1-\epsilon_{\text{double}}^{1/3}ℓ/u≥1−ϵdouble1/3​ then
Return p(x)=x/u8(15−10(x/u)2+3(x/u)4)p(x)=\frac{x/u}{8}\left(15-10(x/u)^{2}+3(x/u)^{4}\right)p(x)=8x/u​(15−10(x/u)2+3(x/u)4)
end if
E0=∞E_{0}=\inftyE0​=∞, E−1=−∞E_{-1}=-\inftyE−1​=−∞
k←0k\leftarrow 0k←0
while ∣∣Ek∣−∣Ek−1∣∣>ϵdouble||E_{k}|-|E_{k-1}||>\epsilon_{\text{double}}∣∣Ek​∣−∣Ek−1​∣∣>ϵdouble​ do
k←k+1k\leftarrow k+1k←k+1
[akbkckEk]=[ℓℓ3ℓ51x1(k)(x1(k))3(x1(k))5−1x2(k)(x2(k))3(x2(1))51uu3u5−1]−1[1111]\begin{bmatrix}a_{k}\\ b_{k}\\ c_{k}\\ E_{k}\end{bmatrix}=\begin{bmatrix}\ell&\ell^{3}&\ell^{5}&1\\ x_{1}^{(k)}&(x_{1}^{(k)})^{3}&(x_{1}^{(k)})^{5}&-1\\ x_{2}^{(k)}&(x_{2}^{(k)})^{3}&(x_{2}^{(1)})^{5}&1\\ u&u^{3}&u^{5}&-1\end{bmatrix}^{-1}\begin{bmatrix}1\\ 1\\ 1\\ 1\end{bmatrix}​ak​bk​ck​Ek​​​=​ℓx1(k)​x2(k)​u​ℓ3(x1(k)​)3(x2(k)​)3u3​ℓ5(x1(k)​)5(x2(1)​)5u5​1−11−1​​−1​1111​​
x1(k+1)=−3bk−9bk2−20akck10ck,x2(k+1)=−3bk+9bk2−20akck10ckx_{1}^{(k+1)}=\sqrt{\frac{-3b_{k}-\sqrt{9b_{k}^{2}-20a_{k}c_{k}}}{10c_{k}}},x_{2}^{(k+1)}=\sqrt{\frac{-3b_{k}+\sqrt{9b_{k}^{2}-20a_{k}c_{k}}}{10c_{k}}}x1(k+1)​=10ck​−3bk​−9bk2​−20ak​ck​​​​,x2(k+1)​=10ck​−3bk​+9bk2​−20ak​ck​​​​
end while
Return p(x)=akx+bkx3+ckx5p(x)=a_{k}x+b_{k}x^{3}+c_{k}x^{5}p(x)=ak​x+bk​x3+ck​x5

Algorithm 3 Remez algorithm (degree 5 approximation for \sign(x)\sign(x)\sign(x))

define ϵdouble=1.11×10−16\epsilon_{\text{double}}=1.11\times 10^{-16}ϵdouble​=1.11×10−16
if ℓ/u≥1−ϵdouble1/3\ell/u\geq 1-\epsilon_{\text{double}}^{1/3}ℓ/u≥1−ϵdouble1/3​ then
Return p(x)=x/u8(15−10(x/u)2+3(x/u)4)p(x)=\frac{x/u}{8}\left(15-10(x/u)^{2}+3(x/u)^{4}\right)p(x)=8x/u​(15−10(x/u)2+3(x/u)4)
end if
E0=∞E_{0}=\inftyE0​=∞,E−1=−∞E_{-1}=-\inftyE−1​=−∞
k←0k\leftarrow 0k←0
while ∣∣Ek∣−∣Ek−1∣∣>ϵdouble||E_{k}|-|E_{k-1}||>\epsilon_{\text{double}}∣∣Ek​∣−∣Ek−1​∣∣>ϵdouble​ do
k←k+1k\leftarrow k+1k←k+1
[akbkckEk]=[ℓℓ3ℓ51x1(k)(x1(k))3(x1(k))5−1x2(k)(x2(k))3(x2(1))51uu3u5−1]−1[1111]\begin{bmatrix}a_{k}\\ b_{k}\\ c_{k}\\ E_{k}\end{bmatrix}=\begin{bmatrix}\ell&\ell^{3}&\ell^{5}&1\\ x_{1}^{(k)}&(x_{1}^{(k)})^{3}&(x_{1}^{(k)})^{5}&-1\\ x_{2}^{(k)}&(x_{2}^{(k)})^{3}&(x_{2}^{(1)})^{5}&1\\ u&u^{3}&u^{5}&-1\end{bmatrix}^{-1}\begin{bmatrix}1\\ 1\\ 1\\ 1\end{bmatrix}​ak​bk​ck​Ek​​​=​ℓx1(k)​x2(k)​u​ℓ3(x1(k)​)3(x2(k)​)3u3​ℓ5(x1(k)​)5(x2(1)​)5u5​1−11−1​​−1​1111​​
x1(k+1)=−3bk−9bk2−20akck10ckx_{1}^{(k+1)}=\sqrt{\frac{-3b_{k}-\sqrt{9b_{k}^{2}-20a_{k}c_{k}}}{10c_{k}}}x1(k+1)​=10ck​−3bk​−9bk2​−20ak​ck​​​​,x2(k+1)=−3bk+9bk2−20akck10ckx_{2}^{(k+1)}=\sqrt{\frac{-3b_{k}+\sqrt{9b_{k}^{2}-20a_{k}c_{k}}}{10c_{k}}}x2(k+1)​=10ck​−3bk​+9bk2​−20ak​ck​​​​
end while
Return p(x)=akx+bkx3+ckx5p(x)=a_{k}x+b_{k}x^{3}+c_{k}x^{5}p(x)=ak​x+bk​x3+ck​x5

算法 3 Remez 算法(对 \sign(x)\sign(x)\sign(x) 的五次逼近)

Appendix E Initialization for Matrices with Large Spectral Gaps

附录 E 大谱间隙矩阵的初始化

In Section 4, we constructed a sequence of polynomials that is adapted to the range of the singular values [ℓ,u][\ell,u][ℓ,u]. Assuming nothing else about the input, these polynomials are optimal because they provide a good approximation to 111 across the entire interval. However, in many applications, the spectrum has large gaps; that is, there are several large outlying singular values that are well-separated from the rest. For these matrices, it is not necessary for the polynomial to be accurate on the entire interval [ℓ,u][\ell,u][ℓ,u], only on the range of the small singular values plus a few other isolated points. In this section, we take advantage of this structure to accelerate our method by preprocessing the matrix to eliminate the largest singular values.

在第 4 节中,我们构造了一列适应奇异值范围 [ℓ,u][\ell,u][ℓ,u] 的多项式。在对输入不做其他假设时,这些多项式是最优的,因为它们在整个区间上都对 111 给出良好逼近。不过在许多应用中,谱有很大的间隙;也就是说,有若干较大的离群奇异值与其余部分分得很开。对这些矩阵,多项式不必在整个区间 [ℓ,u][\ell,u][ℓ,u] 上都精确,只需在较小奇异值的范围再加上几个孤立点上精确即可。本节利用这一结构,通过预处理矩阵以消去最大的那些奇异值,来加速我们的方法。

The first step is to find small intervals containing each of these large singular values. To find lower bounds, we use subspace iteration, which is a generalization of the power method that approximates multiple singular values simultaneously. Fix kkk, the number of singular values we wish to eliminate. Letting σ1≥⋯≥σn\sigma_{1}\geq\cdots\geq\sigma_{n}σ1​≥⋯≥σn​ denote the singular values of M\bm{M}M, subspace iteration produces estimates σ~1≥⋯≥σ~k\tilde{\sigma}_{1}\geq\cdots\geq\tilde{\sigma}_{k}σ~1​≥⋯≥σ~k​ satisfying σi≥σ~i\sigma_{i}\geq\tilde{\sigma}_{i}σi​≥σ~i​ for all i∈1,…,ki\in 1,\ldots,ki∈1,…,k.[^4] To find upper bounds on each σi\sigma_{i}σi​, we can use the fact that ∥M∥F2=∑j=1nσj2\|\bm{M}\|_{\text{F}}^{2}=\sum_{j=1}^{n}\sigma_{j}^{2}∥M∥F2​=∑j=1n​σj2​ as follows:

第一步是找到包含每一个大奇异值的小区间。为得到下界,我们使用子空间迭代,它是幂法的推广,可以同时逼近多个奇异值。固定 kkk,即我们希望消去的奇异值个数。记 M\bm{M}M 的奇异值为 σ1≥⋯≥σn\sigma_{1}\geq\cdots\geq\sigma_{n}σ1​≥⋯≥σn​,子空间迭代产生估计 σ~1≥⋯≥σ~k\tilde{\sigma}_{1}\geq\cdots\geq\tilde{\sigma}_{k}σ~1​≥⋯≥σ~k​,满足对所有 i∈1,…,ki\in 1,\ldots,ki∈1,…,k 都有 σi≥σ~i\sigma_{i}\geq\tilde{\sigma}_{i}σi​≥σ~i​。[^4] 为得到每个 σi\sigma_{i}σi​ 的上界,我们可以利用 ∥M∥F2=∑j=1nσj2\|\bm{M}\|_{\text{F}}^{2}=\sum_{j=1}^{n}\sigma_{j}^{2}∥M∥F2​=∑j=1n​σj2​,做法如下:

$$\sigma_{i}^{2}=|\bm{M}|{\text{F}}^{2}-\sum\limits{\begin{subarray}{c}j=1\
j\neq i\end{subarray}}^{n}\sigma_{j}^{2}\leq|\bm{M}|{\text{F}}^{2}-\sum\limits{\begin{subarray}{c}j=1\
j\neq i\end{subarray}}^{k}\sigma_{j}^{2}\leq|\bm{M}|{\text{F}}^{2}-\sum\limits{\begin{subarray}{c}j=1\
j\neq i\end{subarray}}^{k}\tilde{\sigma}_{j}^{2} \tag{19}$$

That is, for each i∈[n]i\in[n]i∈[n],

也就是说,对每个 i∈[n]i\in[n]i∈[n],

$$\sigma_{i}\in\left[\tilde{\sigma}{i},,,\sqrt{|\bm{M}|{\text{F}}^{2}-\sum\limits_{\begin{subarray}{c}j=1\
j\neq i\end{subarray}}^{k}\tilde{\sigma}_{j}^{2}}\right]$$

Setting i=k+1i=k+1i=k+1, the above also provides an upper bound for the tail of the spectrum, σk+1,…,σn\sigma_{k+1},\ldots,\sigma_{n}σk+1​,…,σn​.

令 i=k+1i=k+1i=k+1,上式同时也给出谱的尾部 σk+1,…,σn\sigma_{k+1},\ldots,\sigma_{n}σk+1​,…,σn​ 的一个上界。

The second step is to find an odd polynomial that well-approximates the constant function on each of these intervals and on the tail simultaneously. For simplicity, we treat only the k=1k=1k=1 case here. Assume that M\bm{M}M is normalized to ∥M∥F=1\|\bm{M}\|_{\text{F}}=1∥M∥F​=1 and let z=σ~1z=\tilde{\sigma}_{1}z=σ~1​ be the lower bound produced by subspace iteration (which reduces to the power method in this case). Then (19) gives σ1∈[z,1]\sigma_{1}\in[z,1]σ1​∈[z,1] and σ2,…,σn≤1−z2\sigma_{2},\ldots,\sigma_{n}\leq\sqrt{1-z^{2}}σ2​,…,σn​≤1−z2​. Assume that these intervals do not overlap, that is, 1−z2≤z  ⟺  z≥1/2\sqrt{1-z^{2}}\leq z\iff z\geq 1/\sqrt{2}1−z2​≤z⟺z≥1/2​. Then we construct the unique odd cubic polynomial p(x)=ax+bx3p(x)=ax+bx^{3}p(x)=ax+bx3 that satisfies p(1−z2)=1p(\sqrt{1-z^{2}})=1p(1−z2​)=1 and p(z)=1p(z)=1p(z)=1 by setting

第二步是找到一个奇次多项式,使它在这些区间以及尾部上同时很好地逼近常值函数。为简单起见,这里只处理 k=1k=1k=1 的情形。假定 M\bm{M}M 已归一化到 ∥M∥F=1\|\bm{M}\|_{\text{F}}=1∥M∥F​=1,并令 z=σ~1z=\tilde{\sigma}_{1}z=σ~1​ 为子空间迭代产生的下界(此时它退化为幂法)。则 (19) 给出 σ1∈[z,1]\sigma_{1}\in[z,1]σ1​∈[z,1] 以及 σ2,…,σn≤1−z2\sigma_{2},\ldots,\sigma_{n}\leq\sqrt{1-z^{2}}σ2​,…,σn​≤1−z2​。假定这些区间不相交,也就是 1−z2≤z  ⟺  z≥1/2\sqrt{1-z^{2}}\leq z\iff z\geq 1/\sqrt{2}1−z2​≤z⟺z≥1/2​。然后我们构造满足 p(1−z2)=1p(\sqrt{1-z^{2}})=1p(1−z2​)=1 和 p(z)=1p(z)=1p(z)=1 的唯一奇次三次多项式 p(x)=ax+bx3p(x)=ax+bx^{3}p(x)=ax+bx3,做法是令

a=z2(z+1−z2)−1−z2z1−z2(2z2−1)b=1−z2−zz1−z2(2z2−1)(20)a=\frac{z^{2}(z+\sqrt{1-z^{2}})-\sqrt{1-z^{2}}}{z\sqrt{1-z^{2}}(2z^{2}-1)}\qquad b=\frac{\sqrt{1-z^{2}}-z}{z\sqrt{1-z^{2}}(2z^{2}-1)} \tag{20}a=z1−z2​(2z2−1)z2(z+1−z2​)−1−z2​​b=z1−z2​(2z2−1)1−z2​−z​(20)

Because p(0)=0p(0)=0p(0)=0 and ppp has at most one local extremum on R≥0\mathbb{R}_{\geq 0}R≥0​, these conditions immediately guarantee that ppp is concave-increasing on [0,1−z2][0,\sqrt{1-z^{2}}][0,1−z2​], so it must lie above the line x↦x/1−z2x\mapsto x/\sqrt{1-z^{2}}x↦x/1−z2​. Furthermore, ppp is decreasing on [σ1,1][\sigma_{1},1][σ1​,1], so it maps σ1∈[z,1]\sigma_{1}\in[z,1]σ1​∈[z,1] to [p(1),1][p(1),1][p(1),1]. By minimizing p(1)p(1)p(1) over all valid zzz (that is, over the interval z∈[1/2,1]z\in[1/\sqrt{2},1]z∈[1/2​,1]), one can further show that p(1)>1/2p(1)>1/\sqrt{2}p(1)>1/2​, so σ1\sigma_{1}σ1​ cannot be decreased very much by applying ppp. Thus, the largest singular value of p(M)p(\bm{M})p(M) is still at most 111, while the smaller singular values have increased by a potentially large factor of 1/1−z21/\sqrt{1-z^{2}}1/1−z2​. When there is a large outlying singular value, zzz is close to 111 and this initialization scheme makes much more progress than a standard iteration of PolarExpress would have.

因为 p(0)=0p(0)=0p(0)=0 且 ppp 在 R≥0\mathbb{R}_{\geq 0}R≥0​ 上至多有一个局部极值,这些条件立刻保证 ppp 在 [0,1−z2][0,\sqrt{1-z^{2}}][0,1−z2​] 上是凹且递增的,因而必然位于直线 x↦x/1−z2x\mapsto x/\sqrt{1-z^{2}}x↦x/1−z2​ 上方。此外,ppp 在 [σ1,1][\sigma_{1},1][σ1​,1] 上递减,因而把 σ1∈[z,1]\sigma_{1}\in[z,1]σ1​∈[z,1] 映射到 [p(1),1][p(1),1][p(1),1]。通过在所有合法的 zzz 上最小化 p(1)p(1)p(1)(也就是在区间 z∈[1/2,1]z\in[1/\sqrt{2},1]z∈[1/2​,1] 上),还可以进一步证明 p(1)>1/2p(1)>1/\sqrt{2}p(1)>1/2​,因此作用 ppp 不会把 σ1\sigma_{1}σ1​ 降低太多。于是 p(M)p(\bm{M})p(M) 的最大奇异值仍然至多为 111,而较小的奇异值则可能被放大了很大的因子 1/1−z21/\sqrt{1-z^{2}}1/1−z2​。当存在很大的离群奇异值时,zzz 接近 111,这种初始化方案比 PolarExpress 的标准一步能推进得更多。

In Figure 7, we demonstrate the benefit of using the ppp given by (20) on a synthetic matrix whose spectrum follows a power law decay. That is, σj(M)=j−5\sigma_{j}(\bm{M})=j^{-5}σj​(M)=j−5, so this matrix has a large outlying singular value σ1≫σ2\sigma_{1}\gg\sigma_{2}σ1​≫σ2​. Applying (20) costs almost as much as performing an iteration of a degree-5 polynomial method, so for fair comparison, we count it as an additional iteration in this plot. For both Newton-Schulz and Polar Express, performing the extra spectrum-aware initialization step described in this section leads to significant speedups in convergence.

在图 7 中,我们展示在谱按幂律衰减的合成矩阵上使用 (20) 给出的 ppp 所带来的好处。也就是说,σj(M)=j−5\sigma_{j}(\bm{M})=j^{-5}σj​(M)=j−5,因而该矩阵有一个很大的离群奇异值 σ1≫σ2\sigma_{1}\gg\sigma_{2}σ1​≫σ2​。应用 (20) 的代价几乎相当于执行一步五次多项式方法,因此为公平比较,我们在图中把它计为额外的一步。对 Newton-Schulz 和 Polar Express 两者,执行本节所述的额外谱感知初始化步骤都会显著加快收敛。

谱感知初始化对 Newton-Schulz 与 Polar Express 的帮助

Figure 7: Benefits of the spectrum-aware initialization scheme of Appendix E. Using this scheme improves convergence of both Newton-Schulz and Polar Express on a synthetic 32×3232\times 3232×32 matrix with σj(M)=j−5\sigma_{j}(\bm{M})=j^{-5}σj​(M)=j−5. Note that we count the spectrum-aware initialization as an additional iteration.

图 7:附录 E 中谱感知初始化方案的好处。该方案改善了 Newton-Schulz 和 Polar Express 在一张合成 32×3232\times 3232×32 矩阵(σj(M)=j−5\sigma_{j}(\bm{M})=j^{-5}σj​(M)=j−5)上的收敛。注意我们把谱感知初始化计为额外的一步。

Appendix F Fast Polynomial Iteration for Rectangular Matrices

附录 F 矩形矩阵的快速多项式迭代

In this section, we describe a simple method for applying an iterative polynomial method to a rectangular matrix. For matrices with a large aspect ratio, this method yields significant computational savings. We emphasize that this method is applicable to any computation of the form (pT∘⋯∘p1)(X)(p_{T}\circ\cdots\circ p_{1})(\bm{X})(pT​∘⋯∘p1​)(X), where each ptp_{t}pt​ is an odd polynomial. Thus, it can be used to apply Newton-Schulz or Jordan’s polynomials in addition to our own.

本节描述一种把迭代多项式方法作用到矩形矩阵上的简单办法。对纵横比很大的矩阵,这种方法能带来显著的计算节省。我们强调,该方法适用于任意形如 (pT∘⋯∘p1)(X)(p_{T}\circ\cdots\circ p_{1})(\bm{X})(pT​∘⋯∘p1​)(X) 的计算,其中每个 ptp_{t}pt​ 都是奇次多项式。因此,除了我们自己的多项式之外,它也可以用来作用 Newton-Schulz 或 Jordan 的多项式。

As a preliminary, we first describe the baseline approach. Let X∈Rm×n\bm{X}\in\mathbb{R}^{m\times n}X∈Rm×n with m≥nm\geq nm≥n, where α:=m/n≥1\alpha:=m/n\geq 1α:=m/n≥1 is called the aspect ratio. Any odd polynomial ppp of degree d=2q+1d=2q+1d=2q+1 can be represented as p(x)=xh(x2)p(x)=xh(x^{2})p(x)=xh(x2), where hhh is a polynomial of degree qqq. Thus, p(X)=Xh(X⊤X)p(\bm{X})=\bm{X}h(\bm{X}^{\top}\bm{X})p(X)=Xh(X⊤X). Furthermore, hhh can be written in a factored form called Horner’s rule to reduce the number of multiplications. For instance, if h(y)=a+by+cy2+dy3h(y)=a+by+cy^{2}+dy^{3}h(y)=a+by+cy2+dy3, Horner’s rule gives h(y)=a+y(b+y(c+dy))h(y)=a+y\left(b+y\left(c+dy\right)\right)h(y)=a+y(b+y(c+dy)). For a matrix, h(Y)=aI+Y(bI+Y(cI+dY))h(\bm{Y})=a\bm{I}+\bm{Y}\left(b\bm{I}+\bm{Y}\left(c\bm{I}+d\bm{Y}\right)\right)h(Y)=aI+Y(bI+Y(cI+dY)). Thus for Y∈Rn×n\bm{Y}\in\mathbb{R}^{n\times n}Y∈Rn×n, computing h(Y)h(\bm{Y})h(Y) costs about (deg⁡(h)−1)⋅n3\left(\deg(h)-1\right)\cdot n^{3}(deg(h)−1)⋅n3 operations, and computing p(X)=Xh(X⊤X)p(\bm{X})=\bm{X}h(\bm{X}^{\top}\bm{X})p(X)=Xh(X⊤X) costs 2mn2+(d−12−1)⋅n3=(d−32+2α)⋅n32mn^{2}+\left(\frac{d-1}{2}-1\right)\cdot n^{3}=\left(\frac{d-3}{2}+2\alpha\right)\cdot n^{3}2mn2+(2d−1​−1)⋅n3=(2d−3​+2α)⋅n3 operations. This process could be repeated for each iteration p1,…,pTp_{1},\ldots,p_{T}p1​,…,pT​. Notice that if we instead computed h(XX⊤)Xh(\bm{X}\bm{X}^{\top})\bm{X}h(XX⊤)X, the result would be the same but the cost would be higher.

作为预备,我们先描述基准做法。设 X∈Rm×n\bm{X}\in\mathbb{R}^{m\times n}X∈Rm×n 且 m≥nm\geq nm≥n,其中 α:=m/n≥1\alpha:=m/n\geq 1α:=m/n≥1 称为纵横比。任意次数 d=2q+1d=2q+1d=2q+1 的奇次多项式 ppp 都可以写成 p(x)=xh(x2)p(x)=xh(x^{2})p(x)=xh(x2),其中 hhh 是次数为 qqq 的多项式。因此 p(X)=Xh(X⊤X)p(\bm{X})=\bm{X}h(\bm{X}^{\top}\bm{X})p(X)=Xh(X⊤X)。此外,hhh 可以写成称为 Horner 法则的因式形式,以减少乘法次数。例如,若 h(y)=a+by+cy2+dy3h(y)=a+by+cy^{2}+dy^{3}h(y)=a+by+cy2+dy3,Horner 法则给出 h(y)=a+y(b+y(c+dy))h(y)=a+y\left(b+y\left(c+dy\right)\right)h(y)=a+y(b+y(c+dy))。对矩阵,h(Y)=aI+Y(bI+Y(cI+dY))h(\bm{Y})=a\bm{I}+\bm{Y}\left(b\bm{I}+\bm{Y}\left(c\bm{I}+d\bm{Y}\right)\right)h(Y)=aI+Y(bI+Y(cI+dY))。因此对 Y∈Rn×n\bm{Y}\in\mathbb{R}^{n\times n}Y∈Rn×n,计算 h(Y)h(\bm{Y})h(Y) 大约花费 (deg⁡(h)−1)⋅n3\left(\deg(h)-1\right)\cdot n^{3}(deg(h)−1)⋅n3 次运算,而计算 p(X)=Xh(X⊤X)p(\bm{X})=\bm{X}h(\bm{X}^{\top}\bm{X})p(X)=Xh(X⊤X) 花费 2mn2+(d−12−1)⋅n3=(d−32+2α)⋅n32mn^{2}+\left(\frac{d-1}{2}-1\right)\cdot n^{3}=\left(\frac{d-3}{2}+2\alpha\right)\cdot n^{3}2mn2+(2d−1​−1)⋅n3=(2d−3​+2α)⋅n3 次运算。这一过程可以对每一步 p1,…,pTp_{1},\ldots,p_{T}p1​,…,pT​ 重复。注意如果我们改算 h(XX⊤)Xh(\bm{X}\bm{X}^{\top})\bm{X}h(XX⊤)X,结果相同但代价更高。

A major drawback of this naive approach is that it has a strong dependence on α\alphaα, since two rectangular matrix multiplications must be performed in each of the TTT iterations. When m≫nm\gg nm≫n, these two multiplications dominate the cost. In Algorithm 4, we introduce a simple trick that dramatically reduces this cost, using just two rectangular matrix multiplications to compute all TTT iterations.

这种朴素做法的一个主要缺点是对 α\alphaα 的依赖很强,因为在全部 TTT 步的每一步都必须做两次矩形矩阵乘法。当 m≫nm\gg nm≫n 时,这两次乘法会主导代价。在算法 4 中,我们引入一个简单技巧来大幅降低这一代价,只用两次矩形矩阵乘法就能完成全部 TTT 步。

Y=X⊤X\bm{Y}=\bm{X}^{\top}\bm{X}Y=X⊤X ▹\triangleright▹ mn2mn^{2}mn2
Let Q0=I\bm{Q}_{0}=\bm{I}Q0​=I
for t=1,2,…,Tt=1,2,\ldots,Tt=1,2,…,T do
Rt=Qt−1⊤YQt−1\bm{R}_{t}=\bm{Q}_{t-1}^{\top}\bm{Y}\bm{Q}_{t-1}Rt​=Qt−1⊤​YQt−1​ ▹\triangleright▹ 2n32n^{3}2n3
Qt=Qt−1ht(Rt)\bm{Q}_{t}=\bm{Q}_{t-1}h_{t}(\bm{R}_{t})Qt​=Qt−1​ht​(Rt​) ▹\triangleright▹ Horner’s rule: deg⁡(ht)⋅n3\deg(h_{t})\cdot n^{3}deg(ht​)⋅n3
end for
return XQT\bm{X}\bm{Q}_{T}XQT​ ▹\triangleright▹ mn2mn^{2}mn2

Algorithm 4 Fast Polynomial Iteration for Rectangular Matrices

Y=X⊤X\bm{Y}=\bm{X}^{\top}\bm{X}Y=X⊤X ▹\triangleright▹ mn2mn^{2}mn2
令 Q0=I\bm{Q}_{0}=\bm{I}Q0​=I
for t=1,2,…,Tt=1,2,\ldots,Tt=1,2,…,T do
Rt=Qt−1⊤YQt−1\bm{R}_{t}=\bm{Q}_{t-1}^{\top}\bm{Y}\bm{Q}_{t-1}Rt​=Qt−1⊤​YQt−1​ ▹\triangleright▹ 2n32n^{3}2n3
Qt=Qt−1ht(Rt)\bm{Q}_{t}=\bm{Q}_{t-1}h_{t}(\bm{R}_{t})Qt​=Qt−1​ht​(Rt​) ▹\triangleright▹ Horner 法则:deg⁡(ht)⋅n3\deg(h_{t})\cdot n^{3}deg(ht​)⋅n3
end for
return XQT\bm{X}\bm{Q}_{T}XQT​ ▹\triangleright▹ mn2mn^{2}mn2

算法 4 矩形矩阵的快速多项式迭代

To see why this works, define q0(x)=xq_{0}(x)=xq0​(x)=x,

为看清这为何成立,定义 q0(x)=xq_{0}(x)=xq0​(x)=x,

qt(x)=(pt∘⋯∘p1)(x)x=pt((pt−1∘⋯∘p1)(x))x=pt(xqt−1(x))x=xqt−1(x)⋅ht((xqt−1(x))2)x=qt−1(x)⋅ht(x2⋅qt−1(x)2)(21)\displaystyle q_{t}(x) \\ \displaystyle=\frac{(p_{t}\circ\cdots\circ p_{1})(x)}{x}=\frac{p_{t}\left((p_{t-1}\circ\cdots\circ p_{1})(x)\right)}{x}=\frac{p_{t}\left(xq_{t-1}(x)\right)}{x} \\ \displaystyle=\frac{xq_{t-1}(x)\cdot h_{t}\left((xq_{t-1}(x))^{2}\right)}{x}=q_{t-1}(x)\cdot h_{t}\left(x^{2}\cdot q_{t-1}(x)^{2}\right) \tag{21}qt​(x)=x(pt​∘⋯∘p1​)(x)​=xpt​((pt−1​∘⋯∘p1​)(x))​=xpt​(xqt−1​(x))​=xxqt−1​(x)⋅ht​((xqt−1​(x))2)​=qt−1​(x)⋅ht​(x2⋅qt−1​(x)2)(21)

and rt(x)=x2⋅qt−1(x)2r_{t}(x)=x^{2}\cdot q_{t-1}(x)^{2}rt​(x)=x2⋅qt−1​(x)2. It is clear by induction that Rt=rt(X),Qt=qt(X)\bm{R}_{t}=r_{t}(\bm{X}),\bm{Q}_{t}=q_{t}(\bm{X})Rt​=rt​(X),Qt​=qt​(X), and XQT=(pt∘⋯∘p1)(X)\bm{X}\bm{Q}_{T}=(p_{t}\circ\cdots\circ p_{1})(\bm{X})XQT​=(pt​∘⋯∘p1​)(X). As promised, this algorithm uses no rectangular multiplications in the for-loop. If each ptp_{t}pt​ is degree ddd, then the total cost is (d+32T+2α)⋅n3\left(\frac{d+3}{2}T+2\alpha\right)\cdot n^{3}(2d+3​T+2α)⋅n3. When α>1.5TT−1\alpha>1.5\frac{T}{T-1}α>1.5T−1T​, this is smaller than the naive method. We can use this criterion to select either Algorithm 4 or the baseline method at runtime.

以及 rt(x)=x2⋅qt−1(x)2r_{t}(x)=x^{2}\cdot q_{t-1}(x)^{2}rt​(x)=x2⋅qt−1​(x)2。由归纳法显然有 Rt=rt(X)\bm{R}_{t}=r_{t}(\bm{X})Rt​=rt​(X)、Qt=qt(X)\bm{Q}_{t}=q_{t}(\bm{X})Qt​=qt​(X),以及 XQT=(pt∘⋯∘p1)(X)\bm{X}\bm{Q}_{T}=(p_{t}\circ\cdots\circ p_{1})(\bm{X})XQT​=(pt​∘⋯∘p1​)(X)。如所承诺,该算法在 for 循环中不做任何矩形乘法。如果每个 ptp_{t}pt​ 的次数都是 ddd,则总代价为 (d+32T+2α)⋅n3\left(\frac{d+3}{2}T+2\alpha\right)\cdot n^{3}(2d+3​T+2α)⋅n3。当 α>1.5TT−1\alpha>1.5\frac{T}{T-1}α>1.5T−1T​ 时,这比朴素方法更小。我们可以在运行时用这一判据来选择算法 4 或基准方法。

There is one significant weakness of Algorithm 4. In bfloat16 precision, it can introduce numerical errors. Our intuition for why this happens is as follows. Let X=UΣV⊤\bm{X}=\bm{U}\bm{\Sigma}\bm{V}^{\top}X=UΣV⊤ be the SVD. For large TTT, (pT∘⋯p1)(X)=XQT≈\polar(X)=UV⊤(p_{T}\circ\cdots p_{1})(\bm{X})=\bm{X}\bm{Q}_{T}\approx\polar(\bm{X})=\bm{U}\bm{V}^{\top}(pT​∘⋯p1​)(X)=XQT​≈\polar(X)=UV⊤. Thus, QT≈V⊤Σ−1V\bm{Q}_{T}\approx\bm{V}^{\top}\bm{\Sigma}^{-1}\bm{V}QT​≈V⊤Σ−1V. When X\bm{X}X has very small singular values and the floating point precision is very low, instantiating QT\bm{Q}_{T}QT​ may be unstable. To mitigate this issue, we use a restarting strategy. Notice that the issue arises only for large TTT, for which (pT∘⋯∘p1)(ϵ)≈1(p_{T}\circ\cdots\circ p_{1})(\epsilon)\approx 1(pT​∘⋯∘p1​)(ϵ)≈1. Limiting ourselves to T=3T=3T=3 iterations improves the conditioning of QT\bm{Q}_{T}QT​ because (pT∘⋯∘p1)(ϵ)≪1(p_{T}\circ\cdots\circ p_{1})(\epsilon)\ll 1(pT​∘⋯∘p1​)(ϵ)≪1 Thus, to compute T=6T=6T=6 iterations, we can apply Algorithm 4 first to the first three polynomials, then again to the last three polynomials. Note that restarting Algorithm 4 after every iteration is exactly the same as the baseline method. This approach provides a tunable hyperparameter—the number of iterations we apply before restarting Algorithm 4—allowing us to find a balance between the fully stable but slow baseline on the one hand, and a very fast but numerically risky method on the other hand.

算法 4 有一个显著弱点。在 bfloat16 精度下,它可能引入数值误差。我们对原因的直觉如下。设 X=UΣV⊤\bm{X}=\bm{U}\bm{\Sigma}\bm{V}^{\top}X=UΣV⊤ 为 SVD。对很大的 TTT,(pT∘⋯p1)(X)=XQT≈\polar(X)=UV⊤(p_{T}\circ\cdots p_{1})(\bm{X})=\bm{X}\bm{Q}_{T}\approx\polar(\bm{X})=\bm{U}\bm{V}^{\top}(pT​∘⋯p1​)(X)=XQT​≈\polar(X)=UV⊤。因此 QT≈V⊤Σ−1V\bm{Q}_{T}\approx\bm{V}^{\top}\bm{\Sigma}^{-1}\bm{V}QT​≈V⊤Σ−1V。当 X\bm{X}X 有非常小的奇异值且浮点精度很低时,实例化 QT\bm{Q}_{T}QT​ 可能不稳定。为缓解这一问题,我们使用一种重启策略。注意该问题只在 TTT 很大、从而 (pT∘⋯∘p1)(ϵ)≈1(p_{T}\circ\cdots\circ p_{1})(\epsilon)\approx 1(pT​∘⋯∘p1​)(ϵ)≈1 时出现。把自己限制在 T=3T=3T=3 步会改善 QT\bm{Q}_{T}QT​ 的条件,因为此时 (pT∘⋯∘p1)(ϵ)≪1(p_{T}\circ\cdots\circ p_{1})(\epsilon)\ll 1(pT​∘⋯∘p1​)(ϵ)≪1。因此,要计算 T=6T=6T=6 步,我们可以先对前三个多项式应用算法 4,再对后三个多项式再应用一次。注意每一步都重启算法 4,就恰好回到基准方法。这一做法提供了一个可调超参数——在重启算法 4 之前应用的步数——让我们能在一端完全稳定但较慢的基准方法,与另一端非常快但数值上有风险的方法之间取得平衡。

Figure 8 shows that using Algorithm 4 can dramatically improve runtime on the GPU when the aspect ratio is large enough. As expected, using Algorithm 4 for many iterations significantly reduces the dependence of the runtime on the aspect ratio. Running six iterations of a degree-5 polynomial method when α=4\alpha=4α=4 (as with the linear transformations in each MLP block of a transformer) we obtain almost a 2x speedup, and when α=32\alpha=32α=32, we obtain nearly a 10x speedup. If we restart every three iterations, the trend is the same but the runtime savings are somewhat smaller.

图 8 表明,当纵横比足够大时,使用算法 4 可以显著改善 GPU 上的运行时间。如所预期,把算法 4 用于许多步,会显著降低运行时间对纵横比的依赖。当 α=4\alpha=4α=4 时(正如 Transformer 每个 MLP 块中的线性变换),跑六步五次多项式方法几乎能获得 2 倍加速;当 α=32\alpha=32α=32 时,加速接近 10 倍。若每三步重启一次,趋势相同,但运行时间节省会少一些。

矩形矩阵上加速多项式迭代的 GPU 运行时间

Figure 8: Effects of using Algorithm 4 on runtime on a GPU. We run T=6T=6T=6 iterations of a degree-5 polynomial method on matrices with various dimensions nnn and aspect ratios α\alphaα. Restart interval =6=6=6 is Algorithm 4, restart interval =1=1=1 is equivalent to the baseline (that is, not using Algorithm 4), and restart interval =3=3=3 is an intermediate method that calls Algorithm 4 once to do the first three iterations and again to do the last three iterations for greater stability. When α≫1\alpha\gg 1α≫1, increasing the restart interval significantly reduces the runtime.

图 8:使用算法 4 对 GPU 运行时间的影响。我们在不同维数 nnn 和纵横比 α\alphaα 的矩阵上,对一种五次多项式方法跑 T=6T=6T=6 步。重启间隔 =6=6=6 就是算法 4,重启间隔 =1=1=1 等价于基准方法(也就是不使用算法 4),重启间隔 =3=3=3 是一种中间方法:先调用一次算法 4 做前三步,再调用一次做后三步,以获得更好的稳定性。当 α≫1\alpha\gg 1α≫1 时,增大重启间隔会显著降低运行时间。

Preliminary experiments using Algorithm 4 with Muon in bfloat16 were not successful. The training and validation losses were sometimes significantly higher than before, even accounting for the runtime savings of Algorithm 4. While this technique may already be applicable in float32 or for architectures whose weight matrices have larger aspect rations, more work is needed to make it practical for general deep learning applications.

把算法 4 与 Muon 一起用于 bfloat16 的初步实验并不成功。即便把算法 4 节省的运行时间考虑在内,训练损失和验证损失有时仍显著高于从前。虽然这一技术也许已经可以用于 float32,或用于权重矩阵纵横比更大的架构,但要使它对一般的深度学习应用切实可用,还需要更多工作。

If these problems can be mitigated, the speed afforded by Algorithm 4 suggests a potentially beneficial change in the way Muon is applied to transformers. Each multi-head attention layer contains four square weight matrices WQ,WK,WV\bm{W}_{Q},\bm{W}_{K},\bm{W}_{V}WQ​,WK​,WV​ and WO∈Rd×d\bm{W}_{O}\in\mathbb{R}^{d\times d}WO​∈Rd×d. The orthogonalization step of Muon is either applied separately to these four matrices or else to [WQ∣WK∣WV][\bm{W}_{Q}\mid\bm{W}_{K}\mid\bm{W}_{V}][WQ​∣WK​∣WV​] and WO\bm{W}_{O}WO​, since typical implementations of multi-head attention store the weights in this concatenated form. However, we believe it is natural to consider each of these four weight matrices to be a concatenation of many smaller linear transformations, each corresponding to a single attention head. If HHH is the number of heads, each of these smaller matrices has size d×dHd\times\frac{d}{H}d×Hd​; that is, they have aspect ratio α=H\alpha=Hα=H. Since typical transformers like GPT-3 can have as many as 969696 heads, this version of Muon can yield huge savings in the runtime of each step. We leave it to future work to examine whether this version of Muon also enjoys fast convergence.

如果这些问题能够缓解,算法 4 带来的速度提示我们,也许可以改变 Muon 作用于 Transformer 的方式。每个多头注意力层包含四个方的权重矩阵 WQ\bm{W}_{Q}WQ​、WK\bm{W}_{K}WK​、WV\bm{W}_{V}WV​ 和 WO∈Rd×d\bm{W}_{O}\in\mathbb{R}^{d\times d}WO​∈Rd×d。Muon 的正交化步骤要么分别作用于这四个矩阵,要么作用于 [WQ∣WK∣WV][\bm{W}_{Q}\mid\bm{W}_{K}\mid\bm{W}_{V}][WQ​∣WK​∣WV​] 和 WO\bm{W}_{O}WO​,因为多头注意力的典型实现会按这种拼接形式存储权重。不过我们觉得,把这四个权重矩阵各自看成许多更小线性变换的拼接是很自然的,每一个小变换对应一个注意力头。若 HHH 是头数,这些较小矩阵的大小为 d×dHd\times\frac{d}{H}d×Hd​;也就是说,它们的纵横比为 α=H\alpha=Hα=H。既然像 GPT-3 这样的典型 Transformer 可以有多达 969696 个头,这种版本的 Muon 可以在每一步的运行时间上带来巨大节省。我们把考察这种版本的 Muon 是否同样收敛很快留给未来工作。

Appendix G Code for Constructing Polynomials of Polar Express

附录 G 构造 Polar Express 多项式的代码

The following code gives a Python implementation of the offline stage of Algorithm 2. This code was used to construct the coefficients of the polynomials given in (), which in turn were used in our Muon experiments (Section 5.2). It uses ℓ=10−3\ell=10^{-3}ℓ=10−3 and u=1u=1u=1 by default. It incorporates Algorithm 3 and the numerical tweaks described in Section 4.4

下面的代码给出算法 2 离线阶段的一个 Python 实现。这段代码被用来构造 () 中给出的多项式系数,而这些系数又被用于我们的 Muon 实验(第 5.2 节)。它默认使用 ℓ=10−3\ell=10^{-3}ℓ=10−3 和 u=1u=1u=1。它纳入了算法 3 以及第 4.4 节所述的数值调整

The Polar Express: Optimal Matrix Sign Methods and Their Application to the Muon Algorithm | AGIDaily