Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3bf2b61
Add Muon microbatch checkpoint and RG spectrum utilities
charlesmartin14 Aug 16, 2026
65f1c4f
Add MNIST MLP3 Muon microbatch training runner
charlesmartin14 Aug 16, 2026
97d2ad5
Test Muon microbatch capture and relative-flow spectra
charlesmartin14 Aug 16, 2026
ff44adb
Add notebook contract test for Muon microbatch RG analysis
charlesmartin14 Aug 16, 2026
fde7dec
Add Muon microbatch ESD and power-law analysis notebook
charlesmartin14 Aug 16, 2026
96e803d
Document MNIST Muon microbatch RG experiment
charlesmartin14 Aug 16, 2026
983a23f
Expose MNIST Muon microbatch runner and powerlaw dependency
charlesmartin14 Aug 16, 2026
075298a
Add powerlaw for microbatch ESD analysis
charlesmartin14 Aug 16, 2026
4d61a67
Run Muon microbatch tests under unittest discovery
charlesmartin14 Aug 16, 2026
b1219fd
Run notebook contract test under unittest discovery
charlesmartin14 Aug 16, 2026
0691af2
Make relative-flow identity test deterministic
charlesmartin14 Aug 16, 2026
9e7d8d5
Expand power-law alpha range and record fit diagnostics
charlesmartin14 Aug 16, 2026
8b7908c
Assert expanded alpha range in Muon analysis notebook
charlesmartin14 Aug 16, 2026
7d3eaeb
Document expanded alpha range and fit diagnostics
charlesmartin14 Aug 16, 2026
b923443
Add gauge-aligned rectangular RG decomposition
charlesmartin14 Aug 16, 2026
85e2cd6
Add FC1/FC2 rectangular RG analysis
charlesmartin14 Aug 16, 2026
92278a0
Expose rectangular RG analysis CLI
charlesmartin14 Aug 16, 2026
328f564
Test rectangular RG decomposition
charlesmartin14 Aug 16, 2026
69f5354
Add FC1/FC2 rectangular RG notebook
charlesmartin14 Aug 16, 2026
1998d9d
Test rectangular RG notebook contract
charlesmartin14 Aug 16, 2026
40c4119
Document rectangular FC1 FC2 analysis
charlesmartin14 Aug 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 124 additions & 0 deletions baseline/MNIST_MUON_MICROBATCH_RG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# MNIST MLP3 Muon microbatch RG capture

This opt-in experiment trains the existing `784-512-512-10` MNIST MLP3 with
the baseline's exact Muon-on-hidden-layers plus auxiliary-AdamW recipe. The
baseline has no gradient accumulation, so each DataLoader minibatch is one
optimizer microbatch.

## Install

```bash
cd baseline
python -m pip install -e '.[experiment]'
```

## Run

A bounded first test that saves the three weight matrices after every update:

```bash
rg-mnist-muon-microbatch \
--data-dir ./data \
--output-dir ./results/mnist_mlp3_muon_microbatch_500 \
--max-steps 500 \
--capture-every 1 \
--checkpoint-dtype float32 \
--overwrite
```

The full 30-epoch baseline has about 12,900 optimizer microbatches. Saving all
three matrices in float32 at every step is roughly 32 GiB before container
overhead, so the runner refuses captures above 8 GiB unless explicitly enabled:

```bash
rg-mnist-muon-microbatch \
--data-dir ./data \
--output-dir ./results/mnist_mlp3_muon_microbatch_full \
--capture-every 1 \
--checkpoint-dtype float32 \
--allow-large-capture \
--overwrite
```

To reduce storage, use `--checkpoint-dtype float16`, increase
`--capture-every`, or set `--max-capture-step` while allowing training to
continue.

## Artifacts

```text
<run>/
manifest.json
training_metrics.csv
final_state.pt
microbatch_checkpoints/
manifest.json
checkpoint_index.csv
frames/
step_0000000.pt
step_0000001.pt
...
```

Each frame stores `fc1.weight`, `fc2.weight`, and `fc3.weight` only.

## Original pseudoinverse analysis

Open:

```text
notebooks/MNIST_MLP3_Muon_Microbatch_RG_ESD.ipynb
```

This exploratory notebook computes the ordinary weight ESD and the supported
pseudoinverse relative-flow spectrum. The latter is complete for square
full-rank matrices but mixes core deformation with subspace overlap for
rectangular matrices.

## Gauge-aligned rectangular analysis

Open:

```text
notebooks/MNIST_MLP3_Muon_Rectangular_RG_ESD.ipynb
```

or run:

```bash
rg-mnist-muon-rectangular-analysis \
--run-dir ./results/mnist_mlp3_muon_microbatch_500 \
--step-stride 1
```

For a wide full-row-rank matrix such as `fc1.weight`, write

```text
W_t = B_t V_t^T,
V_t^T V_t = I.
```

The row-space bases at successive steps are aligned by orthogonal Procrustes.
The analysis then reports two independent spectra:

1. Aligned square-core flow:
`abs(log(sigma(B_t_aligned B_{t-1}^{-1})^2))`.
2. Grassmann angular flow: the squared principal angles `theta_i^2` between
successive row spaces.

For `fc1.weight` (`512 x 784`), two 512-dimensional row spaces must intersect
in at least 240 dimensions, so there are at most 272 nontrivial angular modes.
The implementation removes those dimension-forced zero angles before fitting.

For square full-rank `fc2.weight`, the angular sector vanishes and the aligned
core operator reduces numerically to `W_t W_{t-1}^{-1}`. This gives a direct
control showing that the rectangular construction agrees with the original
square relative Jacobian.

The analysis writes power-law fits, tail sizes, tail fractions, KS distances,
condition numbers, principal-angle diagnostics, ESD archives, and alpha-versus-
step plots.

`powerlaw` 2.0 uses a built-in upper bound of `alpha = 3` for its power-law
model. Both notebooks explicitly expand the fitting range to
`1.01 <= alpha <= 10` and mark fits that reach the expanded boundary.
Loading
Loading