PPO_Bot currently loses Adam optimizer momentum (m, v, t vectors) and round counter on crash/restart. This means:
Optimizer restarts cold after every crash — training slows until momentum rebuilds
Round counter resets to 0 — stats lose continuity
Fix: Save Adam state (ACAdamStates) alongside network weights in weights/latest/ and checkpoint dirs. Save round counter to a simple file. Load both in loadBestAvailable.
Independent of other tickets — improves crash recovery quality regardless of runner design.
Parent: #29
## Question
PPO_Bot currently loses Adam optimizer momentum (m, v, t vectors) and round counter on crash/restart. This means:
- Optimizer restarts cold after every crash — training slows until momentum rebuilds
- Round counter resets to 0 — stats lose continuity
**Fix:** Save Adam state (`ACAdamStates`) alongside network weights in `weights/latest/` and checkpoint dirs. Save round counter to a simple file. Load both in `loadBestAvailable`.
**Independent of other tickets** — improves crash recovery quality regardless of runner design.
Resolved in commit 0b17430 on branch research/goto-controller.
What was done:
Exported AdamState type and its m, v, t fields, plus all ACAdamStates fields, from training.nim so weights.nim can access them.
Added saveAdamStates / loadAdamStates procs in weights.nim: each Adam state's m and v tensors are written as .npy files (same format as weights), t counters go to adam_t.txt (one int per line).
Updated saveCheckpoint signature to (ac, adam, weightsRoot, roundNum) — saves Adam state alongside weights in latest/ and checkpoint dirs; writes round_counter.txt to weightsRoot/.
Updated loadBestAvailable signature to (ac, adam, weightsRoot) → (loaded, roundNum) — loads Adam state if files are present, cold-starts if absent (backward compatible).
Updated PPO_Bot.nim call sites accordingly; roundCounter is now seeded from the persisted value on startup.
All existing tests pass; no new dependencies added.
Resolved in commit `0b17430` on branch `research/goto-controller`.
**What was done:**
- Exported `AdamState` type and its `m`, `v`, `t` fields, plus all `ACAdamStates` fields, from `training.nim` so `weights.nim` can access them.
- Added `saveAdamStates` / `loadAdamStates` procs in `weights.nim`: each Adam state's `m` and `v` tensors are written as `.npy` files (same format as weights), `t` counters go to `adam_t.txt` (one int per line).
- Updated `saveCheckpoint` signature to `(ac, adam, weightsRoot, roundNum)` — saves Adam state alongside weights in `latest/` and checkpoint dirs; writes `round_counter.txt` to `weightsRoot/`.
- Updated `loadBestAvailable` signature to `(ac, adam, weightsRoot) → (loaded, roundNum)` — loads Adam state if files are present, cold-starts if absent (backward compatible).
- Updated `PPO_Bot.nim` call sites accordingly; `roundCounter` is now seeded from the persisted value on startup.
- All existing tests pass; no new dependencies added.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Parent: #29
Question
PPO_Bot currently loses Adam optimizer momentum (m, v, t vectors) and round counter on crash/restart. This means:
Fix: Save Adam state (
ACAdamStates) alongside network weights inweights/latest/and checkpoint dirs. Save round counter to a simple file. Load both inloadBestAvailable.Independent of other tickets — improves crash recovery quality regardless of runner design.
Resolved in commit
0b17430on branchresearch/goto-controller.What was done:
AdamStatetype and itsm,v,tfields, plus allACAdamStatesfields, fromtraining.nimsoweights.nimcan access them.saveAdamStates/loadAdamStatesprocs inweights.nim: each Adam state'smandvtensors are written as.npyfiles (same format as weights),tcounters go toadam_t.txt(one int per line).saveCheckpointsignature to(ac, adam, weightsRoot, roundNum)— saves Adam state alongside weights inlatest/and checkpoint dirs; writesround_counter.txttoweightsRoot/.loadBestAvailablesignature to(ac, adam, weightsRoot) → (loaded, roundNum)— loads Adam state if files are present, cold-starts if absent (backward compatible).PPO_Bot.nimcall sites accordingly;roundCounteris now seeded from the persisted value on startup.