|
| 1 | +# ECS Probe-Loss TraceWall |
| 2 | + |
| 3 | +This folder contains an independent optimizer experiment for the standard |
| 4 | +MNIST MLP3 model. It does **not** modify the existing trace-log, adaptive |
| 5 | +spectral guard, spectral-flow projector, or local-delta WW-PGD implementations. |
| 6 | + |
| 7 | +The method replaces the previous objective of suppressing flow toward a |
| 8 | +putative trivial fixed point with a directly testable task objective measured |
| 9 | +on a rotating subset of the **training** data. |
| 10 | + |
| 11 | +## Definition |
| 12 | + |
| 13 | +For every selected matrix after a completed base-optimizer step, compute |
| 14 | + |
| 15 | +\[ |
| 16 | +W = U\Sigma V^\top, |
| 17 | +\qquad |
| 18 | +W_{\mathrm{ECS}} = U_m\Sigma_m V_m^\top, |
| 19 | +\] |
| 20 | + |
| 21 | +where the retained rank \(m\) is the current bulk-effective, |
| 22 | +self-consistent trace-log ECS. All selected matrices are truncated |
| 23 | +simultaneously. On a rotating training probe subset \(B_t\), the optimizer |
| 24 | +measures |
| 25 | + |
| 26 | +\[ |
| 27 | +\mathcal L_{\mathrm{probe}}(t) |
| 28 | += |
| 29 | +\frac{1}{|B_t|} |
| 30 | +\sum_{(x,y)\in B_t} |
| 31 | +\ell\!\left(f_{W_{\mathrm{ECS}}}(x),y\right). |
| 32 | +\] |
| 33 | + |
| 34 | +It differentiates this loss at the truncated model, projects each matrix |
| 35 | +gradient into the same retained singular subspaces, |
| 36 | + |
| 37 | +\[ |
| 38 | +G_{\mathrm{ECS}} |
| 39 | += |
| 40 | +(U_mU_m^\top)\,G\,(V_mV_m^\top), |
| 41 | +\] |
| 42 | + |
| 43 | +and proposes a negative-gradient component. The completed update is |
| 44 | + |
| 45 | +\[ |
| 46 | +W_{t+1} |
| 47 | += |
| 48 | +W^{\mathrm{base}}_{t+1} |
| 49 | ++ |
| 50 | +a_t\,\Delta W_{\mathrm{probe,ECS}}, |
| 51 | +\] |
| 52 | + |
| 53 | +where \(a_t\) is selected by Armijo backtracking on the same ECS-truncated |
| 54 | +probe objective. A correction is committed only when it lowers that objective. |
| 55 | +The ECS SVD and rank are recomputed at every correction, so the task-loss |
| 56 | +channel follows the ECS if its support contracts or expands during training. |
| 57 | + |
| 58 | +The default projection is the strict ECS core shown above. A rank-\(m\) |
| 59 | +manifold tangent projection is available as an explicit ablation. |
| 60 | + |
| 61 | +## Rotating probe protocol |
| 62 | + |
| 63 | +- The probe is drawn only from the MNIST training set. |
| 64 | +- The official MNIST test set is used only for reporting test loss and accuracy. |
| 65 | +- Probe selection uses an independent seeded random permutation. |
| 66 | +- New slices are consumed without replacement; after a complete pass, a new |
| 67 | + permutation is generated. |
| 68 | +- A draw that crosses a permutation boundary is still unique within that draw. |
| 69 | +- The primary notebooks use 512 examples per correction (two batches of 256) |
| 70 | + and one correction at each epoch boundary. |
| 71 | + |
| 72 | +This avoids tuning directly on the official test set while approximating the |
| 73 | +expected loss of a changing random training probe. |
| 74 | + |
| 75 | +## Paired experiment |
| 76 | + |
| 77 | +Both notebooks train a clean baseline and a TraceWall arm in the same run. |
| 78 | +For every seed, the two arms: |
| 79 | + |
| 80 | +- start from byte-identical weights; |
| 81 | +- receive the same minibatches in the same order; |
| 82 | +- use the same gradient clipping; |
| 83 | +- use the same optimizer hyperparameters; |
| 84 | +- use the same one-epoch linear warmup and cosine decay to 5% of the peak |
| 85 | + learning rate. |
| 86 | + |
| 87 | +Only the TraceWall arm receives the post-step ECS probe-loss component. |
| 88 | + |
| 89 | +Repository-standard peak settings are retained: |
| 90 | + |
| 91 | +- AdamW: learning rate `1e-3`, betas `(0.9, 0.999)`, epsilon `1e-8`, weight |
| 92 | + decay `1e-2`; |
| 93 | +- SGD with classical momentum: learning rate `5e-2`, momentum `0.9`, zero |
| 94 | + dampening, no Nesterov, weight decay `1e-4`. |
| 95 | + |
| 96 | +The MLP is `784 -> 512 -> 512 -> 10` with ReLU activations and no dropout or |
| 97 | +batch normalization. Each notebook runs three independent seeds for 20 epochs |
| 98 | +and reports two-sided 95% Student-t confidence intervals across complete runs. |
| 99 | + |
| 100 | +## Notebooks |
| 101 | + |
| 102 | +- `notebooks/MNIST_MLP3_AdamW_vs_ECS_Probe_Loss_TraceWall.ipynb` |
| 103 | +- `notebooks/MNIST_MLP3_SGD_Momentum_vs_ECS_Probe_Loss_TraceWall.ipynb` |
| 104 | + |
| 105 | +Each notebook records and saves: |
| 106 | + |
| 107 | +- full train/test cross-entropy, accuracy, and classification perplexity; |
| 108 | +- learning rate, parameter norm, and epoch timing; |
| 109 | +- self-consistent ECS rank, trace-log residual, adaptive normalization, |
| 110 | + retained energy, stable rank, and participation ratio; |
| 111 | +- WeightWatcher alpha, `detX_num`, `num_pl_spikes`, and `ERG_gap`; |
| 112 | +- every probe loss before/after correction; |
| 113 | +- line-search scale, acceptance, correction norms, ECS ranks, and numerical |
| 114 | + projection audits; |
| 115 | +- baseline and TraceWall checkpoints after every epoch. |
| 116 | + |
| 117 | +By default outputs are written beneath `runs/`. Set |
| 118 | +`RG_TRACE_WALL_RUN_ROOT` and `RG_TRACE_WALL_DATA_DIR` to redirect experiment |
| 119 | +artifacts and the MNIST cache. |
| 120 | + |
| 121 | +## Tests |
| 122 | + |
| 123 | +From this folder: |
| 124 | + |
| 125 | +```bash |
| 126 | +python -m unittest discover -s tests -v |
| 127 | +``` |
| 128 | + |
| 129 | +The tests cover scale-invariant ECS selection, SVD truncation, ECS projection, |
| 130 | +rotating-probe uniqueness and checkpoint restoration, optimizer loss descent, |
| 131 | +warmup/cosine scheduling, a paired synthetic end-to-end run, plotting, and |
| 132 | +notebook validity. |
0 commit comments