_comment stringclasses 1
value | optimizers dict |
|---|---|
Template — replace `opt_name` and the checkpoint list with your own optimizer's HF checkpoints. iter is the training step. hf_path is a directory containing a HF Qwen3-8B-Base-compatible checkpoint (safetensors + index). | {
"myopt": {
"checkpoints": [
{
"iter": 100,
"hf_path": "/path/to/myopt/iter_0000100-hf"
},
{
"iter": 200,
"hf_path": "/path/to/myopt/iter_0000200-hf"
},
{
"iter": 300,
"hf_path": "/path/to/myopt/iter_0000300-hf"
}
]
}
} |
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
repro_pkg — portable trajectory reproducer
Self-contained package to compute the same (iter, cos_eff, E_phi, E_perp, p_phi)
trajectory as report_full2/data/trajectory_dir_energy.csv, for a new
optimizer's HF checkpoint sequence, on any machine with python + torch.
What's inside
repro_pkg/
reproduce.py standalone trajectory script (no project deps)
build_pkg.py how this package was built (kept for reference)
example_manifest.json template — fill in your own ckpts
phi_hat/ 6 × .npz, shared-direction unit vectors (~328 MB)
theta_0/ 6 × .npz, Qwen3-8B-Base for the 6 params (~440 MB)
README.md this file
Total: ~770 MB. No need to ship the 16 GB base model or the 2.9 GB full phi_hat cache.
Why only 6 parameters?
The trajectory tables and figA/figB aggregate sum_p over 6 representative
parameters, not all 41 LM params. The 6 cover MLP down-proj across depth
(layers 7/14/21/28) and one attention block (layer 21 q+o). n_params=6 in
every row of the output CSV.
(The terminal-state table data/energy_per_opt.csv does use the full 34
params — if you need that, repackage with PHI_DIR pointing at the full
data/weight/energy/phi_hat/ and update PARAMS to the union.)
How to reproduce on another machine
1. Copy the whole repro_pkg/ directory
rsync -ah repro_pkg/ user@host:/dst/path/
2. Install runtime
pip install numpy pandas torch safetensors
3. Produce HF checkpoints for your optimizer
You already have this — a directory per training iter, each containing
model-*.safetensors + model.safetensors.index.json, in Qwen3-8B-Base
layout (same parameter names).
4. Write your own manifest
Copy example_manifest.json to my_manifest.json and fill in:
{
"optimizers": {
"myopt": {
"checkpoints": [
{"iter": 100, "hf_path": "/abs/path/to/myopt/iter_0000100-hf"},
{"iter": 200, "hf_path": "/abs/path/to/myopt/iter_0000200-hf"},
{"iter": 300, "hf_path": "/abs/path/to/myopt/iter_0000300-hf"}
]
}
}
}
You can list one or many optimizers; pick one with --opt myopt.
5. Run
python reproduce.py --manifest my_manifest.json --opt myopt --out traj_myopt.csv
Output CSV columns (identical to source-of-truth
report_full2/data/trajectory_dir_energy.csv):
opt, iter, n_params, E_tau, E_phi, E_perp, p_phi, p_perp, cos_eff
Methodology recap
For each checkpoint at training step t:
tau_t,p = theta_t,p - theta_0,p per representative param p
alpha_p(t) = <tau_t,p , phi_hat_p> projection onto shared dir
E_phi(t) = sum_p alpha_p(t)^2 along phi*
E_tau(t) = sum_p ||tau_t,p||_F^2 total accumulated energy
E_perp(t) = E_tau(t) - E_phi(t) residual / off-axis
p_phi(t) = E_phi(t) / E_tau(t) fraction on shared dir
cos_eff(t) = sqrt(p_phi(t)) energy-equivalent cos
phi_hat = unit(tau_adam_final), cached. The 7 healthy optimizers in the
original study agree on this direction to within 1% (cos ≥ 0.989 to Adam),
so it is the canonical "shared RL direction".
Interpretation cheatsheet (from report_full2/review5_trajectory_explanation.md)
| pattern | meaning |
|---|---|
| cos_eff ~ 1.0, E_tau flat | healthy — energy concentrated on phi* |
| cos_eff ~ 1.0, E_tau flat, low reward | weak — accumulates correctly but RL no-op (e.g. SOAP) |
| cos_eff ~ 1.0, sudden per-step grad spike | step-energy collapse (e.g. Lion @ 80) |
| cos_eff monotonic decline, E_perp >> E_phi | diffuse / off-axis (e.g. SGD, RMS) |
Sanity check (optional)
To verify the package reproduces the original numbers, point the manifest at the Adam HF checkpoints from this project and compare:
opt=adam iter=31 cos_eff=0.9994 E_tau=138.65 p_phi=0.9987
opt=adam iter=1023 cos_eff=1.0000 E_tau=138.84 p_phi=1.0000
These should match report_full2/data/trajectory_dir_energy.csv to all
shown digits.
- Downloads last month
- 41