Commit 55c8be2
committed
feat(v01): rng_key roundtrip → strict 1e-5 H19 loss continuation
V6 H19 left the strict 1e-5 bit-identity claim unreachable because
stage_train's per-step rng_key (mx.random.split each step) was NOT
saved in the checkpoint, so a resumed Train consumed a fresh
key(0) data stream — different synthetic targets at step N+1 vs
the contiguous run's step N+1.
Fix: opt_state save bundle now also writes the active rng_key under
the "_rng_key" entry; load pops it back before tree_unflatten and
seeds the resumed loop with the restored key. New
extras.checkpoint.rng_key_loaded boolean lets tests pin which path
was taken.
Tests (tests/v4/test_stage_train_rng_roundtrip.py): 3/3 —
* Contiguous 5-step losses[4] == (4-save + load + 1-step) losses[0]
within 1e-5 once weights + opt.state + rng_key all restored.
* rng_key_loaded=False without opt_state_load_path.
* rng_key_loaded=True after opt_state_load with the side-car file.
- pytest stage_train + checkpoint regression: 57/57 passing.1 parent 398270e commit 55c8be2
2 files changed
Lines changed: 98 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
682 | 682 | | |
683 | 683 | | |
684 | 684 | | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
685 | 688 | | |
| 689 | + | |
686 | 690 | | |
687 | 691 | | |
688 | 692 | | |
| |||
1118 | 1122 | | |
1119 | 1123 | | |
1120 | 1124 | | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
1121 | 1129 | | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
1122 | 1133 | | |
1123 | 1134 | | |
1124 | 1135 | | |
| |||
1260 | 1271 | | |
1261 | 1272 | | |
1262 | 1273 | | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
1263 | 1277 | | |
1264 | 1278 | | |
1265 | 1279 | | |
1266 | 1280 | | |
1267 | 1281 | | |
1268 | | - | |
1269 | | - | |
1270 | 1282 | | |
1271 | 1283 | | |
1272 | 1284 | | |
1273 | 1285 | | |
| 1286 | + | |
| 1287 | + | |
1274 | 1288 | | |
1275 | 1289 | | |
1276 | 1290 | | |
| |||
1414 | 1428 | | |
1415 | 1429 | | |
1416 | 1430 | | |
| 1431 | + | |
1417 | 1432 | | |
1418 | 1433 | | |
1419 | 1434 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
0 commit comments