Spaces:
Running
Running
Update CurvOpt-MathFoundations.md
Browse files- CurvOpt-MathFoundations.md +60 -104
CurvOpt-MathFoundations.md
CHANGED
|
@@ -2,50 +2,44 @@
|
|
| 2 |
|
| 3 |
## Energy-Constrained Precision Allocation via Curvature and Information Theory
|
| 4 |
|
|
|
|
|
|
|
| 5 |
---
|
| 6 |
|
| 7 |
## 1. Problem Formulation
|
| 8 |
|
| 9 |
-
Let a trained neural network with parameters \( \theta \in \mathbb{R}^d \) minimize empirical risk:
|
| 10 |
|
| 11 |
-
\[
|
| 12 |
L(\theta) = \frac{1}{n} \sum_{i=1}^{n} \ell(f_\theta(x_i), y_i)
|
| 13 |
-
\]
|
| 14 |
|
| 15 |
We introduce quantization:
|
| 16 |
|
| 17 |
-
\[
|
| 18 |
\theta_q = \theta + \varepsilon
|
| 19 |
-
\]
|
| 20 |
-
|
| 21 |
-
where \( \varepsilon \) represents quantization perturbation.
|
| 22 |
|
| 23 |
-
We seek precision assignments \( q_l \) per layer
|
| 24 |
|
| 25 |
-
\[
|
| 26 |
\min_{q_l \in \mathcal{Q}}
|
| 27 |
\sum_{l=1}^{L} \mathcal{E}_l(q_l)
|
| 28 |
\quad
|
| 29 |
\text{s.t.}
|
| 30 |
\quad
|
| 31 |
L(\theta_q) - L(\theta) \le \epsilon
|
| 32 |
-
\]
|
| 33 |
-
|
| 34 |
-
This is a constrained optimization problem over precision levels.
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
- Boyd, S., & Vandenberghe, L. (2004). *Convex Optimization*. Cambridge University Press.
|
| 39 |
|
| 40 |
---
|
| 41 |
|
| 42 |
## 2. Second-Order Loss Perturbation
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
By Taylor expansion around \( \theta \):
|
| 47 |
|
| 48 |
-
\[
|
| 49 |
L(\theta + \varepsilon)
|
| 50 |
=
|
| 51 |
L(\theta)
|
|
@@ -55,158 +49,124 @@ L(\theta)
|
|
| 55 |
\frac{1}{2} \varepsilon^T H(\theta) \varepsilon
|
| 56 |
+
|
| 57 |
o(\|\varepsilon\|^2)
|
| 58 |
-
\]
|
| 59 |
-
|
| 60 |
-
where:
|
| 61 |
-
|
| 62 |
-
\[
|
| 63 |
-
H(\theta) = \nabla^2 L(\theta)
|
| 64 |
-
\]
|
| 65 |
|
| 66 |
Near a stationary point:
|
| 67 |
|
| 68 |
-
\[
|
| 69 |
\nabla L(\theta) \approx 0
|
| 70 |
-
\]
|
| 71 |
|
| 72 |
Thus:
|
| 73 |
|
| 74 |
-
\[
|
| 75 |
\Delta L
|
| 76 |
\approx
|
| 77 |
\frac{1}{2} \varepsilon^T H \varepsilon
|
| 78 |
-
\]
|
| 79 |
-
|
| 80 |
-
**Reference**
|
| 81 |
|
| 82 |
-
|
| 83 |
|
| 84 |
---
|
| 85 |
|
| 86 |
-
## 3. Spectral Bound
|
| 87 |
|
| 88 |
-
Since \( H \) is symmetric:
|
| 89 |
|
| 90 |
-
\[
|
| 91 |
\lambda_{\min}(H) \|\varepsilon\|^2
|
| 92 |
\le
|
| 93 |
\varepsilon^T H \varepsilon
|
| 94 |
\le
|
| 95 |
\lambda_{\max}(H) \|\varepsilon\|^2
|
| 96 |
-
\]
|
| 97 |
|
| 98 |
-
|
| 99 |
|
| 100 |
-
\[
|
| 101 |
\Delta L
|
| 102 |
\le
|
| 103 |
\frac{1}{2}
|
| 104 |
\lambda_{\max}(H)
|
| 105 |
\|\varepsilon\|^2
|
| 106 |
-
\]
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
**Reference**
|
| 111 |
-
|
| 112 |
-
- Goodfellow, I., Bengio, Y., & Courville, A. (2016). *Deep Learning*. MIT Press.
|
| 113 |
|
| 114 |
---
|
| 115 |
|
| 116 |
-
## 4.
|
| 117 |
-
|
| 118 |
-
Exact Hessian computation is infeasible.
|
| 119 |
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
\[
|
| 123 |
\operatorname{Tr}(H)
|
| 124 |
=
|
| 125 |
\mathbb{E}_{v}
|
| 126 |
\left[
|
| 127 |
v^T H v
|
| 128 |
\right]
|
| 129 |
-
\]
|
| 130 |
-
|
| 131 |
-
where \( v_i \sim \{-1,+1\} \) (Rademacher distribution).
|
| 132 |
-
|
| 133 |
-
This estimator is unbiased.
|
| 134 |
|
| 135 |
-
|
| 136 |
|
| 137 |
-
|
| 138 |
|
| 139 |
---
|
| 140 |
|
| 141 |
## 5. Quantization Noise Model
|
| 142 |
|
| 143 |
-
Uniform quantization with step size \( \Delta \):
|
| 144 |
|
| 145 |
-
\[
|
| 146 |
\varepsilon \sim \mathcal{U}\left(-\frac{\Delta}{2}, \frac{\Delta}{2}\right)
|
| 147 |
-
\]
|
| 148 |
|
| 149 |
Variance:
|
| 150 |
|
| 151 |
-
\[
|
| 152 |
\operatorname{Var}(\varepsilon)
|
| 153 |
=
|
| 154 |
\frac{\Delta^2}{12}
|
| 155 |
-
\]
|
| 156 |
|
| 157 |
Expected loss increase:
|
| 158 |
|
| 159 |
-
\[
|
| 160 |
\mathbb{E}[\Delta L]
|
| 161 |
\approx
|
| 162 |
\frac{1}{2}
|
| 163 |
\operatorname{Tr}(H)
|
| 164 |
\cdot
|
| 165 |
\frac{\Delta^2}{12}
|
| 166 |
-
\]
|
| 167 |
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
**Reference**
|
| 171 |
-
|
| 172 |
-
- Gallager, R. (1968). *Information Theory and Reliable Communication*. Wiley.
|
| 173 |
|
| 174 |
---
|
| 175 |
|
| 176 |
-
## 6.
|
| 177 |
-
|
| 178 |
-
For layer \( l \):
|
| 179 |
|
| 180 |
-
\[
|
| 181 |
I(X_l ; Y_l)
|
| 182 |
=
|
| 183 |
\int p(x,y)
|
| 184 |
\log
|
| 185 |
\frac{p(x,y)}{p(x)p(y)}
|
| 186 |
\, dx\,dy
|
| 187 |
-
\]
|
| 188 |
|
| 189 |
Data Processing Inequality:
|
| 190 |
|
| 191 |
-
\[
|
| 192 |
I(X; Y_{l+1}) \le I(X; Y_l)
|
| 193 |
-
\]
|
| 194 |
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
Layers with low marginal information contribution can tolerate larger perturbations.
|
| 198 |
-
|
| 199 |
-
**Reference**
|
| 200 |
-
|
| 201 |
-
- Cover, T., & Thomas, J. (2006). *Elements of Information Theory*. Wiley.
|
| 202 |
|
| 203 |
---
|
| 204 |
|
| 205 |
## 7. Constrained Energy Minimization
|
| 206 |
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
\[
|
| 210 |
\min_{q_l}
|
| 211 |
\sum_l \mathcal{E}_l(q_l)
|
| 212 |
+
|
|
@@ -219,31 +179,27 @@ We combine curvature-based sensitivity and energy cost:
|
|
| 219 |
-
|
| 220 |
\epsilon
|
| 221 |
\right)
|
| 222 |
-
\]
|
| 223 |
|
| 224 |
-
|
| 225 |
|
| 226 |
-
\[
|
| 227 |
\nabla_{q_l} \mathcal{L} = 0
|
| 228 |
-
\]
|
| 229 |
-
|
| 230 |
-
This yields optimal precision allocation under a global accuracy constraint.
|
| 231 |
-
|
| 232 |
-
**Reference**
|
| 233 |
|
| 234 |
-
|
| 235 |
|
| 236 |
---
|
| 237 |
|
| 238 |
-
##
|
| 239 |
|
| 240 |
CurvOpt is grounded in:
|
| 241 |
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
|
| 249 |
-
All
|
|
|
|
| 2 |
|
| 3 |
## Energy-Constrained Precision Allocation via Curvature and Information Theory
|
| 4 |
|
| 5 |
+
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
| 6 |
+
|
| 7 |
---
|
| 8 |
|
| 9 |
## 1. Problem Formulation
|
| 10 |
|
| 11 |
+
Let a trained neural network with parameters \\( \theta \in \mathbb{R}^d \\) minimize empirical risk:
|
| 12 |
|
| 13 |
+
\\[
|
| 14 |
L(\theta) = \frac{1}{n} \sum_{i=1}^{n} \ell(f_\theta(x_i), y_i)
|
| 15 |
+
\\]
|
| 16 |
|
| 17 |
We introduce quantization:
|
| 18 |
|
| 19 |
+
\\[
|
| 20 |
\theta_q = \theta + \varepsilon
|
| 21 |
+
\\]
|
|
|
|
|
|
|
| 22 |
|
| 23 |
+
We seek precision assignments \\( q_l \\) per layer:
|
| 24 |
|
| 25 |
+
\\[
|
| 26 |
\min_{q_l \in \mathcal{Q}}
|
| 27 |
\sum_{l=1}^{L} \mathcal{E}_l(q_l)
|
| 28 |
\quad
|
| 29 |
\text{s.t.}
|
| 30 |
\quad
|
| 31 |
L(\theta_q) - L(\theta) \le \epsilon
|
| 32 |
+
\\]
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
Reference: Boyd & Vandenberghe (2004), *Convex Optimization*
|
|
|
|
|
|
|
| 35 |
|
| 36 |
---
|
| 37 |
|
| 38 |
## 2. Second-Order Loss Perturbation
|
| 39 |
|
| 40 |
+
By Taylor expansion:
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
\\[
|
| 43 |
L(\theta + \varepsilon)
|
| 44 |
=
|
| 45 |
L(\theta)
|
|
|
|
| 49 |
\frac{1}{2} \varepsilon^T H(\theta) \varepsilon
|
| 50 |
+
|
| 51 |
o(\|\varepsilon\|^2)
|
| 52 |
+
\\]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
Near a stationary point:
|
| 55 |
|
| 56 |
+
\\[
|
| 57 |
\nabla L(\theta) \approx 0
|
| 58 |
+
\\]
|
| 59 |
|
| 60 |
Thus:
|
| 61 |
|
| 62 |
+
\\[
|
| 63 |
\Delta L
|
| 64 |
\approx
|
| 65 |
\frac{1}{2} \varepsilon^T H \varepsilon
|
| 66 |
+
\\]
|
|
|
|
|
|
|
| 67 |
|
| 68 |
+
Reference: Nocedal & Wright (2006), *Numerical Optimization*
|
| 69 |
|
| 70 |
---
|
| 71 |
|
| 72 |
+
## 3. Spectral Bound
|
| 73 |
|
| 74 |
+
Since \\( H \\) is symmetric:
|
| 75 |
|
| 76 |
+
\\[
|
| 77 |
\lambda_{\min}(H) \|\varepsilon\|^2
|
| 78 |
\le
|
| 79 |
\varepsilon^T H \varepsilon
|
| 80 |
\le
|
| 81 |
\lambda_{\max}(H) \|\varepsilon\|^2
|
| 82 |
+
\\]
|
| 83 |
|
| 84 |
+
Thus:
|
| 85 |
|
| 86 |
+
\\[
|
| 87 |
\Delta L
|
| 88 |
\le
|
| 89 |
\frac{1}{2}
|
| 90 |
\lambda_{\max}(H)
|
| 91 |
\|\varepsilon\|^2
|
| 92 |
+
\\]
|
| 93 |
|
| 94 |
+
Reference: Goodfellow et al. (2016), *Deep Learning*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
---
|
| 97 |
|
| 98 |
+
## 4. Hutchinson Trace Estimator
|
|
|
|
|
|
|
| 99 |
|
| 100 |
+
\\[
|
|
|
|
|
|
|
| 101 |
\operatorname{Tr}(H)
|
| 102 |
=
|
| 103 |
\mathbb{E}_{v}
|
| 104 |
\left[
|
| 105 |
v^T H v
|
| 106 |
\right]
|
| 107 |
+
\\]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
|
| 109 |
+
where \\( v_i \sim \{-1,+1\} \\).
|
| 110 |
|
| 111 |
+
Reference: Robert & Casella (2004), *Monte Carlo Statistical Methods*
|
| 112 |
|
| 113 |
---
|
| 114 |
|
| 115 |
## 5. Quantization Noise Model
|
| 116 |
|
| 117 |
+
Uniform quantization with step size \\( \Delta \\):
|
| 118 |
|
| 119 |
+
\\[
|
| 120 |
\varepsilon \sim \mathcal{U}\left(-\frac{\Delta}{2}, \frac{\Delta}{2}\right)
|
| 121 |
+
\\]
|
| 122 |
|
| 123 |
Variance:
|
| 124 |
|
| 125 |
+
\\[
|
| 126 |
\operatorname{Var}(\varepsilon)
|
| 127 |
=
|
| 128 |
\frac{\Delta^2}{12}
|
| 129 |
+
\\]
|
| 130 |
|
| 131 |
Expected loss increase:
|
| 132 |
|
| 133 |
+
\\[
|
| 134 |
\mathbb{E}[\Delta L]
|
| 135 |
\approx
|
| 136 |
\frac{1}{2}
|
| 137 |
\operatorname{Tr}(H)
|
| 138 |
\cdot
|
| 139 |
\frac{\Delta^2}{12}
|
| 140 |
+
\\]
|
| 141 |
|
| 142 |
+
Reference: Gallager (1968), *Information Theory and Reliable Communication*
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
---
|
| 145 |
|
| 146 |
+
## 6. Mutual Information
|
|
|
|
|
|
|
| 147 |
|
| 148 |
+
\\[
|
| 149 |
I(X_l ; Y_l)
|
| 150 |
=
|
| 151 |
\int p(x,y)
|
| 152 |
\log
|
| 153 |
\frac{p(x,y)}{p(x)p(y)}
|
| 154 |
\, dx\,dy
|
| 155 |
+
\\]
|
| 156 |
|
| 157 |
Data Processing Inequality:
|
| 158 |
|
| 159 |
+
\\[
|
| 160 |
I(X; Y_{l+1}) \le I(X; Y_l)
|
| 161 |
+
\\]
|
| 162 |
|
| 163 |
+
Reference: Cover & Thomas (2006), *Elements of Information Theory*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
|
| 165 |
---
|
| 166 |
|
| 167 |
## 7. Constrained Energy Minimization
|
| 168 |
|
| 169 |
+
\\[
|
|
|
|
|
|
|
| 170 |
\min_{q_l}
|
| 171 |
\sum_l \mathcal{E}_l(q_l)
|
| 172 |
+
|
|
|
|
| 179 |
-
|
| 180 |
\epsilon
|
| 181 |
\right)
|
| 182 |
+
\\]
|
| 183 |
|
| 184 |
+
KKT condition:
|
| 185 |
|
| 186 |
+
\\[
|
| 187 |
\nabla_{q_l} \mathcal{L} = 0
|
| 188 |
+
\\]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
+
Reference: Bertsekas (1999), *Nonlinear Programming*
|
| 191 |
|
| 192 |
---
|
| 193 |
|
| 194 |
+
## Summary
|
| 195 |
|
| 196 |
CurvOpt is grounded in:
|
| 197 |
|
| 198 |
+
- Second-order perturbation theory
|
| 199 |
+
- Spectral bounds
|
| 200 |
+
- Monte Carlo trace estimation
|
| 201 |
+
- Classical quantization noise modeling
|
| 202 |
+
- Shannon mutual information
|
| 203 |
+
- Constrained nonlinear optimization
|
| 204 |
|
| 205 |
+
All formulas are standard results from established literature.
|