math-skill 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en-US.md +9 -1
- package/README.md +9 -1
- package/agents/math-critic.en.md +27 -25
- package/agents/math-critic.md +27 -27
- package/commands/ask.en.md +10 -0
- package/commands/ask.md +1 -1
- package/design-patterns/attention/equivariant-attention.en.md +9 -9
- package/design-patterns/attention/equivariant-attention.md +9 -9
- package/design-patterns/attention/geometry-aware-attention.en.md +9 -9
- package/design-patterns/attention/geometry-aware-attention.md +9 -9
- package/design-patterns/attention/information-bottleneck-attention.en.md +9 -9
- package/design-patterns/attention/information-bottleneck-attention.md +9 -9
- package/design-patterns/attention/projection-attention.en.md +9 -9
- package/design-patterns/attention/projection-attention.md +9 -9
- package/design-patterns/attention/spectral-attention.en.md +9 -9
- package/design-patterns/attention/spectral-attention.md +9 -9
- package/design-patterns/compression/leverage-score-selection.en.md +1 -1
- package/design-patterns/compression/leverage-score-selection.md +1 -1
- package/design-patterns/compression/low-rank-kv-cache.en.md +1 -1
- package/design-patterns/compression/low-rank-kv-cache.md +1 -1
- package/design-patterns/compression/spectral-token-pruning.en.md +1 -1
- package/design-patterns/compression/spectral-token-pruning.md +1 -1
- package/design-patterns/compression/topology-preserving-compression.en.md +1 -1
- package/design-patterns/compression/topology-preserving-compression.md +1 -1
- package/design-patterns/loss/constraint-penalty.en.md +1 -1
- package/design-patterns/loss/constraint-penalty.md +1 -1
- package/design-patterns/loss/contrastive-loss.en.md +1 -1
- package/design-patterns/loss/contrastive-loss.md +1 -1
- package/design-patterns/loss/information-bottleneck-loss.en.md +1 -1
- package/design-patterns/loss/information-bottleneck-loss.md +1 -1
- package/design-patterns/loss/orthogonality-loss.en.md +1 -1
- package/design-patterns/loss/orthogonality-loss.md +1 -1
- package/design-patterns/loss/variational-loss.en.md +1 -1
- package/design-patterns/loss/variational-loss.md +1 -1
- package/design-patterns/representation/equivariant-split.en.md +1 -1
- package/design-patterns/representation/equivariant-split.md +1 -1
- package/design-patterns/representation/manifold-representation.en.md +1 -1
- package/design-patterns/representation/manifold-representation.md +1 -1
- package/design-patterns/representation/shared-private-decomposition.en.md +1 -1
- package/design-patterns/representation/shared-private-decomposition.md +1 -1
- package/design-patterns/representation/subspace-alignment.en.md +1 -1
- package/design-patterns/representation/subspace-alignment.md +1 -1
- package/design-patterns/routing/graph-routing.en.md +1 -1
- package/design-patterns/routing/graph-routing.md +1 -1
- package/design-patterns/routing/moe-routing.en.md +1 -1
- package/design-patterns/routing/moe-routing.md +1 -1
- package/design-patterns/routing/optimal-transport-routing.en.md +1 -1
- package/design-patterns/routing/optimal-transport-routing.md +1 -1
- package/design-patterns/routing/spectral-clustering-routing.en.md +1 -1
- package/design-patterns/routing/spectral-clustering-routing.md +1 -1
- package/knowledge-base/differential-geometry/metric-tensor.md +1 -1
- package/knowledge-base/information-geometry/fisher-metric.en.md +8 -8
- package/knowledge-base/information-geometry/fisher-metric.md +8 -8
- package/knowledge-base/information-geometry/natural-gradient.en.md +7 -7
- package/knowledge-base/information-geometry/natural-gradient.md +7 -7
- package/knowledge-base/overview.en.md +2 -2
- package/knowledge-base/overview.md +2 -2
- package/knowledge-base/probability/concentration-inequality.en.md +5 -5
- package/knowledge-base/probability/concentration-inequality.md +5 -5
- package/knowledge-base/probability/entropy.en.md +5 -5
- package/knowledge-base/probability/entropy.md +5 -5
- package/knowledge-base/probability/fisher-information.en.md +7 -7
- package/knowledge-base/probability/fisher-information.md +7 -7
- package/knowledge-base/probability/information-bottleneck.en.md +6 -6
- package/knowledge-base/probability/information-bottleneck.md +6 -6
- package/knowledge-base/probability/kl-divergence.en.md +6 -6
- package/knowledge-base/probability/kl-divergence.md +6 -6
- package/lenses/algorithmic.en.md +1 -1
- package/lenses/algorithmic.md +1 -1
- package/lenses/axiomatization.en.md +1 -1
- package/lenses/axiomatization.md +1 -1
- package/lenses/categorical.en.md +1 -1
- package/lenses/categorical.md +1 -1
- package/lenses/causal.en.md +1 -1
- package/lenses/causal.md +1 -1
- package/lenses/duality.en.md +1 -1
- package/lenses/duality.md +1 -1
- package/lenses/game.en.md +2 -2
- package/lenses/game.md +2 -2
- package/lenses/geometric.en.md +1 -1
- package/lenses/geometric.md +1 -1
- package/lenses/local-to-global.en.md +1 -1
- package/lenses/local-to-global.md +1 -1
- package/lenses/perturbation.en.md +1 -1
- package/lenses/perturbation.md +1 -1
- package/lenses/probabilistic.en.md +1 -1
- package/lenses/probabilistic.md +1 -1
- package/lenses/projection.en.md +1 -1
- package/lenses/projection.md +1 -1
- package/lenses/spectral.en.md +1 -1
- package/lenses/spectral.md +1 -1
- package/lenses/symmetry.en.md +1 -1
- package/lenses/symmetry.md +1 -1
- package/lenses/topological.en.md +1 -1
- package/lenses/topological.md +1 -1
- package/lenses/variational.en.md +1 -1
- package/lenses/variational.md +1 -1
- package/package.json +1 -1
- package/references/agentic-workflow.en.md +1 -1
- package/references/agentic-workflow.md +1 -1
- package/references/books/abstract-algebra.en.md +124 -0
- package/references/books/abstract-algebra.md +17 -17
- package/references/books/algebraic-geometry-rising-sea.en.md +171 -0
- package/references/books/algebraic-geometry-rising-sea.md +7 -7
- package/references/books/differential-geometry.en.md +140 -0
- package/references/books/differential-geometry.md +18 -18
- package/references/books/matrix-analysis.en.md +146 -0
- package/references/books/matrix-analysis.md +8 -8
- package/references/books/micro-lie-theory.en.md +116 -0
- package/references/books/micro-lie-theory.md +16 -16
- package/references/books/optimization-ml.en.md +163 -0
- package/references/books/optimization-ml.md +6 -7
- package/references/books/smooth-manifolds.en.md +105 -0
- package/references/books/smooth-manifolds.md +12 -12
- package/references/gpu-friendly-math.en.md +15 -2
- package/references/gpu-friendly-math.md +15 -2
- package/skills/math-research-activator/SKILL.en.md +27 -1
- package/skills/math-research-activator/SKILL.md +26 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 流形与微分几何 / Manifolds & Differential Geometry
|
|
2
2
|
|
|
3
3
|
> **Manifolds and Differential Geometry** — Jeffrey M. Lee
|
|
4
4
|
> American Mathematical Society, *Graduate Studies in Mathematics*, Volume 107 (2009), ISBN 978-0-8218-4815-9.
|
|
@@ -77,36 +77,36 @@
|
|
|
77
77
|
> 用 `../gpu-friendly-math.md` 的**八维记分卡**逐项评判。微分几何最大的坑是"度量 / 曲率矩阵的求逆与物化"。
|
|
78
78
|
|
|
79
79
|
- **维度 2/3(GEMM 可映射 / 复杂度)—— 求逆是生死线。** 朴素自然梯度要算 N×N Fisher 的逆,N 是参数量(~10⁹),O(N³) 求逆 + O(N²) 显存,**直接出局**。
|
|
80
|
-
- **可改造
|
|
80
|
+
- **可改造 [v]**:**K-FAC** 把 F 分块为 Kronecker 积 A⊗B,利用 (A⊗B)⁻¹ = A⁻¹⊗B⁻¹,只需对两个小因子求逆,且预条件作用到梯度上**就是 GEMM**。这就是"能否 Kronecker 因子化为 GEMM"的肯定答案——能,且这是它唯一可上集群的形态。
|
|
81
81
|
- **维度 4(显存)—— 不要物化全 Hessian / 全曲率张量。** Riemann 曲率张量是 4 阶,全物化爆显存。用 **Hessian-vector product(HVP)** 经一次反向以 O(N) 拿到曲率信息,避免 N×N。
|
|
82
82
|
- **维度 5(低精度)—— Fisher / 度量矩阵常病态。** bf16/fp16 下求逆灾难性放大误差,**必须加阻尼(damping / Tikhonov,F+λI)** 并把求逆留在 fp32;否则违反"低精度稳定"。
|
|
83
83
|
- **维度 6(并行)—— 平行移动 / 测地线是串行 ODE。** 沿曲线积分联络方程是长串行递推,并行性差;工程上用**一步 retraction / 闭式平行移动**(特定流形有解析公式)替代逐步积分。
|
|
84
|
-
- **维度 1/2(张量化 / GEMM)—— 群卷积可友好,但连续群要当心。** 离散群(如 C_n、八面体群)的群卷积可展开成 GEMM
|
|
84
|
+
- **维度 1/2(张量化 / GEMM)—— 群卷积可友好,但连续群要当心。** 离散群(如 C_n、八面体群)的群卷积可展开成 GEMM [v];连续李群需采样离散化,采样不当会导致等变性破缺 + 不规则 gather/scatter(维度 7 稀疏不友好)。
|
|
85
85
|
|
|
86
86
|
**自然梯度 / K-FAC 八维记分卡(worked example):**
|
|
87
87
|
|
|
88
88
|
| 维度 | 朴素自然梯度(全 Fisher 求逆)| K-FAC(Kronecker 因子化)|
|
|
89
89
|
|------|------------------------------|--------------------------|
|
|
90
|
-
| 1 张量化 |
|
|
91
|
-
| 2 GEMM |
|
|
92
|
-
| 3 复杂度 |
|
|
93
|
-
| 4 显存 |
|
|
94
|
-
| 5 低精度 |
|
|
95
|
-
| 6 并行 |
|
|
96
|
-
| 7 稀疏 | — |
|
|
97
|
-
| 8 融合 |
|
|
90
|
+
| 1 张量化 | [x] 大矩阵显式逆 | [v] 批量小矩阵代数 |
|
|
91
|
+
| 2 GEMM | [x] N×N 求逆无法 GEMM | [v] A⁻¹⊗B⁻¹ 作用 = GEMM 链 |
|
|
92
|
+
| 3 复杂度 | [x] O(N³) | [v] 两个小因子,亚立方 |
|
|
93
|
+
| 4 显存 | [x] 物化 N×N | [v] 只存两个小因子 |
|
|
94
|
+
| 5 低精度 | [x] 病态、需 fp64 | [~] 加阻尼 + fp32 求逆可改造 |
|
|
95
|
+
| 6 并行 | [~] 单次大求逆难并行 | [v] 各层因子独立、可并行 |
|
|
96
|
+
| 7 稀疏 | — | [v] 块对角结构化 |
|
|
97
|
+
| 8 融合 | [x] | [v] 预条件可融进优化器 kernel |
|
|
98
98
|
|
|
99
99
|
**结论**:黎曼 / 信息几何方法**只有在度量被结构化因子化(Kronecker / 块对角 / 低秩)后才 GPU 可行**;精确求逆与精确平行移动都属于"美但不可算",须改造或淘汰。
|
|
100
100
|
|
|
101
101
|
## 该调用哪个思想透镜
|
|
102
102
|
|
|
103
|
-
- **symmetry
|
|
104
|
-
- **
|
|
105
|
-
- **
|
|
106
|
-
- **
|
|
107
|
-
- **topological
|
|
103
|
+
- **symmetry(对称与不变性)—— 首选。** 规范等变、李群对称、纤维丛 = 把"frame / 坐标选择无关"编码成对称性,是本书与 DL 最强的接口。
|
|
104
|
+
- **variational(变分)—— 并列首选。** 自然梯度、Riemannian SGD、曲率正则都是"在弯曲约束空间里找最优"。
|
|
105
|
+
- **duality(对偶)**:指数 / 对数映射、retraction、坐标变换简化问题。
|
|
106
|
+
- **geometric(几何)**:把参数 / 数据空间显式建模为流形,再翻译回算法。
|
|
107
|
+
- **topological(拓扑)**:辅助——de Rham 上同调 / 整体不变量用于守恒量与可积性诊断。
|
|
108
108
|
|
|
109
|
-
组合建议:先 `symmetry` 定对称结构 → `
|
|
109
|
+
组合建议:先 `symmetry` 定对称结构 → `variational` 落到自然梯度 / Riemannian 优化 → `duality` 处理 retraction → 过 `../gpu-friendly-math.md` 验收门。
|
|
110
110
|
|
|
111
111
|
## 反模式
|
|
112
112
|
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
|
|
128
128
|
## 深挖入口
|
|
129
129
|
|
|
130
|
-
>
|
|
130
|
+
> **书目信息**:Jeffrey M. Lee, *Manifolds and Differential Geometry*, Graduate Studies in Mathematics Vol. 107, American Mathematical Society, 2009. ISBN 978-0-8218-4815-9.
|
|
131
131
|
>
|
|
132
132
|
> **启用方式**:将 `Manifolds and Differential Geometry.pdf` 放入项目根目录的 `math_book/` 文件夹,Agent 即可自动搜索原文。PDF 不随 npm/git 分发(版权原因),需自行获取。
|
|
133
133
|
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Matrix Analysis
|
|
2
|
+
|
|
3
|
+
> Roger A. Horn & Charles R. Johnson, *Matrix Analysis*, 2nd Edition, Cambridge University Press, 2013 (ISBN 978-0-521-83940-2). A graduate-level classic of matrix theory unified by the theme of **canonical forms**.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
This is the authoritative reference for upgrading "linear algebra" to "matrix analysis": not just computing with matrices, but studying invariants under **similarity / unitary equivalence / congruence** transformations, canonical forms, eigenvalue location and perturbation, norm geometry, and positive-definite/nonnegative structures. For AI/ML/GPU, it is the **backbone closest to the hardware-level operators** in the v2 reading list -- GEMM, numerical stability, low-rank compression, and second-order optimization all trace their roots here.
|
|
8
|
+
|
|
9
|
+
Actual chapter map (from the table of contents):
|
|
10
|
+
|
|
11
|
+
- **Ch 0 Review and Miscellanea**: rank, nonsingularity, inner products, block matrices -- quick-reference foundation.
|
|
12
|
+
- **Ch 1 Eigenvalues, Eigenvectors, and Similarity**: characteristic equations, characteristic polynomials, algebraic/geometric multiplicity, similarity (Sec. 1.1-1.4).
|
|
13
|
+
- **Ch 2 Unitary Similarity and Unitary Equivalence**: QR decomposition (Sec. 2.1), Schur triangularization (Sec. 2.4), normal matrices (Sec. 2.5), **SVD (Sec. 2.6)**, CS decomposition (Sec. 2.7).
|
|
14
|
+
- **Ch 3 Canonical Forms for Similarity and Triangular Factorizations**: Jordan canonical form (Sec. 3.1), minimal polynomials and companion matrices (Sec. 3.3), real Jordan and Weyr forms (Sec. 3.4), triangular factorization LU (Sec. 3.5).
|
|
15
|
+
- **Ch 4 Hermitian, Symmetric Matrices, and Congruences**: variational characterization Courant-Fischer (Sec. 4.2), eigenvalue inequalities Weyl/interlacing (Sec. 4.3), congruences and Sylvester's law of inertia (Sec. 4.5).
|
|
16
|
+
- **Ch 5 Norms for Vectors and Matrices**: norms and inner products, dual norms (Sec. 5.5), **matrix norms (Sec. 5.6-5.7)**, **condition numbers (Sec. 5.8)**.
|
|
17
|
+
- **Ch 6 Location and Perturbation of Eigenvalues**: Gershgorin discs (Sec. 6.1-6.2), eigenvalue perturbation theorems (Sec. 6.3).
|
|
18
|
+
- **Ch 7 Positive Definite and Semidefinite Matrices**: polar decomposition and SVD (Sec. 7.3-7.4), **Schur product theorem (Sec. 7.5)**, simultaneous diagonalization (Sec. 7.6), Loewner partial order and block matrices (Sec. 7.7), positive-definite inequalities (Sec. 7.8).
|
|
19
|
+
- **Ch 8 Positive and Nonnegative Matrices**: Perron-Frobenius (Sec. 8.2-8.5), stochastic and doubly stochastic matrices (Sec. 8.7).
|
|
20
|
+
- Appendices A-F: complex numbers, **convex sets and functions (B)**, fundamental theorem of algebra, eigenvalue continuity, compactness, canonical pairs (F).
|
|
21
|
+
|
|
22
|
+
**Boundary reminder for activation**: this book is **theory-first** -- addressing existence, characterizations, inequalities, and canonical forms, **not numerical algorithm recipes**. Specific algorithm implementations, convergence constants, and stability details (e.g., communication lower bounds for blocked QR, actual complexity coefficients for SVD) require a companion numerical linear algebra textbook (Golub-Van Loan / Trefethen-Bau). What is provided here is an **activation index** for "which structure to use + why + can the GPU compute it"; for implementation details, consult those books.
|
|
23
|
+
|
|
24
|
+
## Core Structures Transferable to AI/Infra
|
|
25
|
+
|
|
26
|
+
| Mathematical structure (chapter) | Transfer to ML / algorithms / Infra |
|
|
27
|
+
|---|---|
|
|
28
|
+
| **SVD / low-rank (Sec. 2.6, 7.4)** | The foundation of all low-rank compression: LoRA, PCA/whitening, Eckart-Young optimal low-rank approximation, KV-Cache low-rank reduction, weight compression |
|
|
29
|
+
| **Spectrum and similarity invariants (Ch 1)** | Hessian/gradient covariance spectra, spectral radius determines stability of linear attention / SSM / RNN, trace = parameter counting / regularization |
|
|
30
|
+
| **Schur triangularization + normal matrices (Sec. 2.4-2.5)** | Foundation for numerical EVD algorithms (QR algorithm); normal <=> unitarily diagonalizable, the criterion for "well-behaved spectra" |
|
|
31
|
+
| **Variational characterization Courant-Fischer (Sec. 4.2)** | Rayleigh quotients, spectral normalization, spectral clustering, PCA as min-max; largest singular value = operator norm |
|
|
32
|
+
| **Eigenvalue perturbation Weyl/Bauer-Fike (Sec. 4.3, 6.3)** | Spectral shift bounds under quantization/low-precision/pruning, training perturbation robustness, stability certificates |
|
|
33
|
+
| **Matrix norms + duality (Sec. 5.5-5.7)** | Spectral norm (gradient clipping / Lipschitz), Frobenius (weight decay), **nuclear norm = dual of spectral norm** (low-rank regularization) |
|
|
34
|
+
| **Condition numbers (Sec. 5.8)** | Numerical stability diagnostics, preconditioning, why bf16 training diverges |
|
|
35
|
+
| **Polar decomposition + Newton-Schulz (Sec. 7.3)** | Orthogonalizing gradients/weights (Muon optimizer, orthogonal initialization), computable with pure GEMM |
|
|
36
|
+
| **Positive definiteness / PSD (Ch 7)** | Kernel methods, covariances, attention Gram matrices, second-order method preconditioners, Loewner partial order for matrix inequalities |
|
|
37
|
+
| **Schur product theorem (Sec. 7.5)** | Hadamard products preserve PSD -- learnable kernel engineering, gating that does not destroy positive-definite structure |
|
|
38
|
+
| **Perron-Frobenius / stochastic matrices (Ch 8)** | Row-stochastic attention mixing and collapse (over-smoothing), PageRank, graph propagation, spectral gap = expressivity |
|
|
39
|
+
|
|
40
|
+
The table above is organized into four **activation families** for convenient retrieval:
|
|
41
|
+
|
|
42
|
+
- **Spectral family (Ch 1-3)**: eigenvalues / similarity / canonical forms -- answering "is the dynamics stable, what does the spectrum look like." Note that Jordan/Weyr forms are theoretical tools; numerically one turns to Schur/SVD.
|
|
43
|
+
- **Norm family (Ch 5-6)**: norms / duality / condition numbers / perturbation -- answering "how do errors propagate, is low precision stable, should we precondition."
|
|
44
|
+
- **Positive-definite family (Ch 4, 7)**: Hermitian / PSD / polar decomposition / Loewner -- answering "second-order structure, kernels, covariances, nearest orthogonal matrix."
|
|
45
|
+
- **Nonnegative family (Ch 8)**: Perron-Frobenius / stochastic matrices -- answering "propagation, mixing, collapse, stationary distributions."
|
|
46
|
+
|
|
47
|
+
## Key Bridging Facts (Activation Shorthand)
|
|
48
|
+
|
|
49
|
+
When "activating" this book into algorithms, these are the most frequently used connecting facts -- memorizing them enables rapid navigation between structures:
|
|
50
|
+
|
|
51
|
+
- **Condition number kappa_2(A) = sigma_max / sigma_min (Sec. 5.8)**: directly predicts how many orders of magnitude errors are amplified under bf16/fp8.
|
|
52
|
+
- **SVD <=> eigendecomposition of A^H A and A A^H, sigma = sqrt(lambda) (Sec. 2.6, 7.4)**: singular values are the square roots of the Gram matrix eigenvalues.
|
|
53
|
+
- **Spectral norm = sigma_max, Frobenius = sqrt(Sum sigma^2), nuclear norm = Sum sigma (Sec. 5.6)**: all three major matrix norms are determined entirely by singular values; spectral norm and nuclear norm are dual to each other.
|
|
54
|
+
- **Normal matrices <=> unitarily diagonalizable (Sec. 2.5)**: the only class where "eigenvalue = singular value structure is well-conditioned"; for non-normal matrices one must look at pseudospectra.
|
|
55
|
+
- **Positive definite <=> all eigenvalues > 0 <=> all leading principal minors > 0 (Sec. 7.1)**: the latter is a computable positive-definiteness test (Sylvester's criterion).
|
|
56
|
+
- **Polar decomposition A = UP, P = (A^H A)^{1/2} (Sec. 7.3)**: Newton-Schulz iteration converges to the orthogonal factor U.
|
|
57
|
+
- **Weyl perturbation bound |lambda_i(A+E) - lambda_i(A)| <= ||E||_2 (Sec. 4.3)**: one line gives the spectral shift upper bound for quantization/pruning.
|
|
58
|
+
- **Row-stochastic matrix spectral radius = 1 (Sec. 8.7)**: the Perron root of attention is always 1; the spectral gap determines the collapse rate.
|
|
59
|
+
|
|
60
|
+
## Problem Types Suited for Activation
|
|
61
|
+
|
|
62
|
+
- **Low-rank / compression**: where is the redundancy in attention, KV-Cache, weights, gradients? How low can the rank go? How to estimate the optimal approximation error from truncation (Eckart-Young)? Should low-rank regularization use the nuclear norm or explicit parameterization?
|
|
63
|
+
- **Numerical stability**: why does low-precision (bf16/fp8) training diverge? How to monitor condition numbers and spectral radii online during training? Are there bounds on spectral shifts from quantization/pruning (Weyl, Bauer-Fike)? Which operators need reparameterization for stability?
|
|
64
|
+
- **Spectral design**: the operator norms behind normalization (spectral normalization / BatchNorm); spectral radius constraints for recurrent / state-space models (SSM); spectral gap determines expressivity and separability.
|
|
65
|
+
- **Second-order optimization**: PSD structure and negative curvature of Hessian / Fisher (inertia law for detecting saddle points); condition number improvement via preconditioners; Kronecker-factor approximations (K-FAC / Shampoo).
|
|
66
|
+
- **Graphs / propagation**: stability and over-smoothing of message passing; mixing time of row-stochastic operators; Markov chain stationary distributions and spectral gaps.
|
|
67
|
+
|
|
68
|
+
## Possible Algorithmic Inspirations
|
|
69
|
+
|
|
70
|
+
> Each item is tagged with the **eight-dimension touchpoint** (corresponding to the dimension numbers in `../gpu-friendly-math.md`) for direct entry into the GPU acceptance gate.
|
|
71
|
+
|
|
72
|
+
1. **Randomized numerical linear algebra (randomized NLA)**: using random projections + QR (Sec. 2.1) for randomized SVD, reducing the O(n^3) full decomposition to sub-quadratic, producing low-rank sketches of very large weights/activations. *Touchpoint: D2/D3 -- all GEMM, manageable complexity.*
|
|
73
|
+
2. **Low-rank attention / KV compression**: using Eckart-Young (Sec. 7.4) to guarantee truncated SVD is the optimal low-rank approximation; using the **nuclear norm (dual of spectral norm, Sec. 5.5)** as low-rank regularization, projecting the KV-Cache into a low-dimensional subspace. *Touchpoint: D2/D4 -- GEMM chains + memory compression.*
|
|
74
|
+
3. **Spectral normalization**: power iteration to estimate the largest singular value (operator norm, Sec. 5.6), constraining per-layer Lipschitz constants -- GANs/diffusion/stable training. *Touchpoint: D1/D6 -- matvec, but serial iteration requires blocking.*
|
|
75
|
+
4. **Newton-Schulz orthogonalization (Muon-style)**: polar decomposition (Sec. 7.3) projects gradient matrices onto the nearest orthogonal matrix, with iterations involving only matrix multiplications -- currently the most GPU-friendly "second-order-flavored" update. *Touchpoint: D2/D6/D8 -- pure GEMM, fusible, bf16-stable.*
|
|
76
|
+
5. **Preconditioning / Shampoo / K-FAC**: condition numbers (Sec. 5.8) diagnose ill-conditioning, using PSD Kronecker factors (Ch 7) to approximate the Hessian for preconditioning, rounding out ill-conditioned loss landscapes. *Touchpoint: D2/D5 -- small-matrix GEMM, watch precision for inverse operations.*
|
|
77
|
+
6. **Gershgorin cheap spectral radius gate (Sec. 6.1)**: using the disc bound O(n^2) in the training loop to quickly estimate the spectral radius as a low-cost stability gate, without running a full EVD. *Touchpoint: D1/D3 -- per-row summation, extremely cheap.*
|
|
78
|
+
7. **PSD kernel engineering (Schur product theorem, Sec. 7.5)**: composing multiple PSD kernels via Hadamard products, guaranteeing that learnable similarity matrices remain positive semidefinite. *Touchpoint: D1 -- element-wise tensor products, naturally friendly.*
|
|
79
|
+
8. **Perron-Frobenius diagnostics (Sec. 8.2-8.5)**: treating row-stochastic attention as a Markov operator, using the spectral gap to quantify over-smoothing / rank collapse, guiding residual and temperature design. *Touchpoint: D1/D3 -- cheap spectral estimation, avoids deep-layer collapse.*
|
|
80
|
+
9. **Blocked / communication-avoiding decompositions**: writing QR, Cholesky (Sec. 3.5) in blocked versions, replacing column-by-column elimination with GEMM, reducing communication rounds across devices. *Touchpoint: D2/D6 -- reforming serial recurrences into parallelism + overlap.*
|
|
81
|
+
|
|
82
|
+
## GPU Friendliness Warning
|
|
83
|
+
|
|
84
|
+
> The scoring dimensions reference the **eight-dimension checklist** in `../gpu-friendly-math.md` (Tensorization / GEMM-mappability / Complexity / Memory / Low-precision / Parallelism / Sparsity / Operator fusion); definitions are not repeated here.
|
|
85
|
+
|
|
86
|
+
**Natively friendly (math beautiful x GPU friendly):**
|
|
87
|
+
- **Truncated SVD / low-rank**: expressed as GEMM chains (D2), compressing KV-Cache/weights (D4).
|
|
88
|
+
- **Frobenius / spectral norms, Gram matrices, Hadamard products**: batched tensor algebra (D1, D2).
|
|
89
|
+
- **Polar decomposition Newton-Schulz**: pure matrix-multiplication iteration (D2, D6, D8 fusible), robust under bf16.
|
|
90
|
+
- **Gershgorin discs**: O(n^2) per-row summation (D1), cheap stability estimation.
|
|
91
|
+
- **Well-conditioned PSD blocked Cholesky / Gram construction**: blocked form yields GEMM chains (D2), commonly used in kernel methods and covariance preconditioning.
|
|
92
|
+
|
|
93
|
+
**Beautiful but not computable:**
|
|
94
|
+
- **Jordan canonical form (Sec. 3.1)** -- the classic counter-example: eigenvalue multiplicities are extremely sensitive to perturbation, fundamentally unreliable under floating-point, **never use as a numerical tool** (violates D5 low-precision stability). Weyr form has the same issue.
|
|
95
|
+
- **Full EVD / SVD at O(n^3)** -- blows up for large matrices (violates D3), must switch to randomized/iterative methods.
|
|
96
|
+
- **Non-normal matrices (Sec. 2.5 and beyond)** -- eigenvalues do not reflect true behavior, pseudospectra are needed; spectral distortion under low precision (D5).
|
|
97
|
+
- **Ill-conditioned / high condition number (Sec. 5.8)** -- catastrophic cancellation occurs, requiring fp64 for correctness, conflicting with bf16/fp8 training (D5).
|
|
98
|
+
- **Serial dependencies in QR / Cholesky (Sec. 2.1, 3.5)** -- naive implementations are long serial recurrences (violates D6), requiring blocked / communication-avoiding variants.
|
|
99
|
+
- **Serial iteration in power iteration** -- single-vector iteration has low parallelism; must be blocked (block / subspace iteration) to saturate SMs (D6).
|
|
100
|
+
|
|
101
|
+
**Reform strategies (echoing the Make-It-Computable Toolkit in `../gpu-friendly-math.md`):**
|
|
102
|
+
- Full EVD/SVD -> **randomized + truncated** to reduce complexity (D3);
|
|
103
|
+
- Exact decompositions -> **blocked / GEMM-ified** to eliminate serial dependencies (D2/D6);
|
|
104
|
+
- Ill-conditioned/non-normal -> **reparameterization + spectral normalization** to stabilize low precision (D5);
|
|
105
|
+
- Non-computable canonical forms like Jordan -> retain only for **theoretical proofs**, numerically switch to Schur/SVD.
|
|
106
|
+
|
|
107
|
+
## Which Design Lens to Invoke
|
|
108
|
+
|
|
109
|
+
Used in conjunction with the design lenses in `../../lenses/`:
|
|
110
|
+
|
|
111
|
+
- **`duality`**: similarity / unitary equivalence / congruence, SVD, diagonalization -- the soul of this book is "change coordinates to reveal structure."
|
|
112
|
+
- **`algorithmic`**: power iteration, Newton-Schulz, QR algorithm, randomized NLA -- turning theorems into runnable kernels.
|
|
113
|
+
- **`variational`**: variational characterizations (Sec. 4.2), condition numbers and preconditioning, second-order methods, matrix inequalities under the Loewner partial order.
|
|
114
|
+
- **`symmetry`**: unitary invariance, similarity invariants (eigenvalues/trace/determinant), well-conditioned spectra of normal matrices.
|
|
115
|
+
- **`categorical`**: canonical forms as "representatives of equivalence classes" -- capturing essence through the simplest morphology, ignoring coordinate details.
|
|
116
|
+
- **`probabilistic`**: randomized NLA, random matrix spectra, Perron-Frobenius / Markov chain stationary distributions.
|
|
117
|
+
|
|
118
|
+
## Anti-patterns
|
|
119
|
+
|
|
120
|
+
- **Using Jordan form as a numerical algorithm**: it is not computable under floating-point, only useful for theoretical analysis; do not put it into a kernel.
|
|
121
|
+
- **Defaulting to full SVD/EVD**: in large-scale settings one should use randomized/truncated/iterative methods, otherwise O(n^3) will bog everything down.
|
|
122
|
+
- **Looking only at eigenvalues while ignoring non-normality**: eigenvalues of non-normal matrices do not predict transient behavior; look at singular values / pseudospectra instead.
|
|
123
|
+
- **Assuming all matrices are well-conditioned**: deploying bf16/fp8 without monitoring condition numbers, then debugging after divergence.
|
|
124
|
+
- **Using the nuclear norm while forgetting it requires SVD**: the nuclear norm is an elegant low-rank regularizer, but its computation depends on SVD, requiring proximal/randomized techniques.
|
|
125
|
+
- **Assuming exact positive definiteness numerically**: under floating-point, Gram/covariance matrices can lose positive definiteness; add jitter (diagonal perturbation) or use pivoted Cholesky.
|
|
126
|
+
- **Using Frobenius norm as a low-rank regularizer**: Frobenius / weight decay suppresses "energy" not "rank"; for low rank, use the nuclear norm or explicit low-rank parameterization (e.g., LoRA).
|
|
127
|
+
- **Discussing "eigenvalue magnitudes" for non-symmetric matrices**: when measuring energy/norm/stability margins, look at **singular values**; the modulus of eigenvalues of non-normal matrices is seriously misleading (transient growth far exceeds what the spectral radius predicts).
|
|
128
|
+
- **Materializing the full O(n^2) Gram matrix**: attention/kernel matrices without blocking will blow up memory; use FlashAttention-style fusion + blocking (echoing GPU dimensions D4/D8).
|
|
129
|
+
- **Stacking theorems without diagnosing the bottleneck**: first ask "is the algorithmic bottleneck spectral, low-rank, or stability," then select the structure; do not dump matrix theory upfront.
|
|
130
|
+
|
|
131
|
+
## Deep Dive Entry
|
|
132
|
+
|
|
133
|
+
> **Bibliographic info**: Roger A. Horn & Charles R. Johnson, *Matrix Analysis*, 2nd Edition, Cambridge University Press, 2013. ISBN 978-0-521-83940-2.
|
|
134
|
+
>
|
|
135
|
+
> **Activation method**: Place `Matrix Analysis.pdf` in the `math_book/` folder at the project root; the Agent can then automatically search the original text. The PDF is not distributed via npm/git (copyright reasons); obtain it independently.
|
|
136
|
+
|
|
137
|
+
**Full-fidelity lookup = have the Agent automatically search the local PDF `math_book/Matrix Analysis.pdf`**: extract with `pdftotext` -> `grep` to locate keywords/theorem names -> `Read` the relevant pages for close study. This file is an "activation index," not a substitute; when precise statements, proofs, or constants are needed, go back to the original book.
|
|
138
|
+
|
|
139
|
+
Actual chapters worth deep reading:
|
|
140
|
+
|
|
141
|
+
- **Sec. 2.6 The singular value decomposition** -- the origin of all low-rank compression / LoRA / PCA.
|
|
142
|
+
- **Sec. 4.2-4.3 Variational characterizations & eigenvalue inequalities** -- Courant-Fischer min-max and Weyl inequalities, the theoretical roots of spectral normalization and perturbation bounds.
|
|
143
|
+
- **Sec. 5.6-5.8 Matrix norms & condition numbers** -- all the criteria for numerical stability, gradient clipping, and preconditioning are here.
|
|
144
|
+
- **Sec. 7.3-7.5 Polar/SVD & the Schur product theorem** -- the direct source for Muon orthogonalization and PSD kernel engineering.
|
|
145
|
+
- **Sec. 6.1-6.3 Gershgorin discs & perturbation theorems** -- cheap spectral localization and perturbation robustness.
|
|
146
|
+
- **Sec. 8.2-8.5 Perron-Frobenius theory** -- row-stochastic attention, graph propagation, over-smoothing analysis.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 矩阵分析 / Matrix Analysis
|
|
2
2
|
|
|
3
3
|
> Roger A. Horn & Charles R. Johnson, *Matrix Analysis*, 2nd Edition, Cambridge University Press, 2013(ISBN 978-0-521-83940-2)。以**标准型(canonical forms)作为统一主题**的研究生级矩阵理论经典。
|
|
4
4
|
|
|
@@ -106,14 +106,14 @@
|
|
|
106
106
|
|
|
107
107
|
## 该调用哪个思想透镜
|
|
108
108
|
|
|
109
|
-
配合
|
|
109
|
+
配合 `../../lenses/` 下的思想透镜使用:
|
|
110
110
|
|
|
111
|
-
- **`duality
|
|
112
|
-
- **`algorithmic
|
|
113
|
-
- **`
|
|
111
|
+
- **`duality`(对偶)**:相似 / 酉等价 / 合同、SVD、对角化——本书的灵魂就是"换坐标让结构显形"。
|
|
112
|
+
- **`algorithmic`(算法)**:power iteration、Newton–Schulz、QR algorithm、随机化 NLA——把定理变成可跑的 kernel。
|
|
113
|
+
- **`variational`(变分)**:变分刻画(§4.2)、条件数与预条件、二阶法、Loewner 偏序下的矩阵不等式。
|
|
114
114
|
- **`symmetry`(对称与不变性)**:酉不变性、相似不变量(特征值/迹/行列式)、正规矩阵的良态谱。
|
|
115
|
-
- **`categorical
|
|
116
|
-
- **`
|
|
115
|
+
- **`categorical`(范畴化)**:标准型即"等价类的代表元"——用最简形态抓住本质、忽略坐标细节。
|
|
116
|
+
- **`probabilistic`(概率统计)**:随机化 NLA、随机矩阵谱、Perron–Frobenius/Markov 链平稳分布。
|
|
117
117
|
|
|
118
118
|
## 反模式
|
|
119
119
|
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
|
|
131
131
|
## 深挖入口
|
|
132
132
|
|
|
133
|
-
>
|
|
133
|
+
> **书目信息**:Roger A. Horn & Charles R. Johnson, *Matrix Analysis*, 2nd Edition, Cambridge University Press, 2013. ISBN 978-0-521-83940-2.
|
|
134
134
|
>
|
|
135
135
|
> **启用方式**:将 `Matrix Analysis.pdf` 放入项目根目录的 `math_book/` 文件夹,Agent 即可自动搜索原文。PDF 不随 npm/git 分发(版权原因),需自行获取。
|
|
136
136
|
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# A Micro Lie Theory
|
|
2
|
+
|
|
3
|
+
> **A micro Lie theory for state estimation in robotics** -- Joan Solà, Jeremie Deray, Dinesh Atchuthan.
|
|
4
|
+
> arXiv:1812.01537v9 [cs.RO], 2021-12-08, main text approx. 17 pages + appendix formula handbook. Companion open-source C++ header library **manif** (<https://github.com/artivis/manif>, implementing SO(2)/SO(3)/SE(2)/SE(3) with analytic Jacobians).
|
|
5
|
+
> This file is an "activation" distillation, **not a restatement of the original**; for full fidelity, consult the local PDF (see (Deep Dive Entry)).
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This paper **deliberately "amputates"** the vast edifice of Lie theory down to the minimal subset needed for robotic state estimation: it does not even introduce the Lie bracket, instead reducing the Lie algebra directly to the isomorphic vector space R^n, so that the "curved, nonlinear" Lie group becomes "flat, linear" vector algebra in the tangent space. The one-sentence thesis: **virtually every operation on the group (curved) has an exact counterpart in the Lie algebra (flat)** (Fig. 1) -- this is the modern use of Sophus Lie's "dragon-slaying sword" from inspiration.md: the dragon (solving differential equations) was never slain, yet the sword became a supreme tool for chopping vegetables (linearizing nonlinearities), carving (describing symmetries), and building houses (robotic state estimation).
|
|
10
|
+
|
|
11
|
+
Actual structure map:
|
|
12
|
+
- **II. A micro Lie theory (core)**: A Lie groups (group axioms + manifold) -> B group actions -> C tangent space and Lie algebra (hat `^wedge` / vee `^vee` operators) -> D **exponential map** exp/log and capital Exp/Log (Eq. 23-24) -> E **addition/subtraction operators** oplus/ominus (Eq. 25-28, left and right versions) -> F **adjoint** Ad_X and adjoint matrix (Eq. 30-35) -> G **derivatives on Lie groups**: right Jacobian (Eq. 41a-c) / left Jacobian (Eq. 44) -> H **uncertainty on manifolds and covariance propagation** (Eq. 52) -> I discrete integration on manifolds.
|
|
13
|
+
- **III. Manifold differentiation rules**: A chain rule, B elementary Jacobian blocks, C derived Jacobian blocks.
|
|
14
|
+
- **IV. Composite manifolds / bundles**: assembling heterogeneous large states into non-interacting manifold blocks, differentiating block by block (Eq. 84-90, Ex. 7 comparing SE(n) vs T(n)xSO(n) vs (R^n, SO(n))).
|
|
15
|
+
- **V. Applications**: landmark-based localization and mapping -- error-state Kalman filter on manifolds (Eq. 92-96), graph-optimization SLAM, sensor self-calibration.
|
|
16
|
+
- **VI. Conclusion + Appendix**: complete closed-form formulas for S^1/SO(2)/SE(2), S^3/SO(3), SE(3) (including right/left Jacobians, e.g. SO(3) Eq. 143-145).
|
|
17
|
+
|
|
18
|
+
## Core Structures Transferable to AI/Infra
|
|
19
|
+
|
|
20
|
+
The paper welds together the "curved nonlinear group" and the "flat linear vector space" using five tools, each of which can be directly ported into differentiable algorithms.
|
|
21
|
+
|
|
22
|
+
### 1. exp/log Maps -> Manifold Parameterization (Eq. 23-24, Fig. 1)
|
|
23
|
+
|
|
24
|
+
`Exp: R^n -> M`, `Log: M -> R^n` are the bijective bridges between the manifold and its tangent space (isomorphic to linear R^n). Transfer usage: **let the network freely predict in the unconstrained tangent space R^n, then map back to the valid manifold via Exp**. Rotations, poses, and unit quaternions thus naturally satisfy constraints (orthogonality, unit norm), eliminating the need for various ad-hoc post-hoc orthogonalization or normalization fixes on regressed matrices/quaternions.
|
|
25
|
+
|
|
26
|
+
### 2. oplus/ominus Addition/Subtraction Operators -> "Vector Algebra" on Manifolds (Eq. 25-28)
|
|
27
|
+
|
|
28
|
+
`oplus` (one Exp + one group composition) makes "adding an increment to a manifold state" look like ordinary vector addition; `ominus` computes the difference between two elements (geodesic residual). **Key pitfall**: because group composition is non-commutative, oplus/ominus come in **right versions** (increment in local frame / tangent at X) and **left versions** (increment in global frame / tangent at identity E); the paper defaults to the right version -- in engineering, one must stay consistent throughout; mixing conventions leads to errors.
|
|
29
|
+
|
|
30
|
+
### 3. Right/Left Jacobians -> Geometrically Correct Backpropagation (Eq. 41a-c, 44)
|
|
31
|
+
|
|
32
|
+
The linearization of a manifold function with respect to tangent-space perturbations is the Jacobian; the chain rule on manifolds takes the form `D(g o f)/DX = J_g . J_f` (Sec. III-A), isomorphic to the Euclidean chain rule, so it plugs directly into automatic differentiation. The **right Jacobian** (Eq. 41) and **left Jacobian** (Eq. 44) describe the same derivative in local vs. global tangent spaces, related to each other through the adjoint Ad.
|
|
33
|
+
|
|
34
|
+
### 4. Adjoint Matrix Ad_X -> Transporting Tangent Vectors Across Frames (Eq. 30-35)
|
|
35
|
+
|
|
36
|
+
`Ad_X` transports the same tangent vector between different points and left/right frames (Eq. 32: `X oplus tau = (Ad_X tau) oplus X`). It is the **algebraic realization of equivariance**, and also the transformation matrix for propagating perturbations/covariances across frames; Ex. 6 gives the closed-form adjoint matrix for SE(3).
|
|
37
|
+
|
|
38
|
+
### 5. Covariance Propagation -> Uncertainty on Manifolds (Eq. 52)
|
|
39
|
+
|
|
40
|
+
`Sigma = E[(X om Xbar)(X om Xbar)^T] in R^{m x m}` -- **the covariance lives in the tangent space R^n, not on the group**. Defining variance directly on the group is ill-posed; the tangent-space representation brings the uncertainty computations of Kalman filters / factor graphs back to familiar linear algebra.
|
|
41
|
+
|
|
42
|
+
Two additional directly usable "components":
|
|
43
|
+
- **SE(3) / SO(3)**: rigid body motion group / rotation group -- the unified differentiable representation of pose = rotation + translation, the standard language for cameras, point clouds, and robotic arm joints.
|
|
44
|
+
- **Composite manifolds (bundles, Eq. 84-90)**: assembling multi-pose + feature + calibration heterogeneous large states into non-interacting manifold blocks, with Jacobians **assembled block by block** (Eq. 89 is block-structured sparse), i.e., "assemble the Jacobian matrix block by block" in engineering practice.
|
|
45
|
+
|
|
46
|
+
## Problem Types Suited for Activation
|
|
47
|
+
|
|
48
|
+
- Prediction/regression targets carry **geometric constraints**: rotations, poses, unit vectors, SPD matrices -- forcing them into Euclidean MLPs breaks the constraints.
|
|
49
|
+
- Need **equivariance / invariance**: when the input undergoes rigid body transformations, the output should covary or remain invariant (point clouds, molecules, multi-view geometry).
|
|
50
|
+
- Need **explicit uncertainty**: pose estimation, sensor fusion, SLAM, visual odometry covariance propagation.
|
|
51
|
+
- **Iterative geometric optimization**: camera/point cloud registration, bundle adjustment, inverse kinematics, requiring gradient/Gauss-Newton on manifolds rather than in Euclidean space.
|
|
52
|
+
- States **evolve on Lie groups**: inertial pre-integration, motion models, differentiable physics/control.
|
|
53
|
+
|
|
54
|
+
## Possible Algorithmic Inspirations
|
|
55
|
+
|
|
56
|
+
- **SE(3)/SO(3) equivariant networks**: using group elements as hidden states, updating between layers via Exp/opus, transporting features via Ad; equivariance comes from group actions rather than data augmentation.
|
|
57
|
+
- **Manifold loss for pose regression**: using ominus (geodesic error) as the loss, rather than Euclidean MSE on rotation matrices/quaternions; naturally handles manifold topology (e.g., quaternion double cover).
|
|
58
|
+
- **Lie group optimizers**: rewriting Adam/Gauss-Newton in the retraction form "compute gradient in tangent space -> map back via Exp" (error-state approach, corresponding to the manifold EKF in Sec. V-A).
|
|
59
|
+
- **Differentiable registration / alignment**: camera pose, point cloud ICP, multi-view BA formulated as differentiable optimization layers on SE(3), trained end to end.
|
|
60
|
+
- **Manifold-parameterized output heads**: the network outputs an R^n tangent vector, mapped back to SO(3)/SE(3) via Exp, replacing the various ad-hoc orthogonalization schemes for 6D/9D rotation representations.
|
|
61
|
+
- **Uncertainty-aware fusion**: using the tangent-space covariance from Eq. 52 + Ad propagation to build learnable Kalman/factor-graph layers.
|
|
62
|
+
|
|
63
|
+
## GPU Friendliness Warning
|
|
64
|
+
|
|
65
|
+
> The sole authority for the acceptance gate: [`../gpu-friendly-math.md`](../gpu-friendly-math.md) (eight dimensions: D1 Tensorization, D2 GEMM-mappability, D3 Complexity, D4 Memory/KV, D5 Low-precision stability, D6 Parallelism & communication, D7 Sparse structure, D8 Operator fusion). Dimension-by-dimension scoring follows.
|
|
66
|
+
|
|
67
|
+
| # | Dimension | Rating | Notes |
|
|
68
|
+
|---|---|---|---|
|
|
69
|
+
| D1 | Tensorization | [v] | SO(3)/SE(3) exp/log have **closed forms** (Rodrigues), 3x3/4x4 small matrices, batched as `[B,3,3]` / `[B,4,4]` tensors, sample-independent |
|
|
70
|
+
| D2 | GEMM-mappability | [~] | 3x3/4x4 are too small to **saturate Tensor Cores**, bmm/batched small GEMM has low utilization and is easily memory-bandwidth-bound; fix: stack the batch dimension large, use specialized small kernels or einsum fusion |
|
|
71
|
+
| D3 | Complexity | [v] | O(1) per element, linear in batch |
|
|
72
|
+
| D4 | Memory | [v] | Elements are tiny; however, Jacobians/covariance matrices for high-DOF composite states can grow large (block-structured, still manageable) |
|
|
73
|
+
| D5 | Low-precision stability | [x] **critical** | exp/log contain terms like `sin(theta)/theta`, `(1-cos(theta))/theta^2`, which cause catastrophic cancellation at **theta->0** (division by zero) and **theta->pi** (log singularity); fp16/bf16 are highly prone to NaN. **Must** switch to Taylor expansion for small angles -- branching introduces warp divergence (hurts D1, D8) |
|
|
74
|
+
| D6 | Parallelism & communication | [~] | Per-sample exp/log is embarrassingly parallel [v]; however **discrete integration / motion chains on manifolds** (Sec. II-I, chained Exp products) are **serial recurrences**, long sequences must be rewritten as parallel scans to achieve parallelism |
|
|
75
|
+
| D7 | Sparse structure | [v] | Composite manifold Jacobians are **block-structured sparse** (Eq. 89), GPU-friendly |
|
|
76
|
+
| D8 | Operator fusion | [v] | Closed-form exp/log/Jacobians can be fused into a **single kernel**, avoiding materialization of intermediate small matrices |
|
|
77
|
+
|
|
78
|
+
**Expanded notes (closed-form vs. series / batching / whether small-matrix exponentials can be tensorized)**:
|
|
79
|
+
|
|
80
|
+
The GPU fate of `exp/log` in Lie theory depends entirely on "whether one is working with a low-dimensional group that admits a closed form."
|
|
81
|
+
|
|
82
|
+
- **Closed-form vs. series (Conclusion 1)**: The exponential map for SO(3) is precisely the **Rodrigues formula** `exp([theta]_x) = I + (sin(theta)/theta)[theta]_x + ((1-cos(theta))/theta^2)[theta]_x^2` (Ex. 4); SE(3) is similar with an additional left-Jacobian factor V(theta) -- both are **finite-term closed forms**, pure tensor algebra, per-sample independent, no data-dependent loops. The opposite case is the **general matrix exponential**: for arbitrary Lie groups there is no Rodrigues-style closed form, only Taylor series + scaling-and-squaring **iterative** approximation, with data-dependent step counts, divergent control flow, and difficult tensorization -- a classic "beautiful but not computable" case. Closed forms exist only for the small set SO(3)/SE(3)/SE(2)/S^1/S^3; **do not treat the general matrix exp as a cheap O(1) operator**.
|
|
83
|
+
- **Batching (Conclusion 2)**: stacking N rotations/poses into `[B,3,3]` / `[B,4,4]` for batched Exp/Log is clean element-wise + small bmm, which can be **fused with downstream operators into a single kernel**. Small-matrix exponentials **can** be tensorized -- batched stacking gives per-sample parallelism; but 3x3/4x4 are too small for bmm to saturate Tensor Cores, the value lies in "batchable and fusible" rather than "maxing out compute," and to improve utilization one should stack the batch large or use specialized small kernels.
|
|
84
|
+
- **Low-precision singularities (Conclusion 3, top risk)**: theta->0 (`sin(theta)/theta` division by zero) and theta->pi (log is non-unique) cause catastrophic cancellation, fp16/bf16 produce NaN directly. Before low-precision training, one **must** implement Taylor-expansion fallbacks for small angles and run deterministic reproducibility tests; the fallback branches introduce warp divergence, requiring `where`/mask implementations rather than data-dependent jumps.
|
|
85
|
+
- **Serial recurrence**: motion chains / discrete integration on manifolds (Sec. II-I) are serial recurrences of chained Exp products; long sequences must be rewritten as parallel scans to saturate the GPU.
|
|
86
|
+
|
|
87
|
+
## Which Design Lens to Invoke
|
|
88
|
+
|
|
89
|
+
- **symmetry (primary)**: Lie groups are by definition **continuous symmetry transformation groups**; this paper is the most direct mathematical ammunition for "symmetry/invariance -> equivariant networks."
|
|
90
|
+
- **duality (primary)**: exp/log equivalently transforms "curved nonlinear manifold" to "flat linear tangent space" -- a paradigmatic example of transforming a hard problem into an easy one (the dragon-slaying sword used for "chopping vegetables").
|
|
91
|
+
- **variational**: optimization on manifolds, retractions, error-state filtering (Sec. V-A).
|
|
92
|
+
- **geometric**: the modeling closed loop from reality (robotic/camera state + noise) to mathematics (manifold + covariance) to interpretation.
|
|
93
|
+
- **categorical**: abstracting from concrete matrices/quaternions to the unified "group" interface (the paper's own writing style -- generic formulation + grounded examples -- is itself an abstraction demonstration).
|
|
94
|
+
|
|
95
|
+
## Anti-patterns
|
|
96
|
+
|
|
97
|
+
- **Adding/subtracting rotations/poses directly in Euclidean space**: doing Euclidean MSE or linear interpolation on rotation matrices/quaternions -- breaks manifold constraints; use oplus/ominus and geodesic error instead.
|
|
98
|
+
- **Mixing left and right perturbations**: inconsistent conventions for right/left Jacobians, local/global frames, causing misalignment of covariances and gradients (the paper repeatedly emphasizes defaulting to the right version).
|
|
99
|
+
- **Assuming matrix exp is cheap and closed-form everywhere**: closed forms exist only for SO(3)/SE(3) and a few other groups; general groups require iterative series and cannot be treated as O(1) operators.
|
|
100
|
+
- **Not handling singularities in low precision**: failing to implement Taylor fallbacks for theta->0/pi causes fp16 training to produce NaN immediately.
|
|
101
|
+
- **Treating SE(3) as T(3)xSO(3)**: their tangent-space parameterizations differ (Ex. 7); whether translation and rotation are coupled changes the Jacobian, and misuse leads to systematic bias.
|
|
102
|
+
- **Over-application**: forcing Lie theory onto tasks that do not need uncertainty propagation or geometric constraints, adding complexity and singularity risk for no gain -- mathematical beauty does not mean it should be used.
|
|
103
|
+
|
|
104
|
+
## Deep Dive Entry
|
|
105
|
+
|
|
106
|
+
> **Bibliographic info**: Joan Sola, Jeremie Deray, Dinesh Atchuthan, *A micro Lie theory for state estimation in robotics*, arXiv:1812.01537v9, 2021. Companion open-source C++ library [manif](https://github.com/artivis/manif).
|
|
107
|
+
>
|
|
108
|
+
> **Activation method**: Place `A micro Lie theory.pdf` in the `math_book/` folder at the project root; the Agent can then automatically search the original text. The PDF is not distributed via npm/git (copyright reasons); obtain it independently.
|
|
109
|
+
|
|
110
|
+
> Full-fidelity lookup = have the Agent automatically retrieve the local PDF: `math_book/A micro Lie theory.pdf` (using `pdftotext` or Read PDF pages). The following are actual section/equation-block locations within that PDF:
|
|
111
|
+
|
|
112
|
+
1. **Sec. II-D Exponential map + Fig. 1**: exp/log and capital Exp/Log operators (Eq. 23-24) -- the manifold-to-tangent-space bridge and closed-form source; with Ex. 3 (SO(3) Lie algebra `[omega]_x`), Ex. 4 (SO(3) exp = Rodrigues).
|
|
113
|
+
2. **Sec. II-E Addition/subtraction operators (Eq. 25-28) + Sec. II-F Adjoint Ad_X (Eq. 30-35)**: "addition/subtraction" on manifolds and left/right perturbation conversions; Ex. 6 (SE(3) adjoint matrix).
|
|
114
|
+
3. **Sec. II-G Derivatives on Lie groups + Sec. III-A Chain rule**: right Jacobian (Eq. 41a-c), left Jacobian (Eq. 44), related through the adjoint -- the geometrically correct form for backpropagation/gradients.
|
|
115
|
+
4. **Sec. II-H Uncertainty on manifolds and covariance propagation (Eq. 52)**: Sigma defined on the tangent space; Sec. V-A manifold error-state EKF (Eq. 92-96) is the applied example.
|
|
116
|
+
5. **Appendix formula handbook**: SO(3) right/left Jacobian closed forms (Eq. 143-145), SE(3) Jacobians (citing Barfoot), and Sec. IV composite manifold block-wise Jacobians (Eq. 84-90, Ex. 7) -- direct lookup tables for engineering implementation, cross-referenced with the manif library.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# 李理论速成 / A micro Lie theory
|
|
2
2
|
|
|
3
3
|
> **A micro Lie theory for state estimation in robotics** — Joan Solà, Jeremie Deray, Dinesh Atchuthan.
|
|
4
4
|
> arXiv:1812.01537v9 [cs.RO],2021-12-08,正文约 17 页 + 附录公式手册。配套开源 C++ 头文件库 **manif**(<https://github.com/artivis/manif>,实现 SO(2)/SO(3)/SE(2)/SE(3) 及解析雅可比)。
|
|
@@ -66,14 +66,14 @@
|
|
|
66
66
|
|
|
67
67
|
| # | 维度 | 评级 | 说明 |
|
|
68
68
|
|---|---|---|---|
|
|
69
|
-
| ① | 张量化 |
|
|
70
|
-
| ② | GEMM 可映射 |
|
|
71
|
-
| ③ | 复杂度 |
|
|
72
|
-
| ④ | 显存 |
|
|
73
|
-
| ⑤ | 低精度稳定 |
|
|
74
|
-
| ⑥ | 并行与通信 |
|
|
75
|
-
| ⑦ | 稀疏结构 |
|
|
76
|
-
| ⑧ | 算子融合 |
|
|
69
|
+
| ① | 张量化 | [v] | SO(3)/SE(3) 的 exp/log 有**闭式**(Rodrigues),3×3/4×4 小矩阵,批量化为 `[B,3,3]` / `[B,4,4]` 张量逐样本独立 |
|
|
70
|
+
| ② | GEMM 可映射 | [~] | 3×3/4×4 太小,**吃不满 Tensor Core**,bmm/批量小 GEMM 利用率低、易受访存带宽限制;改造:把 batch 维堆大、用专用小核或 einsum 融合 |
|
|
71
|
+
| ③ | 复杂度 | [v] | 每元素 O(1),随 batch 线性 |
|
|
72
|
+
| ④ | 显存 | [v] | 元素极小;但高自由度复合状态的雅可比/协方差矩阵会变大(块结构,仍可控) |
|
|
73
|
+
| ⑤ | 低精度稳定 | [x] **重点** | exp/log 含 `sinθ/θ`、`(1−cosθ)/θ²` 等项,在 **θ→0**(除零)与 **θ→π**(log 奇异)处灾难性抵消;fp16/bf16 极易 NaN。**必须**对小角做 Taylor 展开切换——而分支会带来 warp divergence(伤①⑧) |
|
|
74
|
+
| ⑥ | 并行与通信 | [~] | 逐样本 exp/log 是 embarrassingly parallel [v];但**流形上的离散积分/运动链**(§II-I,连乘 Exp)是**串行递推**,长序列需写成并行扫描(parallel scan)才能并行 |
|
|
75
|
+
| ⑦ | 稀疏结构 | [v] | 复合流形的雅可比是**块结构化稀疏**(式 89),对 GPU 友好 |
|
|
76
|
+
| ⑧ | 算子融合 | [v] | 闭式 exp/log/雅可比可融进**单 kernel**,避免物化中间小矩阵 |
|
|
77
77
|
|
|
78
78
|
**展开说明(闭式 vs 级数 / 批量化 / 小矩阵指数能否张量化)**:
|
|
79
79
|
|
|
@@ -86,11 +86,11 @@
|
|
|
86
86
|
|
|
87
87
|
## 该调用哪个思想透镜
|
|
88
88
|
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
89
|
+
- **symmetry(首选)**:李群本就是**连续对称变换群**,本文是"对称/不变性→等变网络"最直接的数学弹药。
|
|
90
|
+
- **duality(首选)**:exp/log 把"曲的非线性流形"等价变换到"平的线性切空间"——把难问题变换成易问题的范式样板(屠龙刀"切菜")。
|
|
91
|
+
- **variational**:流形上的优化、retraction、误差状态滤波(§V-A)。
|
|
92
|
+
- **geometric**:现实(机器人/相机状态+噪声)→数学(流形+协方差)→解释的建模闭环。
|
|
93
|
+
- **categorical**:从具体矩阵/四元数抽象出"群"的统一接口(论文正文泛型 + 例子接地的写法本身就是抽象示范)。
|
|
94
94
|
|
|
95
95
|
## 反模式
|
|
96
96
|
|
|
@@ -103,13 +103,13 @@
|
|
|
103
103
|
|
|
104
104
|
## 深挖入口
|
|
105
105
|
|
|
106
|
-
>
|
|
106
|
+
> **书目信息**:Joan Solà, Jérémie Deray, Dinesh Atchuthan, *A micro Lie theory for state estimation in robotics*, arXiv:1812.01537v9, 2021. 配套开源 C++ 库 [manif](https://github.com/artivis/manif)。
|
|
107
107
|
>
|
|
108
108
|
> **启用方式**:将 `A micro Lie theory.pdf` 放入项目根目录的 `math_book/` 文件夹,Agent 即可自动搜索原文。PDF 不随 npm/git 分发(版权原因),需自行获取。
|
|
109
109
|
|
|
110
110
|
> 全保真回查 = 让 Agent 自动检索本地 PDF:`math_book/A micro Lie theory.pdf`(用 `pdftotext` 或 Read PDF pages)。下列为该 PDF 内的真实章节/公式块定位:
|
|
111
111
|
|
|
112
|
-
1. **§II-D 指数映射 + Fig. 1**:exp/log 与大写 Exp/Log 算子(式 23–24
|
|
112
|
+
1. **§II-D 指数映射 + Fig. 1**:exp/log 与大写 Exp/Log 算子(式 23–24)——流形-> 切空间桥梁与闭式来源;配 Ex. 3(SO(3) 的李代数 `[ω]×`)、Ex. 4(SO(3) 的 exp = Rodrigues)。
|
|
113
113
|
2. **§II-E 加减算子(式 25–28)+ §II-F 伴随 Ad_X(式 30–35)**:流形上的"加/减"与左右扰动互转;Ex. 6(SE(3) 的伴随矩阵)。
|
|
114
114
|
3. **§II-G 李群上的导数 + §III-A 链式法则**:右雅可比(式 41a–c)、左雅可比(式 44),二者由伴随相联——反传/梯度的几何正确形式。
|
|
115
115
|
4. **§II-H 流形上的不确定性与协方差传播(式 52)**:Σ 定义在切空间;§V-A 流形误差状态 EKF(式 92–96)是落地范例。
|