Persist Adam optimizer state and round counter across restarts #35
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.