math-skill 2.0.1 → 3.0.0
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 +167 -175
- package/README.md +167 -175
- package/agents/math-critic.en.md +235 -0
- package/agents/math-critic.md +10 -8
- package/commands/ask.md +3 -12
- package/design-patterns/attention/equivariant-attention.en.md +72 -0
- package/design-patterns/attention/equivariant-attention.md +72 -0
- package/design-patterns/attention/geometry-aware-attention.en.md +73 -0
- package/design-patterns/attention/geometry-aware-attention.md +72 -0
- package/design-patterns/attention/information-bottleneck-attention.en.md +72 -0
- package/design-patterns/attention/information-bottleneck-attention.md +72 -0
- package/design-patterns/attention/projection-attention.en.md +68 -0
- package/design-patterns/attention/projection-attention.md +68 -0
- package/design-patterns/attention/spectral-attention.en.md +71 -0
- package/design-patterns/attention/spectral-attention.md +71 -0
- package/design-patterns/compression/leverage-score-selection.en.md +71 -0
- package/design-patterns/compression/leverage-score-selection.md +71 -0
- package/design-patterns/compression/low-rank-kv-cache.en.md +60 -0
- package/design-patterns/compression/low-rank-kv-cache.md +60 -0
- package/design-patterns/compression/spectral-token-pruning.en.md +61 -0
- package/design-patterns/compression/spectral-token-pruning.md +61 -0
- package/design-patterns/compression/topology-preserving-compression.en.md +64 -0
- package/design-patterns/compression/topology-preserving-compression.md +64 -0
- package/design-patterns/loss/constraint-penalty.en.md +67 -0
- package/design-patterns/loss/constraint-penalty.md +78 -0
- package/design-patterns/loss/contrastive-loss.en.md +59 -0
- package/design-patterns/loss/contrastive-loss.md +68 -0
- package/design-patterns/loss/information-bottleneck-loss.en.md +69 -0
- package/design-patterns/loss/information-bottleneck-loss.md +74 -0
- package/design-patterns/loss/orthogonality-loss.en.md +56 -0
- package/design-patterns/loss/orthogonality-loss.md +60 -0
- package/design-patterns/loss/variational-loss.en.md +61 -0
- package/design-patterns/loss/variational-loss.md +71 -0
- package/design-patterns/representation/equivariant-split.en.md +87 -0
- package/design-patterns/representation/equivariant-split.md +89 -0
- package/design-patterns/representation/manifold-representation.en.md +85 -0
- package/design-patterns/representation/manifold-representation.md +87 -0
- package/design-patterns/representation/shared-private-decomposition.en.md +84 -0
- package/design-patterns/representation/shared-private-decomposition.md +86 -0
- package/design-patterns/representation/subspace-alignment.en.md +90 -0
- package/design-patterns/representation/subspace-alignment.md +92 -0
- package/design-patterns/routing/graph-routing.en.md +79 -0
- package/design-patterns/routing/graph-routing.md +81 -0
- package/design-patterns/routing/moe-routing.en.md +85 -0
- package/design-patterns/routing/moe-routing.md +87 -0
- package/design-patterns/routing/optimal-transport-routing.en.md +68 -0
- package/design-patterns/routing/optimal-transport-routing.md +72 -0
- package/design-patterns/routing/spectral-clustering-routing.en.md +88 -0
- package/design-patterns/routing/spectral-clustering-routing.md +90 -0
- package/knowledge-base/differential-geometry/connection.en.md +51 -0
- package/knowledge-base/differential-geometry/connection.md +51 -0
- package/knowledge-base/differential-geometry/curvature.en.md +49 -0
- package/knowledge-base/differential-geometry/curvature.md +49 -0
- package/knowledge-base/differential-geometry/geodesic.en.md +51 -0
- package/knowledge-base/differential-geometry/geodesic.md +51 -0
- package/knowledge-base/differential-geometry/manifold.en.md +47 -0
- package/knowledge-base/differential-geometry/manifold.md +47 -0
- package/knowledge-base/differential-geometry/metric-tensor.en.md +50 -0
- package/knowledge-base/differential-geometry/metric-tensor.md +50 -0
- package/knowledge-base/differential-geometry/tangent-space.en.md +48 -0
- package/knowledge-base/differential-geometry/tangent-space.md +48 -0
- package/knowledge-base/information-geometry/fisher-metric.en.md +56 -0
- package/knowledge-base/information-geometry/fisher-metric.md +56 -0
- package/knowledge-base/information-geometry/natural-gradient.en.md +54 -0
- package/knowledge-base/information-geometry/natural-gradient.md +54 -0
- package/knowledge-base/lie-theory/equivariance.en.md +54 -0
- package/knowledge-base/lie-theory/equivariance.md +54 -0
- package/knowledge-base/lie-theory/group-action.en.md +51 -0
- package/knowledge-base/lie-theory/group-action.md +51 -0
- package/knowledge-base/lie-theory/lie-algebra.en.md +51 -0
- package/knowledge-base/lie-theory/lie-algebra.md +51 -0
- package/knowledge-base/lie-theory/lie-group.en.md +51 -0
- package/knowledge-base/lie-theory/lie-group.md +51 -0
- package/knowledge-base/lie-theory/representation.en.md +52 -0
- package/knowledge-base/lie-theory/representation.md +52 -0
- package/knowledge-base/matrix-analysis/low-rank-approximation.en.md +49 -0
- package/knowledge-base/matrix-analysis/low-rank-approximation.md +49 -0
- package/knowledge-base/matrix-analysis/matrix-perturbation.en.md +49 -0
- package/knowledge-base/matrix-analysis/matrix-perturbation.md +49 -0
- package/knowledge-base/matrix-analysis/positive-semidefinite.en.md +50 -0
- package/knowledge-base/matrix-analysis/positive-semidefinite.md +50 -0
- package/knowledge-base/matrix-analysis/projection.en.md +47 -0
- package/knowledge-base/matrix-analysis/projection.md +47 -0
- package/knowledge-base/matrix-analysis/spectral-decomposition.en.md +48 -0
- package/knowledge-base/matrix-analysis/spectral-decomposition.md +48 -0
- package/knowledge-base/optimization/constrained-optimization.en.md +53 -0
- package/knowledge-base/optimization/constrained-optimization.md +53 -0
- package/knowledge-base/optimization/convex-optimization.en.md +50 -0
- package/knowledge-base/optimization/convex-optimization.md +50 -0
- package/knowledge-base/optimization/lagrangian-duality.en.md +50 -0
- package/knowledge-base/optimization/lagrangian-duality.md +50 -0
- package/knowledge-base/optimization/proximal-method.en.md +52 -0
- package/knowledge-base/optimization/proximal-method.md +52 -0
- package/knowledge-base/optimization/riemannian-optimization.en.md +51 -0
- package/knowledge-base/optimization/riemannian-optimization.md +51 -0
- package/knowledge-base/overview.en.md +39 -0
- package/knowledge-base/overview.md +29 -218
- package/knowledge-base/probability/concentration-inequality.en.md +45 -0
- package/knowledge-base/probability/concentration-inequality.md +45 -0
- package/knowledge-base/probability/entropy.en.md +47 -0
- package/knowledge-base/probability/entropy.md +47 -0
- package/knowledge-base/probability/fisher-information.en.md +48 -0
- package/knowledge-base/probability/fisher-information.md +48 -0
- package/knowledge-base/probability/information-bottleneck.en.md +49 -0
- package/knowledge-base/probability/information-bottleneck.md +49 -0
- package/knowledge-base/probability/kl-divergence.en.md +51 -0
- package/knowledge-base/probability/kl-divergence.md +51 -0
- package/knowledge-base/topology/euler-characteristic.en.md +54 -0
- package/knowledge-base/topology/euler-characteristic.md +54 -0
- package/knowledge-base/topology/fundamental-group.en.md +52 -0
- package/knowledge-base/topology/fundamental-group.md +52 -0
- package/knowledge-base/topology/persistent-homology.en.md +54 -0
- package/knowledge-base/topology/persistent-homology.md +54 -0
- package/lenses/algorithmic.en.md +49 -0
- package/lenses/algorithmic.md +49 -0
- package/lenses/axiomatization.en.md +48 -0
- package/lenses/axiomatization.md +48 -0
- package/lenses/categorical.en.md +48 -0
- package/lenses/categorical.md +48 -0
- package/lenses/causal.en.md +49 -0
- package/lenses/causal.md +49 -0
- package/lenses/duality.en.md +47 -0
- package/lenses/duality.md +47 -0
- package/lenses/game.en.md +50 -0
- package/lenses/game.md +50 -0
- package/lenses/geometric.en.md +53 -0
- package/lenses/geometric.md +53 -0
- package/lenses/local-to-global.en.md +52 -0
- package/lenses/local-to-global.md +52 -0
- package/lenses/perturbation.en.md +51 -0
- package/lenses/perturbation.md +51 -0
- package/lenses/probabilistic.en.md +48 -0
- package/lenses/probabilistic.md +48 -0
- package/lenses/projection.en.md +50 -0
- package/lenses/projection.md +50 -0
- package/lenses/spectral.en.md +52 -0
- package/lenses/spectral.md +52 -0
- package/lenses/symmetry.en.md +49 -0
- package/lenses/symmetry.md +49 -0
- package/lenses/topological.en.md +48 -0
- package/lenses/topological.md +48 -0
- package/lenses/variational.en.md +48 -0
- package/lenses/variational.md +48 -0
- package/package.json +11 -3
- package/references/agentic-workflow.en.md +53 -0
- package/references/agentic-workflow.md +2 -0
- package/references/books/abstract-algebra.md +9 -5
- package/references/books/algebraic-geometry-rising-sea.md +9 -5
- package/references/books/differential-geometry.md +7 -3
- package/references/books/matrix-analysis.md +8 -4
- package/references/books/micro-lie-theory.md +7 -3
- package/references/books/optimization-ml.md +5 -1
- package/references/books/smooth-manifolds.md +7 -3
- package/references/gpu-friendly-math.en.md +65 -0
- package/references/gpu-friendly-math.md +4 -2
- package/references/inspiration.en.md +113 -0
- package/references/inspiration.md +4 -2
- package/skills/math-research-activator/SKILL.en.md +187 -0
- package/skills/math-research-activator/SKILL.md +162 -108
- package/skills/math-research-activator/original-texts.en.md +105 -0
- package/skills/math-research-activator/original-texts.md +11 -11
- package/commands/abstraction.md +0 -13
- package/commands/algorithmic-thinking.md +0 -13
- package/commands/axiomatization.md +0 -13
- package/commands/causal-inference.md +0 -13
- package/commands/discrete-combinatorial.md +0 -13
- package/commands/game-theory.md +0 -13
- package/commands/induction-analogy.md +0 -13
- package/commands/information-theory.md +0 -13
- package/commands/logic-deduction.md +0 -13
- package/commands/modeling.md +0 -13
- package/commands/optimization.md +0 -13
- package/commands/probability-statistics.md +0 -13
- package/commands/symmetry-invariance.md +0 -13
- package/commands/topological-thinking.md +0 -13
- package/commands/transformation.md +0 -13
- package/skills/abstraction/SKILL.md +0 -119
- package/skills/abstraction/original-texts.md +0 -175
- package/skills/algorithmic-thinking/SKILL.md +0 -136
- package/skills/algorithmic-thinking/original-texts.md +0 -256
- package/skills/axiomatization/SKILL.md +0 -149
- package/skills/axiomatization/original-texts.md +0 -160
- package/skills/causal-inference/SKILL.md +0 -149
- package/skills/causal-inference/original-texts.md +0 -167
- package/skills/discrete-combinatorial/SKILL.md +0 -129
- package/skills/discrete-combinatorial/original-texts.md +0 -185
- package/skills/game-theory/SKILL.md +0 -121
- package/skills/game-theory/original-texts.md +0 -131
- package/skills/induction-analogy/SKILL.md +0 -150
- package/skills/induction-analogy/original-texts.md +0 -154
- package/skills/information-theory/SKILL.md +0 -138
- package/skills/information-theory/original-texts.md +0 -127
- package/skills/logic-deduction/SKILL.md +0 -133
- package/skills/logic-deduction/original-texts.md +0 -173
- package/skills/modeling/SKILL.md +0 -137
- package/skills/modeling/original-texts.md +0 -165
- package/skills/optimization/SKILL.md +0 -133
- package/skills/optimization/original-texts.md +0 -168
- package/skills/probability-statistics/SKILL.md +0 -149
- package/skills/probability-statistics/original-texts.md +0 -193
- package/skills/symmetry-invariance/SKILL.md +0 -137
- package/skills/symmetry-invariance/original-texts.md +0 -221
- package/skills/topological-thinking/SKILL.md +0 -126
- package/skills/topological-thinking/original-texts.md +0 -164
- package/skills/transformation/SKILL.md +0 -122
- package/skills/transformation/original-texts.md +0 -216
|
@@ -104,15 +104,15 @@
|
|
|
104
104
|
- 病态/非正规 → **重参数化 + 谱归一化**稳低精度(维度 5);
|
|
105
105
|
- Jordan 等不可算标准型 → 只留作**理论证明**,数值上换 Schur/SVD。
|
|
106
106
|
|
|
107
|
-
##
|
|
107
|
+
## 该调用哪个思想透镜
|
|
108
108
|
|
|
109
109
|
配合 `skills/` 下的现有武器使用:
|
|
110
110
|
|
|
111
|
-
- **`
|
|
111
|
+
- **`duality`(变换)**:相似 / 酉等价 / 合同、SVD、对角化——本书的灵魂就是"换坐标让结构显形"。
|
|
112
112
|
- **`algorithmic-thinking`(算法与计算)**:power iteration、Newton–Schulz、QR algorithm、随机化 NLA——把定理变成可跑的 kernel。
|
|
113
113
|
- **`optimization`(优化)**:变分刻画(§4.2)、条件数与预条件、二阶法、Loewner 偏序下的矩阵不等式。
|
|
114
|
-
- **`symmetry
|
|
115
|
-
- **`
|
|
114
|
+
- **`symmetry`(对称与不变性)**:酉不变性、相似不变量(特征值/迹/行列式)、正规矩阵的良态谱。
|
|
115
|
+
- **`categorical`(抽象化)**:标准型即"等价类的代表元"——用最简形态抓住本质、忽略坐标细节。
|
|
116
116
|
- **`probability-statistics`(概率与统计)**:随机化 NLA、随机矩阵谱、Perron–Frobenius/Markov 链平稳分布。
|
|
117
117
|
|
|
118
118
|
## 反模式
|
|
@@ -130,6 +130,10 @@
|
|
|
130
130
|
|
|
131
131
|
## 深挖入口
|
|
132
132
|
|
|
133
|
+
> **📖 书目信息**:Roger A. Horn & Charles R. Johnson, *Matrix Analysis*, 2nd Edition, Cambridge University Press, 2013. ISBN 978-0-521-83940-2.
|
|
134
|
+
>
|
|
135
|
+
> **启用方式**:将 `Matrix Analysis.pdf` 放入项目根目录的 `math_book/` 文件夹,Agent 即可自动搜索原文。PDF 不随 npm/git 分发(版权原因),需自行获取。
|
|
136
|
+
|
|
133
137
|
**全保真回查 = 让 Agent 自动搜索本地 PDF `math_book/Matrix Analysis.pdf`**:用 `pdftotext` 抽取 → `grep` 定位关键词/定理名 → `Read` 命中页精读。本文件是"激活索引",不是替代品;需要精确陈述、证明或常数时,回原书核对。
|
|
134
138
|
|
|
135
139
|
值得深读的真实章节:
|
|
@@ -84,10 +84,10 @@
|
|
|
84
84
|
- **低精度奇异点(结论 3,头号风险)**:θ→0(`sinθ/θ` 除零)与 θ→π(log 不唯一)会灾难性抵消,fp16/bf16 直接 NaN。低精度训练前**必须**对小角做 Taylor 兜底并做确定性复现测试;兜底分支又会引入 warp divergence,需用 `where`/掩码而非数据相关跳转实现。
|
|
85
85
|
- **串行递推**:流形上的运动链/离散积分(§II-I)是连乘 Exp 的串行递推,长序列要改写成并行扫描(parallel scan)才能喂满 GPU。
|
|
86
86
|
|
|
87
|
-
##
|
|
87
|
+
## 该调用哪个思想透镜
|
|
88
88
|
|
|
89
|
-
- **⚛️ symmetry
|
|
90
|
-
- **🔄
|
|
89
|
+
- **⚛️ symmetry(首选)**:李群本就是**连续对称变换群**,本文是"对称/不变性→等变网络"最直接的数学弹药。
|
|
90
|
+
- **🔄 duality(首选)**:exp/log 把"曲的非线性流形"等价变换到"平的线性切空间"——把难问题变换成易问题的范式样板(屠龙刀"切菜")。
|
|
91
91
|
- **⚖️ optimization**:流形上的优化、retraction、误差状态滤波(§V-A)。
|
|
92
92
|
- **🌉 modeling**:现实(机器人/相机状态+噪声)→数学(流形+协方差)→解释的建模闭环。
|
|
93
93
|
- **🧩 abstraction**:从具体矩阵/四元数抽象出"群"的统一接口(论文正文泛型 + 例子接地的写法本身就是抽象示范)。
|
|
@@ -103,6 +103,10 @@
|
|
|
103
103
|
|
|
104
104
|
## 深挖入口
|
|
105
105
|
|
|
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
|
+
>
|
|
108
|
+
> **启用方式**:将 `A micro Lie theory.pdf` 放入项目根目录的 `math_book/` 文件夹,Agent 即可自动搜索原文。PDF 不随 npm/git 分发(版权原因),需自行获取。
|
|
109
|
+
|
|
106
110
|
> 全保真回查 = 让 Agent 自动检索本地 PDF:`math_book/A micro Lie theory.pdf`(用 `pdftotext` 或 Read PDF pages)。下列为该 PDF 内的真实章节/公式块定位:
|
|
107
111
|
|
|
108
112
|
1. **§II-D 指数映射 + Fig. 1**:exp/log 与大写 Exp/Log 算子(式 23–24)——流形↔切空间桥梁与闭式来源;配 Ex. 3(SO(3) 的李代数 `[ω]×`)、Ex. 4(SO(3) 的 exp = Rodrigues)。
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
- κ 大 → **维度 5** 在低精度下被进一步放大(病态梯度)。
|
|
131
131
|
- 必须配归一化 / 预条件,否则 bf16 训练发散。
|
|
132
132
|
|
|
133
|
-
##
|
|
133
|
+
## 该调用哪个思想透镜
|
|
134
134
|
|
|
135
135
|
- **optimization**(主):目标-约束-最优性-收敛的完整框架,本书是其核心出处。
|
|
136
136
|
- **algorithmic-thinking**:迭代算法的收敛性、复杂度、步长 / 停机判据。
|
|
@@ -150,6 +150,10 @@
|
|
|
150
150
|
|
|
151
151
|
## 深挖入口
|
|
152
152
|
|
|
153
|
+
> **📖 书目信息**:Edwin K. P. Chong, Wu-Sheng Lu, Stanisław H. Żak, *An Introduction to Optimization, With Applications to Machine Learning*, 5th Edition, John Wiley & Sons, 2024. ISBN 978-1-119-87763-9.
|
|
154
|
+
>
|
|
155
|
+
> **启用方式**:将 `An Introduction to Optimization With Applications to Machine Learning.pdf` 放入项目根目录的 `math_book/` 文件夹,Agent 即可自动搜索原文。PDF 不随 npm/git 分发(版权原因),需自行获取。
|
|
156
|
+
|
|
153
157
|
全保真回查 = 让 Agent 直接搜索本地 PDF
|
|
154
158
|
`math_book/An Introduction to Optimization With Applications to Machine Learning.pdf`,按真实章号定位:
|
|
155
159
|
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
4. **结构化 Jacobian**:归一化流坚持三角/耦合结构,杜绝通用 LU 求 det。
|
|
72
72
|
5. **精度护栏**:凡矩阵 exp/log/eig,强制 fp32 累加并做数值稳定(log-sum-exp 式)。
|
|
73
73
|
|
|
74
|
-
##
|
|
74
|
+
## 该调用哪个思想透镜
|
|
75
75
|
|
|
76
76
|
- **optimization(⚖️ 优化思想)**:主武器——约束下寻最优、黎曼/流形优化、retraction 选型。
|
|
77
|
-
- **symmetry
|
|
78
|
-
- **
|
|
77
|
+
- **symmetry(⚛️ 对称与不变性)**:李群、等变、商流形、群作用下的不变量。
|
|
78
|
+
- **duality(对偶透镜)**:坐标卡变换、pushforward/pullback、归一化流的变量替换、微分同胚。
|
|
79
79
|
- **topological-thinking(🌀 拓扑思想)**:de Rham 上同调、全局障碍、隐空间的"洞"与连通性。
|
|
80
80
|
- **abstraction(🧩 抽象化思想)**:从高维杂乱的环境数据中抽出"局部线性 + 光滑拼接"的流形骨架(流形假设)。
|
|
81
81
|
|
|
@@ -90,6 +90,10 @@
|
|
|
90
90
|
|
|
91
91
|
## 深挖入口
|
|
92
92
|
|
|
93
|
+
> **📖 书目信息**:John M. Lee, *Introduction to Smooth Manifolds*, 2nd Edition, Graduate Texts in Mathematics 218, Springer, 2013. ISBN 978-1-4419-9981-8.
|
|
94
|
+
>
|
|
95
|
+
> **启用方式**:将 `Introduction to Smooth Manifolds.pdf` 放入项目根目录的 `math_book/` 文件夹,Agent 即可自动搜索原文。PDF 不随 npm/git 分发(版权原因),需自行获取。
|
|
96
|
+
|
|
93
97
|
> **全保真回查**:需要原文定义/定理/证明时,让 Agent **自动搜索本地 PDF** `math_book/Introduction to Smooth Manifolds.pdf`(按章号/关键词定位,勿凭记忆复述)。下列为真实章号(2nd ed.):
|
|
94
98
|
|
|
95
99
|
- **Ch 3 Tangent Vectors** — 切空间、微分/pushforward、切丛:局部线性化与反传的几何原型。
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# GPU-Friendly Math Checklist
|
|
2
|
+
|
|
3
|
+
> This file is the **single source of truth** for the "GPU-feasibility" acceptance gate.
|
|
4
|
+
> The activator, the 15 thinking lenses, `books/*.md`, and `../agents/math-critic.md` all reference this file; no duplicate definitions elsewhere.
|
|
5
|
+
>
|
|
6
|
+
> This file is the single source of truth for the "GPU-feasibility" acceptance gate. The activator, the 15 thinking lenses, the book references, and the math-critic all point here.
|
|
7
|
+
|
|
8
|
+
## Core Proposition
|
|
9
|
+
|
|
10
|
+
**Mathematical beauty ≠ computability.** For a structure to truly enter training and inference on modern GPU clusters, it must simultaneously satisfy two requirements:
|
|
11
|
+
|
|
12
|
+
1. **Mathematically correct (beautiful in math)** — The structure is self-consistent, differentiable (or relaxable to differentiable), with correctness guarantees.
|
|
13
|
+
2. **Hardware-feasible (friendly to GPU)** — It can be efficiently mapped onto GPU microarchitecture (Tensor Cores, memory hierarchy, parallelism, and interconnects).
|
|
14
|
+
|
|
15
|
+
Many "beautiful on paper" modern mathematical structures cannot run at high performance once they encounter GPU parallelism and low-precision arithmetic errors. This checklist turns "GPU feasibility" into an **item-by-item scorable** engineering standard, preventing non-computable constructs from being accepted as deliverables.
|
|
16
|
+
|
|
17
|
+
## The 8-Dimension Scorecard
|
|
18
|
+
|
|
19
|
+
For any candidate structure (operator, attention variant, routing mechanism, regularization term, compression scheme…) rate each dimension as `Friendly / Retrofittable / Unfriendly` and provide adaptation recommendations.
|
|
20
|
+
|
|
21
|
+
| # | Dimension | Key Question | Friendly ✅ | Unfriendly ❌ |
|
|
22
|
+
|---|-----------|-------------|------------|--------------|
|
|
23
|
+
| 1 | **Tensorization** | Can it be expressed as dense tensor operations, avoiding element-wise irregular control flow? | Batched tensor algebra | Scalar loops, data-dependent branches |
|
|
24
|
+
| 2 | **GEMM-mappability** | Can it be reduced to matrix multiplication / batched GEMM / convolution to fully utilize Tensor Cores? | Expressible as a GEMM chain | Irregular computations that cannot be expressed as matrix operations |
|
|
25
|
+
| 3 | **Complexity** | Is the forward/backward pass sub-quadratic? How does it scale with sequence length / model size? | Linear / sub-quadratic, blockable | $O(n^2)$ or worse memory/compute blowup |
|
|
26
|
+
| 4 | **Memory & KV-Cache** | Peak memory usage; activation / state / KV footprint; can it be compressed? | Low-rank / quantized / block-summary compressible | Must materialize large intermediate tensors |
|
|
27
|
+
| 5 | **Low-Precision Stability** | Is it stable under fp16/bf16/fp8 with deterministic reproducibility? | Controlled dynamic range, numerically robust | Catastrophic cancellation, ill-conditioned, requires fp64 |
|
|
28
|
+
| 6 | **Parallelism & Communication** | Can it be parallelized across SMs / devices? Communication-to-compute ratio; can overlap be achieved? | Highly parallel, communication overlap-able | Long serial recurrences, communication bottleneck |
|
|
29
|
+
| 7 | **Sparse structure** | Structured or unstructured sparsity? | Block / banded structured sparsity | Random gather/scatter |
|
|
30
|
+
| 8 | **Operator Fusion** | Can kernels be fused to avoid materializing large intermediates (FlashAttention-style)? | Fusible, recomputable | Frequent small kernels, divergent control flow |
|
|
31
|
+
|
|
32
|
+
**Scoring conclusion**: Retain only candidates that are **mathematically beautiful AND (all eight dimensions friendly or retrofittable)**; any dimension rated "unfriendly and non-retrofittable" means the candidate must be adapted or eliminated.
|
|
33
|
+
|
|
34
|
+
## Common "Beautiful but Non-Computable" Anti-Patterns
|
|
35
|
+
|
|
36
|
+
- **Dense global $O(n^2)$ operators**: Naive softmax attention explodes with context length.
|
|
37
|
+
- **Unstructured sparsity / irregular graph traversal**: Random memory access destroys locality.
|
|
38
|
+
- **High-precision dependency**: Ill-conditioned problems that require fp64 for correctness (most training runs only bf16/fp16/fp8).
|
|
39
|
+
- **Serial recurrence**: Long-range dependencies that cannot be parallelized (naive RNN-style).
|
|
40
|
+
- **Frequent small kernels + control-flow divergence**: Launch overhead and warp divergence consume throughput.
|
|
41
|
+
- **Non-differentiable / requiring discrete search**: Breaks end-to-end gradient-based training.
|
|
42
|
+
|
|
43
|
+
## Make-It-Computable Toolkit
|
|
44
|
+
|
|
45
|
+
Common techniques for transforming "beautiful but non-computable" into "both beautiful and computable":
|
|
46
|
+
|
|
47
|
+
- **Discrete → continuous relaxation**: Gumbel-softmax; **piecewise-linear** gating on the **tropical semiring** as a replacement for hard Top-K.
|
|
48
|
+
- **Block sparsification**: Dense attention within blocks, structured sparse between blocks (e.g., DeepSeek CSA-style blocking).
|
|
49
|
+
- **Low-rank / projection compression**: Restriction maps via low-rank linear transformations; **low-rank basis-style block summaries** for KV-Cache compression (store the basis rather than Plücker coordinates — the latter expands when low-rank).
|
|
50
|
+
- **Numerical reparameterization**: log-sum-exp, normalization, stable softmax — ensuring low-precision stability.
|
|
51
|
+
- **Operator fusion / recomputation**: Fused kernels, activation recompute to save memory.
|
|
52
|
+
- **Embedding structure into GEMM**: Express algebraic/geometric transformations as **learnable linear maps** so they naturally map onto Tensor Cores.
|
|
53
|
+
|
|
54
|
+
## Worked Example: Tropical Sheaf Attention
|
|
55
|
+
|
|
56
|
+
Drawn from the auto-research directions cited in `agentic-workflow.md`, demonstrating how a **candidate design enters the 8-dimension verification**:
|
|
57
|
+
|
|
58
|
+
| Component | Mathematical Source | GPU Friendliness |
|
|
59
|
+
|-----------|-------------------|-----------------|
|
|
60
|
+
| Tropical Gating | Tropical semiring, piecewise-linear | Replaces Top-K: element-wise max-plus — dim 1 ✅ Tensorization / dim 2 ❌ Not a Tensor Core GEMM (runs on CUDA cores) / dim 3 ✅ Per-token gating only, sub-quadratic (min-plus matmul is APSP-hard, not sub-quadratic); sub-differentiable, kinks require LogSumExp smoothing (smoothing recovers standard softmax) |
|
|
61
|
+
| Cellular Sheaf Diffusion | Algebraic geometry / topology (sheaves, restriction maps) | Each edge is a low-rank linear transform = small GEMM (dim 2/4) |
|
|
62
|
+
| Čech Cohomology Regularization | Algebraic topology (first cohomology $H^1$) | Local, inexpensive; serves as an algebraic criterion for hallucination (dim 3/8) |
|
|
63
|
+
| Low-Rank Basis KV Compression (Plücker/Grassmannian perspective) | Projective geometry | Store the basis rather than Plücker coordinates (the latter expands when low-rank); block-summary candidate — compression ratio / error / throughput must be benchmarked (dim 4) |
|
|
64
|
+
|
|
65
|
+
Do not treat the table above as validated conclusions. The correct approach is to enter each component into the test plan: prove or estimate complexity, measure peak memory and throughput, check bf16/fp8 stability, and confirm whether it can be mapped to GEMM / batched GEMM / fused kernels. Only after both empirical benchmarks and theoretical derivations pass should a component be labeled "math beautiful × GPU friendly."
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
> **语言路由**:若用户消息为英文,请读取并遵循同目录下的 `gpu-friendly-math.en.md`。
|
|
2
|
+
|
|
1
3
|
# GPU 友好性总清单 / GPU-Friendly Math Checklist
|
|
2
4
|
|
|
3
5
|
> 本文件是「GPU 可行性」验收门的**唯一权威来源(single source of truth)**。
|
|
4
|
-
> activator、
|
|
6
|
+
> activator、15 个思想透镜、`books/*.md`、以及 `../agents/math-critic.md` 都引用此处,不重复定义。
|
|
5
7
|
>
|
|
6
|
-
> This file is the single source of truth for the "GPU-feasibility" acceptance gate. The activator, the
|
|
8
|
+
> This file is the single source of truth for the "GPU-feasibility" acceptance gate. The activator, the 15 thinking lenses, the book references, and the math-critic all point here.
|
|
7
9
|
|
|
8
10
|
## 核心命题 / Core Proposition
|
|
9
11
|
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# Inspirational Musings
|
|
2
|
+
|
|
3
|
+
> Mathematics is more than a computational tool — it is a way of thinking. Sometimes a mathematical concept resonates with life itself, and you suddenly realize that behind those cold formulas lies a warm perspective on understanding the world.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. The Dragon-Slaying Blade: The Origin of Lie Groups and Lie Algebras
|
|
8
|
+
|
|
9
|
+
I still remember reading a Zhihu answer while pondering the question "How to understand that the original motivation of Lie groups and Lie algebras was to solve differential equations?" — one response left an indelible impression on me [Source: https://www.zhihu.com/question/356243536/answer/1992290356713259459].
|
|
10
|
+
|
|
11
|
+
Sophus Lie was a blacksmith who wanted to forge a **dragon-slaying blade** — a universal method for solving all differential equations.
|
|
12
|
+
|
|
13
|
+
Although the final blade could not slay every dragon, the craft of its forging — the correspondence between Lie groups and Lie algebras — has been passed down through generations. Later researchers discovered that while this blade cannot cut through every differential equation, it serves as a divine instrument for **chopping vegetables** (linearizing nonlinear problems), for **sculpting** (describing physical symmetries), and for **building houses** (robot state estimation).
|
|
14
|
+
|
|
15
|
+
So, when you stare at a screen full of `se(3)` and exponential map notation and feel dizzy, do not forget that all of this began with a single Norwegian mathematician wondering: what miracles would unfold if you took Galois's game of permuting roots and extended it to the infinitesimal?
|
|
16
|
+
|
|
17
|
+
**This is what makes mathematics most enchanting.**
|
|
18
|
+
|
|
19
|
+
A tool invented to solve a specific problem ultimately reveals value far beyond its original intent in entirely different domains. Axiomatic thinking was initially developed to make geometry rigorous, yet it became the foundational language of every mathematical discipline. The Fourier transform was originally devised to solve the heat equation, yet it became central to signal processing and quantum mechanics. Euler's generating functions were initially created to count integer partitions, yet they became universal tools in combinatorics and probability theory.
|
|
20
|
+
|
|
21
|
+
Mathematical thinking works the same way — you may learn it to review a paper or solve a specific problem, but its true value lies in how it transforms the way you see the world.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 2. Life as an Optimization Problem
|
|
26
|
+
|
|
27
|
+
If you treat a human being as a high-dimensional, nonlinear, dynamic optimization problem with a time-varying objective function, you will find that optimization theory and life paths share a striking philosophical resonance.
|
|
28
|
+
|
|
29
|
+
### The Objective Function: What Do You Want to "Optimize"?
|
|
30
|
+
|
|
31
|
+
In mathematics, the first step is to define the objective function $f(x)$. In life, this is the value you pursue: happiness, achievement, meaning, wealth, balance…
|
|
32
|
+
|
|
33
|
+
The difficulty is that life goals are often **multi-objective, vague, and time-varying** — and may even conflict with one another.
|
|
34
|
+
|
|
35
|
+
### Initial Point and Resource Constraints
|
|
36
|
+
|
|
37
|
+
$x_0$ is your origin, talent, and starting point.
|
|
38
|
+
|
|
39
|
+
Constraint conditions: time, money, health, social rules… These are like the constraints $g(x) \leq 0$ in an optimization problem, delineating the feasible region.
|
|
40
|
+
|
|
41
|
+
### Step Size and Direction: Everyday Decisions
|
|
42
|
+
|
|
43
|
+
**Direction**: The direction you choose to invest effort — career, relationships, fields of study.
|
|
44
|
+
|
|
45
|
+
**Step size**: The intensity and time you devote to a given direction.
|
|
46
|
+
|
|
47
|
+
Precision requirement: if every step only pursues immediate returns (e.g., short-term profit maximization), you may fall into a "local optimum" trap — for example, a high-paying but meaningless job, or a busy but stagnant life.
|
|
48
|
+
|
|
49
|
+
### Local Optimum vs. Global Optimum
|
|
50
|
+
|
|
51
|
+
This is the core dilemma of "life optimization":
|
|
52
|
+
|
|
53
|
+
- **Local optimum**: The seemingly best choice within your city, industry, and social circle.
|
|
54
|
+
- **Global optimum**: Perhaps in another country, another field, or another lifestyle, there exists a life that better aligns with your true nature. But you cannot foresee the global landscape, just as an optimization algorithm can only access local information at its current position.
|
|
55
|
+
|
|
56
|
+
### Randomness and Noise
|
|
57
|
+
|
|
58
|
+
Life is not a smooth numerical function — it is full of random noise:
|
|
59
|
+
|
|
60
|
+
Luck, opportunities, unexpected events… These are equivalent to stochastic perturbations $f(x) + \epsilon$ on the objective function.
|
|
61
|
+
|
|
62
|
+
Therefore, pursuing excessive precision is often uneconomical; what you need is **robustness and adaptability**.
|
|
63
|
+
|
|
64
|
+
### The Exploration–Exploitation Trade-off
|
|
65
|
+
|
|
66
|
+
This is the fundamental tension of life:
|
|
67
|
+
|
|
68
|
+
- **Exploration**: Trying new fields, new relationships, new knowledge — risky, but potentially discovering an entirely new "basin of attraction."
|
|
69
|
+
- **Exploitation**: Deepening your current domain to harvest stable returns.
|
|
70
|
+
|
|
71
|
+
Explore more when young, exploit more in middle age? But the rule is not fixed.
|
|
72
|
+
|
|
73
|
+
### Dynamic Objectives and Lifelong Learning
|
|
74
|
+
|
|
75
|
+
Life goals change: passion at 20, meaning at 40, legacy at 60…
|
|
76
|
+
|
|
77
|
+
This means the objective function $f(x)$ itself is constantly evolving. Therefore, "optimizing yourself" is more important than "optimizing a fixed target" — this is **meta-optimization** (learning how to learn, adapting how to adapt).
|
|
78
|
+
|
|
79
|
+
### Algorithm Choice: Your Life Strategy
|
|
80
|
+
|
|
81
|
+
| Algorithm | Life Strategy |
|
|
82
|
+
|-----------|--------------|
|
|
83
|
+
| Gradient Descent | Follow the most pressing direction at each step (salary, social pressure) |
|
|
84
|
+
| Momentum | Maintain historical inertia (persist in long-term goals, resist short-term fluctuations) |
|
|
85
|
+
| Stochastic Gradient Descent | Accept mini-batch random samples, adjust flexibly |
|
|
86
|
+
| Evolutionary Algorithms | Try multiple life paths, discard ineffective strategies, retain effective patterns |
|
|
87
|
+
|
|
88
|
+
No single algorithm is universally best; what matters is knowing which strategy you are using and adjusting it at the right time.
|
|
89
|
+
|
|
90
|
+
### The Most Important Insight
|
|
91
|
+
|
|
92
|
+
In mathematical optimization, we assume a global optimum $x^*$ exists. But in life, there may be no "absolutely optimal life" at all.
|
|
93
|
+
|
|
94
|
+
We are merely "participants" in our own lives, searching for a satisfactory solution and striving to make the process full of learning, growth, and meaning.
|
|
95
|
+
|
|
96
|
+
What matters is not finding the legendary "global optimum," but rather, at each iteration:
|
|
97
|
+
|
|
98
|
+
- Keeping the general direction roughly correct
|
|
99
|
+
- Balancing exploration and exploitation
|
|
100
|
+
- Accepting noise and constraints
|
|
101
|
+
- Allowing the objective function to evolve gracefully as experience grows
|
|
102
|
+
|
|
103
|
+
**The process itself is the meaning; optimization is life.**
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## How These Stories Connect to This Project
|
|
108
|
+
|
|
109
|
+
The inspiration for this project stems precisely from these two insights:
|
|
110
|
+
|
|
111
|
+
1. **The value of mathematical tools far exceeds their original intent** — Sophus Lie's dragon-slaying blade story teaches us that a tool invented for solving differential equations ultimately became the universal language for describing symmetry. This is the core idea behind "thinking lenses": every mathematical concept carries transferable value far beyond its original application domain.
|
|
112
|
+
|
|
113
|
+
2. **Mathematics is a lens for understanding life** — Optimization theory is not just about algorithms; it is a framework for understanding the structure of life decisions. When you transfer the "exploration–exploitation trade-off" from reinforcement learning to career choices, or the "local optimum trap" from convex optimization to everyday decisions, mathematics steps off the blackboard and into daily life.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> **语言路由**:若用户消息为英文,请读取并遵循同目录下的 `inspiration.en.md`。
|
|
2
|
+
|
|
1
3
|
# 灵感杂谈 / Inspirational Musings
|
|
2
4
|
|
|
3
5
|
> 数学不只是一种计算工具,更是一种思想方法。有时,某个数学概念与人生之间的共鸣,会让你突然意识到——那些冰冷的公式背后,藏着理解世界的温暖视角。
|
|
@@ -18,7 +20,7 @@ Sophus Lie 是一个想打造一把**屠龙刀**(解通微分方程)的铁
|
|
|
18
20
|
|
|
19
21
|
一个为解决特定问题而发明的工具,最终在完全不同的领域展现出远超初衷的价值。公理化思想最初是为了让几何严密,后来却成了所有数学分支的基础语言;傅里叶变换最初是为了解热方程,后来却成了信号处理和量子力学的核心;欧拉的生成函数最初是为了算整数分拆,后来却成了组合学和概率论的通用工具。
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
数学思想透镜也是如此——你学习它,可能是为了审查一篇论文或解决一个具体问题,但它真正的价值,在于它改变了你看世界的方式。
|
|
22
24
|
|
|
23
25
|
---
|
|
24
26
|
|
|
@@ -108,6 +110,6 @@ $x_0$ 是你的出身、天赋、起点。
|
|
|
108
110
|
|
|
109
111
|
本项目的灵感来源,正是这两段感悟:
|
|
110
112
|
|
|
111
|
-
1. **数学工具的价值远超初衷** —— Sophus Lie 的屠龙刀故事告诉我们,一个为解微分方程而发明的工具,最终成为描述对称性的通用语言。这正是"
|
|
113
|
+
1. **数学工具的价值远超初衷** —— Sophus Lie 的屠龙刀故事告诉我们,一个为解微分方程而发明的工具,最终成为描述对称性的通用语言。这正是"思想透镜"的核心理念:每个数学思想方法,都有远超其原始应用场景的迁移价值。
|
|
112
114
|
|
|
113
115
|
2. **数学是理解生活的透镜** —— 最优化理论不只是算法,它还是一种理解人生决策结构的方式。当你把"探索与利用的权衡"从强化学习迁移到职业选择,把"局部最优陷阱"从凸优化迁移到生活决策,数学就从黑板走进了日常。
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: math-research-activator
|
|
3
|
+
description: |
|
|
4
|
+
Mathematical research OS — auto-diagnoses user intent, routes to thinking lenses, math knowledge base, or design translation layer. Triggers on architecture/operator design, theoretical analysis, math-to-AI transfer. Does NOT trigger for pure engineering tasks (debug, refactoring, hyperparameter tuning).
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
> **File routing**: When this document references any file (lenses, knowledge-base, design-patterns, references, agents), always load the `.en.md` variant if it exists. For example, `../../lenses/symmetry.md` → load `lenses/symmetry.en.md`.
|
|
9
|
+
# 🧭 Math Research OS
|
|
10
|
+
|
|
11
|
+
> "The thinking system does not hand out theorems, the knowledge system does not indulge in loose inspiration, and the design layer does not fake profundity."
|
|
12
|
+
|
|
13
|
+
This system is a mathematical staff office for AI architecture innovation — not an arsenal, but one that tells you: **what kind of battle this is, which arms to deploy, how to deploy them, and where things could go wrong.**
|
|
14
|
+
|
|
15
|
+
## Three-Layer Orthogonal Architecture
|
|
16
|
+
|
|
17
|
+
| Layer | Responsibility | Directory | Core Question |
|
|
18
|
+
|-------|---------------|-----------|--------------|
|
|
19
|
+
| **Thinking Lenses** | Diagnose problem structure, recommend mathematical perspectives | `../../lenses/*.md` | Which perspective should we view this problem through? |
|
|
20
|
+
| **Math Knowledge** | Provide concrete mathematical tools (definitions/theorems/formulas) | `../../knowledge-base/*/*.md` | What specific mathematics does this perspective require? |
|
|
21
|
+
| **Design Translation** | Translate mathematics into AI modules/losses/operators | `../../design-patterns/*/*.md` | How does this mathematics become model architecture? |
|
|
22
|
+
|
|
23
|
+
Auxiliary layers:
|
|
24
|
+
- `../../references/books/*.md`: Distilled notes from 7 textbooks; full context when deeper understanding is needed
|
|
25
|
+
- `../../references/gpu-friendly-math.md`: GPU Eight-Dimension Acceptance Gate (single source of truth)
|
|
26
|
+
- `../../agents/math-critic.md`: Math-engineering dual critic
|
|
27
|
+
|
|
28
|
+
## Intent Diagnosis (5 Scenarios)
|
|
29
|
+
|
|
30
|
+
| Scenario | Diagnostic Signal | Invocation Path |
|
|
31
|
+
|----------|------------------|-----------------|
|
|
32
|
+
| **A. Problem Analysis** | "Is this design sound?" "Are there gaps in the reasoning chain?" | Lenses → critic |
|
|
33
|
+
| **B. Mechanism Design** | "Design a new attention mechanism" "Transfer X to Y" | Lenses → Knowledge → Design → critic |
|
|
34
|
+
| **C. Knowledge Query** | "What is a tangent space on a manifold?" "How is the projection theorem applied?" | Knowledge |
|
|
35
|
+
| **D. Verification & Review** | "Does this formula hold?" "What guarantees does this loss provide?" | Knowledge → critic |
|
|
36
|
+
| **E. Pure Engineering** | Debugging, refactoring, hyperparameter tuning, code review | **Do not invoke the math system** |
|
|
37
|
+
|
|
38
|
+
## Lens Library (15 Mathematical Perspectives)
|
|
39
|
+
|
|
40
|
+
Each lens answers: What is this perspective? What kinds of problems is it suited to diagnose? Which knowledge domains does it route to?
|
|
41
|
+
|
|
42
|
+
| Lens | File | Core Perspective |
|
|
43
|
+
|------|------|-----------------|
|
|
44
|
+
| Axiomatization | `../../lenses/axiomatization.md` | Examine consistency/independence/completeness of assumptions |
|
|
45
|
+
| Duality | `../../lenses/duality.md` | Transform to the dual space to expose constraints and invariants |
|
|
46
|
+
| Symmetry | `../../lenses/symmetry.md` | Invariants and conservation laws under transformations |
|
|
47
|
+
| Spectral Decomposition | `../../lenses/spectral.md` | Eigenvalues/singular values reveal dominant structure |
|
|
48
|
+
| Geometric | `../../lenses/geometric.md` | Metric/curvature/spatial structure on manifolds |
|
|
49
|
+
| Projection & Decomposition | `../../lenses/projection.md` | Orthogonal decomposition, subspace separation, conflict elimination |
|
|
50
|
+
| Variational | `../../lenses/variational.md` | Constrained extrema, energy minimization |
|
|
51
|
+
| Local-to-Global | `../../lenses/local-to-global.md` | Patching local properties into global ones, cohomological obstructions |
|
|
52
|
+
| Topological | `../../lenses/topological.md` | Invariants under continuous deformation, connectedness, holes |
|
|
53
|
+
| Categorical | `../../lenses/categorical.md` | Universal properties, functors, natural transformations |
|
|
54
|
+
| Perturbation | `../../lenses/perturbation.md` | Propagation of small perturbations, stability, robustness |
|
|
55
|
+
| Causal | `../../lenses/causal.md` | Correlation ≠ causation, interventions, counterfactuals |
|
|
56
|
+
| Game-Theoretic | `../../lenses/game.md` | Multi-agent strategic interaction, equilibria, mechanism design |
|
|
57
|
+
| Probabilistic & Statistical | `../../lenses/probabilistic.md` | Quantifying uncertainty, Bayesian updating |
|
|
58
|
+
| Algorithmic | `../../lenses/algorithmic.md` | Complexity, feasibility, parallelizability |
|
|
59
|
+
|
|
60
|
+
## Knowledge Base (Organized by Mathematical Domain)
|
|
61
|
+
|
|
62
|
+
Each knowledge card answers: Minimal definition, core formulas, applicable problems, AI design translation, engineering feasibility, risks.
|
|
63
|
+
|
|
64
|
+
| Domain | Directory | Knowledge Cards |
|
|
65
|
+
|--------|-----------|----------------|
|
|
66
|
+
| Matrix Analysis | `../../knowledge-base/matrix-analysis/` | projection, spectral-decomposition, low-rank-approximation, positive-semidefinite, matrix-perturbation |
|
|
67
|
+
| Optimization | `../../knowledge-base/optimization/` | lagrangian-duality, convex-optimization, constrained-optimization, riemannian-optimization, proximal-method |
|
|
68
|
+
| Differential Geometry | `../../knowledge-base/differential-geometry/` | manifold, tangent-space, metric-tensor, geodesic, curvature, connection |
|
|
69
|
+
| Lie Theory | `../../knowledge-base/lie-theory/` | group-action, lie-group, lie-algebra, representation, equivariance |
|
|
70
|
+
| Topology | `../../knowledge-base/topology/` | persistent-homology, euler-characteristic, fundamental-group |
|
|
71
|
+
| Probability & Information | `../../knowledge-base/probability/` | concentration-inequality, entropy, kl-divergence, information-bottleneck, fisher-information |
|
|
72
|
+
| Information Geometry | `../../knowledge-base/information-geometry/` | natural-gradient, fisher-metric |
|
|
73
|
+
|
|
74
|
+
## Design Pattern Library (Organized by AI Component)
|
|
75
|
+
|
|
76
|
+
Each design pattern answers: Mathematical origin, AI module form, implementable architecture, GPU feasibility, paper-level exposition, risks.
|
|
77
|
+
|
|
78
|
+
| Component Type | Directory | Patterns |
|
|
79
|
+
|---------------|-----------|----------|
|
|
80
|
+
| Attention | `../../design-patterns/attention/` | projection-attention, spectral-attention, equivariant-attention, geometry-aware-attention, information-bottleneck-attention |
|
|
81
|
+
| Loss Functions | `../../design-patterns/loss/` | orthogonality-loss, contrastive-loss, variational-loss, information-bottleneck-loss, constraint-penalty |
|
|
82
|
+
| Routing | `../../design-patterns/routing/` | optimal-transport-routing, graph-routing, moe-routing, spectral-clustering-routing |
|
|
83
|
+
| Representation | `../../design-patterns/representation/` | shared-private-decomposition, manifold-representation, equivariant-split, subspace-alignment |
|
|
84
|
+
| Compression | `../../design-patterns/compression/` | low-rank-kv-cache, spectral-token-pruning, topology-preserving-compression, leverage-score-selection |
|
|
85
|
+
|
|
86
|
+
## Automatic Trigger Conditions
|
|
87
|
+
|
|
88
|
+
**All of Gate 1 + Gate 2 + Gate 3 must be satisfied simultaneously for intervention:**
|
|
89
|
+
|
|
90
|
+
### Gate 0 · Exclusion Gate (Highest Priority)
|
|
91
|
+
The following tasks **never** trigger the system regardless of workspace contents: code review, debugging, refactoring, hyperparameter tuning, build/deployment, purely factual queries, general software engineering.
|
|
92
|
+
|
|
93
|
+
### Gate 1 · Environment Signal
|
|
94
|
+
The workspace contains architecture-level core code (attention/transformer/MoE, `*.cu`/kernel) or research notes. Routine files like `model.py` or `trainer.py` alone **do not** constitute an environment signal.
|
|
95
|
+
|
|
96
|
+
### Gate 2 · Task Signal
|
|
97
|
+
The user's task involves **designing/improving** a new architecture/operator, **analyzing** theoretical properties, **transferring** mathematical structures into AI design, or **querying math knowledge relevant to AI research** (e.g., "how is tangent space used in optimization?"). Pure encyclopedic math queries (e.g., "what is a group?" with no AI context) do not auto-trigger, but can be accessed via `/ask`.
|
|
98
|
+
|
|
99
|
+
### Gate 3 · Intent Match
|
|
100
|
+
The user's intent matches one of scenarios A/B/C/D. Pure engineering tasks matching scenario E → no intervention.
|
|
101
|
+
|
|
102
|
+
> **`/ask` entry**: Manual invocation skips Gate 1 and Gate 2, executing only Gate 0 (exclusion) + Gate 3 (intent match), allowing direct access to any scenario including knowledge queries.
|
|
103
|
+
|
|
104
|
+
## Main Workflow
|
|
105
|
+
|
|
106
|
+
### Step 1: Diagnose Intent
|
|
107
|
+
1. Determine which scenario (A/B/C/D/E) the user's intent belongs to
|
|
108
|
+
2. Extract the core tension of the problem: what to preserve? what to suppress? what are the constraints? what is the engineering bottleneck?
|
|
109
|
+
3. Output a problem-type classification
|
|
110
|
+
|
|
111
|
+
### Step 2: Route Invocation
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
Scenario A (Analysis): Select 1–3 lenses → output perspective diagnosis → critic review
|
|
115
|
+
Scenario B (Design): Select 1–3 lenses → query knowledge cards → generate design patterns → critic review
|
|
116
|
+
Scenario C (Query): Load knowledge cards directly → output per knowledge activation protocol
|
|
117
|
+
Scenario D (Verification): Load knowledge cards → critic reviews conditions and boundaries
|
|
118
|
+
Scenario E (Engineering): No intervention
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Step 3: Output Format
|
|
122
|
+
|
|
123
|
+
**Scenario A/B Output**:
|
|
124
|
+
1. **[Diagnosis]** Problem type + core tension
|
|
125
|
+
2. **[Lens]** Recommend 1–3 mathematical perspectives (annotate why each is/is not suitable)
|
|
126
|
+
3. **[Knowledge]** (Scenario B only) Required concrete mathematical tools (reference knowledge cards)
|
|
127
|
+
4. **[Design]** (Scenario B only) Candidate AI module drafts (reference design patterns)
|
|
128
|
+
5. **[GPU]** Run candidates through the Eight-Dimension Gate (friendly/retrofittable/unfriendly)
|
|
129
|
+
6. **[Conclusion]** Retain candidates that pass both acceptance gates + next-step recommendations
|
|
130
|
+
|
|
131
|
+
**Scenario C Output** (Knowledge Activation Protocol):
|
|
132
|
+
1. Minimal definition
|
|
133
|
+
2. Core formulas
|
|
134
|
+
3. Applicable problems
|
|
135
|
+
4. AI design translation
|
|
136
|
+
5. Engineering feasibility
|
|
137
|
+
6. Risks and failure conditions
|
|
138
|
+
7. Further references (distilled book notes / original book paths)
|
|
139
|
+
|
|
140
|
+
**Scenario D Output**:
|
|
141
|
+
1. Conditions under which it holds
|
|
142
|
+
2. Conditions under which it fails
|
|
143
|
+
3. What it can guarantee at most
|
|
144
|
+
4. What it cannot guarantee
|
|
145
|
+
5. Engineering feasibility
|
|
146
|
+
|
|
147
|
+
**A conclusion must always be provided — never output analysis alone without convergence.**
|
|
148
|
+
|
|
149
|
+
## GPU Eight-Dimension Acceptance Gate
|
|
150
|
+
|
|
151
|
+
Formal terminology (single authoritative source: `../../references/gpu-friendly-math.md`):
|
|
152
|
+
**Tensorization / GEMM-mappability / Complexity / Memory & KV-Cache / Low-Precision Stability / Parallelism & Communication / Sparse Structure / Operator Fusion**
|
|
153
|
+
|
|
154
|
+
## Depth-of-Consultation Protocol
|
|
155
|
+
|
|
156
|
+
- **Light**: Read knowledge cards (`../../knowledge-base/*/*.md`); self-contained and immediately usable
|
|
157
|
+
- **Medium**: Read distilled book notes (`../../references/books/*.md`) for more complete context
|
|
158
|
+
- **Deep**: When `math_book/<PDF>` is available locally, the agent automatically runs `pdftotext` + grep to locate the original page
|
|
159
|
+
|
|
160
|
+
## Workflow Example
|
|
161
|
+
|
|
162
|
+
**User**: "Design a new KV Cache compression method that preserves long-range dependencies — I don't want to just do top-k."
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
Step 1 — Diagnosis: Scenario B (Mechanism Design)
|
|
166
|
+
Problem type: Sequence memory compression + information preservation + long-range structure
|
|
167
|
+
Core tension: Compressing token count vs. preserving long-range dependencies
|
|
168
|
+
|
|
169
|
+
Step 2 — Lens Selection:
|
|
170
|
+
1. Spectral Decomposition (preserve dominant subspace)
|
|
171
|
+
2. Information Theory (retain states with maximum mutual information)
|
|
172
|
+
3. Topological (preserve critical connectivity points of sequential structure)
|
|
173
|
+
|
|
174
|
+
Step 3 — Knowledge Query:
|
|
175
|
+
→ low-rank-approximation (Matrix Analysis)
|
|
176
|
+
→ leverage-score-selection (Design Pattern: compression)
|
|
177
|
+
→ information-bottleneck (Probability & Information)
|
|
178
|
+
|
|
179
|
+
Step 4 — Design Translation:
|
|
180
|
+
Candidate A: Spectral KV Compression (low-rank + leverage score)
|
|
181
|
+
Candidate B: Information-Preserving Cache (query sensitivity)
|
|
182
|
+
Candidate C: Topology-Preserving Cache (graph bridge-node retention)
|
|
183
|
+
|
|
184
|
+
Step 5 — Critic Review:
|
|
185
|
+
A is most GPU-friendly; B requires estimating future queries with inherent uncertainty; C has prohibitive graph construction cost
|
|
186
|
+
Recommendation: Prioritize A; use B as a lightweight gate
|
|
187
|
+
```
|