Record the curvature-dependent schedule, its rationale and equations
Browse files- research/README.md +3 -0
- research/docs/index.html +1 -0
- research/docs/third-derivative-penalty.md +16 -0
- research/reports/literature-review.md +1 -0
- research/reports/paper.pdf +0 -0
- research/reports/plan.md +10 -0
- research/reports/planned-runs.md +4 -0
- research/src/thirdloss/report_paper.py +45 -0
- research/tests/test_reporting.py +4 -0
research/README.md
CHANGED
|
@@ -12,6 +12,8 @@ The registered study tests whether this penalty improves prediction on unseen to
|
|
| 12 |
|
| 13 |
**Why add the third-derivative penalty late?** Even a steep valley can have constant curvature. The proposed TinyStories follow-up would first train with the Hessian-trace penalty to favor low average curvature. At a prespecified token count, it would keep the trace active and gradually add the third-derivative penalty. If the weights have reached a flat region where curvature changes faster toward the edge, the new penalty rises as the weights move outward. Its gradient can then oppose that movement. Delaying the penalty also avoids early fourth-derivative computations. If this schedule helps retain a wider region, later checkpoints should tolerate larger weight perturbations than trace-only controls at the same allowed increase in unregularized next-token loss. [Timing controls and width measurement](reports/plan.md#late-third-derivative-regularization)
|
| 14 |
|
|
|
|
|
|
|
| 15 |
## Can the penalty favor a wider minimum?
|
| 16 |
|
| 17 |
A minimum is **wide** if the weights can move a long way before the loss rises by a chosen amount. [Basin width, Definition 1](https://proceedings.mlr.press/v70/dinh17b/dinh17b.pdf#page=2)
|
|
@@ -393,3 +395,4 @@ The pipeline pins the source texts, splits by document, learns the stories token
|
|
| 393 |
- Train the pilot, publish throughput and establish feasibility on the local GPU.
|
| 394 |
- Complete controls, development selection, paired confirmations and a reproducible report.
|
| 395 |
- [ ] Test whether adding the third-derivative penalty late in Hessian-trace training helps the model stay in a wider low-loss region. [Exploratory plan and rationale](reports/plan.md#late-third-derivative-regularization)
|
|
|
|
|
|
| 12 |
|
| 13 |
**Why add the third-derivative penalty late?** Even a steep valley can have constant curvature. The proposed TinyStories follow-up would first train with the Hessian-trace penalty to favor low average curvature. At a prespecified token count, it would keep the trace active and gradually add the third-derivative penalty. If the weights have reached a flat region where curvature changes faster toward the edge, the new penalty rises as the weights move outward. Its gradient can then oppose that movement. Delaying the penalty also avoids early fourth-derivative computations. If this schedule helps retain a wider region, later checkpoints should tolerate larger weight perturbations than trace-only controls at the same allowed increase in unregularized next-token loss. [Timing controls and width measurement](reports/plan.md#late-third-derivative-regularization)
|
| 14 |
|
| 15 |
+
**Should the penalty get stronger as curvature falls?** A second proposal would keep the trace active and turn up the **weight on the squared third derivatives** once training loss is low and recent Hessian measurements are small. The idea is to preserve low curvature once reached. Keeping the highest weight reached, up to a cap, would sustain that pressure if the model starts drifting toward a steeper edge. Direct division can act in the opposite direction. For $L(w)=w^4$, the squared ratio $(L'''/L'')^2=4/w^2$ grows without bound as the weights approach the flat bottom. [Derivation](docs/third-derivative-penalty.md#weighting-the-penalty-by-curvature) · [Proposed comparison with a fixed start](reports/plan.md#curvature-dependent-penalty-weight)
|
| 16 |
+
|
| 17 |
## Can the penalty favor a wider minimum?
|
| 18 |
|
| 19 |
A minimum is **wide** if the weights can move a long way before the loss rises by a chosen amount. [Basin width, Definition 1](https://proceedings.mlr.press/v70/dinh17b/dinh17b.pdf#page=2)
|
|
|
|
| 395 |
- Train the pilot, publish throughput and establish feasibility on the local GPU.
|
| 396 |
- Complete controls, development selection, paired confirmations and a reproducible report.
|
| 397 |
- [ ] Test whether adding the third-derivative penalty late in Hessian-trace training helps the model stay in a wider low-loss region. [Exploratory plan and rationale](reports/plan.md#late-third-derivative-regularization)
|
| 398 |
+
- [ ] Compare a capped third-derivative penalty weight that rises as measured curvature falls with the fixed-token schedule. Test whether it preserves directional width at comparable training fit and whether it improves held-out token prediction. [Curvature-dependent schedule and controls](reports/plan.md#curvature-dependent-penalty-weight)
|
research/docs/index.html
CHANGED
|
@@ -95,6 +95,7 @@
|
|
| 95 |
<p class="prose">Hochreiter and Schmidhuber proposed that among equally good training fits, flatter minima may generalize better. If weights can be rounded more coarsely and still fit, a good predictor can take fewer bits to describe. Here the test of generalization is how well the model predicts unseen tokens. <a href="https://people.idsia.ch/~juergen/fm/node1.html">Flat Minima (1997) ↗</a></p>
|
| 96 |
<p class="prose">The Hessian describes local loss curvature. On active updates, two independent random sign vectors estimate how quickly that curvature changes for the next-token loss of two text windows. The derivatives cover all TinyStories decoder weights or only Pythia’s trainable attention adapters, including interactions between trainable weights.</p>
|
| 97 |
<p class="prose">When moving away from a flat bottom makes curvature change faster, the third-derivative penalty can pull the weights back. A steep bowl with constant curvature receives zero penalty from this term. Whether the optimizer finds wider minima is a separate question from the measured next-token loss.</p>
|
|
|
|
| 98 |
<img class="architecture" src="figures/penalty-directions.png" alt="Analytic loss curves. Trace and third-derivative penalties push in opposite directions at an asymmetric minimum. They pull displaced weights back in a flat quartic and give zero update in a steep quadratic." loading="lazy">
|
| 99 |
<p class="curve-note">Circles mark the ordinary loss minima. Arrows show downhill directions for each penalty. The vertical scales vary by panel. <a href="https://github.com/BurnyCoder/llm-training-with-penalizing-rapid-changes-of-curvature-of-its-loss-with-derivative-of-hessian/blob/main/docs/third-derivative-penalty.md#when-can-the-penalty-favor-a-wider-minimum">Worked examples and the basin-width bound ↗</a></p>
|
| 100 |
<img class="architecture" src="figures/architecture.png" alt="TinyStories full-weight training and Pythia QKV adaptation feed next-token cross-entropy, a Hessian contraction, a third derivative and the regularized objective." loading="lazy">
|
|
|
|
| 95 |
<p class="prose">Hochreiter and Schmidhuber proposed that among equally good training fits, flatter minima may generalize better. If weights can be rounded more coarsely and still fit, a good predictor can take fewer bits to describe. Here the test of generalization is how well the model predicts unseen tokens. <a href="https://people.idsia.ch/~juergen/fm/node1.html">Flat Minima (1997) ↗</a></p>
|
| 96 |
<p class="prose">The Hessian describes local loss curvature. On active updates, two independent random sign vectors estimate how quickly that curvature changes for the next-token loss of two text windows. The derivatives cover all TinyStories decoder weights or only Pythia’s trainable attention adapters, including interactions between trainable weights.</p>
|
| 97 |
<p class="prose">When moving away from a flat bottom makes curvature change faster, the third-derivative penalty can pull the weights back. A steep bowl with constant curvature receives zero penalty from this term. Whether the optimizer finds wider minima is a separate question from the measured next-token loss.</p>
|
| 98 |
+
<p class="prose">A proposed TinyStories follow-up would keep the trace active and increase the weight on the third-derivative penalty once loss and recent curvature are low. Keeping that weight high could discourage later steps toward an edge where curvature changes rapidly. The experiment would compare the width retained with a fixed late start. <a href="https://github.com/BurnyCoder/llm-training-with-penalizing-rapid-changes-of-curvature-of-its-loss-with-derivative-of-hessian/blob/main/reports/plan.md#curvature-dependent-penalty-weight">Schedule and planned controls ↗</a></p>
|
| 99 |
<img class="architecture" src="figures/penalty-directions.png" alt="Analytic loss curves. Trace and third-derivative penalties push in opposite directions at an asymmetric minimum. They pull displaced weights back in a flat quartic and give zero update in a steep quadratic." loading="lazy">
|
| 100 |
<p class="curve-note">Circles mark the ordinary loss minima. Arrows show downhill directions for each penalty. The vertical scales vary by panel. <a href="https://github.com/BurnyCoder/llm-training-with-penalizing-rapid-changes-of-curvature-of-its-loss-with-derivative-of-hessian/blob/main/docs/third-derivative-penalty.md#when-can-the-penalty-favor-a-wider-minimum">Worked examples and the basin-width bound ↗</a></p>
|
| 101 |
<img class="architecture" src="figures/architecture.png" alt="TinyStories full-weight training and Pythia QKV adaptation feed next-token cross-entropy, a Hessian contraction, a third derivative and the regularized objective." loading="lazy">
|
research/docs/third-derivative-penalty.md
CHANGED
|
@@ -41,6 +41,22 @@ $$
|
|
| 41 |
|
| 42 |
Small initial curvature and slowly changing curvature across the interval together limit the loss increase. The training code samples the third derivative of two-window cross-entropy at the **current weights**. For TinyStories these coordinates include the whole decoder. For research abstracts they include only the trainable low-rank attention factors of Pythia-410M. A width measurement would therefore need a fixed loss tolerance and perturbations in the corresponding stage’s trainable coordinates. The logged penalty estimates describe local curvature change. The preregistered test compares held-out next-token loss across matched seeds at equal training tokens. [Taylor remainder, equation 22](https://link.springer.com/article/10.1007/s10288-023-00541-9) · [Stage definitions](../reports/planned-runs.md) · [Preregistered comparison](../reports/preregistration.md)
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
## What gets differentiated?
|
| 45 |
|
| 46 |
Let $\theta=(\theta_1,\ldots,\theta_d)$ be the $d$ trainable numbers. Let $B$ be the fixed **minibatch**, the training examples whose mean loss is $\ell_B(\theta)$. Write $\partial_i$ for the rate of change as weight $\theta_i$ moves with all other weights held fixed.
|
|
|
|
| 41 |
|
| 42 |
Small initial curvature and slowly changing curvature across the interval together limit the loss increase. The training code samples the third derivative of two-window cross-entropy at the **current weights**. For TinyStories these coordinates include the whole decoder. For research abstracts they include only the trainable low-rank attention factors of Pythia-410M. A width measurement would therefore need a fixed loss tolerance and perturbations in the corresponding stage’s trainable coordinates. The logged penalty estimates describe local curvature change. The preregistered test compares held-out next-token loss across matched seeds at equal training tokens. [Taylor remainder, equation 22](https://link.springer.com/article/10.1007/s10288-023-00541-9) · [Stage definitions](../reports/planned-runs.md) · [Preregistered comparison](../reports/preregistration.md)
|
| 43 |
|
| 44 |
+
### Weighting the penalty by curvature
|
| 45 |
+
|
| 46 |
+
The proposed TinyStories schedule keeps the Hessian-trace penalty active. Its hypothesis is that, after training has reached low loss and small curvature, it is worth penalizing rapid changes in that curvature more strongly. A small Hessian can also occur on a slope. For example, $L(w)=w$ has zero Hessian and unit gradient everywhere. The follow-up therefore records training loss and gradient norm and tests width by perturbing the weights. [Experiment design](../reports/plan.md#curvature-dependent-penalty-weight)
|
| 47 |
+
|
| 48 |
+
Direct division changes the objective. For $L(w)=w^4$, the existing penalty is $(L''')^2=576w^2$. The squared relative change $(L'''/L'')^2=4/w^2$ for $w\ne0$ diverges toward the minimum and is undefined at zero. Descending that ratio pushes a displaced weight outward. In many dimensions $H$ is a matrix and $D H$ is a third-order tensor, so a ratio also requires a choice of norms or contraction. A positive floor prevents division by zero, but a differentiable denominator can still reward increasing the curvature magnitude. [Quartic gradient check](../tests/test_derivatives.py)
|
| 49 |
+
|
| 50 |
+
One testable rule uses the magnitude of the Hessian of unregularized training loss. For $d$ trainable coordinates and an independent random sign vector $v$, $\mathbb E_v\lVert Hv\rVert_2^2=\operatorname{tr}(H^\top H)=\lVert H\rVert_F^2$. This counts curvature of either sign and can be estimated with the project’s existing Hessian-vector probe. Let $c_t$ be the square root of the mean of $\lVert Hv\rVert_2^2/d$ over the last $m$ completed training-only probe measurements before update $t$. This measures typical curvature in fixed weight coordinates. A few sharp directions can coexist with a small average. [Hessian-norm estimator](../src/thirdloss/penalties.py) · [Trace identity](https://arxiv.org/pdf/2010.09649#page=2)
|
| 51 |
+
|
| 52 |
+
After a trace-only warm-up, once the prespecified training-loss criterion is met and the probe window is full, one possible update for the coefficient is
|
| 53 |
+
|
| 54 |
+
$$
|
| 55 |
+
\lambda_{3,t}=\max\!\left(\lambda_{3,t-1},\ \lambda_{\max}\max\!\left(0,1-\frac{c_t}{c_*}\right)\right).
|
| 56 |
+
$$
|
| 57 |
+
|
| 58 |
+
Start at zero, with fixed $c_*>0$ and $\lambda_{\max}>0$. Lower measured curvature can raise the weight up to $\lambda_{\max}$. Retaining the highest value reached keeps the penalty active if curvature rebounds. For the existing squared third-derivative estimate $\widehat P_3$, holding the coefficient fixed during differentiation gives $\nabla_\theta(\lambda_{3,t}\widehat P_3)=\lambda_{3,t}\nabla_\theta\widehat P_3$. The usual sampled-update scaling still applies. If the estimate increases toward the edge, this penalty gradient can oppose an outward step. [Study objective and gradient](#the-actual-training-update) · [Proposed controls](../reports/plan.md#curvature-dependent-penalty-weight)
|
| 59 |
+
|
| 60 |
## What gets differentiated?
|
| 61 |
|
| 62 |
Let $\theta=(\theta_1,\ldots,\theta_d)$ be the $d$ trainable numbers. Let $B$ be the fixed **minibatch**, the training examples whose mean loss is $\ell_B(\theta)$. Write $\partial_i$ for the rate of change as weight $\theta_i$ moves with all other weights held fixed.
|
research/reports/literature-review.md
CHANGED
|
@@ -14,6 +14,7 @@
|
|
| 14 |
| [Chattopadhyay et al., equation 10](https://arxiv.org/pdf/1710.11063#page=4) · [Grad-CAM++ implementation](https://github.com/adityac94/Grad_CAM_plus_plus) | A prediction explanation weights convolutional features using diagonal second and third derivatives of a differentiable class score with respect to each feature activation. | The differentiation coordinates, scalar objective and use of cross-partials distinguish the parameter-space training penalty from this image explanation method. |
|
| 15 |
| [Liu et al., ICML 2023](https://proceedings.mlr.press/v202/liu23ao.html) | Language-model runs can have similar pretraining losses and different downstream behavior. | Limit the main claim to within-domain next-token prediction. |
|
| 16 |
| [Dinh et al.](https://proceedings.mlr.press/v70/dinh17b.html) | Reparameterization can alter local geometry while preserving the predictor. | Interpret geometry in the fixed training coordinates. Compare methods within each model stage. |
|
|
|
|
| 17 |
| [Eldan and Li](https://arxiv.org/pdf/2305.07759) | Synthetic English stories allow small causal models to exhibit meaningful language behavior. | Use full-weight pretraining with fixed-prompt, uncurated continuations. |
|
| 18 |
| [Pythia](https://arxiv.org/pdf/2304.01373), [LoRA](https://arxiv.org/pdf/2106.09685), [Common Pile](https://huggingface.co/datasets/common-pile/arxiv_abstracts_filtered) | An open pretrained decoder, low-rank adaptation and a dated abstracts collection support a second-domain experiment. | Restrict derivatives to the trained QKV adapters. Use first-submission months after the Pythia release. |
|
| 19 |
| [Bouthillier et al.](https://proceedings.mlsys.org/paper_files/paper/2021/hash/0184b0cd3cfb185989f858a1d9f5c1eb-Abstract.html), [Lones](https://arxiv.org/abs/2108.02497), [NeurIPS checklist](https://neurips.cc/public/guides/PaperChecklist) | Evaluation needs explicit variability, data isolation, reporting and reproducibility. | Pair seeds, fix the estimand and tuning budget, and report individual runs and both comparisons. |
|
|
|
|
| 14 |
| [Chattopadhyay et al., equation 10](https://arxiv.org/pdf/1710.11063#page=4) · [Grad-CAM++ implementation](https://github.com/adityac94/Grad_CAM_plus_plus) | A prediction explanation weights convolutional features using diagonal second and third derivatives of a differentiable class score with respect to each feature activation. | The differentiation coordinates, scalar objective and use of cross-partials distinguish the parameter-space training penalty from this image explanation method. |
|
| 15 |
| [Liu et al., ICML 2023](https://proceedings.mlr.press/v202/liu23ao.html) | Language-model runs can have similar pretraining losses and different downstream behavior. | Limit the main claim to within-domain next-token prediction. |
|
| 16 |
| [Dinh et al.](https://proceedings.mlr.press/v70/dinh17b.html) | Reparameterization can alter local geometry while preserving the predictor. | Interpret geometry in the fixed training coordinates. Compare methods within each model stage. |
|
| 17 |
+
| [Jiang et al., §3.2](https://arxiv.org/pdf/2304.14647#page=4) | Their adaptive policy uses the squared minibatch gradient norm and its recent history to select sharpness-aware or ordinary updates. | This is a precedent for choosing when to apply a regularizer. The proposed TinyStories follow-up would test whether a Hessian-based coefficient adds value over fixed timing. [Planned comparison](plan.md#curvature-dependent-penalty-weight) |
|
| 18 |
| [Eldan and Li](https://arxiv.org/pdf/2305.07759) | Synthetic English stories allow small causal models to exhibit meaningful language behavior. | Use full-weight pretraining with fixed-prompt, uncurated continuations. |
|
| 19 |
| [Pythia](https://arxiv.org/pdf/2304.01373), [LoRA](https://arxiv.org/pdf/2106.09685), [Common Pile](https://huggingface.co/datasets/common-pile/arxiv_abstracts_filtered) | An open pretrained decoder, low-rank adaptation and a dated abstracts collection support a second-domain experiment. | Restrict derivatives to the trained QKV adapters. Use first-submission months after the Pythia release. |
|
| 20 |
| [Bouthillier et al.](https://proceedings.mlsys.org/paper_files/paper/2021/hash/0184b0cd3cfb185989f858a1d9f5c1eb-Abstract.html), [Lones](https://arxiv.org/abs/2108.02497), [NeurIPS checklist](https://neurips.cc/public/guides/PaperChecklist) | Evaluation needs explicit variability, data isolation, reporting and reproducibility. | Pair seeds, fix the estimand and tuning budget, and report individual runs and both comparisons. |
|
research/reports/paper.pdf
CHANGED
|
Binary files a/research/reports/paper.pdf and b/research/reports/paper.pdf differ
|
|
|
research/reports/plan.md
CHANGED
|
@@ -18,8 +18,18 @@ The dated progress record gives completed milestones and outstanding work. Sourc
|
|
| 18 |
|
| 19 |
- [ ] Preregister a TinyStories follow-up. Train first with next-token loss plus the signed Hessian trace. At a prespecified token count, keep the trace active and gradually increase the coefficient of the existing squared third-derivative penalty. Specify the ramp and its final strength before comparing runs. [Current run matrix](planned-runs.md)
|
| 20 |
|
|
|
|
|
|
|
| 21 |
**Rationale.** Near a smooth minimum, the trace favors low average curvature. If curvature starts changing faster as weights move toward the edge of a flat region, the third-derivative penalty grows and its gradient can oppose that movement. Delaying the penalty gives the trace time to act and saves the early fourth-derivative computations. A stronger trace alone could explain any benefit. For $L(w)=w^4$, the two penalties are proportional and can produce exactly the same pull. In a related CIFAR-10 experiment, switching from SGD to sharpness-aware minimization late gave nearly the same test error as using it throughout. [Worked examples](../docs/third-derivative-penalty.md#when-can-the-penalty-favor-a-wider-minimum) · [Zhou et al., Figure 1](https://proceedings.iclr.cc/paper_files/paper/2025/file/35d5ad984cc0ddd84c6f1c177a2066e5-Paper-Conference.pdf#page=2)
|
| 22 |
|
| 23 |
**Comparisons.** For each seed, branch from the same trace-trained weights and AdamW state. Continue with trace alone, increase trace alone, or add the third-derivative term. Use the same ramp for both increases. On training batches, match the norm of the extra trace gradient to that of the added penalty gradient before clipping. Compare timing against a fourth run using both penalties from the start. Match initialization, data order and training tokens across runs.
|
| 24 |
|
| 25 |
**Readouts.** At the switch and at prespecified later checkpoints, perturb the weights both ways along fixed unit vectors. Measure the width between the first points where unregularized next-token loss on fixed training examples rises by a prespecified amount. For each seed, compare the change in median width between arms. If stronger trace preserves as much width, the result weakens the case for a distinct third-derivative effect. Compare held-out development loss at equal tokens. A width gain accompanied by lower development loss at comparable training fit would be consistent with the flat-minima hypothesis. A width gain alone would support only the geometric prediction. [Width definition](../docs/third-derivative-penalty.md#from-a-local-penalty-to-basin-width)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
- [ ] Preregister a TinyStories follow-up. Train first with next-token loss plus the signed Hessian trace. At a prespecified token count, keep the trace active and gradually increase the coefficient of the existing squared third-derivative penalty. Specify the ramp and its final strength before comparing runs. [Current run matrix](planned-runs.md)
|
| 20 |
|
| 21 |
+
One candidate is a linear ramp. If $n_t$ is the number of training tokens before update $t$, $n_0$ is the switch and $R>0$ is the ramp length in tokens, set $s_t=\min(1,\max(0,(n_t-n_0)/R))$ and $\lambda_{3,t}=\lambda_{\max}s_t$. Use the same cap for the curvature-dependent comparison. [Objective, schedules and width equations in the paper’s final appendix](paper.pdf)
|
| 22 |
+
|
| 23 |
**Rationale.** Near a smooth minimum, the trace favors low average curvature. If curvature starts changing faster as weights move toward the edge of a flat region, the third-derivative penalty grows and its gradient can oppose that movement. Delaying the penalty gives the trace time to act and saves the early fourth-derivative computations. A stronger trace alone could explain any benefit. For $L(w)=w^4$, the two penalties are proportional and can produce exactly the same pull. In a related CIFAR-10 experiment, switching from SGD to sharpness-aware minimization late gave nearly the same test error as using it throughout. [Worked examples](../docs/third-derivative-penalty.md#when-can-the-penalty-favor-a-wider-minimum) · [Zhou et al., Figure 1](https://proceedings.iclr.cc/paper_files/paper/2025/file/35d5ad984cc0ddd84c6f1c177a2066e5-Paper-Conference.pdf#page=2)
|
| 24 |
|
| 25 |
**Comparisons.** For each seed, branch from the same trace-trained weights and AdamW state. Continue with trace alone, increase trace alone, or add the third-derivative term. Use the same ramp for both increases. On training batches, match the norm of the extra trace gradient to that of the added penalty gradient before clipping. Compare timing against a fourth run using both penalties from the start. Match initialization, data order and training tokens across runs.
|
| 26 |
|
| 27 |
**Readouts.** At the switch and at prespecified later checkpoints, perturb the weights both ways along fixed unit vectors. Measure the width between the first points where unregularized next-token loss on fixed training examples rises by a prespecified amount. For each seed, compare the change in median width between arms. If stronger trace preserves as much width, the result weakens the case for a distinct third-derivative effect. Compare held-out development loss at equal tokens. A width gain accompanied by lower development loss at comparable training fit would be consistent with the flat-minima hypothesis. A width gain alone would support only the geometric prediction. [Width definition](../docs/third-derivative-penalty.md#from-a-local-penalty-to-basin-width)
|
| 28 |
+
|
| 29 |
+
### Curvature-dependent penalty weight
|
| 30 |
+
|
| 31 |
+
- [ ] Preregister an alternative to the fixed-token switch. For each seed, branch from the same trace-trained weights and AdamW state before either schedule can activate. Keep trace regularization active. After a trace-only warm-up and a prespecified low training loss, increase the weight on the squared third derivatives as a rolling estimate of Hessian magnitude falls. Cap the weight and retain the greatest value reached so that drifting toward higher curvature cannot turn the penalty down. An outward step that increases curvature variation would then still carry a cost. [Coefficient rule and quartic counterexample](../docs/third-derivative-penalty.md#weighting-the-penalty-by-curvature)
|
| 32 |
+
|
| 33 |
+
**Measurement.** Use past training-only Hessian-vector probes to estimate root-mean-square curvature in the TinyStories weight coordinates. Signed trace can be small when positive and negative eigenvalues cancel. Freeze the warm-up, loss criterion, probe interval, averaging window, curvature threshold and coefficient cap before comparing runs. Treat the coefficient as constant during each gradient update. Record the coefficient, curvature, training loss and gradient norm, including seeds where the coefficient stays zero. [Existing probe](../src/thirdloss/penalties.py)
|
| 34 |
+
|
| 35 |
+
**Test of the rationale.** Compare against trace alone, stronger trace and the fixed-token schedule at equal training tokens with the same monitoring budget. To test whether adapting to each run matters, replay the adaptive coefficient histories across seeds using a permutation fixed in advance. This preserves the set of coefficient histories while breaking their link to the receiving run's curvature. The geometric prediction is better retention of median directional width from the shared checkpoint at comparable training fit. Equal or narrower widths than the fixed or replayed schedules weaken that claim. Evaluate held-out development NLL separately for predictive benefit. [Width and timing comparisons](#late-third-derivative-regularization)
|
research/reports/planned-runs.md
CHANGED
|
@@ -15,3 +15,7 @@ AdamW peaks at 0.0003 for stories and 0.0001 for adapters, with betas 0.9 and 0.
|
|
| 15 |
| Confirmation | 1–8 | Ordinary, signed trace, and third order at the selected strength, each at the full stage horizon. |
|
| 16 |
|
| 17 |
Evaluate seed-paired final test predictions only when the stage has all planned confirmatory checkpoints. Preserve every development candidate. The one-week allocation prioritizes the two registered stages and their controls. The first 14 hours target a real one-seed pilot with its untrained controls. [Protocol](preregistration.md)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
| Confirmation | 1–8 | Ordinary, signed trace, and third order at the selected strength, each at the full stage horizon. |
|
| 16 |
|
| 17 |
Evaluate seed-paired final test predictions only when the stage has all planned confirmatory checkpoints. Preserve every development candidate. The one-week allocation prioritizes the two registered stages and their controls. The first 14 hours target a real one-seed pilot with its untrained controls. [Protocol](preregistration.md)
|
| 18 |
+
|
| 19 |
+
## Proposed follow-up
|
| 20 |
+
|
| 21 |
+
A future TinyStories comparison would keep the trace active and compare adding the third-derivative penalty at a fixed token count with increasing its coefficient as measured curvature falls. The research plan gives the rationale, controls and proposed width measurement for a separate preregistration. [Follow-up design](plan.md#curvature-dependent-penalty-weight)
|
research/src/thirdloss/report_paper.py
CHANGED
|
@@ -320,6 +320,14 @@ def write_paper(study: dict, output: Path, figure_dir: Path, figures: dict) -> N
|
|
| 320 |
"two tokenization schemes bound the interpretation. More tokens per GPU hour can change "
|
| 321 |
"the practical ranking. "
|
| 322 |
f"{_cite('coordinates')} · {_link(REPOSITORY + '/blob/main/reports/preregistration.md', 'Scope of inference')}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 323 |
p("Conclusion", "heading")
|
| 324 |
if all(outcome.get("complete") for outcome in study["stages"].values()):
|
| 325 |
confirmed = [STAGES[s] for s, outcome in study["stages"].items() if outcome.get("success")]
|
|
@@ -404,6 +412,43 @@ def write_paper(study: dict, output: Path, figure_dir: Path, figures: dict) -> N
|
|
| 404 |
p(_link(url, title), "caption")
|
| 405 |
p(f"Rebuild tables, figures, the explorer and this paper with <b>uv run thirdloss report</b>. "
|
| 406 |
f"{_link(REPOSITORY, 'Code and versioned protocol')}", "caption")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 407 |
p("AI statement", "subheading")
|
| 408 |
p("Codex wrote the codebase and paper from the exact specification provided by a human. "
|
| 409 |
"Human cleanup and rewriting are in progress.", "caption")
|
|
|
|
| 320 |
"two tokenization schemes bound the interpretation. More tokens per GPU hour can change "
|
| 321 |
"the practical ranking. "
|
| 322 |
f"{_cite('coordinates')} · {_link(REPOSITORY + '/blob/main/reports/preregistration.md', 'Scope of inference')}")
|
| 323 |
+
p("Proposed curvature-dependent schedule", "subheading")
|
| 324 |
+
p("A TinyStories follow-up would keep the trace active and increase the weight on squared third "
|
| 325 |
+
"derivatives once training loss and measured curvature are low. Retaining the highest weight reached "
|
| 326 |
+
"could oppose later drift if curvature changes faster at the edge. Direct division can reverse "
|
| 327 |
+
"the incentive. For the quartic loss above, the squared ratio of third to second derivative "
|
| 328 |
+
"is 4/w<super>2</super> away from zero and grows toward the flat bottom. The final appendix "
|
| 329 |
+
"specifies both schedules and the proposed width test. "
|
| 330 |
+
f"{_link(REPOSITORY + '/blob/main/reports/plan.md#curvature-dependent-penalty-weight', 'Follow-up design')}")
|
| 331 |
p("Conclusion", "heading")
|
| 332 |
if all(outcome.get("complete") for outcome in study["stages"].values()):
|
| 333 |
confirmed = [STAGES[s] for s, outcome in study["stages"].items() if outcome.get("success")]
|
|
|
|
| 412 |
p(_link(url, title), "caption")
|
| 413 |
p(f"Rebuild tables, figures, the explorer and this paper with <b>uv run thirdloss report</b>. "
|
| 414 |
f"{_link(REPOSITORY, 'Code and versioned protocol')}", "caption")
|
| 415 |
+
flow.append(PageBreak())
|
| 416 |
+
p("Appendix · Proposed TinyStories schedules", "heading")
|
| 417 |
+
p("The follow-up asks whether changing the third-derivative coefficient in response to low curvature "
|
| 418 |
+
"helps retain a wider low-loss neighborhood. The equations below specify candidate arms for a "
|
| 419 |
+
"separate preregistration.")
|
| 420 |
+
p("Shared training objective", "subheading")
|
| 421 |
+
p("J<sub>t</sub> = L<sub>t</sub> + (I<sub>t</sub>/p) [α<sub>t</sub> h<sub>t</sub> + λ<sub>t</sub> P<sub>3,t</sub>]", "equation")
|
| 422 |
+
p("h<sub>t</sub> = a<super>T</super>H<sub>t</sub>a, "
|
| 423 |
+
"P<sub>3,t</sub> = ‖T<sub>t</sub>[u, v, ·]‖²", "equation")
|
| 424 |
+
p("L<sub>t</sub> is the full update’s next-token loss. H<sub>t</sub> and T<sub>t</sub> are the Hessian "
|
| 425 |
+
"and third derivative of the unregularized two-window loss in the trainable weights. The trace probe "
|
| 426 |
+
"a and the two independent third-derivative probes u, v have random sign entries. I<sub>t</sub> is "
|
| 427 |
+
"the Bernoulli gate with activation probability p = 1/8. Both coefficients are held fixed in each weight update.")
|
| 428 |
+
p("Fixed-token ramp and controls", "subheading")
|
| 429 |
+
p("s<sub>t</sub> = min(1, max(0, (n<sub>t</sub> − n<sub>0</sub>)/R)), "
|
| 430 |
+
"λ<sub>t</sub> = λ<sub>max</sub> s<sub>t</sub>", "equation")
|
| 431 |
+
p("Here n<sub>t</sub> counts training targets before update t, n<sub>0</sub> is the switch point, "
|
| 432 |
+
"and R is the positive ramp length in tokens. The trace coefficient stays at α. Trace alone sets "
|
| 433 |
+
"λ<sub>t</sub> = 0. Stronger trace sets λ<sub>t</sub> = 0 and α<sub>t</sub> = α + Δα s<sub>t</sub>, "
|
| 434 |
+
"with Δα calibrated to the added penalty-gradient norm. The always-on comparison sets "
|
| 435 |
+
"λ<sub>t</sub> = λ<sub>max</sub> from the start.")
|
| 436 |
+
p("Curvature-dependent coefficient", "subheading")
|
| 437 |
+
p("c<sub>t</sub> = [(1/(md)) ∑<sub>j∈S(t)</sub> ‖H<sub>j</sub>z<sub>j</sub>‖²]<super>1/2</super>", "equation")
|
| 438 |
+
p("λ<sub>t</sub> = max(λ<sub>t−1</sub>, λ<sub>max</sub> max(0, 1 − c<sub>t</sub>/c<sub>*</sub>))", "equation")
|
| 439 |
+
p("S(t) contains the last m training-only measurements before the update. Each z<sub>j</sub> is a random "
|
| 440 |
+
"sign probe and d is the number of trainable weights. Start λ at zero. Enable this rule after warm-up "
|
| 441 |
+
"once the loss criterion is met and the window is full. Below the fixed positive threshold c<sub>*</sub>, "
|
| 442 |
+
"smaller curvature can raise λ up to λ<sub>max</sub>. Retaining the peak keeps the penalty active "
|
| 443 |
+
"when curvature rebounds. A control replays other seeds’ coefficient histories in a prespecified permutation.")
|
| 444 |
+
p("Directional width", "subheading")
|
| 445 |
+
p("r<sub>±</sub>(θ, e) = inf { r > 0 | L<sub>probe</sub>(θ ± re) − L<sub>probe</sub>(θ) ≥ δ }", "equation")
|
| 446 |
+
p("W<sub>δ</sub>(θ) = median<sub>e</sub> [r<sub>+</sub>(θ, e) + r<sub>−</sub>(θ, e)]", "equation")
|
| 447 |
+
p("Use fixed unit directions e, fixed training examples, unregularized loss L<sub>probe</sub>, and a "
|
| 448 |
+
"positive loss tolerance δ. Compare changes in W<sub>δ</sub> from a common trace-trained checkpoint "
|
| 449 |
+
"at matched token counts. Held-out development loss tests prediction separately. "
|
| 450 |
+
f"{_link(REPOSITORY + '/blob/main/docs/third-derivative-penalty.md#weighting-the-penalty-by-curvature', 'Derivation')} · "
|
| 451 |
+
f"{_link(REPOSITORY + '/blob/main/reports/plan.md#curvature-dependent-penalty-weight', 'Controls and readouts')}")
|
| 452 |
p("AI statement", "subheading")
|
| 453 |
p("Codex wrote the codebase and paper from the exact specification provided by a human. "
|
| 454 |
"Human cleanup and rewriting are in progress.", "caption")
|
research/tests/test_reporting.py
CHANGED
|
@@ -52,3 +52,7 @@ def test_report_before_first_run_keeps_readme_and_emits_protocol_paper(tmp_path)
|
|
| 52 |
assert "AI statement" in text
|
| 53 |
assert "Awaiting paired test results" in text
|
| 54 |
assert "Libor" in text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
assert "AI statement" in text
|
| 53 |
assert "Awaiting paired test results" in text
|
| 54 |
assert "Libor" in text
|
| 55 |
+
# Check that the PDF font preserves the symbols in the proposed schedule and width test.
|
| 56 |
+
appendix = " ".join(reader.pages[-1].extract_text().split())
|
| 57 |
+
assert "λt = max(λt−1, λmax max(0, 1 − ct/c*))" in appendix
|
| 58 |
+
assert "Lprobe(θ ± re) − Lprobe(θ) ≥ δ" in appendix
|