Commit b0520da
committed
NNX: fix DiLoCo train loop + checkpoint under pure_nnx
Under enable_diloco the state becomes a DiLoCoTrainState, but the pure_nnx path
still merged it against the plain-model graphdef (nnx.merge leaf mismatch +
segfault), and several downstream sites assumed a plain TrainStateNNX. Guard the
merge and surface the graphdef as model; fix get_first_step, jit_model,
params_shardings, setup_params, and the rng args in train_loop; match the diloco
sharding's params to_pure_dict; and handle the DiLoCoTrainState in
maybe_save_checkpoint by saving the synchronized global model. Train + checkpoint
save/restore validated end-to-end on CPU.1 parent d358e8b commit b0520da
3 files changed
Lines changed: 39 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1040 | 1040 | | |
1041 | 1041 | | |
1042 | 1042 | | |
1043 | | - | |
| 1043 | + | |
| 1044 | + | |
1044 | 1045 | | |
1045 | 1046 | | |
1046 | 1047 | | |
| |||
1051 | 1052 | | |
1052 | 1053 | | |
1053 | 1054 | | |
1054 | | - | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
1055 | 1062 | | |
1056 | 1063 | | |
1057 | 1064 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
80 | 82 | | |
81 | 83 | | |
82 | 84 | | |
| |||
598 | 600 | | |
599 | 601 | | |
600 | 602 | | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
601 | 606 | | |
602 | 607 | | |
603 | 608 | | |
604 | | - | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
605 | 616 | | |
606 | 617 | | |
607 | 618 | | |
| |||
622 | 633 | | |
623 | 634 | | |
624 | 635 | | |
625 | | - | |
| 636 | + | |
| 637 | + | |
626 | 638 | | |
627 | 639 | | |
628 | 640 | | |
| |||
638 | 650 | | |
639 | 651 | | |
640 | 652 | | |
| 653 | + | |
| 654 | + | |
641 | 655 | | |
642 | 656 | | |
643 | 657 | | |
| |||
652 | 666 | | |
653 | 667 | | |
654 | 668 | | |
655 | | - | |
| 669 | + | |
656 | 670 | | |
657 | 671 | | |
658 | 672 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
299 | 301 | | |
300 | 302 | | |
301 | 303 | | |
| |||
319 | 321 | | |
320 | 322 | | |
321 | 323 | | |
322 | | - | |
323 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
324 | 334 | | |
325 | 335 | | |
326 | 336 | | |
| |||
0 commit comments