@@ -4,23 +4,50 @@ This folder contains **unmodified optimizer baselines** for the RG-optimizer
44experiments. No trace-log projection, self-consistent ECS correction, WW-PGD
55retraction, spectral-flow subtraction, or other RG intervention is applied.
66
7- The three notebooks are:
7+ The notebooks are:
88
991 . ` notebooks/MNIST_MLP3_SGD_Momentum_Baseline.ipynb `
10102 . ` notebooks/MNIST_MLP3_AdamW_Baseline.ipynb `
11113 . ` notebooks/MNIST_MLP3_SGD_Momentum_Muon_Baseline.ipynb `
12+ 4 . ` notebooks/MNIST_MLP3_Baseline_Comparison.ipynb `
1213
13- All runs use the same architecture and preprocessing:
14+ Run the first three notebooks to produce the persisted optimizer results, then
15+ run the fourth notebook to validate and compare all three experiments.
16+
17+ All training runs use the same architecture and preprocessing:
1418
1519``` text
1620784 -> 512 -> 512 -> 10
1721ReLU after fc1 and fc2
1822MNIST normalized by mean 0.1307 and std 0.3081
1923```
2024
25+ ## Shared persistent run directory
26+
27+ All four notebooks resolve the same run root:
28+
29+ ``` text
30+ RG_BASELINE_RUN_ROOT, when set
31+ otherwise: baseline/runs/
32+ ```
33+
34+ For a clone at ` /tmp/rg_optimizers ` , the default is therefore
35+ ` /tmp/rg_optimizers/baseline/runs ` . A different shared local directory can be
36+ selected before starting Jupyter:
37+
38+ ``` bash
39+ export RG_BASELINE_RUN_ROOT=/tmp/rg_optimizers_baseline_runs
40+ ```
41+
42+ The MNIST download/cache directory can likewise be overridden with
43+ ` RG_BASELINE_DATA_DIR ` ; its default remains ` baseline/data/ ` .
44+
45+ The comparison notebook reads only persisted files. It does not depend on a
46+ live ` suite ` variable or on running all notebooks in one kernel.
47+
2148## Independent replicates and error bars
2249
23- Each notebook now runs three independent complete training trajectories:
50+ Each optimizer notebook runs three independent complete training trajectories:
2451
2552``` python
2653SEEDS = (1337 , 2027 , 31415 )
@@ -44,18 +71,15 @@ confidence band, and capped error bars. Summary CSV files record `n`, sample
4471standard deviation, standard error, Student-t critical value, interval
4572half-width, lower/upper bounds, minimum, and maximum.
4673
47- The color convention is fixed across all three notebooks:
74+ The single-optimizer notebooks keep a fixed train/test and layer color scheme.
75+ The comparison notebook uses a fixed color-blind-safe optimizer mapping:
4876
4977``` text
50- train blue
51- test vermillion
52- FC1 blue
53- FC2 orange
54- FC3 green
78+ SGD + momentum blue
79+ AdamW vermillion
80+ SGD + momentum + Muon bluish green
5581```
5682
57- This prevents colors from changing meaning between optimizers or figures.
58-
5983## Baseline definitions
6084
6185### SGD + momentum
@@ -150,47 +174,104 @@ $$
150174gap, incomplete epoch/layer, or inconsistent midpoint rather than substituting
151175a silent fallback.
152176
153- ## Required aggregate plots
177+ ## Checkpoint and result persistence
154178
155- Every notebook creates and saves, with individual seed traces and 95% confidence
156- intervals:
179+ Every optimizer notebook sets ` save_epoch_checkpoints=True ` . Each seed folder
180+ therefore contains both a final state and one complete model/optimizer state
181+ after every training epoch:
157182
158- 0 . full train/test loss and full train/test accuracy;
159- 0b. a dedicated test-accuracy figure;
160- 1 . layerwise WeightWatcher ` alpha ` ;
161- 2 . original WeightWatcher ` detX_num ` , ` num_pl_spikes ` , and full-` M ` ` ERG_gap ` ;
162- 3 . original midpoint retained rank, midpoint trace-log per eigenvalue, and
163- midpoint trace-log total;
164- 4 . effective-rank and retained-energy diagnostics;
165- 5 . gradient, parameter-norm, and timing diagnostics;
166- 6 . spectral scale, midpoint geometric mean, and ESD conditioning.
183+ ``` text
184+ runs/<optimizer>/
185+ performance_by_epoch_and_seed.csv
186+ spectral_metrics_by_epoch_layer_and_seed.csv
187+ weightwatcher_details_by_epoch_and_seed.csv
188+ optimizer_groups_by_epoch_and_seed.csv
189+ combined_metrics_by_epoch_layer_and_seed.csv
190+ performance_summary_95ci.csv
191+ spectral_summary_95ci.csv
192+ replicate_manifest.json
193+ plots/
194+ seeds/
195+ seed_1337/
196+ performance_by_epoch.csv
197+ spectral_metrics_by_epoch_and_layer.csv
198+ weightwatcher_details_by_epoch.csv
199+ optimizer_groups_by_epoch.csv
200+ combined_metrics_by_epoch_and_layer.csv
201+ esd_history.npz
202+ config.json
203+ final_state.pt
204+ checkpoints/
205+ epoch_001.pt
206+ ...
207+ epoch_020.pt
208+ seed_2027/
209+ seed_31415/
210+ ```
211+
212+ Each training notebook fails at the end if any aggregate result, final state,
213+ or requested epoch checkpoint is missing.
214+
215+ ## Three-optimizer comparison
216+
217+ ` MNIST_MLP3_Baseline_Comparison.ipynb ` validates that all three optimizers have:
218+
219+ - identical seed tuples;
220+ - identical epoch grids and shared data/evaluation/WeightWatcher settings;
221+ - complete FC1/FC2/FC3 spectral measurements;
222+ - ` final_state.pt ` for every seed;
223+ - all 20 epoch checkpoints for every seed.
167224
168- ## Output layout
225+ It then produces:
169226
170- Each notebook writes to ` baseline/runs/<optimizer>/ ` :
227+ - mean and 95% confidence-interval trajectories for train/test accuracy,
228+ train/test loss, classification perplexity, and generalization gaps;
229+ - layerwise comparisons of ` alpha ` , ` detX_num ` , ` num_pl_spikes ` , ` ERG_gap ` ,
230+ midpoint retained rank, midpoint trace-log, and stable rank;
231+ - final-epoch metric tables;
232+ - best-achieved test accuracy and convergence-threshold tables;
233+ - paired seed-level final differences for every optimizer pair;
234+ - a checkpoint inventory and reproducibility manifest.
235+
236+ Classification perplexity is derived from the saved cross-entropy as
237+ ` exp(cross_entropy) ` . For MNIST this is an effective-class-count transform, not
238+ language-model perplexity.
239+
240+ Comparison outputs are written under:
171241
172242``` text
173- performance_by_epoch_and_seed.csv
174- spectral_metrics_by_epoch_layer_and_seed.csv
175- weightwatcher_details_by_epoch_and_seed.csv
176- optimizer_groups_by_epoch_and_seed.csv
177- combined_metrics_by_epoch_layer_and_seed.csv
178- performance_summary_95ci.csv
179- spectral_summary_95ci.csv
180- replicate_manifest.json
181- plots/
182- seeds/
183- seed_1337/
184- seed_2027/
185- seed_31415/
243+ runs/comparison/
244+ checkpoint_inventory.csv
245+ all_optimizers_performance_by_epoch_and_seed.csv
246+ all_optimizers_spectral_metrics_by_epoch_layer_and_seed.csv
247+ performance_summary_95ci.csv
248+ spectral_summary_95ci.csv
249+ final_epoch_summary_95ci.csv
250+ convergence_by_seed.csv
251+ convergence_summary_95ci.csv
252+ paired_final_differences_95ci.csv
253+ comparison_manifest.json
254+ plots/
186255```
187256
188- Each seed folder retains its own raw per-epoch CSVs, ` esd_history.npz ` ,
189- ` config.json ` , and ` final_state.pt ` .
257+ Paired contrasts are always reported as ` optimizer_a - optimizer_b ` . Positive
258+ is favorable for accuracy; negative is favorable for loss and perplexity. With
259+ only three paired seeds, the notebook reports Student-t intervals and does not
260+ claim high-powered asymptotic significance tests.
261+
262+ ## Run order
190263
191- ## Run
264+ From the repository root, open the notebooks in ` baseline/notebooks/ ` and run:
265+
266+ ``` text
267+ 1. MNIST_MLP3_SGD_Momentum_Baseline.ipynb
268+ 2. MNIST_MLP3_AdamW_Baseline.ipynb
269+ 3. MNIST_MLP3_SGD_Momentum_Muon_Baseline.ipynb
270+ 4. MNIST_MLP3_Baseline_Comparison.ipynb
271+ ```
192272
193- From the repository root, open any notebook in ` baseline/notebooks/ ` .
273+ The first three may be run in any order; the comparison must be run after all
274+ three have completed under the same run root.
194275
195276## Tests
196277
0 commit comments