loopback-kr commited on
Commit
b4db4e8
·
verified ·
1 Parent(s): ade174d

Upload folder using huggingface_hub

Browse files
Files changed (36) hide show
  1. checkpoint-20000/global_step20000/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt +3 -0
  2. checkpoint-20000/global_step20000/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt +3 -0
  3. checkpoint-20000/global_step20000/mp_rank_00_model_states.pt +3 -0
  4. checkpoint-20000/latest +1 -0
  5. checkpoint-20000/pytorch_model.bin +3 -0
  6. checkpoint-20000/rng_state_0.pth +3 -0
  7. checkpoint-20000/rng_state_1.pth +3 -0
  8. checkpoint-20000/scheduler.pt +3 -0
  9. checkpoint-20000/trainer_state.json +3635 -0
  10. checkpoint-20000/training_args.bin +3 -0
  11. checkpoint-20000/zero_to_fp32.py +760 -0
  12. checkpoint-30000/global_step30000/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt +3 -0
  13. checkpoint-30000/global_step30000/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt +3 -0
  14. checkpoint-30000/global_step30000/mp_rank_00_model_states.pt +3 -0
  15. checkpoint-30000/latest +1 -0
  16. checkpoint-30000/pytorch_model.bin +3 -0
  17. checkpoint-30000/rng_state_0.pth +3 -0
  18. checkpoint-30000/rng_state_1.pth +3 -0
  19. checkpoint-30000/scheduler.pt +3 -0
  20. checkpoint-30000/trainer_state.json +0 -0
  21. checkpoint-30000/training_args.bin +3 -0
  22. checkpoint-30000/zero_to_fp32.py +760 -0
  23. checkpoint-38184/global_step38184/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt +3 -0
  24. checkpoint-38184/global_step38184/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt +3 -0
  25. checkpoint-38184/global_step38184/mp_rank_00_model_states.pt +3 -0
  26. checkpoint-38184/latest +1 -0
  27. checkpoint-38184/pytorch_model.bin +3 -0
  28. checkpoint-38184/rng_state_0.pth +3 -0
  29. checkpoint-38184/rng_state_1.pth +3 -0
  30. checkpoint-38184/scheduler.pt +3 -0
  31. checkpoint-38184/trainer_state.json +0 -0
  32. checkpoint-38184/training_args.bin +3 -0
  33. checkpoint-38184/zero_to_fp32.py +760 -0
  34. model_with_lora.bin +3 -0
  35. runs/Mar07_05-23-18_886823f2c465/events.out.tfevents.1741292890.886823f2c465.10378.0 +3 -0
  36. trainer_state.json +0 -0
checkpoint-20000/global_step20000/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6a82034f591875a14d9f4a49e8d9dbc568934b84935d7410da278234c9358c84
3
+ size 8005108236
checkpoint-20000/global_step20000/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:982ca4f12681c7fcc3fba0075236cceb81df4951e4eb4ce11af34a01f5470d03
3
+ size 8005064076
checkpoint-20000/global_step20000/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:63ea0428c56c789a1d9eba212618848ddf13a5ed0af9c66995979dbae0d155ec
3
+ size 2668900764
checkpoint-20000/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step20000
checkpoint-20000/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21a001af098ab0ac11193ce7a5b60b2ae0e45c9bc7355655eef6036deb4dc7dc
3
+ size 17678656921
checkpoint-20000/rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da837a3dc60030878e2e36dde59c7a42c5b2a0990a58ec999c8d40cbbd08cbae
3
+ size 14448
checkpoint-20000/rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d5324a6dcbd22295551b4869a476cd5a0bd46ef0c171d9e99fc907d329900026
3
+ size 14448
checkpoint-20000/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fe06eb3768bad55eda84c238768081d2f935f4d0698457552be2007b79bd641d
3
+ size 1064
checkpoint-20000/trainer_state.json ADDED
@@ -0,0 +1,3635 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_metric": 0.01002925168722868,
3
+ "best_model_checkpoint": "/workspace/previous_works/RadFM/output/RadFM-Llama3-8B-pretrain-0002-embed_tokens-depth32-lora-8ep-maxlen2048/checkpoint-20000",
4
+ "epoch": 4.190236748376283,
5
+ "eval_steps": 10000,
6
+ "global_step": 20000,
7
+ "is_hyper_param_search": false,
8
+ "is_local_process_zero": true,
9
+ "is_world_process_zero": true,
10
+ "log_history": [
11
+ {
12
+ "epoch": 0.008170961659333752,
13
+ "grad_norm": 42.493404388427734,
14
+ "learning_rate": 3.4031413612565448e-06,
15
+ "loss": 2.5663,
16
+ "step": 39
17
+ },
18
+ {
19
+ "epoch": 0.016341923318667503,
20
+ "grad_norm": 4.584639072418213,
21
+ "learning_rate": 6.8062827225130895e-06,
22
+ "loss": 1.8589,
23
+ "step": 78
24
+ },
25
+ {
26
+ "epoch": 0.02451288497800126,
27
+ "grad_norm": 4.140661239624023,
28
+ "learning_rate": 1.0209424083769634e-05,
29
+ "loss": 1.1348,
30
+ "step": 117
31
+ },
32
+ {
33
+ "epoch": 0.03268384663733501,
34
+ "grad_norm": 4.312882423400879,
35
+ "learning_rate": 1.3612565445026179e-05,
36
+ "loss": 0.8666,
37
+ "step": 156
38
+ },
39
+ {
40
+ "epoch": 0.04085480829666876,
41
+ "grad_norm": 5.689533710479736,
42
+ "learning_rate": 1.7015706806282724e-05,
43
+ "loss": 0.7726,
44
+ "step": 195
45
+ },
46
+ {
47
+ "epoch": 0.04902576995600252,
48
+ "grad_norm": 3.757542133331299,
49
+ "learning_rate": 2.0418848167539268e-05,
50
+ "loss": 0.7232,
51
+ "step": 234
52
+ },
53
+ {
54
+ "epoch": 0.05719673161533627,
55
+ "grad_norm": 3.461946487426758,
56
+ "learning_rate": 2.382198952879581e-05,
57
+ "loss": 0.6182,
58
+ "step": 273
59
+ },
60
+ {
61
+ "epoch": 0.06536769327467001,
62
+ "grad_norm": 2.7702128887176514,
63
+ "learning_rate": 2.7225130890052358e-05,
64
+ "loss": 0.6639,
65
+ "step": 312
66
+ },
67
+ {
68
+ "epoch": 0.07353865493400377,
69
+ "grad_norm": 3.7390189170837402,
70
+ "learning_rate": 3.0628272251308905e-05,
71
+ "loss": 0.5924,
72
+ "step": 351
73
+ },
74
+ {
75
+ "epoch": 0.08170961659333752,
76
+ "grad_norm": 2.9384899139404297,
77
+ "learning_rate": 3.403141361256545e-05,
78
+ "loss": 0.594,
79
+ "step": 390
80
+ },
81
+ {
82
+ "epoch": 0.08988057825267128,
83
+ "grad_norm": 4.2483930587768555,
84
+ "learning_rate": 3.743455497382199e-05,
85
+ "loss": 0.5782,
86
+ "step": 429
87
+ },
88
+ {
89
+ "epoch": 0.09805153991200503,
90
+ "grad_norm": 2.8193845748901367,
91
+ "learning_rate": 4.0837696335078535e-05,
92
+ "loss": 0.6084,
93
+ "step": 468
94
+ },
95
+ {
96
+ "epoch": 0.10622250157133878,
97
+ "grad_norm": 2.6130402088165283,
98
+ "learning_rate": 4.424083769633508e-05,
99
+ "loss": 0.5876,
100
+ "step": 507
101
+ },
102
+ {
103
+ "epoch": 0.11439346323067254,
104
+ "grad_norm": 2.0634474754333496,
105
+ "learning_rate": 4.764397905759162e-05,
106
+ "loss": 0.5596,
107
+ "step": 546
108
+ },
109
+ {
110
+ "epoch": 0.12256442489000628,
111
+ "grad_norm": 3.275634288787842,
112
+ "learning_rate": 5.104712041884817e-05,
113
+ "loss": 0.6195,
114
+ "step": 585
115
+ },
116
+ {
117
+ "epoch": 0.13073538654934003,
118
+ "grad_norm": 2.8859968185424805,
119
+ "learning_rate": 5.4450261780104716e-05,
120
+ "loss": 0.5626,
121
+ "step": 624
122
+ },
123
+ {
124
+ "epoch": 0.13890634820867379,
125
+ "grad_norm": 2.7095537185668945,
126
+ "learning_rate": 5.785340314136126e-05,
127
+ "loss": 0.5534,
128
+ "step": 663
129
+ },
130
+ {
131
+ "epoch": 0.14707730986800754,
132
+ "grad_norm": 2.249742031097412,
133
+ "learning_rate": 6.125654450261781e-05,
134
+ "loss": 0.5859,
135
+ "step": 702
136
+ },
137
+ {
138
+ "epoch": 0.1552482715273413,
139
+ "grad_norm": 3.251708745956421,
140
+ "learning_rate": 6.465968586387435e-05,
141
+ "loss": 0.5644,
142
+ "step": 741
143
+ },
144
+ {
145
+ "epoch": 0.16341923318667503,
146
+ "grad_norm": 2.18890380859375,
147
+ "learning_rate": 6.80628272251309e-05,
148
+ "loss": 0.5465,
149
+ "step": 780
150
+ },
151
+ {
152
+ "epoch": 0.1715901948460088,
153
+ "grad_norm": 1.5962858200073242,
154
+ "learning_rate": 7.146596858638743e-05,
155
+ "loss": 0.5377,
156
+ "step": 819
157
+ },
158
+ {
159
+ "epoch": 0.17976115650534255,
160
+ "grad_norm": 1.8569731712341309,
161
+ "learning_rate": 7.486910994764398e-05,
162
+ "loss": 0.5627,
163
+ "step": 858
164
+ },
165
+ {
166
+ "epoch": 0.1879321181646763,
167
+ "grad_norm": 2.0382535457611084,
168
+ "learning_rate": 7.827225130890053e-05,
169
+ "loss": 0.5778,
170
+ "step": 897
171
+ },
172
+ {
173
+ "epoch": 0.19610307982401007,
174
+ "grad_norm": 2.0339195728302,
175
+ "learning_rate": 8.167539267015707e-05,
176
+ "loss": 0.5407,
177
+ "step": 936
178
+ },
179
+ {
180
+ "epoch": 0.2042740414833438,
181
+ "grad_norm": 2.1229023933410645,
182
+ "learning_rate": 8.507853403141361e-05,
183
+ "loss": 0.6132,
184
+ "step": 975
185
+ },
186
+ {
187
+ "epoch": 0.21244500314267756,
188
+ "grad_norm": 1.6219509840011597,
189
+ "learning_rate": 8.848167539267016e-05,
190
+ "loss": 0.6153,
191
+ "step": 1014
192
+ },
193
+ {
194
+ "epoch": 0.22061596480201132,
195
+ "grad_norm": 2.0772364139556885,
196
+ "learning_rate": 9.18848167539267e-05,
197
+ "loss": 0.533,
198
+ "step": 1053
199
+ },
200
+ {
201
+ "epoch": 0.22878692646134507,
202
+ "grad_norm": 2.073230504989624,
203
+ "learning_rate": 9.528795811518324e-05,
204
+ "loss": 0.5661,
205
+ "step": 1092
206
+ },
207
+ {
208
+ "epoch": 0.2369578881206788,
209
+ "grad_norm": 1.96063232421875,
210
+ "learning_rate": 9.86910994764398e-05,
211
+ "loss": 0.5962,
212
+ "step": 1131
213
+ },
214
+ {
215
+ "epoch": 0.24512884978001256,
216
+ "grad_norm": 1.5799710750579834,
217
+ "learning_rate": 9.999989639826398e-05,
218
+ "loss": 0.552,
219
+ "step": 1170
220
+ },
221
+ {
222
+ "epoch": 0.2532998114393463,
223
+ "grad_norm": 1.5227395296096802,
224
+ "learning_rate": 9.999928612073995e-05,
225
+ "loss": 0.5739,
226
+ "step": 1209
227
+ },
228
+ {
229
+ "epoch": 0.26147077309868005,
230
+ "grad_norm": 1.7215867042541504,
231
+ "learning_rate": 9.99981287046695e-05,
232
+ "loss": 0.5363,
233
+ "step": 1248
234
+ },
235
+ {
236
+ "epoch": 0.26964173475801384,
237
+ "grad_norm": 1.5819590091705322,
238
+ "learning_rate": 9.999642416271812e-05,
239
+ "loss": 0.5223,
240
+ "step": 1287
241
+ },
242
+ {
243
+ "epoch": 0.27781269641734757,
244
+ "grad_norm": 1.3706092834472656,
245
+ "learning_rate": 9.999417251353851e-05,
246
+ "loss": 0.5236,
247
+ "step": 1326
248
+ },
249
+ {
250
+ "epoch": 0.28598365807668136,
251
+ "grad_norm": 1.57364022731781,
252
+ "learning_rate": 9.999137378177029e-05,
253
+ "loss": 0.5454,
254
+ "step": 1365
255
+ },
256
+ {
257
+ "epoch": 0.2941546197360151,
258
+ "grad_norm": 1.2142678499221802,
259
+ "learning_rate": 9.998802799803979e-05,
260
+ "loss": 0.5247,
261
+ "step": 1404
262
+ },
263
+ {
264
+ "epoch": 0.3023255813953488,
265
+ "grad_norm": 1.275280237197876,
266
+ "learning_rate": 9.998413519895968e-05,
267
+ "loss": 0.5048,
268
+ "step": 1443
269
+ },
270
+ {
271
+ "epoch": 0.3104965430546826,
272
+ "grad_norm": 1.4138684272766113,
273
+ "learning_rate": 9.997969542712856e-05,
274
+ "loss": 0.5675,
275
+ "step": 1482
276
+ },
277
+ {
278
+ "epoch": 0.31866750471401634,
279
+ "grad_norm": 1.2247836589813232,
280
+ "learning_rate": 9.997470873113055e-05,
281
+ "loss": 0.523,
282
+ "step": 1521
283
+ },
284
+ {
285
+ "epoch": 0.32683846637335007,
286
+ "grad_norm": 1.1925996541976929,
287
+ "learning_rate": 9.996917516553468e-05,
288
+ "loss": 0.5555,
289
+ "step": 1560
290
+ },
291
+ {
292
+ "epoch": 0.33500942803268385,
293
+ "grad_norm": 1.0786908864974976,
294
+ "learning_rate": 9.996309479089436e-05,
295
+ "loss": 0.4793,
296
+ "step": 1599
297
+ },
298
+ {
299
+ "epoch": 0.3431803896920176,
300
+ "grad_norm": 1.1928977966308594,
301
+ "learning_rate": 9.995646767374671e-05,
302
+ "loss": 0.4938,
303
+ "step": 1638
304
+ },
305
+ {
306
+ "epoch": 0.35135135135135137,
307
+ "grad_norm": 1.0230952501296997,
308
+ "learning_rate": 9.994929388661176e-05,
309
+ "loss": 0.5405,
310
+ "step": 1677
311
+ },
312
+ {
313
+ "epoch": 0.3595223130106851,
314
+ "grad_norm": 1.436375379562378,
315
+ "learning_rate": 9.994157350799176e-05,
316
+ "loss": 0.5168,
317
+ "step": 1716
318
+ },
319
+ {
320
+ "epoch": 0.36769327467001883,
321
+ "grad_norm": 1.0002754926681519,
322
+ "learning_rate": 9.993330662237024e-05,
323
+ "loss": 0.5547,
324
+ "step": 1755
325
+ },
326
+ {
327
+ "epoch": 0.3758642363293526,
328
+ "grad_norm": 1.4565436840057373,
329
+ "learning_rate": 9.992449332021114e-05,
330
+ "loss": 0.5013,
331
+ "step": 1794
332
+ },
333
+ {
334
+ "epoch": 0.38403519798868635,
335
+ "grad_norm": 0.9139441251754761,
336
+ "learning_rate": 9.991513369795777e-05,
337
+ "loss": 0.5084,
338
+ "step": 1833
339
+ },
340
+ {
341
+ "epoch": 0.39220615964802014,
342
+ "grad_norm": 1.054423451423645,
343
+ "learning_rate": 9.99052278580318e-05,
344
+ "loss": 0.5277,
345
+ "step": 1872
346
+ },
347
+ {
348
+ "epoch": 0.40037712130735387,
349
+ "grad_norm": 2.1869988441467285,
350
+ "learning_rate": 9.989477590883211e-05,
351
+ "loss": 0.5121,
352
+ "step": 1911
353
+ },
354
+ {
355
+ "epoch": 0.4085480829666876,
356
+ "grad_norm": 1.1452125310897827,
357
+ "learning_rate": 9.988377796473363e-05,
358
+ "loss": 0.4957,
359
+ "step": 1950
360
+ },
361
+ {
362
+ "epoch": 0.4167190446260214,
363
+ "grad_norm": 0.8906638622283936,
364
+ "learning_rate": 9.987223414608605e-05,
365
+ "loss": 0.4706,
366
+ "step": 1989
367
+ },
368
+ {
369
+ "epoch": 0.4248900062853551,
370
+ "grad_norm": 1.0864148139953613,
371
+ "learning_rate": 9.986014457921253e-05,
372
+ "loss": 0.5475,
373
+ "step": 2028
374
+ },
375
+ {
376
+ "epoch": 0.4330609679446889,
377
+ "grad_norm": 0.9262130856513977,
378
+ "learning_rate": 9.984750939640835e-05,
379
+ "loss": 0.5052,
380
+ "step": 2067
381
+ },
382
+ {
383
+ "epoch": 0.44123192960402263,
384
+ "grad_norm": 0.8391928672790527,
385
+ "learning_rate": 9.983432873593937e-05,
386
+ "loss": 0.4524,
387
+ "step": 2106
388
+ },
389
+ {
390
+ "epoch": 0.44940289126335636,
391
+ "grad_norm": 0.9878028631210327,
392
+ "learning_rate": 9.98206027420406e-05,
393
+ "loss": 0.4461,
394
+ "step": 2145
395
+ },
396
+ {
397
+ "epoch": 0.45757385292269015,
398
+ "grad_norm": 0.9766435623168945,
399
+ "learning_rate": 9.980633156491459e-05,
400
+ "loss": 0.4987,
401
+ "step": 2184
402
+ },
403
+ {
404
+ "epoch": 0.4657448145820239,
405
+ "grad_norm": 0.7703444957733154,
406
+ "learning_rate": 9.979151536072982e-05,
407
+ "loss": 0.4865,
408
+ "step": 2223
409
+ },
410
+ {
411
+ "epoch": 0.4739157762413576,
412
+ "grad_norm": 1.0184051990509033,
413
+ "learning_rate": 9.977615429161888e-05,
414
+ "loss": 0.4715,
415
+ "step": 2262
416
+ },
417
+ {
418
+ "epoch": 0.4820867379006914,
419
+ "grad_norm": 0.8845427632331848,
420
+ "learning_rate": 9.976024852567689e-05,
421
+ "loss": 0.4961,
422
+ "step": 2301
423
+ },
424
+ {
425
+ "epoch": 0.49025769956002513,
426
+ "grad_norm": 1.0399807691574097,
427
+ "learning_rate": 9.974379823695944e-05,
428
+ "loss": 0.5169,
429
+ "step": 2340
430
+ },
431
+ {
432
+ "epoch": 0.4984286612193589,
433
+ "grad_norm": 0.91423499584198,
434
+ "learning_rate": 9.972680360548085e-05,
435
+ "loss": 0.4783,
436
+ "step": 2379
437
+ },
438
+ {
439
+ "epoch": 0.5065996228786926,
440
+ "grad_norm": 0.9913365840911865,
441
+ "learning_rate": 9.970926481721216e-05,
442
+ "loss": 0.4726,
443
+ "step": 2418
444
+ },
445
+ {
446
+ "epoch": 0.5147705845380264,
447
+ "grad_norm": 0.9079034924507141,
448
+ "learning_rate": 9.969118206407905e-05,
449
+ "loss": 0.4486,
450
+ "step": 2457
451
+ },
452
+ {
453
+ "epoch": 0.5229415461973601,
454
+ "grad_norm": 0.9283367395401001,
455
+ "learning_rate": 9.967255554395976e-05,
456
+ "loss": 0.4654,
457
+ "step": 2496
458
+ },
459
+ {
460
+ "epoch": 0.531112507856694,
461
+ "grad_norm": 0.8894864916801453,
462
+ "learning_rate": 9.965338546068292e-05,
463
+ "loss": 0.4977,
464
+ "step": 2535
465
+ },
466
+ {
467
+ "epoch": 0.5392834695160277,
468
+ "grad_norm": 0.913196861743927,
469
+ "learning_rate": 9.963367202402538e-05,
470
+ "loss": 0.5067,
471
+ "step": 2574
472
+ },
473
+ {
474
+ "epoch": 0.5474544311753614,
475
+ "grad_norm": 0.9744309186935425,
476
+ "learning_rate": 9.961341544970984e-05,
477
+ "loss": 0.4797,
478
+ "step": 2613
479
+ },
480
+ {
481
+ "epoch": 0.5556253928346951,
482
+ "grad_norm": 1.048804759979248,
483
+ "learning_rate": 9.959261595940252e-05,
484
+ "loss": 0.4383,
485
+ "step": 2652
486
+ },
487
+ {
488
+ "epoch": 0.5637963544940289,
489
+ "grad_norm": 1.0824997425079346,
490
+ "learning_rate": 9.957127378071072e-05,
491
+ "loss": 0.4866,
492
+ "step": 2691
493
+ },
494
+ {
495
+ "epoch": 0.5719673161533627,
496
+ "grad_norm": 1.0387648344039917,
497
+ "learning_rate": 9.954938914718035e-05,
498
+ "loss": 0.4659,
499
+ "step": 2730
500
+ },
501
+ {
502
+ "epoch": 0.5801382778126964,
503
+ "grad_norm": 0.8543350100517273,
504
+ "learning_rate": 9.952696229829335e-05,
505
+ "loss": 0.4576,
506
+ "step": 2769
507
+ },
508
+ {
509
+ "epoch": 0.5883092394720302,
510
+ "grad_norm": 0.8038038015365601,
511
+ "learning_rate": 9.950399347946512e-05,
512
+ "loss": 0.4594,
513
+ "step": 2808
514
+ },
515
+ {
516
+ "epoch": 0.5964802011313639,
517
+ "grad_norm": 1.0086504220962524,
518
+ "learning_rate": 9.948048294204175e-05,
519
+ "loss": 0.4974,
520
+ "step": 2847
521
+ },
522
+ {
523
+ "epoch": 0.6046511627906976,
524
+ "grad_norm": 0.9558520913124084,
525
+ "learning_rate": 9.945643094329735e-05,
526
+ "loss": 0.4723,
527
+ "step": 2886
528
+ },
529
+ {
530
+ "epoch": 0.6128221244500315,
531
+ "grad_norm": 1.0693845748901367,
532
+ "learning_rate": 9.943183774643116e-05,
533
+ "loss": 0.4563,
534
+ "step": 2925
535
+ },
536
+ {
537
+ "epoch": 0.6209930861093652,
538
+ "grad_norm": 0.8957254886627197,
539
+ "learning_rate": 9.94067036205648e-05,
540
+ "loss": 0.4668,
541
+ "step": 2964
542
+ },
543
+ {
544
+ "epoch": 0.6291640477686989,
545
+ "grad_norm": 0.8896434903144836,
546
+ "learning_rate": 9.938102884073914e-05,
547
+ "loss": 0.4707,
548
+ "step": 3003
549
+ },
550
+ {
551
+ "epoch": 0.6373350094280327,
552
+ "grad_norm": 1.0319199562072754,
553
+ "learning_rate": 9.935481368791141e-05,
554
+ "loss": 0.484,
555
+ "step": 3042
556
+ },
557
+ {
558
+ "epoch": 0.6455059710873664,
559
+ "grad_norm": 0.8816359043121338,
560
+ "learning_rate": 9.932805844895216e-05,
561
+ "loss": 0.475,
562
+ "step": 3081
563
+ },
564
+ {
565
+ "epoch": 0.6536769327467001,
566
+ "grad_norm": 0.7812872529029846,
567
+ "learning_rate": 9.930076341664201e-05,
568
+ "loss": 0.4838,
569
+ "step": 3120
570
+ },
571
+ {
572
+ "epoch": 0.661847894406034,
573
+ "grad_norm": 1.0631335973739624,
574
+ "learning_rate": 9.927292888966848e-05,
575
+ "loss": 0.4791,
576
+ "step": 3159
577
+ },
578
+ {
579
+ "epoch": 0.6700188560653677,
580
+ "grad_norm": 0.9721090793609619,
581
+ "learning_rate": 9.92445551726228e-05,
582
+ "loss": 0.4701,
583
+ "step": 3198
584
+ },
585
+ {
586
+ "epoch": 0.6781898177247014,
587
+ "grad_norm": 0.9454875588417053,
588
+ "learning_rate": 9.921564257599649e-05,
589
+ "loss": 0.4397,
590
+ "step": 3237
591
+ },
592
+ {
593
+ "epoch": 0.6863607793840352,
594
+ "grad_norm": 0.6671223044395447,
595
+ "learning_rate": 9.918619141617797e-05,
596
+ "loss": 0.4557,
597
+ "step": 3276
598
+ },
599
+ {
600
+ "epoch": 0.6945317410433689,
601
+ "grad_norm": 0.6020123958587646,
602
+ "learning_rate": 9.915620201544915e-05,
603
+ "loss": 0.4454,
604
+ "step": 3315
605
+ },
606
+ {
607
+ "epoch": 0.7027027027027027,
608
+ "grad_norm": 0.5989274382591248,
609
+ "learning_rate": 9.912567470198186e-05,
610
+ "loss": 0.4762,
611
+ "step": 3354
612
+ },
613
+ {
614
+ "epoch": 0.7108736643620365,
615
+ "grad_norm": 0.9229285717010498,
616
+ "learning_rate": 9.909460980983427e-05,
617
+ "loss": 0.4928,
618
+ "step": 3393
619
+ },
620
+ {
621
+ "epoch": 0.7190446260213702,
622
+ "grad_norm": 0.8499952554702759,
623
+ "learning_rate": 9.906300767894721e-05,
624
+ "loss": 0.4491,
625
+ "step": 3432
626
+ },
627
+ {
628
+ "epoch": 0.7272155876807039,
629
+ "grad_norm": 0.801685631275177,
630
+ "learning_rate": 9.903086865514053e-05,
631
+ "loss": 0.4496,
632
+ "step": 3471
633
+ },
634
+ {
635
+ "epoch": 0.7353865493400377,
636
+ "grad_norm": 1.049750566482544,
637
+ "learning_rate": 9.89981930901092e-05,
638
+ "loss": 0.4741,
639
+ "step": 3510
640
+ },
641
+ {
642
+ "epoch": 0.7435575109993715,
643
+ "grad_norm": 0.7072298526763916,
644
+ "learning_rate": 9.896498134141957e-05,
645
+ "loss": 0.454,
646
+ "step": 3549
647
+ },
648
+ {
649
+ "epoch": 0.7517284726587052,
650
+ "grad_norm": 0.674797773361206,
651
+ "learning_rate": 9.893123377250535e-05,
652
+ "loss": 0.4244,
653
+ "step": 3588
654
+ },
655
+ {
656
+ "epoch": 0.759899434318039,
657
+ "grad_norm": 0.6849934458732605,
658
+ "learning_rate": 9.889695075266377e-05,
659
+ "loss": 0.4631,
660
+ "step": 3627
661
+ },
662
+ {
663
+ "epoch": 0.7680703959773727,
664
+ "grad_norm": 0.6002283692359924,
665
+ "learning_rate": 9.88621326570514e-05,
666
+ "loss": 0.4936,
667
+ "step": 3666
668
+ },
669
+ {
670
+ "epoch": 0.7762413576367064,
671
+ "grad_norm": 0.8119000196456909,
672
+ "learning_rate": 9.882677986668014e-05,
673
+ "loss": 0.471,
674
+ "step": 3705
675
+ },
676
+ {
677
+ "epoch": 0.7844123192960403,
678
+ "grad_norm": 0.8308870792388916,
679
+ "learning_rate": 9.879089276841297e-05,
680
+ "loss": 0.4419,
681
+ "step": 3744
682
+ },
683
+ {
684
+ "epoch": 0.792583280955374,
685
+ "grad_norm": 0.7574063539505005,
686
+ "learning_rate": 9.875447175495983e-05,
687
+ "loss": 0.4286,
688
+ "step": 3783
689
+ },
690
+ {
691
+ "epoch": 0.8007542426147077,
692
+ "grad_norm": 0.7497377991676331,
693
+ "learning_rate": 9.871751722487317e-05,
694
+ "loss": 0.4773,
695
+ "step": 3822
696
+ },
697
+ {
698
+ "epoch": 0.8089252042740415,
699
+ "grad_norm": 0.761298418045044,
700
+ "learning_rate": 9.868002958254377e-05,
701
+ "loss": 0.4813,
702
+ "step": 3861
703
+ },
704
+ {
705
+ "epoch": 0.8170961659333752,
706
+ "grad_norm": 0.9213526844978333,
707
+ "learning_rate": 9.864200923819613e-05,
708
+ "loss": 0.4777,
709
+ "step": 3900
710
+ },
711
+ {
712
+ "epoch": 0.825267127592709,
713
+ "grad_norm": 0.9028540849685669,
714
+ "learning_rate": 9.860345660788414e-05,
715
+ "loss": 0.4302,
716
+ "step": 3939
717
+ },
718
+ {
719
+ "epoch": 0.8334380892520428,
720
+ "grad_norm": 0.6980260610580444,
721
+ "learning_rate": 9.856437211348641e-05,
722
+ "loss": 0.4283,
723
+ "step": 3978
724
+ },
725
+ {
726
+ "epoch": 0.8416090509113765,
727
+ "grad_norm": 0.6451707482337952,
728
+ "learning_rate": 9.852475618270172e-05,
729
+ "loss": 0.425,
730
+ "step": 4017
731
+ },
732
+ {
733
+ "epoch": 0.8497800125707102,
734
+ "grad_norm": 0.712598443031311,
735
+ "learning_rate": 9.848460924904432e-05,
736
+ "loss": 0.4638,
737
+ "step": 4056
738
+ },
739
+ {
740
+ "epoch": 0.857950974230044,
741
+ "grad_norm": 0.614088773727417,
742
+ "learning_rate": 9.844393175183917e-05,
743
+ "loss": 0.4557,
744
+ "step": 4095
745
+ },
746
+ {
747
+ "epoch": 0.8661219358893778,
748
+ "grad_norm": 0.8028059601783752,
749
+ "learning_rate": 9.840272413621716e-05,
750
+ "loss": 0.4699,
751
+ "step": 4134
752
+ },
753
+ {
754
+ "epoch": 0.8742928975487115,
755
+ "grad_norm": 0.8500687479972839,
756
+ "learning_rate": 9.836098685311024e-05,
757
+ "loss": 0.4392,
758
+ "step": 4173
759
+ },
760
+ {
761
+ "epoch": 0.8824638592080453,
762
+ "grad_norm": 0.7735748291015625,
763
+ "learning_rate": 9.831872035924645e-05,
764
+ "loss": 0.4197,
765
+ "step": 4212
766
+ },
767
+ {
768
+ "epoch": 0.890634820867379,
769
+ "grad_norm": 0.6959074139595032,
770
+ "learning_rate": 9.827592511714493e-05,
771
+ "loss": 0.4347,
772
+ "step": 4251
773
+ },
774
+ {
775
+ "epoch": 0.8988057825267127,
776
+ "grad_norm": 0.5992249846458435,
777
+ "learning_rate": 9.823260159511096e-05,
778
+ "loss": 0.4327,
779
+ "step": 4290
780
+ },
781
+ {
782
+ "epoch": 0.9069767441860465,
783
+ "grad_norm": 0.591803252696991,
784
+ "learning_rate": 9.818875026723063e-05,
785
+ "loss": 0.463,
786
+ "step": 4329
787
+ },
788
+ {
789
+ "epoch": 0.9151477058453803,
790
+ "grad_norm": 0.7650397419929504,
791
+ "learning_rate": 9.814437161336583e-05,
792
+ "loss": 0.4393,
793
+ "step": 4368
794
+ },
795
+ {
796
+ "epoch": 0.923318667504714,
797
+ "grad_norm": 0.7083756923675537,
798
+ "learning_rate": 9.809946611914896e-05,
799
+ "loss": 0.4431,
800
+ "step": 4407
801
+ },
802
+ {
803
+ "epoch": 0.9314896291640478,
804
+ "grad_norm": 0.5570526719093323,
805
+ "learning_rate": 9.805403427597757e-05,
806
+ "loss": 0.4293,
807
+ "step": 4446
808
+ },
809
+ {
810
+ "epoch": 0.9396605908233815,
811
+ "grad_norm": 0.7944348454475403,
812
+ "learning_rate": 9.800807658100902e-05,
813
+ "loss": 0.4331,
814
+ "step": 4485
815
+ },
816
+ {
817
+ "epoch": 0.9478315524827152,
818
+ "grad_norm": 0.9344629645347595,
819
+ "learning_rate": 9.796159353715498e-05,
820
+ "loss": 0.4461,
821
+ "step": 4524
822
+ },
823
+ {
824
+ "epoch": 0.9560025141420491,
825
+ "grad_norm": 0.6917528510093689,
826
+ "learning_rate": 9.791458565307604e-05,
827
+ "loss": 0.4441,
828
+ "step": 4563
829
+ },
830
+ {
831
+ "epoch": 0.9641734758013828,
832
+ "grad_norm": 0.6871070861816406,
833
+ "learning_rate": 9.786705344317606e-05,
834
+ "loss": 0.4461,
835
+ "step": 4602
836
+ },
837
+ {
838
+ "epoch": 0.9723444374607165,
839
+ "grad_norm": 0.7774878740310669,
840
+ "learning_rate": 9.781899742759652e-05,
841
+ "loss": 0.4693,
842
+ "step": 4641
843
+ },
844
+ {
845
+ "epoch": 0.9805153991200503,
846
+ "grad_norm": 0.7668758630752563,
847
+ "learning_rate": 9.777041813221095e-05,
848
+ "loss": 0.4073,
849
+ "step": 4680
850
+ },
851
+ {
852
+ "epoch": 0.988686360779384,
853
+ "grad_norm": 0.7705347537994385,
854
+ "learning_rate": 9.772131608861899e-05,
855
+ "loss": 0.474,
856
+ "step": 4719
857
+ },
858
+ {
859
+ "epoch": 0.9968573224387178,
860
+ "grad_norm": 0.8965923190116882,
861
+ "learning_rate": 9.767169183414075e-05,
862
+ "loss": 0.4741,
863
+ "step": 4758
864
+ },
865
+ {
866
+ "epoch": 1.0050282840980516,
867
+ "grad_norm": 0.7429456114768982,
868
+ "learning_rate": 9.762154591181083e-05,
869
+ "loss": 0.4326,
870
+ "step": 4797
871
+ },
872
+ {
873
+ "epoch": 1.0131992457573853,
874
+ "grad_norm": 0.8201857209205627,
875
+ "learning_rate": 9.757087887037241e-05,
876
+ "loss": 0.4252,
877
+ "step": 4836
878
+ },
879
+ {
880
+ "epoch": 1.021370207416719,
881
+ "grad_norm": 0.9046009182929993,
882
+ "learning_rate": 9.751969126427122e-05,
883
+ "loss": 0.4176,
884
+ "step": 4875
885
+ },
886
+ {
887
+ "epoch": 1.0295411690760528,
888
+ "grad_norm": 0.9283869862556458,
889
+ "learning_rate": 9.746798365364952e-05,
890
+ "loss": 0.4024,
891
+ "step": 4914
892
+ },
893
+ {
894
+ "epoch": 1.0377121307353865,
895
+ "grad_norm": 0.8236905932426453,
896
+ "learning_rate": 9.741575660433993e-05,
897
+ "loss": 0.409,
898
+ "step": 4953
899
+ },
900
+ {
901
+ "epoch": 1.0458830923947202,
902
+ "grad_norm": 0.713076651096344,
903
+ "learning_rate": 9.736301068785923e-05,
904
+ "loss": 0.4466,
905
+ "step": 4992
906
+ },
907
+ {
908
+ "epoch": 1.054054054054054,
909
+ "grad_norm": 0.8006173372268677,
910
+ "learning_rate": 9.730974648140214e-05,
911
+ "loss": 0.3786,
912
+ "step": 5031
913
+ },
914
+ {
915
+ "epoch": 1.062225015713388,
916
+ "grad_norm": 0.924655020236969,
917
+ "learning_rate": 9.725596456783502e-05,
918
+ "loss": 0.4276,
919
+ "step": 5070
920
+ },
921
+ {
922
+ "epoch": 1.0703959773727216,
923
+ "grad_norm": 0.7090715765953064,
924
+ "learning_rate": 9.72016655356894e-05,
925
+ "loss": 0.3978,
926
+ "step": 5109
927
+ },
928
+ {
929
+ "epoch": 1.0785669390320554,
930
+ "grad_norm": 0.8049948215484619,
931
+ "learning_rate": 9.714684997915566e-05,
932
+ "loss": 0.423,
933
+ "step": 5148
934
+ },
935
+ {
936
+ "epoch": 1.086737900691389,
937
+ "grad_norm": 0.7052054405212402,
938
+ "learning_rate": 9.709151849807643e-05,
939
+ "loss": 0.3803,
940
+ "step": 5187
941
+ },
942
+ {
943
+ "epoch": 1.0949088623507228,
944
+ "grad_norm": 1.0038681030273438,
945
+ "learning_rate": 9.703567169794008e-05,
946
+ "loss": 0.4221,
947
+ "step": 5226
948
+ },
949
+ {
950
+ "epoch": 1.1030798240100566,
951
+ "grad_norm": 0.6527186036109924,
952
+ "learning_rate": 9.697931018987408e-05,
953
+ "loss": 0.3858,
954
+ "step": 5265
955
+ },
956
+ {
957
+ "epoch": 1.1112507856693903,
958
+ "grad_norm": 0.7536753416061401,
959
+ "learning_rate": 9.69224345906383e-05,
960
+ "loss": 0.3981,
961
+ "step": 5304
962
+ },
963
+ {
964
+ "epoch": 1.119421747328724,
965
+ "grad_norm": 1.1964749097824097,
966
+ "learning_rate": 9.68650455226183e-05,
967
+ "loss": 0.3858,
968
+ "step": 5343
969
+ },
970
+ {
971
+ "epoch": 1.1275927089880577,
972
+ "grad_norm": 0.717378556728363,
973
+ "learning_rate": 9.680714361381844e-05,
974
+ "loss": 0.4056,
975
+ "step": 5382
976
+ },
977
+ {
978
+ "epoch": 1.1357636706473917,
979
+ "grad_norm": 0.8927372694015503,
980
+ "learning_rate": 9.674872949785511e-05,
981
+ "loss": 0.3831,
982
+ "step": 5421
983
+ },
984
+ {
985
+ "epoch": 1.1439346323067254,
986
+ "grad_norm": 0.8325986266136169,
987
+ "learning_rate": 9.668980381394972e-05,
988
+ "loss": 0.3996,
989
+ "step": 5460
990
+ },
991
+ {
992
+ "epoch": 1.1521055939660592,
993
+ "grad_norm": 0.8707286715507507,
994
+ "learning_rate": 9.663036720692175e-05,
995
+ "loss": 0.4171,
996
+ "step": 5499
997
+ },
998
+ {
999
+ "epoch": 1.160276555625393,
1000
+ "grad_norm": 0.6361021399497986,
1001
+ "learning_rate": 9.657042032718165e-05,
1002
+ "loss": 0.4033,
1003
+ "step": 5538
1004
+ },
1005
+ {
1006
+ "epoch": 1.1684475172847266,
1007
+ "grad_norm": 0.9237117171287537,
1008
+ "learning_rate": 9.650996383072375e-05,
1009
+ "loss": 0.3497,
1010
+ "step": 5577
1011
+ },
1012
+ {
1013
+ "epoch": 1.1766184789440604,
1014
+ "grad_norm": 0.7840002179145813,
1015
+ "learning_rate": 9.644899837911912e-05,
1016
+ "loss": 0.3789,
1017
+ "step": 5616
1018
+ },
1019
+ {
1020
+ "epoch": 1.184789440603394,
1021
+ "grad_norm": 0.6757360100746155,
1022
+ "learning_rate": 9.638752463950821e-05,
1023
+ "loss": 0.4085,
1024
+ "step": 5655
1025
+ },
1026
+ {
1027
+ "epoch": 1.1929604022627278,
1028
+ "grad_norm": 0.8231393098831177,
1029
+ "learning_rate": 9.632554328459371e-05,
1030
+ "loss": 0.4015,
1031
+ "step": 5694
1032
+ },
1033
+ {
1034
+ "epoch": 1.2011313639220615,
1035
+ "grad_norm": 1.001394271850586,
1036
+ "learning_rate": 9.626305499263307e-05,
1037
+ "loss": 0.3671,
1038
+ "step": 5733
1039
+ },
1040
+ {
1041
+ "epoch": 1.2093023255813953,
1042
+ "grad_norm": 0.7362861633300781,
1043
+ "learning_rate": 9.620006044743111e-05,
1044
+ "loss": 0.4108,
1045
+ "step": 5772
1046
+ },
1047
+ {
1048
+ "epoch": 1.217473287240729,
1049
+ "grad_norm": 0.873781144618988,
1050
+ "learning_rate": 9.613656033833255e-05,
1051
+ "loss": 0.3959,
1052
+ "step": 5811
1053
+ },
1054
+ {
1055
+ "epoch": 1.2256442489000627,
1056
+ "grad_norm": 0.745134174823761,
1057
+ "learning_rate": 9.607255536021445e-05,
1058
+ "loss": 0.4003,
1059
+ "step": 5850
1060
+ },
1061
+ {
1062
+ "epoch": 1.2338152105593967,
1063
+ "grad_norm": 0.9675105810165405,
1064
+ "learning_rate": 9.600804621347865e-05,
1065
+ "loss": 0.4446,
1066
+ "step": 5889
1067
+ },
1068
+ {
1069
+ "epoch": 1.2419861722187304,
1070
+ "grad_norm": 0.6674776673316956,
1071
+ "learning_rate": 9.594303360404401e-05,
1072
+ "loss": 0.3975,
1073
+ "step": 5928
1074
+ },
1075
+ {
1076
+ "epoch": 1.2501571338780642,
1077
+ "grad_norm": 1.0288015604019165,
1078
+ "learning_rate": 9.587751824333882e-05,
1079
+ "loss": 0.371,
1080
+ "step": 5967
1081
+ },
1082
+ {
1083
+ "epoch": 1.2583280955373979,
1084
+ "grad_norm": 1.1984747648239136,
1085
+ "learning_rate": 9.581150084829287e-05,
1086
+ "loss": 0.391,
1087
+ "step": 6006
1088
+ },
1089
+ {
1090
+ "epoch": 1.2664990571967316,
1091
+ "grad_norm": 0.7332170009613037,
1092
+ "learning_rate": 9.574498214132971e-05,
1093
+ "loss": 0.4048,
1094
+ "step": 6045
1095
+ },
1096
+ {
1097
+ "epoch": 1.2746700188560653,
1098
+ "grad_norm": 0.7564400434494019,
1099
+ "learning_rate": 9.56779628503587e-05,
1100
+ "loss": 0.4403,
1101
+ "step": 6084
1102
+ },
1103
+ {
1104
+ "epoch": 1.282840980515399,
1105
+ "grad_norm": 0.8034684658050537,
1106
+ "learning_rate": 9.561044370876709e-05,
1107
+ "loss": 0.3841,
1108
+ "step": 6123
1109
+ },
1110
+ {
1111
+ "epoch": 1.2910119421747328,
1112
+ "grad_norm": 0.8448123335838318,
1113
+ "learning_rate": 9.55424254554119e-05,
1114
+ "loss": 0.3906,
1115
+ "step": 6162
1116
+ },
1117
+ {
1118
+ "epoch": 1.2991829038340668,
1119
+ "grad_norm": 1.2661123275756836,
1120
+ "learning_rate": 9.547390883461194e-05,
1121
+ "loss": 0.3858,
1122
+ "step": 6201
1123
+ },
1124
+ {
1125
+ "epoch": 1.3073538654934005,
1126
+ "grad_norm": 0.7595413327217102,
1127
+ "learning_rate": 9.54048945961396e-05,
1128
+ "loss": 0.4283,
1129
+ "step": 6240
1130
+ },
1131
+ {
1132
+ "epoch": 1.3155248271527342,
1133
+ "grad_norm": 0.8576300740242004,
1134
+ "learning_rate": 9.533538349521263e-05,
1135
+ "loss": 0.3916,
1136
+ "step": 6279
1137
+ },
1138
+ {
1139
+ "epoch": 1.323695788812068,
1140
+ "grad_norm": 0.5660988092422485,
1141
+ "learning_rate": 9.526537629248598e-05,
1142
+ "loss": 0.3639,
1143
+ "step": 6318
1144
+ },
1145
+ {
1146
+ "epoch": 1.3318667504714017,
1147
+ "grad_norm": 0.7187468409538269,
1148
+ "learning_rate": 9.519487375404337e-05,
1149
+ "loss": 0.3861,
1150
+ "step": 6357
1151
+ },
1152
+ {
1153
+ "epoch": 1.3400377121307354,
1154
+ "grad_norm": 0.8099279999732971,
1155
+ "learning_rate": 9.512387665138894e-05,
1156
+ "loss": 0.3975,
1157
+ "step": 6396
1158
+ },
1159
+ {
1160
+ "epoch": 1.3482086737900691,
1161
+ "grad_norm": 0.8016268610954285,
1162
+ "learning_rate": 9.50523857614388e-05,
1163
+ "loss": 0.3751,
1164
+ "step": 6435
1165
+ },
1166
+ {
1167
+ "epoch": 1.3563796354494029,
1168
+ "grad_norm": 0.6431599855422974,
1169
+ "learning_rate": 9.498040186651258e-05,
1170
+ "loss": 0.4014,
1171
+ "step": 6474
1172
+ },
1173
+ {
1174
+ "epoch": 1.3645505971087366,
1175
+ "grad_norm": 0.8925536274909973,
1176
+ "learning_rate": 9.490792575432475e-05,
1177
+ "loss": 0.3871,
1178
+ "step": 6513
1179
+ },
1180
+ {
1181
+ "epoch": 1.3727215587680703,
1182
+ "grad_norm": 0.8553928136825562,
1183
+ "learning_rate": 9.483495821797619e-05,
1184
+ "loss": 0.3949,
1185
+ "step": 6552
1186
+ },
1187
+ {
1188
+ "epoch": 1.380892520427404,
1189
+ "grad_norm": 0.8019265532493591,
1190
+ "learning_rate": 9.476150005594528e-05,
1191
+ "loss": 0.4086,
1192
+ "step": 6591
1193
+ },
1194
+ {
1195
+ "epoch": 1.3890634820867378,
1196
+ "grad_norm": 0.7925927639007568,
1197
+ "learning_rate": 9.468755207207937e-05,
1198
+ "loss": 0.4024,
1199
+ "step": 6630
1200
+ },
1201
+ {
1202
+ "epoch": 1.3972344437460715,
1203
+ "grad_norm": 0.7827038168907166,
1204
+ "learning_rate": 9.461311507558586e-05,
1205
+ "loss": 0.421,
1206
+ "step": 6669
1207
+ },
1208
+ {
1209
+ "epoch": 1.4054054054054055,
1210
+ "grad_norm": 0.5531708598136902,
1211
+ "learning_rate": 9.453818988102336e-05,
1212
+ "loss": 0.4183,
1213
+ "step": 6708
1214
+ },
1215
+ {
1216
+ "epoch": 1.4135763670647392,
1217
+ "grad_norm": 0.7605539560317993,
1218
+ "learning_rate": 9.446277730829284e-05,
1219
+ "loss": 0.4314,
1220
+ "step": 6747
1221
+ },
1222
+ {
1223
+ "epoch": 1.421747328724073,
1224
+ "grad_norm": 0.49756988883018494,
1225
+ "learning_rate": 9.438687818262857e-05,
1226
+ "loss": 0.4118,
1227
+ "step": 6786
1228
+ },
1229
+ {
1230
+ "epoch": 1.4299182903834067,
1231
+ "grad_norm": 0.9179204106330872,
1232
+ "learning_rate": 9.431049333458917e-05,
1233
+ "loss": 0.4027,
1234
+ "step": 6825
1235
+ },
1236
+ {
1237
+ "epoch": 1.4380892520427404,
1238
+ "grad_norm": 0.7112446427345276,
1239
+ "learning_rate": 9.423362360004848e-05,
1240
+ "loss": 0.3961,
1241
+ "step": 6864
1242
+ },
1243
+ {
1244
+ "epoch": 1.4462602137020741,
1245
+ "grad_norm": 0.6417878866195679,
1246
+ "learning_rate": 9.415626982018637e-05,
1247
+ "loss": 0.426,
1248
+ "step": 6903
1249
+ },
1250
+ {
1251
+ "epoch": 1.4544311753614079,
1252
+ "grad_norm": 0.7054896950721741,
1253
+ "learning_rate": 9.407843284147966e-05,
1254
+ "loss": 0.3592,
1255
+ "step": 6942
1256
+ },
1257
+ {
1258
+ "epoch": 1.4626021370207416,
1259
+ "grad_norm": 0.3770501911640167,
1260
+ "learning_rate": 9.400011351569272e-05,
1261
+ "loss": 0.4205,
1262
+ "step": 6981
1263
+ },
1264
+ {
1265
+ "epoch": 1.4707730986800756,
1266
+ "grad_norm": 0.7424401044845581,
1267
+ "learning_rate": 9.392131269986821e-05,
1268
+ "loss": 0.3862,
1269
+ "step": 7020
1270
+ },
1271
+ {
1272
+ "epoch": 1.4789440603394093,
1273
+ "grad_norm": 0.7774800062179565,
1274
+ "learning_rate": 9.384203125631774e-05,
1275
+ "loss": 0.4186,
1276
+ "step": 7059
1277
+ },
1278
+ {
1279
+ "epoch": 1.487115021998743,
1280
+ "grad_norm": 0.6684144735336304,
1281
+ "learning_rate": 9.376227005261237e-05,
1282
+ "loss": 0.3793,
1283
+ "step": 7098
1284
+ },
1285
+ {
1286
+ "epoch": 1.4952859836580767,
1287
+ "grad_norm": 0.8839356899261475,
1288
+ "learning_rate": 9.368202996157314e-05,
1289
+ "loss": 0.3927,
1290
+ "step": 7137
1291
+ },
1292
+ {
1293
+ "epoch": 1.5034569453174105,
1294
+ "grad_norm": 0.7853700518608093,
1295
+ "learning_rate": 9.36013118612615e-05,
1296
+ "loss": 0.3842,
1297
+ "step": 7176
1298
+ },
1299
+ {
1300
+ "epoch": 1.5116279069767442,
1301
+ "grad_norm": 0.9322993159294128,
1302
+ "learning_rate": 9.35201166349698e-05,
1303
+ "loss": 0.3737,
1304
+ "step": 7215
1305
+ },
1306
+ {
1307
+ "epoch": 1.519798868636078,
1308
+ "grad_norm": 0.7737587094306946,
1309
+ "learning_rate": 9.343844517121145e-05,
1310
+ "loss": 0.3681,
1311
+ "step": 7254
1312
+ },
1313
+ {
1314
+ "epoch": 1.5279698302954117,
1315
+ "grad_norm": 0.7644033432006836,
1316
+ "learning_rate": 9.335629836371132e-05,
1317
+ "loss": 0.3786,
1318
+ "step": 7293
1319
+ },
1320
+ {
1321
+ "epoch": 1.5361407919547454,
1322
+ "grad_norm": 0.7909252643585205,
1323
+ "learning_rate": 9.327367711139596e-05,
1324
+ "loss": 0.4039,
1325
+ "step": 7332
1326
+ },
1327
+ {
1328
+ "epoch": 1.5443117536140791,
1329
+ "grad_norm": 0.5451653599739075,
1330
+ "learning_rate": 9.31905823183837e-05,
1331
+ "loss": 0.3507,
1332
+ "step": 7371
1333
+ },
1334
+ {
1335
+ "epoch": 1.5524827152734129,
1336
+ "grad_norm": 0.7788479328155518,
1337
+ "learning_rate": 9.310701489397485e-05,
1338
+ "loss": 0.3732,
1339
+ "step": 7410
1340
+ },
1341
+ {
1342
+ "epoch": 1.5606536769327466,
1343
+ "grad_norm": 0.8460758924484253,
1344
+ "learning_rate": 9.302297575264159e-05,
1345
+ "loss": 0.3692,
1346
+ "step": 7449
1347
+ },
1348
+ {
1349
+ "epoch": 1.5688246385920803,
1350
+ "grad_norm": 0.8979092240333557,
1351
+ "learning_rate": 9.293846581401815e-05,
1352
+ "loss": 0.4246,
1353
+ "step": 7488
1354
+ },
1355
+ {
1356
+ "epoch": 1.576995600251414,
1357
+ "grad_norm": 0.8408267498016357,
1358
+ "learning_rate": 9.285348600289063e-05,
1359
+ "loss": 0.4018,
1360
+ "step": 7527
1361
+ },
1362
+ {
1363
+ "epoch": 1.585166561910748,
1364
+ "grad_norm": 0.9224086999893188,
1365
+ "learning_rate": 9.276803724918692e-05,
1366
+ "loss": 0.3774,
1367
+ "step": 7566
1368
+ },
1369
+ {
1370
+ "epoch": 1.5933375235700817,
1371
+ "grad_norm": 0.760299563407898,
1372
+ "learning_rate": 9.268212048796652e-05,
1373
+ "loss": 0.4074,
1374
+ "step": 7605
1375
+ },
1376
+ {
1377
+ "epoch": 1.6015084852294155,
1378
+ "grad_norm": 0.6859989166259766,
1379
+ "learning_rate": 9.259573665941027e-05,
1380
+ "loss": 0.4017,
1381
+ "step": 7644
1382
+ },
1383
+ {
1384
+ "epoch": 1.6096794468887492,
1385
+ "grad_norm": 0.5509856939315796,
1386
+ "learning_rate": 9.250888670881011e-05,
1387
+ "loss": 0.3785,
1388
+ "step": 7683
1389
+ },
1390
+ {
1391
+ "epoch": 1.617850408548083,
1392
+ "grad_norm": 0.8195124864578247,
1393
+ "learning_rate": 9.242157158655875e-05,
1394
+ "loss": 0.3985,
1395
+ "step": 7722
1396
+ },
1397
+ {
1398
+ "epoch": 1.6260213702074169,
1399
+ "grad_norm": 0.6665972471237183,
1400
+ "learning_rate": 9.23337922481392e-05,
1401
+ "loss": 0.3827,
1402
+ "step": 7761
1403
+ },
1404
+ {
1405
+ "epoch": 1.6341923318667506,
1406
+ "grad_norm": 0.7980179786682129,
1407
+ "learning_rate": 9.224554965411435e-05,
1408
+ "loss": 0.3854,
1409
+ "step": 7800
1410
+ },
1411
+ {
1412
+ "epoch": 1.6423632935260843,
1413
+ "grad_norm": 0.7136581540107727,
1414
+ "learning_rate": 9.21568447701165e-05,
1415
+ "loss": 0.3632,
1416
+ "step": 7839
1417
+ },
1418
+ {
1419
+ "epoch": 1.650534255185418,
1420
+ "grad_norm": 0.5472484230995178,
1421
+ "learning_rate": 9.206767856683674e-05,
1422
+ "loss": 0.3906,
1423
+ "step": 7878
1424
+ },
1425
+ {
1426
+ "epoch": 1.6587052168447518,
1427
+ "grad_norm": 0.7572371959686279,
1428
+ "learning_rate": 9.19780520200143e-05,
1429
+ "loss": 0.4074,
1430
+ "step": 7917
1431
+ },
1432
+ {
1433
+ "epoch": 1.6668761785040855,
1434
+ "grad_norm": 0.7541080117225647,
1435
+ "learning_rate": 9.1887966110426e-05,
1436
+ "loss": 0.3769,
1437
+ "step": 7956
1438
+ },
1439
+ {
1440
+ "epoch": 1.6750471401634193,
1441
+ "grad_norm": 0.7768887281417847,
1442
+ "learning_rate": 9.179742182387538e-05,
1443
+ "loss": 0.3887,
1444
+ "step": 7995
1445
+ },
1446
+ {
1447
+ "epoch": 1.683218101822753,
1448
+ "grad_norm": 0.4816763699054718,
1449
+ "learning_rate": 9.170642015118195e-05,
1450
+ "loss": 0.3968,
1451
+ "step": 8034
1452
+ },
1453
+ {
1454
+ "epoch": 1.6913890634820867,
1455
+ "grad_norm": 0.798069953918457,
1456
+ "learning_rate": 9.16149620881704e-05,
1457
+ "loss": 0.3929,
1458
+ "step": 8073
1459
+ },
1460
+ {
1461
+ "epoch": 1.6995600251414205,
1462
+ "grad_norm": 0.6265507340431213,
1463
+ "learning_rate": 9.152304863565965e-05,
1464
+ "loss": 0.3509,
1465
+ "step": 8112
1466
+ },
1467
+ {
1468
+ "epoch": 1.7077309868007542,
1469
+ "grad_norm": 0.7725851535797119,
1470
+ "learning_rate": 9.143068079945191e-05,
1471
+ "loss": 0.416,
1472
+ "step": 8151
1473
+ },
1474
+ {
1475
+ "epoch": 1.715901948460088,
1476
+ "grad_norm": 0.7044919729232788,
1477
+ "learning_rate": 9.133785959032172e-05,
1478
+ "loss": 0.3901,
1479
+ "step": 8190
1480
+ },
1481
+ {
1482
+ "epoch": 1.7240729101194217,
1483
+ "grad_norm": 0.7072455883026123,
1484
+ "learning_rate": 9.124458602400476e-05,
1485
+ "loss": 0.4162,
1486
+ "step": 8229
1487
+ },
1488
+ {
1489
+ "epoch": 1.7322438717787554,
1490
+ "grad_norm": 0.6308450698852539,
1491
+ "learning_rate": 9.11508611211869e-05,
1492
+ "loss": 0.3617,
1493
+ "step": 8268
1494
+ },
1495
+ {
1496
+ "epoch": 1.7404148334380891,
1497
+ "grad_norm": 0.9505504369735718,
1498
+ "learning_rate": 9.105668590749292e-05,
1499
+ "loss": 0.4235,
1500
+ "step": 8307
1501
+ },
1502
+ {
1503
+ "epoch": 1.7485857950974228,
1504
+ "grad_norm": 0.6861995458602905,
1505
+ "learning_rate": 9.096206141347533e-05,
1506
+ "loss": 0.3757,
1507
+ "step": 8346
1508
+ },
1509
+ {
1510
+ "epoch": 1.7567567567567568,
1511
+ "grad_norm": 0.7003109455108643,
1512
+ "learning_rate": 9.086698867460306e-05,
1513
+ "loss": 0.3672,
1514
+ "step": 8385
1515
+ },
1516
+ {
1517
+ "epoch": 1.7649277184160905,
1518
+ "grad_norm": 0.7863865494728088,
1519
+ "learning_rate": 9.07714687312502e-05,
1520
+ "loss": 0.4294,
1521
+ "step": 8424
1522
+ },
1523
+ {
1524
+ "epoch": 1.7730986800754243,
1525
+ "grad_norm": 0.7616212964057922,
1526
+ "learning_rate": 9.067550262868449e-05,
1527
+ "loss": 0.3681,
1528
+ "step": 8463
1529
+ },
1530
+ {
1531
+ "epoch": 1.781269641734758,
1532
+ "grad_norm": 0.7139325737953186,
1533
+ "learning_rate": 9.057909141705603e-05,
1534
+ "loss": 0.4084,
1535
+ "step": 8502
1536
+ },
1537
+ {
1538
+ "epoch": 1.7894406033940917,
1539
+ "grad_norm": 0.6723546981811523,
1540
+ "learning_rate": 9.04822361513857e-05,
1541
+ "loss": 0.4052,
1542
+ "step": 8541
1543
+ },
1544
+ {
1545
+ "epoch": 1.7976115650534257,
1546
+ "grad_norm": 0.6281395554542542,
1547
+ "learning_rate": 9.038493789155356e-05,
1548
+ "loss": 0.3924,
1549
+ "step": 8580
1550
+ },
1551
+ {
1552
+ "epoch": 1.8057825267127594,
1553
+ "grad_norm": 0.7400838732719421,
1554
+ "learning_rate": 9.028719770228744e-05,
1555
+ "loss": 0.4011,
1556
+ "step": 8619
1557
+ },
1558
+ {
1559
+ "epoch": 1.8139534883720931,
1560
+ "grad_norm": 1.0410945415496826,
1561
+ "learning_rate": 9.01890166531511e-05,
1562
+ "loss": 0.385,
1563
+ "step": 8658
1564
+ },
1565
+ {
1566
+ "epoch": 1.8221244500314269,
1567
+ "grad_norm": 0.7112125158309937,
1568
+ "learning_rate": 9.009039581853259e-05,
1569
+ "loss": 0.4204,
1570
+ "step": 8697
1571
+ },
1572
+ {
1573
+ "epoch": 1.8302954116907606,
1574
+ "grad_norm": 0.667522668838501,
1575
+ "learning_rate": 8.999133627763252e-05,
1576
+ "loss": 0.4274,
1577
+ "step": 8736
1578
+ },
1579
+ {
1580
+ "epoch": 1.8384663733500943,
1581
+ "grad_norm": 0.6372833251953125,
1582
+ "learning_rate": 8.989183911445228e-05,
1583
+ "loss": 0.3725,
1584
+ "step": 8775
1585
+ },
1586
+ {
1587
+ "epoch": 1.846637335009428,
1588
+ "grad_norm": 0.8261222839355469,
1589
+ "learning_rate": 8.979190541778199e-05,
1590
+ "loss": 0.4256,
1591
+ "step": 8814
1592
+ },
1593
+ {
1594
+ "epoch": 1.8548082966687618,
1595
+ "grad_norm": 0.6333631873130798,
1596
+ "learning_rate": 8.969153628118891e-05,
1597
+ "loss": 0.3836,
1598
+ "step": 8853
1599
+ },
1600
+ {
1601
+ "epoch": 1.8629792583280955,
1602
+ "grad_norm": 0.6916419863700867,
1603
+ "learning_rate": 8.959073280300514e-05,
1604
+ "loss": 0.3756,
1605
+ "step": 8892
1606
+ },
1607
+ {
1608
+ "epoch": 1.8711502199874293,
1609
+ "grad_norm": 0.5185075998306274,
1610
+ "learning_rate": 8.948949608631578e-05,
1611
+ "loss": 0.3772,
1612
+ "step": 8931
1613
+ },
1614
+ {
1615
+ "epoch": 1.879321181646763,
1616
+ "grad_norm": 0.8508359789848328,
1617
+ "learning_rate": 8.93878272389469e-05,
1618
+ "loss": 0.42,
1619
+ "step": 8970
1620
+ },
1621
+ {
1622
+ "epoch": 1.8874921433060967,
1623
+ "grad_norm": 0.6042287349700928,
1624
+ "learning_rate": 8.928572737345328e-05,
1625
+ "loss": 0.4111,
1626
+ "step": 9009
1627
+ },
1628
+ {
1629
+ "epoch": 1.8956631049654304,
1630
+ "grad_norm": 0.8972792625427246,
1631
+ "learning_rate": 8.918319760710629e-05,
1632
+ "loss": 0.4178,
1633
+ "step": 9048
1634
+ },
1635
+ {
1636
+ "epoch": 1.9038340666247642,
1637
+ "grad_norm": 0.7205092310905457,
1638
+ "learning_rate": 8.90802390618817e-05,
1639
+ "loss": 0.3947,
1640
+ "step": 9087
1641
+ },
1642
+ {
1643
+ "epoch": 1.912005028284098,
1644
+ "grad_norm": 0.7933651804924011,
1645
+ "learning_rate": 8.897685286444737e-05,
1646
+ "loss": 0.3934,
1647
+ "step": 9126
1648
+ },
1649
+ {
1650
+ "epoch": 1.9201759899434316,
1651
+ "grad_norm": 0.7529005408287048,
1652
+ "learning_rate": 8.887304014615094e-05,
1653
+ "loss": 0.3951,
1654
+ "step": 9165
1655
+ },
1656
+ {
1657
+ "epoch": 1.9283469516027656,
1658
+ "grad_norm": 0.5970722436904907,
1659
+ "learning_rate": 8.876880204300744e-05,
1660
+ "loss": 0.3671,
1661
+ "step": 9204
1662
+ },
1663
+ {
1664
+ "epoch": 1.9365179132620993,
1665
+ "grad_norm": 0.7347320914268494,
1666
+ "learning_rate": 8.86641396956868e-05,
1667
+ "loss": 0.4362,
1668
+ "step": 9243
1669
+ },
1670
+ {
1671
+ "epoch": 1.944688874921433,
1672
+ "grad_norm": 0.6225306391716003,
1673
+ "learning_rate": 8.855905424950149e-05,
1674
+ "loss": 0.4039,
1675
+ "step": 9282
1676
+ },
1677
+ {
1678
+ "epoch": 1.9528598365807668,
1679
+ "grad_norm": 0.7711159586906433,
1680
+ "learning_rate": 8.845354685439388e-05,
1681
+ "loss": 0.3766,
1682
+ "step": 9321
1683
+ },
1684
+ {
1685
+ "epoch": 1.9610307982401005,
1686
+ "grad_norm": 0.7624640464782715,
1687
+ "learning_rate": 8.834761866492373e-05,
1688
+ "loss": 0.3854,
1689
+ "step": 9360
1690
+ },
1691
+ {
1692
+ "epoch": 1.9692017598994345,
1693
+ "grad_norm": 0.8946365118026733,
1694
+ "learning_rate": 8.824127084025551e-05,
1695
+ "loss": 0.3675,
1696
+ "step": 9399
1697
+ },
1698
+ {
1699
+ "epoch": 1.9773727215587682,
1700
+ "grad_norm": 0.5043982863426208,
1701
+ "learning_rate": 8.813450454414567e-05,
1702
+ "loss": 0.4078,
1703
+ "step": 9438
1704
+ },
1705
+ {
1706
+ "epoch": 1.985543683218102,
1707
+ "grad_norm": 0.6283956170082092,
1708
+ "learning_rate": 8.802732094493007e-05,
1709
+ "loss": 0.382,
1710
+ "step": 9477
1711
+ },
1712
+ {
1713
+ "epoch": 1.9937146448774357,
1714
+ "grad_norm": 0.6801990866661072,
1715
+ "learning_rate": 8.7919721215511e-05,
1716
+ "loss": 0.3883,
1717
+ "step": 9516
1718
+ },
1719
+ {
1720
+ "epoch": 2.0018856065367694,
1721
+ "grad_norm": 0.6821087598800659,
1722
+ "learning_rate": 8.781170653334445e-05,
1723
+ "loss": 0.3598,
1724
+ "step": 9555
1725
+ },
1726
+ {
1727
+ "epoch": 2.010056568196103,
1728
+ "grad_norm": 0.8372517824172974,
1729
+ "learning_rate": 8.770327808042724e-05,
1730
+ "loss": 0.3097,
1731
+ "step": 9594
1732
+ },
1733
+ {
1734
+ "epoch": 2.018227529855437,
1735
+ "grad_norm": 0.5700801014900208,
1736
+ "learning_rate": 8.759443704328405e-05,
1737
+ "loss": 0.2982,
1738
+ "step": 9633
1739
+ },
1740
+ {
1741
+ "epoch": 2.0263984915147706,
1742
+ "grad_norm": 0.7326349020004272,
1743
+ "learning_rate": 8.748518461295438e-05,
1744
+ "loss": 0.344,
1745
+ "step": 9672
1746
+ },
1747
+ {
1748
+ "epoch": 2.0345694531741043,
1749
+ "grad_norm": 0.7985721230506897,
1750
+ "learning_rate": 8.737552198497965e-05,
1751
+ "loss": 0.3516,
1752
+ "step": 9711
1753
+ },
1754
+ {
1755
+ "epoch": 2.042740414833438,
1756
+ "grad_norm": 0.8567628264427185,
1757
+ "learning_rate": 8.726545035939e-05,
1758
+ "loss": 0.3252,
1759
+ "step": 9750
1760
+ },
1761
+ {
1762
+ "epoch": 2.0509113764927718,
1763
+ "grad_norm": 0.9082648158073425,
1764
+ "learning_rate": 8.715497094069121e-05,
1765
+ "loss": 0.3487,
1766
+ "step": 9789
1767
+ },
1768
+ {
1769
+ "epoch": 2.0590823381521055,
1770
+ "grad_norm": 1.0632450580596924,
1771
+ "learning_rate": 8.70440849378515e-05,
1772
+ "loss": 0.3224,
1773
+ "step": 9828
1774
+ },
1775
+ {
1776
+ "epoch": 2.0672532998114392,
1777
+ "grad_norm": 0.8348027467727661,
1778
+ "learning_rate": 8.693279356428835e-05,
1779
+ "loss": 0.313,
1780
+ "step": 9867
1781
+ },
1782
+ {
1783
+ "epoch": 2.075424261470773,
1784
+ "grad_norm": 0.6354735493659973,
1785
+ "learning_rate": 8.682109803785514e-05,
1786
+ "loss": 0.3337,
1787
+ "step": 9906
1788
+ },
1789
+ {
1790
+ "epoch": 2.0835952231301067,
1791
+ "grad_norm": 0.9293564558029175,
1792
+ "learning_rate": 8.67089995808279e-05,
1793
+ "loss": 0.3353,
1794
+ "step": 9945
1795
+ },
1796
+ {
1797
+ "epoch": 2.0917661847894404,
1798
+ "grad_norm": 0.653914213180542,
1799
+ "learning_rate": 8.659649941989186e-05,
1800
+ "loss": 0.3348,
1801
+ "step": 9984
1802
+ },
1803
+ {
1804
+ "epoch": 2.0951183741881416,
1805
+ "eval_accuracy": 0.009820309467613697,
1806
+ "eval_loss": 0.4311712086200714,
1807
+ "eval_runtime": 816.6202,
1808
+ "eval_samples_per_second": 5.86,
1809
+ "eval_steps_per_second": 1.466,
1810
+ "step": 10000
1811
+ },
1812
+ {
1813
+ "epoch": 2.099937146448774,
1814
+ "grad_norm": 0.7376769781112671,
1815
+ "learning_rate": 8.648359878612807e-05,
1816
+ "loss": 0.3043,
1817
+ "step": 10023
1818
+ },
1819
+ {
1820
+ "epoch": 2.108108108108108,
1821
+ "grad_norm": 0.965570330619812,
1822
+ "learning_rate": 8.637029891499997e-05,
1823
+ "loss": 0.3619,
1824
+ "step": 10062
1825
+ },
1826
+ {
1827
+ "epoch": 2.116279069767442,
1828
+ "grad_norm": 0.8820568919181824,
1829
+ "learning_rate": 8.625660104633981e-05,
1830
+ "loss": 0.3519,
1831
+ "step": 10101
1832
+ },
1833
+ {
1834
+ "epoch": 2.124450031426776,
1835
+ "grad_norm": 0.9719869494438171,
1836
+ "learning_rate": 8.614250642433506e-05,
1837
+ "loss": 0.3524,
1838
+ "step": 10140
1839
+ },
1840
+ {
1841
+ "epoch": 2.1326209930861095,
1842
+ "grad_norm": 0.8123674392700195,
1843
+ "learning_rate": 8.602801629751486e-05,
1844
+ "loss": 0.3324,
1845
+ "step": 10179
1846
+ },
1847
+ {
1848
+ "epoch": 2.1407919547454433,
1849
+ "grad_norm": 0.4851992130279541,
1850
+ "learning_rate": 8.591313191873634e-05,
1851
+ "loss": 0.3331,
1852
+ "step": 10218
1853
+ },
1854
+ {
1855
+ "epoch": 2.148962916404777,
1856
+ "grad_norm": 0.7514449954032898,
1857
+ "learning_rate": 8.579785454517089e-05,
1858
+ "loss": 0.3195,
1859
+ "step": 10257
1860
+ },
1861
+ {
1862
+ "epoch": 2.1571338780641107,
1863
+ "grad_norm": 0.6087148785591125,
1864
+ "learning_rate": 8.568218543829039e-05,
1865
+ "loss": 0.3819,
1866
+ "step": 10296
1867
+ },
1868
+ {
1869
+ "epoch": 2.1653048397234445,
1870
+ "grad_norm": 0.547778308391571,
1871
+ "learning_rate": 8.556612586385349e-05,
1872
+ "loss": 0.3231,
1873
+ "step": 10335
1874
+ },
1875
+ {
1876
+ "epoch": 2.173475801382778,
1877
+ "grad_norm": 1.0253907442092896,
1878
+ "learning_rate": 8.544967709189162e-05,
1879
+ "loss": 0.3325,
1880
+ "step": 10374
1881
+ },
1882
+ {
1883
+ "epoch": 2.181646763042112,
1884
+ "grad_norm": 0.7467255592346191,
1885
+ "learning_rate": 8.533284039669524e-05,
1886
+ "loss": 0.3224,
1887
+ "step": 10413
1888
+ },
1889
+ {
1890
+ "epoch": 2.1898177247014456,
1891
+ "grad_norm": 0.8590918779373169,
1892
+ "learning_rate": 8.52156170567998e-05,
1893
+ "loss": 0.3293,
1894
+ "step": 10452
1895
+ },
1896
+ {
1897
+ "epoch": 2.1979886863607794,
1898
+ "grad_norm": 0.6754146814346313,
1899
+ "learning_rate": 8.509800835497175e-05,
1900
+ "loss": 0.3227,
1901
+ "step": 10491
1902
+ },
1903
+ {
1904
+ "epoch": 2.206159648020113,
1905
+ "grad_norm": 0.6803106069564819,
1906
+ "learning_rate": 8.498001557819455e-05,
1907
+ "loss": 0.3381,
1908
+ "step": 10530
1909
+ },
1910
+ {
1911
+ "epoch": 2.214330609679447,
1912
+ "grad_norm": 1.0634793043136597,
1913
+ "learning_rate": 8.486164001765457e-05,
1914
+ "loss": 0.3659,
1915
+ "step": 10569
1916
+ },
1917
+ {
1918
+ "epoch": 2.2225015713387806,
1919
+ "grad_norm": 0.6654180288314819,
1920
+ "learning_rate": 8.474288296872695e-05,
1921
+ "loss": 0.3359,
1922
+ "step": 10608
1923
+ },
1924
+ {
1925
+ "epoch": 2.2306725329981143,
1926
+ "grad_norm": 0.9800730347633362,
1927
+ "learning_rate": 8.462374573096143e-05,
1928
+ "loss": 0.3483,
1929
+ "step": 10647
1930
+ },
1931
+ {
1932
+ "epoch": 2.238843494657448,
1933
+ "grad_norm": 0.7170436382293701,
1934
+ "learning_rate": 8.45042296080681e-05,
1935
+ "loss": 0.3477,
1936
+ "step": 10686
1937
+ },
1938
+ {
1939
+ "epoch": 2.2470144563167818,
1940
+ "grad_norm": 0.8500722646713257,
1941
+ "learning_rate": 8.438433590790323e-05,
1942
+ "loss": 0.3347,
1943
+ "step": 10725
1944
+ },
1945
+ {
1946
+ "epoch": 2.2551854179761155,
1947
+ "grad_norm": 0.9178040623664856,
1948
+ "learning_rate": 8.426406594245482e-05,
1949
+ "loss": 0.3455,
1950
+ "step": 10764
1951
+ },
1952
+ {
1953
+ "epoch": 2.2633563796354492,
1954
+ "grad_norm": 1.0374339818954468,
1955
+ "learning_rate": 8.414342102782833e-05,
1956
+ "loss": 0.3548,
1957
+ "step": 10803
1958
+ },
1959
+ {
1960
+ "epoch": 2.2715273412947834,
1961
+ "grad_norm": 0.9963250160217285,
1962
+ "learning_rate": 8.40224024842323e-05,
1963
+ "loss": 0.3563,
1964
+ "step": 10842
1965
+ },
1966
+ {
1967
+ "epoch": 2.2796983029541167,
1968
+ "grad_norm": 0.8895733952522278,
1969
+ "learning_rate": 8.390101163596385e-05,
1970
+ "loss": 0.3229,
1971
+ "step": 10881
1972
+ },
1973
+ {
1974
+ "epoch": 2.287869264613451,
1975
+ "grad_norm": 0.7974137663841248,
1976
+ "learning_rate": 8.377924981139413e-05,
1977
+ "loss": 0.3201,
1978
+ "step": 10920
1979
+ },
1980
+ {
1981
+ "epoch": 2.2960402262727846,
1982
+ "grad_norm": 0.8204047083854675,
1983
+ "learning_rate": 8.3657118342954e-05,
1984
+ "loss": 0.341,
1985
+ "step": 10959
1986
+ },
1987
+ {
1988
+ "epoch": 2.3042111879321183,
1989
+ "grad_norm": 0.7952179312705994,
1990
+ "learning_rate": 8.353461856711916e-05,
1991
+ "loss": 0.3362,
1992
+ "step": 10998
1993
+ },
1994
+ {
1995
+ "epoch": 2.312382149591452,
1996
+ "grad_norm": 0.6790579557418823,
1997
+ "learning_rate": 8.341175182439577e-05,
1998
+ "loss": 0.322,
1999
+ "step": 11037
2000
+ },
2001
+ {
2002
+ "epoch": 2.320553111250786,
2003
+ "grad_norm": 0.7183639407157898,
2004
+ "learning_rate": 8.328851945930563e-05,
2005
+ "loss": 0.3193,
2006
+ "step": 11076
2007
+ },
2008
+ {
2009
+ "epoch": 2.3287240729101195,
2010
+ "grad_norm": 0.7216742038726807,
2011
+ "learning_rate": 8.316492282037154e-05,
2012
+ "loss": 0.3319,
2013
+ "step": 11115
2014
+ },
2015
+ {
2016
+ "epoch": 2.3368950345694532,
2017
+ "grad_norm": 0.7550281882286072,
2018
+ "learning_rate": 8.30409632601025e-05,
2019
+ "loss": 0.3249,
2020
+ "step": 11154
2021
+ },
2022
+ {
2023
+ "epoch": 2.345065996228787,
2024
+ "grad_norm": 0.9077494740486145,
2025
+ "learning_rate": 8.291664213497901e-05,
2026
+ "loss": 0.3097,
2027
+ "step": 11193
2028
+ },
2029
+ {
2030
+ "epoch": 2.3532369578881207,
2031
+ "grad_norm": 0.793636679649353,
2032
+ "learning_rate": 8.279196080543803e-05,
2033
+ "loss": 0.3515,
2034
+ "step": 11232
2035
+ },
2036
+ {
2037
+ "epoch": 2.3614079195474544,
2038
+ "grad_norm": 0.8357187509536743,
2039
+ "learning_rate": 8.266692063585828e-05,
2040
+ "loss": 0.3516,
2041
+ "step": 11271
2042
+ },
2043
+ {
2044
+ "epoch": 2.369578881206788,
2045
+ "grad_norm": 0.9153121709823608,
2046
+ "learning_rate": 8.254152299454522e-05,
2047
+ "loss": 0.3579,
2048
+ "step": 11310
2049
+ },
2050
+ {
2051
+ "epoch": 2.377749842866122,
2052
+ "grad_norm": 0.671792209148407,
2053
+ "learning_rate": 8.241576925371615e-05,
2054
+ "loss": 0.3215,
2055
+ "step": 11349
2056
+ },
2057
+ {
2058
+ "epoch": 2.3859208045254556,
2059
+ "grad_norm": 0.7391782999038696,
2060
+ "learning_rate": 8.228966078948503e-05,
2061
+ "loss": 0.3572,
2062
+ "step": 11388
2063
+ },
2064
+ {
2065
+ "epoch": 2.3940917661847894,
2066
+ "grad_norm": 0.5811970829963684,
2067
+ "learning_rate": 8.216319898184766e-05,
2068
+ "loss": 0.3054,
2069
+ "step": 11427
2070
+ },
2071
+ {
2072
+ "epoch": 2.402262727844123,
2073
+ "grad_norm": 0.5288280248641968,
2074
+ "learning_rate": 8.203638521466637e-05,
2075
+ "loss": 0.3348,
2076
+ "step": 11466
2077
+ },
2078
+ {
2079
+ "epoch": 2.410433689503457,
2080
+ "grad_norm": 0.8727484941482544,
2081
+ "learning_rate": 8.190922087565496e-05,
2082
+ "loss": 0.3514,
2083
+ "step": 11505
2084
+ },
2085
+ {
2086
+ "epoch": 2.4186046511627906,
2087
+ "grad_norm": 0.8370525240898132,
2088
+ "learning_rate": 8.178170735636354e-05,
2089
+ "loss": 0.3155,
2090
+ "step": 11544
2091
+ },
2092
+ {
2093
+ "epoch": 2.4267756128221243,
2094
+ "grad_norm": 0.6996369361877441,
2095
+ "learning_rate": 8.165384605216329e-05,
2096
+ "loss": 0.3474,
2097
+ "step": 11583
2098
+ },
2099
+ {
2100
+ "epoch": 2.434946574481458,
2101
+ "grad_norm": 0.6904685497283936,
2102
+ "learning_rate": 8.152563836223111e-05,
2103
+ "loss": 0.3453,
2104
+ "step": 11622
2105
+ },
2106
+ {
2107
+ "epoch": 2.443117536140792,
2108
+ "grad_norm": 0.7102589011192322,
2109
+ "learning_rate": 8.139708568953444e-05,
2110
+ "loss": 0.337,
2111
+ "step": 11661
2112
+ },
2113
+ {
2114
+ "epoch": 2.4512884978001255,
2115
+ "grad_norm": 0.7969030737876892,
2116
+ "learning_rate": 8.12681894408158e-05,
2117
+ "loss": 0.3213,
2118
+ "step": 11700
2119
+ },
2120
+ {
2121
+ "epoch": 2.4594594594594597,
2122
+ "grad_norm": 0.961298942565918,
2123
+ "learning_rate": 8.113895102657744e-05,
2124
+ "loss": 0.3386,
2125
+ "step": 11739
2126
+ },
2127
+ {
2128
+ "epoch": 2.4676304211187934,
2129
+ "grad_norm": 0.8089680075645447,
2130
+ "learning_rate": 8.100937186106596e-05,
2131
+ "loss": 0.3091,
2132
+ "step": 11778
2133
+ },
2134
+ {
2135
+ "epoch": 2.475801382778127,
2136
+ "grad_norm": 1.0000693798065186,
2137
+ "learning_rate": 8.087945336225668e-05,
2138
+ "loss": 0.3335,
2139
+ "step": 11817
2140
+ },
2141
+ {
2142
+ "epoch": 2.483972344437461,
2143
+ "grad_norm": 0.6780822277069092,
2144
+ "learning_rate": 8.074919695183831e-05,
2145
+ "loss": 0.3306,
2146
+ "step": 11856
2147
+ },
2148
+ {
2149
+ "epoch": 2.4921433060967946,
2150
+ "grad_norm": 0.8540327548980713,
2151
+ "learning_rate": 8.061860405519724e-05,
2152
+ "loss": 0.3527,
2153
+ "step": 11895
2154
+ },
2155
+ {
2156
+ "epoch": 2.5003142677561283,
2157
+ "grad_norm": 0.8583691120147705,
2158
+ "learning_rate": 8.048767610140204e-05,
2159
+ "loss": 0.3257,
2160
+ "step": 11934
2161
+ },
2162
+ {
2163
+ "epoch": 2.508485229415462,
2164
+ "grad_norm": 0.6268760561943054,
2165
+ "learning_rate": 8.035641452318775e-05,
2166
+ "loss": 0.2978,
2167
+ "step": 11973
2168
+ },
2169
+ {
2170
+ "epoch": 2.5166561910747958,
2171
+ "grad_norm": 0.9798884391784668,
2172
+ "learning_rate": 8.022482075694027e-05,
2173
+ "loss": 0.3297,
2174
+ "step": 12012
2175
+ },
2176
+ {
2177
+ "epoch": 2.5248271527341295,
2178
+ "grad_norm": 0.8267270922660828,
2179
+ "learning_rate": 8.009289624268062e-05,
2180
+ "loss": 0.3509,
2181
+ "step": 12051
2182
+ },
2183
+ {
2184
+ "epoch": 2.5329981143934632,
2185
+ "grad_norm": 0.6128790974617004,
2186
+ "learning_rate": 7.996064242404912e-05,
2187
+ "loss": 0.3134,
2188
+ "step": 12090
2189
+ },
2190
+ {
2191
+ "epoch": 2.541169076052797,
2192
+ "grad_norm": 0.8551040887832642,
2193
+ "learning_rate": 7.98280607482897e-05,
2194
+ "loss": 0.3563,
2195
+ "step": 12129
2196
+ },
2197
+ {
2198
+ "epoch": 2.5493400377121307,
2199
+ "grad_norm": 0.9739424586296082,
2200
+ "learning_rate": 7.969515266623396e-05,
2201
+ "loss": 0.3468,
2202
+ "step": 12168
2203
+ },
2204
+ {
2205
+ "epoch": 2.5575109993714644,
2206
+ "grad_norm": 0.6370837092399597,
2207
+ "learning_rate": 7.956191963228538e-05,
2208
+ "loss": 0.3462,
2209
+ "step": 12207
2210
+ },
2211
+ {
2212
+ "epoch": 2.565681961030798,
2213
+ "grad_norm": 0.6456401944160461,
2214
+ "learning_rate": 7.942836310440334e-05,
2215
+ "loss": 0.3266,
2216
+ "step": 12246
2217
+ },
2218
+ {
2219
+ "epoch": 2.573852922690132,
2220
+ "grad_norm": 0.8971288800239563,
2221
+ "learning_rate": 7.929448454408719e-05,
2222
+ "loss": 0.3292,
2223
+ "step": 12285
2224
+ },
2225
+ {
2226
+ "epoch": 2.5820238843494656,
2227
+ "grad_norm": 0.8512323498725891,
2228
+ "learning_rate": 7.916028541636027e-05,
2229
+ "loss": 0.3402,
2230
+ "step": 12324
2231
+ },
2232
+ {
2233
+ "epoch": 2.5901948460087993,
2234
+ "grad_norm": 0.7138497233390808,
2235
+ "learning_rate": 7.902576718975387e-05,
2236
+ "loss": 0.3658,
2237
+ "step": 12363
2238
+ },
2239
+ {
2240
+ "epoch": 2.5983658076681335,
2241
+ "grad_norm": 0.9771799445152283,
2242
+ "learning_rate": 7.889093133629115e-05,
2243
+ "loss": 0.312,
2244
+ "step": 12402
2245
+ },
2246
+ {
2247
+ "epoch": 2.606536769327467,
2248
+ "grad_norm": 0.8607495427131653,
2249
+ "learning_rate": 7.875577933147101e-05,
2250
+ "loss": 0.3289,
2251
+ "step": 12441
2252
+ },
2253
+ {
2254
+ "epoch": 2.614707730986801,
2255
+ "grad_norm": 0.9107287526130676,
2256
+ "learning_rate": 7.8620312654252e-05,
2257
+ "loss": 0.3435,
2258
+ "step": 12480
2259
+ },
2260
+ {
2261
+ "epoch": 2.6228786926461343,
2262
+ "grad_norm": 0.7893658876419067,
2263
+ "learning_rate": 7.848453278703613e-05,
2264
+ "loss": 0.3325,
2265
+ "step": 12519
2266
+ },
2267
+ {
2268
+ "epoch": 2.6310496543054684,
2269
+ "grad_norm": 0.6861433982849121,
2270
+ "learning_rate": 7.834844121565257e-05,
2271
+ "loss": 0.3185,
2272
+ "step": 12558
2273
+ },
2274
+ {
2275
+ "epoch": 2.639220615964802,
2276
+ "grad_norm": 0.6425657272338867,
2277
+ "learning_rate": 7.821203942934148e-05,
2278
+ "loss": 0.3314,
2279
+ "step": 12597
2280
+ },
2281
+ {
2282
+ "epoch": 2.647391577624136,
2283
+ "grad_norm": 0.6099838018417358,
2284
+ "learning_rate": 7.807532892073768e-05,
2285
+ "loss": 0.3302,
2286
+ "step": 12636
2287
+ },
2288
+ {
2289
+ "epoch": 2.6555625392834696,
2290
+ "grad_norm": 0.8393537402153015,
2291
+ "learning_rate": 7.793831118585429e-05,
2292
+ "loss": 0.3088,
2293
+ "step": 12675
2294
+ },
2295
+ {
2296
+ "epoch": 2.6637335009428034,
2297
+ "grad_norm": 0.752255916595459,
2298
+ "learning_rate": 7.780098772406643e-05,
2299
+ "loss": 0.3205,
2300
+ "step": 12714
2301
+ },
2302
+ {
2303
+ "epoch": 2.671904462602137,
2304
+ "grad_norm": 0.7880775928497314,
2305
+ "learning_rate": 7.766336003809472e-05,
2306
+ "loss": 0.3306,
2307
+ "step": 12753
2308
+ },
2309
+ {
2310
+ "epoch": 2.680075424261471,
2311
+ "grad_norm": 0.708419919013977,
2312
+ "learning_rate": 7.752542963398892e-05,
2313
+ "loss": 0.3554,
2314
+ "step": 12792
2315
+ },
2316
+ {
2317
+ "epoch": 2.6882463859208046,
2318
+ "grad_norm": 0.8341570496559143,
2319
+ "learning_rate": 7.738719802111139e-05,
2320
+ "loss": 0.3145,
2321
+ "step": 12831
2322
+ },
2323
+ {
2324
+ "epoch": 2.6964173475801383,
2325
+ "grad_norm": 0.703484058380127,
2326
+ "learning_rate": 7.724866671212059e-05,
2327
+ "loss": 0.3284,
2328
+ "step": 12870
2329
+ },
2330
+ {
2331
+ "epoch": 2.704588309239472,
2332
+ "grad_norm": 0.7732682228088379,
2333
+ "learning_rate": 7.710983722295455e-05,
2334
+ "loss": 0.3376,
2335
+ "step": 12909
2336
+ },
2337
+ {
2338
+ "epoch": 2.7127592708988058,
2339
+ "grad_norm": 0.7687979340553284,
2340
+ "learning_rate": 7.697071107281428e-05,
2341
+ "loss": 0.3418,
2342
+ "step": 12948
2343
+ },
2344
+ {
2345
+ "epoch": 2.7209302325581395,
2346
+ "grad_norm": 0.6588707566261292,
2347
+ "learning_rate": 7.683128978414707e-05,
2348
+ "loss": 0.3352,
2349
+ "step": 12987
2350
+ },
2351
+ {
2352
+ "epoch": 2.729101194217473,
2353
+ "grad_norm": 1.0603809356689453,
2354
+ "learning_rate": 7.669157488262997e-05,
2355
+ "loss": 0.3409,
2356
+ "step": 13026
2357
+ },
2358
+ {
2359
+ "epoch": 2.737272155876807,
2360
+ "grad_norm": 0.603203296661377,
2361
+ "learning_rate": 7.655156789715295e-05,
2362
+ "loss": 0.3578,
2363
+ "step": 13065
2364
+ },
2365
+ {
2366
+ "epoch": 2.7454431175361407,
2367
+ "grad_norm": 0.9588086605072021,
2368
+ "learning_rate": 7.641127035980222e-05,
2369
+ "loss": 0.3463,
2370
+ "step": 13104
2371
+ },
2372
+ {
2373
+ "epoch": 2.7536140791954744,
2374
+ "grad_norm": 0.7366406917572021,
2375
+ "learning_rate": 7.627068380584359e-05,
2376
+ "loss": 0.3262,
2377
+ "step": 13143
2378
+ },
2379
+ {
2380
+ "epoch": 2.761785040854808,
2381
+ "grad_norm": 0.7737981677055359,
2382
+ "learning_rate": 7.612980977370542e-05,
2383
+ "loss": 0.3463,
2384
+ "step": 13182
2385
+ },
2386
+ {
2387
+ "epoch": 2.7699560025141423,
2388
+ "grad_norm": 0.7862906455993652,
2389
+ "learning_rate": 7.5988649804962e-05,
2390
+ "loss": 0.3257,
2391
+ "step": 13221
2392
+ },
2393
+ {
2394
+ "epoch": 2.7781269641734756,
2395
+ "grad_norm": 0.8357959389686584,
2396
+ "learning_rate": 7.584720544431661e-05,
2397
+ "loss": 0.3365,
2398
+ "step": 13260
2399
+ },
2400
+ {
2401
+ "epoch": 2.7862979258328098,
2402
+ "grad_norm": 0.8603371381759644,
2403
+ "learning_rate": 7.570547823958454e-05,
2404
+ "loss": 0.3296,
2405
+ "step": 13299
2406
+ },
2407
+ {
2408
+ "epoch": 2.794468887492143,
2409
+ "grad_norm": 1.0153621435165405,
2410
+ "learning_rate": 7.55634697416763e-05,
2411
+ "loss": 0.3621,
2412
+ "step": 13338
2413
+ },
2414
+ {
2415
+ "epoch": 2.8026398491514772,
2416
+ "grad_norm": 0.6060919761657715,
2417
+ "learning_rate": 7.542118150458054e-05,
2418
+ "loss": 0.3263,
2419
+ "step": 13377
2420
+ },
2421
+ {
2422
+ "epoch": 2.810810810810811,
2423
+ "grad_norm": 0.6489693522453308,
2424
+ "learning_rate": 7.527861508534706e-05,
2425
+ "loss": 0.3632,
2426
+ "step": 13416
2427
+ },
2428
+ {
2429
+ "epoch": 2.8189817724701447,
2430
+ "grad_norm": 0.7105704545974731,
2431
+ "learning_rate": 7.513577204406985e-05,
2432
+ "loss": 0.3522,
2433
+ "step": 13455
2434
+ },
2435
+ {
2436
+ "epoch": 2.8271527341294784,
2437
+ "grad_norm": 0.7109383940696716,
2438
+ "learning_rate": 7.499265394386983e-05,
2439
+ "loss": 0.3462,
2440
+ "step": 13494
2441
+ },
2442
+ {
2443
+ "epoch": 2.835323695788812,
2444
+ "grad_norm": 0.7103734016418457,
2445
+ "learning_rate": 7.484926235087799e-05,
2446
+ "loss": 0.3559,
2447
+ "step": 13533
2448
+ },
2449
+ {
2450
+ "epoch": 2.843494657448146,
2451
+ "grad_norm": 0.6860262155532837,
2452
+ "learning_rate": 7.470559883421809e-05,
2453
+ "loss": 0.3576,
2454
+ "step": 13572
2455
+ },
2456
+ {
2457
+ "epoch": 2.8516656191074796,
2458
+ "grad_norm": 0.7737835645675659,
2459
+ "learning_rate": 7.456166496598953e-05,
2460
+ "loss": 0.3712,
2461
+ "step": 13611
2462
+ },
2463
+ {
2464
+ "epoch": 2.8598365807668134,
2465
+ "grad_norm": 0.8572138547897339,
2466
+ "learning_rate": 7.441746232125013e-05,
2467
+ "loss": 0.3201,
2468
+ "step": 13650
2469
+ },
2470
+ {
2471
+ "epoch": 2.868007542426147,
2472
+ "grad_norm": 0.9748623967170715,
2473
+ "learning_rate": 7.427299247799895e-05,
2474
+ "loss": 0.3563,
2475
+ "step": 13689
2476
+ },
2477
+ {
2478
+ "epoch": 2.876178504085481,
2479
+ "grad_norm": 0.8315281867980957,
2480
+ "learning_rate": 7.412825701715893e-05,
2481
+ "loss": 0.3346,
2482
+ "step": 13728
2483
+ },
2484
+ {
2485
+ "epoch": 2.8843494657448145,
2486
+ "grad_norm": 0.890327513217926,
2487
+ "learning_rate": 7.398325752255973e-05,
2488
+ "loss": 0.3337,
2489
+ "step": 13767
2490
+ },
2491
+ {
2492
+ "epoch": 2.8925204274041483,
2493
+ "grad_norm": 0.6312198638916016,
2494
+ "learning_rate": 7.38379955809202e-05,
2495
+ "loss": 0.337,
2496
+ "step": 13806
2497
+ },
2498
+ {
2499
+ "epoch": 2.900691389063482,
2500
+ "grad_norm": 0.6604064702987671,
2501
+ "learning_rate": 7.369247278183123e-05,
2502
+ "loss": 0.3397,
2503
+ "step": 13845
2504
+ },
2505
+ {
2506
+ "epoch": 2.9088623507228157,
2507
+ "grad_norm": 0.5490432381629944,
2508
+ "learning_rate": 7.35466907177382e-05,
2509
+ "loss": 0.326,
2510
+ "step": 13884
2511
+ },
2512
+ {
2513
+ "epoch": 2.9170333123821495,
2514
+ "grad_norm": 0.9371681809425354,
2515
+ "learning_rate": 7.340065098392361e-05,
2516
+ "loss": 0.3435,
2517
+ "step": 13923
2518
+ },
2519
+ {
2520
+ "epoch": 2.925204274041483,
2521
+ "grad_norm": 0.8379968404769897,
2522
+ "learning_rate": 7.325435517848963e-05,
2523
+ "loss": 0.3321,
2524
+ "step": 13962
2525
+ },
2526
+ {
2527
+ "epoch": 2.933375235700817,
2528
+ "grad_norm": 0.3769962191581726,
2529
+ "learning_rate": 7.310780490234061e-05,
2530
+ "loss": 0.3707,
2531
+ "step": 14001
2532
+ },
2533
+ {
2534
+ "epoch": 2.941546197360151,
2535
+ "grad_norm": 0.659055233001709,
2536
+ "learning_rate": 7.296100175916556e-05,
2537
+ "loss": 0.331,
2538
+ "step": 14040
2539
+ },
2540
+ {
2541
+ "epoch": 2.9497171590194844,
2542
+ "grad_norm": 0.840793251991272,
2543
+ "learning_rate": 7.281394735542056e-05,
2544
+ "loss": 0.3382,
2545
+ "step": 14079
2546
+ },
2547
+ {
2548
+ "epoch": 2.9578881206788186,
2549
+ "grad_norm": 0.8272313475608826,
2550
+ "learning_rate": 7.266664330031128e-05,
2551
+ "loss": 0.316,
2552
+ "step": 14118
2553
+ },
2554
+ {
2555
+ "epoch": 2.966059082338152,
2556
+ "grad_norm": 0.9367392063140869,
2557
+ "learning_rate": 7.25190912057752e-05,
2558
+ "loss": 0.336,
2559
+ "step": 14157
2560
+ },
2561
+ {
2562
+ "epoch": 2.974230043997486,
2563
+ "grad_norm": 0.6122297048568726,
2564
+ "learning_rate": 7.237129268646419e-05,
2565
+ "loss": 0.323,
2566
+ "step": 14196
2567
+ },
2568
+ {
2569
+ "epoch": 2.9824010056568198,
2570
+ "grad_norm": 0.7298004031181335,
2571
+ "learning_rate": 7.22232493597267e-05,
2572
+ "loss": 0.3361,
2573
+ "step": 14235
2574
+ },
2575
+ {
2576
+ "epoch": 2.9905719673161535,
2577
+ "grad_norm": 0.7116037607192993,
2578
+ "learning_rate": 7.207496284559003e-05,
2579
+ "loss": 0.3035,
2580
+ "step": 14274
2581
+ },
2582
+ {
2583
+ "epoch": 2.998742928975487,
2584
+ "grad_norm": 0.886817216873169,
2585
+ "learning_rate": 7.192643476674272e-05,
2586
+ "loss": 0.3156,
2587
+ "step": 14313
2588
+ },
2589
+ {
2590
+ "epoch": 3.006913890634821,
2591
+ "grad_norm": 0.7054494619369507,
2592
+ "learning_rate": 7.177766674851674e-05,
2593
+ "loss": 0.2916,
2594
+ "step": 14352
2595
+ },
2596
+ {
2597
+ "epoch": 3.0150848522941547,
2598
+ "grad_norm": 0.6415011882781982,
2599
+ "learning_rate": 7.162866041886963e-05,
2600
+ "loss": 0.2485,
2601
+ "step": 14391
2602
+ },
2603
+ {
2604
+ "epoch": 3.0232558139534884,
2605
+ "grad_norm": 0.9112984538078308,
2606
+ "learning_rate": 7.147941740836686e-05,
2607
+ "loss": 0.2598,
2608
+ "step": 14430
2609
+ },
2610
+ {
2611
+ "epoch": 3.031426775612822,
2612
+ "grad_norm": 0.9063923358917236,
2613
+ "learning_rate": 7.132993935016377e-05,
2614
+ "loss": 0.255,
2615
+ "step": 14469
2616
+ },
2617
+ {
2618
+ "epoch": 3.039597737272156,
2619
+ "grad_norm": 0.897348165512085,
2620
+ "learning_rate": 7.118022787998788e-05,
2621
+ "loss": 0.2622,
2622
+ "step": 14508
2623
+ },
2624
+ {
2625
+ "epoch": 3.0477686989314896,
2626
+ "grad_norm": 0.9947516322135925,
2627
+ "learning_rate": 7.103028463612094e-05,
2628
+ "loss": 0.2539,
2629
+ "step": 14547
2630
+ },
2631
+ {
2632
+ "epoch": 3.0559396605908233,
2633
+ "grad_norm": 0.9619819521903992,
2634
+ "learning_rate": 7.088011125938091e-05,
2635
+ "loss": 0.2546,
2636
+ "step": 14586
2637
+ },
2638
+ {
2639
+ "epoch": 3.064110622250157,
2640
+ "grad_norm": 0.9941222071647644,
2641
+ "learning_rate": 7.072970939310412e-05,
2642
+ "loss": 0.2605,
2643
+ "step": 14625
2644
+ },
2645
+ {
2646
+ "epoch": 3.072281583909491,
2647
+ "grad_norm": 0.8076801896095276,
2648
+ "learning_rate": 7.057908068312726e-05,
2649
+ "loss": 0.2748,
2650
+ "step": 14664
2651
+ },
2652
+ {
2653
+ "epoch": 3.0804525455688245,
2654
+ "grad_norm": 0.9070518016815186,
2655
+ "learning_rate": 7.042822677776929e-05,
2656
+ "loss": 0.26,
2657
+ "step": 14703
2658
+ },
2659
+ {
2660
+ "epoch": 3.0886235072281583,
2661
+ "grad_norm": 1.0293809175491333,
2662
+ "learning_rate": 7.027714932781355e-05,
2663
+ "loss": 0.2703,
2664
+ "step": 14742
2665
+ },
2666
+ {
2667
+ "epoch": 3.096794468887492,
2668
+ "grad_norm": 0.982684850692749,
2669
+ "learning_rate": 7.012584998648956e-05,
2670
+ "loss": 0.2693,
2671
+ "step": 14781
2672
+ },
2673
+ {
2674
+ "epoch": 3.1049654305468257,
2675
+ "grad_norm": 1.306250810623169,
2676
+ "learning_rate": 6.997433040945498e-05,
2677
+ "loss": 0.2772,
2678
+ "step": 14820
2679
+ },
2680
+ {
2681
+ "epoch": 3.1131363922061595,
2682
+ "grad_norm": 0.8497562408447266,
2683
+ "learning_rate": 6.982259225477753e-05,
2684
+ "loss": 0.278,
2685
+ "step": 14859
2686
+ },
2687
+ {
2688
+ "epoch": 3.121307353865493,
2689
+ "grad_norm": 0.9325224161148071,
2690
+ "learning_rate": 6.967063718291673e-05,
2691
+ "loss": 0.2726,
2692
+ "step": 14898
2693
+ },
2694
+ {
2695
+ "epoch": 3.1294783155248274,
2696
+ "grad_norm": 0.9601906538009644,
2697
+ "learning_rate": 6.951846685670594e-05,
2698
+ "loss": 0.2573,
2699
+ "step": 14937
2700
+ },
2701
+ {
2702
+ "epoch": 3.137649277184161,
2703
+ "grad_norm": 0.8388446569442749,
2704
+ "learning_rate": 6.936608294133391e-05,
2705
+ "loss": 0.2719,
2706
+ "step": 14976
2707
+ },
2708
+ {
2709
+ "epoch": 3.145820238843495,
2710
+ "grad_norm": 0.7028934359550476,
2711
+ "learning_rate": 6.921348710432675e-05,
2712
+ "loss": 0.2539,
2713
+ "step": 15015
2714
+ },
2715
+ {
2716
+ "epoch": 3.1539912005028286,
2717
+ "grad_norm": 0.8849790692329407,
2718
+ "learning_rate": 6.906068101552957e-05,
2719
+ "loss": 0.2436,
2720
+ "step": 15054
2721
+ },
2722
+ {
2723
+ "epoch": 3.1621621621621623,
2724
+ "grad_norm": 0.7171310186386108,
2725
+ "learning_rate": 6.890766634708826e-05,
2726
+ "loss": 0.26,
2727
+ "step": 15093
2728
+ },
2729
+ {
2730
+ "epoch": 3.170333123821496,
2731
+ "grad_norm": 0.8107304573059082,
2732
+ "learning_rate": 6.875444477343123e-05,
2733
+ "loss": 0.2505,
2734
+ "step": 15132
2735
+ },
2736
+ {
2737
+ "epoch": 3.1785040854808297,
2738
+ "grad_norm": 1.0732225179672241,
2739
+ "learning_rate": 6.860101797125098e-05,
2740
+ "loss": 0.2418,
2741
+ "step": 15171
2742
+ },
2743
+ {
2744
+ "epoch": 3.1866750471401635,
2745
+ "grad_norm": 1.0856764316558838,
2746
+ "learning_rate": 6.844738761948584e-05,
2747
+ "loss": 0.2585,
2748
+ "step": 15210
2749
+ },
2750
+ {
2751
+ "epoch": 3.194846008799497,
2752
+ "grad_norm": 1.0335191488265991,
2753
+ "learning_rate": 6.829355539930156e-05,
2754
+ "loss": 0.2838,
2755
+ "step": 15249
2756
+ },
2757
+ {
2758
+ "epoch": 3.203016970458831,
2759
+ "grad_norm": 0.895849883556366,
2760
+ "learning_rate": 6.81395229940729e-05,
2761
+ "loss": 0.2619,
2762
+ "step": 15288
2763
+ },
2764
+ {
2765
+ "epoch": 3.2111879321181647,
2766
+ "grad_norm": 1.054457426071167,
2767
+ "learning_rate": 6.798529208936528e-05,
2768
+ "loss": 0.2867,
2769
+ "step": 15327
2770
+ },
2771
+ {
2772
+ "epoch": 3.2193588937774984,
2773
+ "grad_norm": 1.171610951423645,
2774
+ "learning_rate": 6.783086437291623e-05,
2775
+ "loss": 0.2718,
2776
+ "step": 15366
2777
+ },
2778
+ {
2779
+ "epoch": 3.227529855436832,
2780
+ "grad_norm": 1.4226104021072388,
2781
+ "learning_rate": 6.767624153461701e-05,
2782
+ "loss": 0.2584,
2783
+ "step": 15405
2784
+ },
2785
+ {
2786
+ "epoch": 3.235700817096166,
2787
+ "grad_norm": 0.7325811386108398,
2788
+ "learning_rate": 6.75214252664941e-05,
2789
+ "loss": 0.2572,
2790
+ "step": 15444
2791
+ },
2792
+ {
2793
+ "epoch": 3.2438717787554996,
2794
+ "grad_norm": 1.8367798328399658,
2795
+ "learning_rate": 6.736641726269065e-05,
2796
+ "loss": 0.2383,
2797
+ "step": 15483
2798
+ },
2799
+ {
2800
+ "epoch": 3.2520427404148333,
2801
+ "grad_norm": 1.2098209857940674,
2802
+ "learning_rate": 6.721121921944791e-05,
2803
+ "loss": 0.2668,
2804
+ "step": 15522
2805
+ },
2806
+ {
2807
+ "epoch": 3.260213702074167,
2808
+ "grad_norm": 0.9780440330505371,
2809
+ "learning_rate": 6.70558328350868e-05,
2810
+ "loss": 0.2375,
2811
+ "step": 15561
2812
+ },
2813
+ {
2814
+ "epoch": 3.268384663733501,
2815
+ "grad_norm": 0.8904445767402649,
2816
+ "learning_rate": 6.69002598099892e-05,
2817
+ "loss": 0.2525,
2818
+ "step": 15600
2819
+ },
2820
+ {
2821
+ "epoch": 3.2765556253928345,
2822
+ "grad_norm": 0.9340187311172485,
2823
+ "learning_rate": 6.674450184657939e-05,
2824
+ "loss": 0.2691,
2825
+ "step": 15639
2826
+ },
2827
+ {
2828
+ "epoch": 3.2847265870521687,
2829
+ "grad_norm": 0.9010167717933655,
2830
+ "learning_rate": 6.658856064930542e-05,
2831
+ "loss": 0.258,
2832
+ "step": 15678
2833
+ },
2834
+ {
2835
+ "epoch": 3.292897548711502,
2836
+ "grad_norm": 1.3005743026733398,
2837
+ "learning_rate": 6.643243792462047e-05,
2838
+ "loss": 0.2713,
2839
+ "step": 15717
2840
+ },
2841
+ {
2842
+ "epoch": 3.301068510370836,
2843
+ "grad_norm": 0.9360527396202087,
2844
+ "learning_rate": 6.627613538096412e-05,
2845
+ "loss": 0.2615,
2846
+ "step": 15756
2847
+ },
2848
+ {
2849
+ "epoch": 3.30923947203017,
2850
+ "grad_norm": 0.8945103287696838,
2851
+ "learning_rate": 6.611965472874371e-05,
2852
+ "loss": 0.2698,
2853
+ "step": 15795
2854
+ },
2855
+ {
2856
+ "epoch": 3.3174104336895036,
2857
+ "grad_norm": 0.8402488827705383,
2858
+ "learning_rate": 6.596299768031567e-05,
2859
+ "loss": 0.2723,
2860
+ "step": 15834
2861
+ },
2862
+ {
2863
+ "epoch": 3.3255813953488373,
2864
+ "grad_norm": 0.8912140130996704,
2865
+ "learning_rate": 6.580616594996663e-05,
2866
+ "loss": 0.2754,
2867
+ "step": 15873
2868
+ },
2869
+ {
2870
+ "epoch": 3.333752357008171,
2871
+ "grad_norm": 0.9579502940177917,
2872
+ "learning_rate": 6.564916125389482e-05,
2873
+ "loss": 0.2474,
2874
+ "step": 15912
2875
+ },
2876
+ {
2877
+ "epoch": 3.341923318667505,
2878
+ "grad_norm": 1.2083587646484375,
2879
+ "learning_rate": 6.549198531019116e-05,
2880
+ "loss": 0.2546,
2881
+ "step": 15951
2882
+ },
2883
+ {
2884
+ "epoch": 3.3500942803268385,
2885
+ "grad_norm": 1.0274497270584106,
2886
+ "learning_rate": 6.533463983882059e-05,
2887
+ "loss": 0.2659,
2888
+ "step": 15990
2889
+ },
2890
+ {
2891
+ "epoch": 3.3582652419861723,
2892
+ "grad_norm": 0.9805575609207153,
2893
+ "learning_rate": 6.517712656160313e-05,
2894
+ "loss": 0.2639,
2895
+ "step": 16029
2896
+ },
2897
+ {
2898
+ "epoch": 3.366436203645506,
2899
+ "grad_norm": 1.1635912656784058,
2900
+ "learning_rate": 6.501944720219508e-05,
2901
+ "loss": 0.2805,
2902
+ "step": 16068
2903
+ },
2904
+ {
2905
+ "epoch": 3.3746071653048397,
2906
+ "grad_norm": 1.2201091051101685,
2907
+ "learning_rate": 6.486160348607023e-05,
2908
+ "loss": 0.2581,
2909
+ "step": 16107
2910
+ },
2911
+ {
2912
+ "epoch": 3.3827781269641735,
2913
+ "grad_norm": 0.8909711837768555,
2914
+ "learning_rate": 6.470359714050083e-05,
2915
+ "loss": 0.2699,
2916
+ "step": 16146
2917
+ },
2918
+ {
2919
+ "epoch": 3.390949088623507,
2920
+ "grad_norm": 1.3544241189956665,
2921
+ "learning_rate": 6.454542989453882e-05,
2922
+ "loss": 0.2694,
2923
+ "step": 16185
2924
+ },
2925
+ {
2926
+ "epoch": 3.399120050282841,
2927
+ "grad_norm": 0.7139955163002014,
2928
+ "learning_rate": 6.438710347899687e-05,
2929
+ "loss": 0.2752,
2930
+ "step": 16224
2931
+ },
2932
+ {
2933
+ "epoch": 3.4072910119421747,
2934
+ "grad_norm": 0.9686264991760254,
2935
+ "learning_rate": 6.422861962642938e-05,
2936
+ "loss": 0.2614,
2937
+ "step": 16263
2938
+ },
2939
+ {
2940
+ "epoch": 3.4154619736015084,
2941
+ "grad_norm": 0.9705599546432495,
2942
+ "learning_rate": 6.406998007111365e-05,
2943
+ "loss": 0.2515,
2944
+ "step": 16302
2945
+ },
2946
+ {
2947
+ "epoch": 3.423632935260842,
2948
+ "grad_norm": 0.5927676558494568,
2949
+ "learning_rate": 6.391118654903074e-05,
2950
+ "loss": 0.2638,
2951
+ "step": 16341
2952
+ },
2953
+ {
2954
+ "epoch": 3.431803896920176,
2955
+ "grad_norm": 1.0339412689208984,
2956
+ "learning_rate": 6.375224079784662e-05,
2957
+ "loss": 0.281,
2958
+ "step": 16380
2959
+ },
2960
+ {
2961
+ "epoch": 3.4399748585795096,
2962
+ "grad_norm": 1.2015362977981567,
2963
+ "learning_rate": 6.359314455689308e-05,
2964
+ "loss": 0.2517,
2965
+ "step": 16419
2966
+ },
2967
+ {
2968
+ "epoch": 3.4481458202388433,
2969
+ "grad_norm": 0.8283564448356628,
2970
+ "learning_rate": 6.343389956714866e-05,
2971
+ "loss": 0.2675,
2972
+ "step": 16458
2973
+ },
2974
+ {
2975
+ "epoch": 3.4563167818981775,
2976
+ "grad_norm": 0.9697973132133484,
2977
+ "learning_rate": 6.32745075712197e-05,
2978
+ "loss": 0.2725,
2979
+ "step": 16497
2980
+ },
2981
+ {
2982
+ "epoch": 3.4644877435575108,
2983
+ "grad_norm": 0.8286094665527344,
2984
+ "learning_rate": 6.311497031332122e-05,
2985
+ "loss": 0.2689,
2986
+ "step": 16536
2987
+ },
2988
+ {
2989
+ "epoch": 3.472658705216845,
2990
+ "grad_norm": 0.9562814235687256,
2991
+ "learning_rate": 6.29552895392578e-05,
2992
+ "loss": 0.2619,
2993
+ "step": 16575
2994
+ },
2995
+ {
2996
+ "epoch": 3.4808296668761787,
2997
+ "grad_norm": 0.840769350528717,
2998
+ "learning_rate": 6.279546699640452e-05,
2999
+ "loss": 0.2574,
3000
+ "step": 16614
3001
+ },
3002
+ {
3003
+ "epoch": 3.4890006285355124,
3004
+ "grad_norm": 0.820468008518219,
3005
+ "learning_rate": 6.263550443368783e-05,
3006
+ "loss": 0.2482,
3007
+ "step": 16653
3008
+ },
3009
+ {
3010
+ "epoch": 3.497171590194846,
3011
+ "grad_norm": 0.8476835489273071,
3012
+ "learning_rate": 6.247540360156638e-05,
3013
+ "loss": 0.2823,
3014
+ "step": 16692
3015
+ },
3016
+ {
3017
+ "epoch": 3.50534255185418,
3018
+ "grad_norm": 1.0869783163070679,
3019
+ "learning_rate": 6.231516625201196e-05,
3020
+ "loss": 0.266,
3021
+ "step": 16731
3022
+ },
3023
+ {
3024
+ "epoch": 3.5135135135135136,
3025
+ "grad_norm": 1.0051486492156982,
3026
+ "learning_rate": 6.215479413849019e-05,
3027
+ "loss": 0.2489,
3028
+ "step": 16770
3029
+ },
3030
+ {
3031
+ "epoch": 3.5216844751728473,
3032
+ "grad_norm": 1.0071632862091064,
3033
+ "learning_rate": 6.199428901594142e-05,
3034
+ "loss": 0.2776,
3035
+ "step": 16809
3036
+ },
3037
+ {
3038
+ "epoch": 3.529855436832181,
3039
+ "grad_norm": 1.0343513488769531,
3040
+ "learning_rate": 6.183365264076152e-05,
3041
+ "loss": 0.2811,
3042
+ "step": 16848
3043
+ },
3044
+ {
3045
+ "epoch": 3.538026398491515,
3046
+ "grad_norm": 1.3418666124343872,
3047
+ "learning_rate": 6.167288677078266e-05,
3048
+ "loss": 0.2581,
3049
+ "step": 16887
3050
+ },
3051
+ {
3052
+ "epoch": 3.5461973601508485,
3053
+ "grad_norm": 1.228233814239502,
3054
+ "learning_rate": 6.151199316525403e-05,
3055
+ "loss": 0.3023,
3056
+ "step": 16926
3057
+ },
3058
+ {
3059
+ "epoch": 3.5543683218101823,
3060
+ "grad_norm": 1.132449746131897,
3061
+ "learning_rate": 6.135097358482265e-05,
3062
+ "loss": 0.2763,
3063
+ "step": 16965
3064
+ },
3065
+ {
3066
+ "epoch": 3.562539283469516,
3067
+ "grad_norm": 0.8154187202453613,
3068
+ "learning_rate": 6.118982979151405e-05,
3069
+ "loss": 0.2607,
3070
+ "step": 17004
3071
+ },
3072
+ {
3073
+ "epoch": 3.5707102451288497,
3074
+ "grad_norm": 0.7642055749893188,
3075
+ "learning_rate": 6.102856354871304e-05,
3076
+ "loss": 0.2704,
3077
+ "step": 17043
3078
+ },
3079
+ {
3080
+ "epoch": 3.5788812067881834,
3081
+ "grad_norm": 0.7441285252571106,
3082
+ "learning_rate": 6.086717662114434e-05,
3083
+ "loss": 0.2704,
3084
+ "step": 17082
3085
+ },
3086
+ {
3087
+ "epoch": 3.587052168447517,
3088
+ "grad_norm": 1.1328179836273193,
3089
+ "learning_rate": 6.0705670774853375e-05,
3090
+ "loss": 0.2734,
3091
+ "step": 17121
3092
+ },
3093
+ {
3094
+ "epoch": 3.595223130106851,
3095
+ "grad_norm": 1.2895148992538452,
3096
+ "learning_rate": 6.054404777718683e-05,
3097
+ "loss": 0.2534,
3098
+ "step": 17160
3099
+ },
3100
+ {
3101
+ "epoch": 3.6033940917661846,
3102
+ "grad_norm": 1.1969038248062134,
3103
+ "learning_rate": 6.0382309396773405e-05,
3104
+ "loss": 0.288,
3105
+ "step": 17199
3106
+ },
3107
+ {
3108
+ "epoch": 3.611565053425519,
3109
+ "grad_norm": 1.0326099395751953,
3110
+ "learning_rate": 6.022045740350444e-05,
3111
+ "loss": 0.273,
3112
+ "step": 17238
3113
+ },
3114
+ {
3115
+ "epoch": 3.619736015084852,
3116
+ "grad_norm": 0.842157244682312,
3117
+ "learning_rate": 6.005849356851448e-05,
3118
+ "loss": 0.2757,
3119
+ "step": 17277
3120
+ },
3121
+ {
3122
+ "epoch": 3.6279069767441863,
3123
+ "grad_norm": 1.004172444343567,
3124
+ "learning_rate": 5.989641966416201e-05,
3125
+ "loss": 0.2719,
3126
+ "step": 17316
3127
+ },
3128
+ {
3129
+ "epoch": 3.6360779384035196,
3130
+ "grad_norm": 1.0707955360412598,
3131
+ "learning_rate": 5.973423746400991e-05,
3132
+ "loss": 0.2785,
3133
+ "step": 17355
3134
+ },
3135
+ {
3136
+ "epoch": 3.6442489000628537,
3137
+ "grad_norm": 0.9679854512214661,
3138
+ "learning_rate": 5.957194874280623e-05,
3139
+ "loss": 0.2628,
3140
+ "step": 17394
3141
+ },
3142
+ {
3143
+ "epoch": 3.6524198617221875,
3144
+ "grad_norm": 1.2920995950698853,
3145
+ "learning_rate": 5.940955527646461e-05,
3146
+ "loss": 0.2803,
3147
+ "step": 17433
3148
+ },
3149
+ {
3150
+ "epoch": 3.660590823381521,
3151
+ "grad_norm": 1.1548652648925781,
3152
+ "learning_rate": 5.924705884204491e-05,
3153
+ "loss": 0.2827,
3154
+ "step": 17472
3155
+ },
3156
+ {
3157
+ "epoch": 3.668761785040855,
3158
+ "grad_norm": 1.4897462129592896,
3159
+ "learning_rate": 5.908446121773381e-05,
3160
+ "loss": 0.2883,
3161
+ "step": 17511
3162
+ },
3163
+ {
3164
+ "epoch": 3.6769327467001887,
3165
+ "grad_norm": 1.005393147468567,
3166
+ "learning_rate": 5.892176418282522e-05,
3167
+ "loss": 0.2635,
3168
+ "step": 17550
3169
+ },
3170
+ {
3171
+ "epoch": 3.6851037083595224,
3172
+ "grad_norm": 1.1993404626846313,
3173
+ "learning_rate": 5.8758969517701e-05,
3174
+ "loss": 0.2786,
3175
+ "step": 17589
3176
+ },
3177
+ {
3178
+ "epoch": 3.693274670018856,
3179
+ "grad_norm": 1.0545886754989624,
3180
+ "learning_rate": 5.859607900381129e-05,
3181
+ "loss": 0.2567,
3182
+ "step": 17628
3183
+ },
3184
+ {
3185
+ "epoch": 3.70144563167819,
3186
+ "grad_norm": 0.632892906665802,
3187
+ "learning_rate": 5.84330944236551e-05,
3188
+ "loss": 0.2755,
3189
+ "step": 17667
3190
+ },
3191
+ {
3192
+ "epoch": 3.7096165933375236,
3193
+ "grad_norm": 1.0235896110534668,
3194
+ "learning_rate": 5.8270017560760845e-05,
3195
+ "loss": 0.2709,
3196
+ "step": 17706
3197
+ },
3198
+ {
3199
+ "epoch": 3.7177875549968573,
3200
+ "grad_norm": 1.0493903160095215,
3201
+ "learning_rate": 5.8106850199666754e-05,
3202
+ "loss": 0.2707,
3203
+ "step": 17745
3204
+ },
3205
+ {
3206
+ "epoch": 3.725958516656191,
3207
+ "grad_norm": 1.1471383571624756,
3208
+ "learning_rate": 5.794359412590136e-05,
3209
+ "loss": 0.257,
3210
+ "step": 17784
3211
+ },
3212
+ {
3213
+ "epoch": 3.7341294783155248,
3214
+ "grad_norm": 1.0675766468048096,
3215
+ "learning_rate": 5.778025112596401e-05,
3216
+ "loss": 0.2665,
3217
+ "step": 17823
3218
+ },
3219
+ {
3220
+ "epoch": 3.7423004399748585,
3221
+ "grad_norm": 1.0171725749969482,
3222
+ "learning_rate": 5.761682298730524e-05,
3223
+ "loss": 0.27,
3224
+ "step": 17862
3225
+ },
3226
+ {
3227
+ "epoch": 3.7504714016341922,
3228
+ "grad_norm": 1.209671139717102,
3229
+ "learning_rate": 5.745331149830729e-05,
3230
+ "loss": 0.2723,
3231
+ "step": 17901
3232
+ },
3233
+ {
3234
+ "epoch": 3.758642363293526,
3235
+ "grad_norm": 1.1893844604492188,
3236
+ "learning_rate": 5.728971844826445e-05,
3237
+ "loss": 0.2835,
3238
+ "step": 17940
3239
+ },
3240
+ {
3241
+ "epoch": 3.7668133249528597,
3242
+ "grad_norm": 1.2675912380218506,
3243
+ "learning_rate": 5.7126045627363556e-05,
3244
+ "loss": 0.2979,
3245
+ "step": 17979
3246
+ },
3247
+ {
3248
+ "epoch": 3.7749842866121934,
3249
+ "grad_norm": 1.090598464012146,
3250
+ "learning_rate": 5.6962294826664385e-05,
3251
+ "loss": 0.2748,
3252
+ "step": 18018
3253
+ },
3254
+ {
3255
+ "epoch": 3.7831552482715276,
3256
+ "grad_norm": 1.0700677633285522,
3257
+ "learning_rate": 5.679846783808e-05,
3258
+ "loss": 0.3043,
3259
+ "step": 18057
3260
+ },
3261
+ {
3262
+ "epoch": 3.791326209930861,
3263
+ "grad_norm": 1.0571792125701904,
3264
+ "learning_rate": 5.6634566454357196e-05,
3265
+ "loss": 0.2589,
3266
+ "step": 18096
3267
+ },
3268
+ {
3269
+ "epoch": 3.799497171590195,
3270
+ "grad_norm": 0.8858397006988525,
3271
+ "learning_rate": 5.6470592469056915e-05,
3272
+ "loss": 0.2976,
3273
+ "step": 18135
3274
+ },
3275
+ {
3276
+ "epoch": 3.8076681332495284,
3277
+ "grad_norm": 1.1942354440689087,
3278
+ "learning_rate": 5.6306547676534514e-05,
3279
+ "loss": 0.2742,
3280
+ "step": 18174
3281
+ },
3282
+ {
3283
+ "epoch": 3.8158390949088625,
3284
+ "grad_norm": 1.4405794143676758,
3285
+ "learning_rate": 5.614243387192022e-05,
3286
+ "loss": 0.3013,
3287
+ "step": 18213
3288
+ },
3289
+ {
3290
+ "epoch": 3.8240100565681963,
3291
+ "grad_norm": 0.9287608861923218,
3292
+ "learning_rate": 5.5978252851099425e-05,
3293
+ "loss": 0.2542,
3294
+ "step": 18252
3295
+ },
3296
+ {
3297
+ "epoch": 3.83218101822753,
3298
+ "grad_norm": 1.217387080192566,
3299
+ "learning_rate": 5.581400641069309e-05,
3300
+ "loss": 0.2768,
3301
+ "step": 18291
3302
+ },
3303
+ {
3304
+ "epoch": 3.8403519798868637,
3305
+ "grad_norm": 1.1811288595199585,
3306
+ "learning_rate": 5.564969634803806e-05,
3307
+ "loss": 0.263,
3308
+ "step": 18330
3309
+ },
3310
+ {
3311
+ "epoch": 3.8485229415461975,
3312
+ "grad_norm": 0.9432389140129089,
3313
+ "learning_rate": 5.548532446116737e-05,
3314
+ "loss": 0.2612,
3315
+ "step": 18369
3316
+ },
3317
+ {
3318
+ "epoch": 3.856693903205531,
3319
+ "grad_norm": 1.010432243347168,
3320
+ "learning_rate": 5.532089254879061e-05,
3321
+ "loss": 0.2505,
3322
+ "step": 18408
3323
+ },
3324
+ {
3325
+ "epoch": 3.864864864864865,
3326
+ "grad_norm": 1.1816331148147583,
3327
+ "learning_rate": 5.515640241027423e-05,
3328
+ "loss": 0.282,
3329
+ "step": 18447
3330
+ },
3331
+ {
3332
+ "epoch": 3.8730358265241986,
3333
+ "grad_norm": 1.011232614517212,
3334
+ "learning_rate": 5.499185584562183e-05,
3335
+ "loss": 0.2894,
3336
+ "step": 18486
3337
+ },
3338
+ {
3339
+ "epoch": 3.8812067881835324,
3340
+ "grad_norm": 0.7370874881744385,
3341
+ "learning_rate": 5.482725465545449e-05,
3342
+ "loss": 0.2692,
3343
+ "step": 18525
3344
+ },
3345
+ {
3346
+ "epoch": 3.889377749842866,
3347
+ "grad_norm": 0.831798791885376,
3348
+ "learning_rate": 5.4662600640991025e-05,
3349
+ "loss": 0.2984,
3350
+ "step": 18564
3351
+ },
3352
+ {
3353
+ "epoch": 3.8975487115022,
3354
+ "grad_norm": 0.7684634923934937,
3355
+ "learning_rate": 5.4497895604028334e-05,
3356
+ "loss": 0.282,
3357
+ "step": 18603
3358
+ },
3359
+ {
3360
+ "epoch": 3.9057196731615336,
3361
+ "grad_norm": 1.2753115892410278,
3362
+ "learning_rate": 5.4333141346921644e-05,
3363
+ "loss": 0.2692,
3364
+ "step": 18642
3365
+ },
3366
+ {
3367
+ "epoch": 3.9138906348208673,
3368
+ "grad_norm": 0.9664742350578308,
3369
+ "learning_rate": 5.4168339672564795e-05,
3370
+ "loss": 0.2683,
3371
+ "step": 18681
3372
+ },
3373
+ {
3374
+ "epoch": 3.922061596480201,
3375
+ "grad_norm": 1.0317939519882202,
3376
+ "learning_rate": 5.4003492384370504e-05,
3377
+ "loss": 0.2635,
3378
+ "step": 18720
3379
+ },
3380
+ {
3381
+ "epoch": 3.9302325581395348,
3382
+ "grad_norm": 0.88239985704422,
3383
+ "learning_rate": 5.383860128625062e-05,
3384
+ "loss": 0.2631,
3385
+ "step": 18759
3386
+ },
3387
+ {
3388
+ "epoch": 3.9384035197988685,
3389
+ "grad_norm": 1.137979507446289,
3390
+ "learning_rate": 5.367366818259646e-05,
3391
+ "loss": 0.2734,
3392
+ "step": 18798
3393
+ },
3394
+ {
3395
+ "epoch": 3.946574481458202,
3396
+ "grad_norm": 1.0174254179000854,
3397
+ "learning_rate": 5.3508694878258934e-05,
3398
+ "loss": 0.278,
3399
+ "step": 18837
3400
+ },
3401
+ {
3402
+ "epoch": 3.9547454431175364,
3403
+ "grad_norm": 0.9561147093772888,
3404
+ "learning_rate": 5.334368317852889e-05,
3405
+ "loss": 0.2552,
3406
+ "step": 18876
3407
+ },
3408
+ {
3409
+ "epoch": 3.9629164047768697,
3410
+ "grad_norm": 1.178209662437439,
3411
+ "learning_rate": 5.317863488911737e-05,
3412
+ "loss": 0.2615,
3413
+ "step": 18915
3414
+ },
3415
+ {
3416
+ "epoch": 3.971087366436204,
3417
+ "grad_norm": 1.1684329509735107,
3418
+ "learning_rate": 5.3013551816135756e-05,
3419
+ "loss": 0.283,
3420
+ "step": 18954
3421
+ },
3422
+ {
3423
+ "epoch": 3.979258328095537,
3424
+ "grad_norm": 0.7574102878570557,
3425
+ "learning_rate": 5.2848435766076096e-05,
3426
+ "loss": 0.3018,
3427
+ "step": 18993
3428
+ },
3429
+ {
3430
+ "epoch": 3.9874292897548713,
3431
+ "grad_norm": 1.389844298362732,
3432
+ "learning_rate": 5.268328854579132e-05,
3433
+ "loss": 0.2737,
3434
+ "step": 19032
3435
+ },
3436
+ {
3437
+ "epoch": 3.995600251414205,
3438
+ "grad_norm": 0.8808802366256714,
3439
+ "learning_rate": 5.251811196247541e-05,
3440
+ "loss": 0.2656,
3441
+ "step": 19071
3442
+ },
3443
+ {
3444
+ "epoch": 4.003771213073539,
3445
+ "grad_norm": 1.1782208681106567,
3446
+ "learning_rate": 5.2352907823643715e-05,
3447
+ "loss": 0.2257,
3448
+ "step": 19110
3449
+ },
3450
+ {
3451
+ "epoch": 4.011942174732872,
3452
+ "grad_norm": 0.7572002410888672,
3453
+ "learning_rate": 5.218767793711306e-05,
3454
+ "loss": 0.1908,
3455
+ "step": 19149
3456
+ },
3457
+ {
3458
+ "epoch": 4.020113136392206,
3459
+ "grad_norm": 1.2401790618896484,
3460
+ "learning_rate": 5.202242411098206e-05,
3461
+ "loss": 0.173,
3462
+ "step": 19188
3463
+ },
3464
+ {
3465
+ "epoch": 4.0282840980515395,
3466
+ "grad_norm": 1.61008882522583,
3467
+ "learning_rate": 5.1857148153611336e-05,
3468
+ "loss": 0.1997,
3469
+ "step": 19227
3470
+ },
3471
+ {
3472
+ "epoch": 4.036455059710874,
3473
+ "grad_norm": 1.042442798614502,
3474
+ "learning_rate": 5.169185187360362e-05,
3475
+ "loss": 0.1846,
3476
+ "step": 19266
3477
+ },
3478
+ {
3479
+ "epoch": 4.044626021370207,
3480
+ "grad_norm": 1.8919810056686401,
3481
+ "learning_rate": 5.1526537079784076e-05,
3482
+ "loss": 0.1755,
3483
+ "step": 19305
3484
+ },
3485
+ {
3486
+ "epoch": 4.052796983029541,
3487
+ "grad_norm": 1.427526593208313,
3488
+ "learning_rate": 5.136120558118044e-05,
3489
+ "loss": 0.1782,
3490
+ "step": 19344
3491
+ },
3492
+ {
3493
+ "epoch": 4.060967944688875,
3494
+ "grad_norm": 0.9603130221366882,
3495
+ "learning_rate": 5.119585918700327e-05,
3496
+ "loss": 0.1934,
3497
+ "step": 19383
3498
+ },
3499
+ {
3500
+ "epoch": 4.069138906348209,
3501
+ "grad_norm": 1.2158547639846802,
3502
+ "learning_rate": 5.1030499706626126e-05,
3503
+ "loss": 0.1834,
3504
+ "step": 19422
3505
+ },
3506
+ {
3507
+ "epoch": 4.077309868007543,
3508
+ "grad_norm": 1.2463704347610474,
3509
+ "learning_rate": 5.0865128949565735e-05,
3510
+ "loss": 0.1956,
3511
+ "step": 19461
3512
+ },
3513
+ {
3514
+ "epoch": 4.085480829666876,
3515
+ "grad_norm": 0.9006099700927734,
3516
+ "learning_rate": 5.069974872546227e-05,
3517
+ "loss": 0.1949,
3518
+ "step": 19500
3519
+ },
3520
+ {
3521
+ "epoch": 4.09365179132621,
3522
+ "grad_norm": 1.2113624811172485,
3523
+ "learning_rate": 5.053436084405946e-05,
3524
+ "loss": 0.1901,
3525
+ "step": 19539
3526
+ },
3527
+ {
3528
+ "epoch": 4.1018227529855436,
3529
+ "grad_norm": 1.0677685737609863,
3530
+ "learning_rate": 5.036896711518485e-05,
3531
+ "loss": 0.1904,
3532
+ "step": 19578
3533
+ },
3534
+ {
3535
+ "epoch": 4.109993714644878,
3536
+ "grad_norm": 1.0412025451660156,
3537
+ "learning_rate": 5.020356934872997e-05,
3538
+ "loss": 0.1894,
3539
+ "step": 19617
3540
+ },
3541
+ {
3542
+ "epoch": 4.118164676304211,
3543
+ "grad_norm": 1.1890144348144531,
3544
+ "learning_rate": 5.0038169354630537e-05,
3545
+ "loss": 0.1765,
3546
+ "step": 19656
3547
+ },
3548
+ {
3549
+ "epoch": 4.126335637963545,
3550
+ "grad_norm": 1.4251190423965454,
3551
+ "learning_rate": 4.9872768942846645e-05,
3552
+ "loss": 0.1896,
3553
+ "step": 19695
3554
+ },
3555
+ {
3556
+ "epoch": 4.1345065996228785,
3557
+ "grad_norm": 1.3054598569869995,
3558
+ "learning_rate": 4.970736992334294e-05,
3559
+ "loss": 0.1956,
3560
+ "step": 19734
3561
+ },
3562
+ {
3563
+ "epoch": 4.142677561282213,
3564
+ "grad_norm": 1.2113808393478394,
3565
+ "learning_rate": 4.9541974106068844e-05,
3566
+ "loss": 0.1876,
3567
+ "step": 19773
3568
+ },
3569
+ {
3570
+ "epoch": 4.150848522941546,
3571
+ "grad_norm": 1.1403577327728271,
3572
+ "learning_rate": 4.9376583300938756e-05,
3573
+ "loss": 0.1958,
3574
+ "step": 19812
3575
+ },
3576
+ {
3577
+ "epoch": 4.15901948460088,
3578
+ "grad_norm": 1.28948974609375,
3579
+ "learning_rate": 4.921119931781218e-05,
3580
+ "loss": 0.1856,
3581
+ "step": 19851
3582
+ },
3583
+ {
3584
+ "epoch": 4.167190446260213,
3585
+ "grad_norm": 1.168059229850769,
3586
+ "learning_rate": 4.9045823966474046e-05,
3587
+ "loss": 0.1867,
3588
+ "step": 19890
3589
+ },
3590
+ {
3591
+ "epoch": 4.175361407919548,
3592
+ "grad_norm": 0.7937365770339966,
3593
+ "learning_rate": 4.888045905661472e-05,
3594
+ "loss": 0.1846,
3595
+ "step": 19929
3596
+ },
3597
+ {
3598
+ "epoch": 4.183532369578881,
3599
+ "grad_norm": 0.8156687021255493,
3600
+ "learning_rate": 4.871510639781043e-05,
3601
+ "loss": 0.1879,
3602
+ "step": 19968
3603
+ },
3604
+ {
3605
+ "epoch": 4.190236748376283,
3606
+ "eval_accuracy": 0.01002925168722868,
3607
+ "eval_loss": 0.5226494073867798,
3608
+ "eval_runtime": 848.4593,
3609
+ "eval_samples_per_second": 5.64,
3610
+ "eval_steps_per_second": 1.411,
3611
+ "step": 20000
3612
+ }
3613
+ ],
3614
+ "logging_steps": 39,
3615
+ "max_steps": 38184,
3616
+ "num_input_tokens_seen": 0,
3617
+ "num_train_epochs": 8,
3618
+ "save_steps": 10000,
3619
+ "stateful_callbacks": {
3620
+ "TrainerControl": {
3621
+ "args": {
3622
+ "should_epoch_stop": false,
3623
+ "should_evaluate": false,
3624
+ "should_log": false,
3625
+ "should_save": true,
3626
+ "should_training_stop": false
3627
+ },
3628
+ "attributes": {}
3629
+ }
3630
+ },
3631
+ "total_flos": 7.632883174699172e+18,
3632
+ "train_batch_size": 2,
3633
+ "trial_name": null,
3634
+ "trial_params": null
3635
+ }
checkpoint-20000/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:735a552aa1714bfc383df4ff1a42a38cfe32c5c5b2762c0a21b52159da19005f
3
+ size 6904
checkpoint-20000/zero_to_fp32.py ADDED
@@ -0,0 +1,760 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # Copyright (c) Microsoft Corporation.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ # DeepSpeed Team
7
+
8
+ # This script extracts fp32 consolidated weights from a zero 1, 2 and 3 DeepSpeed checkpoints. It gets
9
+ # copied into the top level checkpoint dir, so the user can easily do the conversion at any point in
10
+ # the future. Once extracted, the weights don't require DeepSpeed and can be used in any
11
+ # application.
12
+ #
13
+ # example:
14
+ # python zero_to_fp32.py . output_dir/
15
+ # or
16
+ # python zero_to_fp32.py . output_dir/ --safe_serialization
17
+
18
+ import argparse
19
+ import torch
20
+ import glob
21
+ import math
22
+ import os
23
+ import re
24
+ import gc
25
+ import json
26
+ import numpy as np
27
+ from tqdm import tqdm
28
+ from collections import OrderedDict
29
+ from dataclasses import dataclass
30
+
31
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
32
+ # DeepSpeed data structures it has to be available in the current python environment.
33
+ from deepspeed.utils import logger
34
+ from deepspeed.checkpoint.constants import (DS_VERSION, OPTIMIZER_STATE_DICT, SINGLE_PARTITION_OF_FP32_GROUPS,
35
+ FP32_FLAT_GROUPS, ZERO_STAGE, PARTITION_COUNT, PARAM_SHAPES, BUFFER_NAMES,
36
+ FROZEN_PARAM_SHAPES, FROZEN_PARAM_FRAGMENTS)
37
+
38
+
39
+ @dataclass
40
+ class zero_model_state:
41
+ buffers: dict()
42
+ param_shapes: dict()
43
+ shared_params: list
44
+ ds_version: int
45
+ frozen_param_shapes: dict()
46
+ frozen_param_fragments: dict()
47
+
48
+
49
+ debug = 0
50
+
51
+ # load to cpu
52
+ device = torch.device('cpu')
53
+
54
+
55
+ def atoi(text):
56
+ return int(text) if text.isdigit() else text
57
+
58
+
59
+ def natural_keys(text):
60
+ '''
61
+ alist.sort(key=natural_keys) sorts in human order
62
+ http://nedbatchelder.com/blog/200712/human_sorting.html
63
+ (See Toothy's implementation in the comments)
64
+ '''
65
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
66
+
67
+
68
+ def get_model_state_file(checkpoint_dir, zero_stage):
69
+ if not os.path.isdir(checkpoint_dir):
70
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
71
+
72
+ # there should be only one file
73
+ if zero_stage <= 2:
74
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
75
+ elif zero_stage == 3:
76
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
77
+
78
+ if not os.path.exists(file):
79
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
80
+
81
+ return file
82
+
83
+
84
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
85
+ # XXX: need to test that this simple glob rule works for multi-node setup too
86
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
87
+
88
+ if len(ckpt_files) == 0:
89
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
90
+
91
+ return ckpt_files
92
+
93
+
94
+ def get_optim_files(checkpoint_dir):
95
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
96
+
97
+
98
+ def get_model_state_files(checkpoint_dir):
99
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
100
+
101
+
102
+ def parse_model_states(files):
103
+ zero_model_states = []
104
+ for file in files:
105
+ state_dict = torch.load(file, map_location=device, weights_only=False)
106
+
107
+ if BUFFER_NAMES not in state_dict:
108
+ raise ValueError(f"{file} is not a model state checkpoint")
109
+ buffer_names = state_dict[BUFFER_NAMES]
110
+ if debug:
111
+ print("Found buffers:", buffer_names)
112
+
113
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
114
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
115
+ param_shapes = state_dict[PARAM_SHAPES]
116
+
117
+ # collect parameters that are included in param_shapes
118
+ param_names = []
119
+ for s in param_shapes:
120
+ for name in s.keys():
121
+ param_names.append(name)
122
+
123
+ # update with frozen parameters
124
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
125
+ if frozen_param_shapes is not None:
126
+ if debug:
127
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
128
+ param_names += list(frozen_param_shapes.keys())
129
+
130
+ # handle shared params
131
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
132
+
133
+ ds_version = state_dict.get(DS_VERSION, None)
134
+
135
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
136
+
137
+ z_model_state = zero_model_state(buffers=buffers,
138
+ param_shapes=param_shapes,
139
+ shared_params=shared_params,
140
+ ds_version=ds_version,
141
+ frozen_param_shapes=frozen_param_shapes,
142
+ frozen_param_fragments=frozen_param_fragments)
143
+ zero_model_states.append(z_model_state)
144
+
145
+ return zero_model_states
146
+
147
+
148
+ def parse_optim_states(files, ds_checkpoint_dir):
149
+ total_files = len(files)
150
+ state_dicts = []
151
+ for f in tqdm(files, desc='Loading checkpoint shards'):
152
+ state_dict = torch.load(f, map_location=device, mmap=True, weights_only=False)
153
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
154
+ # and also handle the case where it was already removed by another helper script
155
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
156
+ state_dicts.append(state_dict)
157
+
158
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
159
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
160
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
161
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
162
+
163
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
164
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
165
+ # use the max of the partition_count to get the dp world_size.
166
+
167
+ if type(world_size) is list:
168
+ world_size = max(world_size)
169
+
170
+ if world_size != total_files:
171
+ raise ValueError(
172
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
173
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
174
+ )
175
+
176
+ # the groups are named differently in each stage
177
+ if zero_stage <= 2:
178
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
179
+ elif zero_stage == 3:
180
+ fp32_groups_key = FP32_FLAT_GROUPS
181
+ else:
182
+ raise ValueError(f"unknown zero stage {zero_stage}")
183
+
184
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
185
+ return zero_stage, world_size, fp32_flat_groups
186
+
187
+
188
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
189
+ """
190
+ Returns fp32 state_dict reconstructed from ds checkpoint
191
+
192
+ Args:
193
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
194
+
195
+ """
196
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
197
+
198
+ optim_files = get_optim_files(ds_checkpoint_dir)
199
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
200
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
201
+
202
+ model_files = get_model_state_files(ds_checkpoint_dir)
203
+
204
+ zero_model_states = parse_model_states(model_files)
205
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
206
+
207
+ if zero_stage <= 2:
208
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
209
+ exclude_frozen_parameters)
210
+ elif zero_stage == 3:
211
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
212
+ exclude_frozen_parameters)
213
+
214
+
215
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
216
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
217
+ return
218
+
219
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
220
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
221
+
222
+ if debug:
223
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
224
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
225
+
226
+ wanted_params = len(frozen_param_shapes)
227
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
228
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
229
+ print(f'Frozen params: Have {avail_numel} numels to process.')
230
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
231
+
232
+ total_params = 0
233
+ total_numel = 0
234
+ for name, shape in frozen_param_shapes.items():
235
+ total_params += 1
236
+ unpartitioned_numel = shape.numel()
237
+ total_numel += unpartitioned_numel
238
+
239
+ state_dict[name] = frozen_param_fragments[name]
240
+
241
+ if debug:
242
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
243
+
244
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
245
+
246
+
247
+ def _has_callable(obj, fn):
248
+ attr = getattr(obj, fn, None)
249
+ return callable(attr)
250
+
251
+
252
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
253
+ param_shapes = zero_model_states[0].param_shapes
254
+
255
+ # Reconstruction protocol:
256
+ #
257
+ # XXX: document this
258
+
259
+ if debug:
260
+ for i in range(world_size):
261
+ for j in range(len(fp32_flat_groups[0])):
262
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
263
+
264
+ # XXX: memory usage doubles here (zero2)
265
+ num_param_groups = len(fp32_flat_groups[0])
266
+ merged_single_partition_of_fp32_groups = []
267
+ for i in range(num_param_groups):
268
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
269
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
270
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
271
+ avail_numel = sum(
272
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
273
+
274
+ if debug:
275
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
276
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
277
+ # not asserting if there is a mismatch due to possible padding
278
+ print(f"Have {avail_numel} numels to process.")
279
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
280
+
281
+ # params
282
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
283
+ # out-of-core computing solution
284
+ total_numel = 0
285
+ total_params = 0
286
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
287
+ offset = 0
288
+ avail_numel = full_single_fp32_vector.numel()
289
+ for name, shape in shapes.items():
290
+
291
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
292
+ total_numel += unpartitioned_numel
293
+ total_params += 1
294
+
295
+ if debug:
296
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
297
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
298
+ offset += unpartitioned_numel
299
+
300
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
301
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
302
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
303
+ # live optimizer object, so we are checking that the numbers are within the right range
304
+ align_to = 2 * world_size
305
+
306
+ def zero2_align(x):
307
+ return align_to * math.ceil(x / align_to)
308
+
309
+ if debug:
310
+ print(f"original offset={offset}, avail_numel={avail_numel}")
311
+
312
+ offset = zero2_align(offset)
313
+ avail_numel = zero2_align(avail_numel)
314
+
315
+ if debug:
316
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
317
+
318
+ # Sanity check
319
+ if offset != avail_numel:
320
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
321
+
322
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
323
+
324
+
325
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
326
+ exclude_frozen_parameters):
327
+ state_dict = OrderedDict()
328
+
329
+ # buffers
330
+ buffers = zero_model_states[0].buffers
331
+ state_dict.update(buffers)
332
+ if debug:
333
+ print(f"added {len(buffers)} buffers")
334
+
335
+ if not exclude_frozen_parameters:
336
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
337
+
338
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
339
+
340
+ # recover shared parameters
341
+ for pair in zero_model_states[0].shared_params:
342
+ if pair[1] in state_dict:
343
+ state_dict[pair[0]] = state_dict[pair[1]]
344
+
345
+ return state_dict
346
+
347
+
348
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
349
+ remainder = unpartitioned_numel % world_size
350
+ padding_numel = (world_size - remainder) if remainder else 0
351
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
352
+ return partitioned_numel, padding_numel
353
+
354
+
355
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
356
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
357
+ return
358
+
359
+ if debug:
360
+ for i in range(world_size):
361
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
362
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
363
+
364
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
365
+ wanted_params = len(frozen_param_shapes)
366
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
367
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
368
+ print(f'Frozen params: Have {avail_numel} numels to process.')
369
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
370
+
371
+ total_params = 0
372
+ total_numel = 0
373
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
374
+ total_params += 1
375
+ unpartitioned_numel = shape.numel()
376
+ total_numel += unpartitioned_numel
377
+
378
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
379
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
380
+
381
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
382
+
383
+ if debug:
384
+ print(
385
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
386
+ )
387
+
388
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
389
+
390
+
391
+ class GatheredTensor:
392
+ """
393
+ A pseudo tensor that collects partitioned weights.
394
+ It is more memory efficient when there are multiple groups.
395
+ """
396
+
397
+ def __init__(self, flat_groups, flat_groups_offset, offset, partitioned_numel, shape):
398
+ self.flat_groups = flat_groups
399
+ self.flat_groups_offset = flat_groups_offset
400
+ self.offset = offset
401
+ self.partitioned_numel = partitioned_numel
402
+ self.shape = shape
403
+ self.dtype = self.flat_groups[0][0].dtype
404
+
405
+ def contiguous(self):
406
+ """
407
+ Merge partitioned weights from flat_groups into a single tensor.
408
+ """
409
+ end_idx = self.offset + self.partitioned_numel
410
+ world_size = len(self.flat_groups)
411
+ pad_flat_param_chunks = []
412
+
413
+ for rank_i in range(world_size):
414
+ # for each rank, we need to collect weights from related group/groups
415
+ flat_groups_at_rank_i = self.flat_groups[rank_i]
416
+ start_group_id = None
417
+ end_group_id = None
418
+ for group_id in range(len(self.flat_groups_offset)):
419
+ if self.flat_groups_offset[group_id] <= self.offset < self.flat_groups_offset[group_id + 1]:
420
+ start_group_id = group_id
421
+ if self.flat_groups_offset[group_id] < end_idx <= self.flat_groups_offset[group_id + 1]:
422
+ end_group_id = group_id
423
+ break
424
+ # collect weights from related group/groups
425
+ for group_id in range(start_group_id, end_group_id + 1):
426
+ flat_tensor = flat_groups_at_rank_i[group_id]
427
+ start_offset = self.offset - self.flat_groups_offset[group_id]
428
+ end_offset = min(end_idx, self.flat_groups_offset[group_id + 1]) - self.flat_groups_offset[group_id]
429
+ pad_flat_param_chunks.append(flat_tensor[start_offset:end_offset])
430
+
431
+ # collect weights from all ranks
432
+ pad_flat_param = torch.cat(pad_flat_param_chunks, dim=0)
433
+ param = pad_flat_param[:self.shape.numel()].view(self.shape).contiguous()
434
+ return param
435
+
436
+
437
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
438
+ param_shapes = zero_model_states[0].param_shapes
439
+ avail_numel = sum([flat_group.numel() for flat_group in fp32_flat_groups[0]]) * world_size
440
+
441
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
442
+ # param, re-consolidating each param, while dealing with padding if any
443
+
444
+ # merge list of dicts, preserving order
445
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
446
+
447
+ if debug:
448
+ for i in range(world_size):
449
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
450
+
451
+ wanted_params = len(param_shapes)
452
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
453
+ # not asserting if there is a mismatch due to possible padding
454
+ avail_numel = fp32_flat_groups[0].numel() * world_size
455
+ print(f"Trainable params: Have {avail_numel} numels to process.")
456
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
457
+
458
+ # params
459
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
460
+ # out-of-core computing solution
461
+ offset = 0
462
+ total_numel = 0
463
+ total_params = 0
464
+ flat_groups_offset = [0] + list(np.cumsum([flat_tensor.numel() for flat_tensor in fp32_flat_groups[0]]))
465
+ for name, shape in tqdm(param_shapes.items(), desc='Gathering sharded weights'):
466
+ unpartitioned_numel = shape.numel()
467
+ total_numel += unpartitioned_numel
468
+ total_params += 1
469
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
470
+
471
+ if debug:
472
+ print(
473
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
474
+ )
475
+
476
+ # memory efficient tensor
477
+ tensor = GatheredTensor(fp32_flat_groups, flat_groups_offset, offset, partitioned_numel, shape)
478
+ state_dict[name] = tensor
479
+ offset += partitioned_numel
480
+
481
+ offset *= world_size
482
+
483
+ # Sanity check
484
+ if offset != avail_numel:
485
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
486
+
487
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
488
+
489
+
490
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
491
+ exclude_frozen_parameters):
492
+ state_dict = OrderedDict()
493
+
494
+ # buffers
495
+ buffers = zero_model_states[0].buffers
496
+ state_dict.update(buffers)
497
+ if debug:
498
+ print(f"added {len(buffers)} buffers")
499
+
500
+ if not exclude_frozen_parameters:
501
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
502
+
503
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
504
+
505
+ # recover shared parameters
506
+ for pair in zero_model_states[0].shared_params:
507
+ if pair[1] in state_dict:
508
+ state_dict[pair[0]] = state_dict[pair[1]]
509
+
510
+ return state_dict
511
+
512
+
513
+ def to_torch_tensor(state_dict, return_empty_tensor=False):
514
+ """
515
+ Convert state_dict of GatheredTensor to torch tensor
516
+ """
517
+ torch_state_dict = {}
518
+ converted_tensors = {}
519
+ for name, tensor in state_dict.items():
520
+ tensor_id = id(tensor)
521
+ if tensor_id in converted_tensors: # shared tensors
522
+ shared_tensor = torch_state_dict[converted_tensors[tensor_id]]
523
+ torch_state_dict[name] = shared_tensor
524
+ else:
525
+ converted_tensors[tensor_id] = name
526
+ if return_empty_tensor:
527
+ torch_state_dict[name] = torch.empty(tensor.shape, dtype=tensor.dtype)
528
+ else:
529
+ torch_state_dict[name] = tensor.contiguous()
530
+ return torch_state_dict
531
+
532
+
533
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
534
+ tag=None,
535
+ exclude_frozen_parameters=False,
536
+ lazy_mode=False):
537
+ """
538
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
539
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
540
+ via a model hub.
541
+
542
+ Args:
543
+ - ``checkpoint_dir``: path to the desired checkpoint folder
544
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in 'latest' file. e.g., ``global_step14``
545
+ - ``exclude_frozen_parameters``: exclude frozen parameters
546
+ - ``lazy_mode``: get state_dict in lazy mode. It returns a dict of pesduo tensor instead of torch tensor, which is more memory efficient.
547
+ Convert the pesduo tensor to torch tensor by ``.contiguous()``
548
+
549
+ Returns:
550
+ - pytorch ``state_dict``
551
+
552
+ A typical usage might be ::
553
+
554
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
555
+ # do the training and checkpoint saving
556
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
557
+ model = model.cpu() # move to cpu
558
+ model.load_state_dict(state_dict)
559
+ # submit to model hub or save the model to share with others
560
+
561
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
562
+ application. i.e. you will need to re-initialize the deepspeed engine, since
563
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
564
+
565
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
566
+
567
+ Note: the above usage may not work if your application doesn't have sufficient free CPU memory.
568
+ You may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
569
+ the checkpoint. Or you can load state_dict in lazy mode ::
570
+
571
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
572
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, lazy_mode=True) # not on cpu
573
+ for name, lazy_tensor in state_dict.item():
574
+ tensor = lazy_tensor.contiguous() # to cpu
575
+ print(name, tensor)
576
+ # del tensor to release memory if it no longer in use
577
+ """
578
+ if tag is None:
579
+ latest_path = os.path.join(checkpoint_dir, 'latest')
580
+ if os.path.isfile(latest_path):
581
+ with open(latest_path, 'r') as fd:
582
+ tag = fd.read().strip()
583
+ else:
584
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
585
+
586
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
587
+
588
+ if not os.path.isdir(ds_checkpoint_dir):
589
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
590
+
591
+ state_dict = _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
592
+ if lazy_mode:
593
+ return state_dict
594
+ else:
595
+ return to_torch_tensor(state_dict)
596
+
597
+
598
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
599
+ output_dir,
600
+ max_shard_size="5GB",
601
+ safe_serialization=False,
602
+ tag=None,
603
+ exclude_frozen_parameters=False):
604
+ """
605
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
606
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
607
+
608
+ Args:
609
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
610
+ - ``output_dir``: directory to the pytorch fp32 state_dict output files
611
+ - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
612
+ - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
613
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
614
+ - ``exclude_frozen_parameters``: exclude frozen parameters
615
+ """
616
+
617
+ # Dependency pre-check
618
+ if safe_serialization:
619
+ try:
620
+ from safetensors.torch import save_file
621
+ except ImportError:
622
+ print('If you want to use `safe_serialization`, please `pip install safetensors`')
623
+ raise
624
+ if max_shard_size is not None:
625
+ try:
626
+ from huggingface_hub import split_torch_state_dict_into_shards
627
+ except ImportError:
628
+ print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
629
+ raise
630
+
631
+ # Convert zero checkpoint to state_dict
632
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
633
+ tag,
634
+ exclude_frozen_parameters,
635
+ lazy_mode=True)
636
+
637
+ # Shard the model if it is too big.
638
+ weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
639
+ if max_shard_size is not None:
640
+ filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
641
+ # an memory-efficient approach for sharding
642
+ empty_state_dict = to_torch_tensor(state_dict, return_empty_tensor=True)
643
+ state_dict_split = split_torch_state_dict_into_shards(empty_state_dict,
644
+ filename_pattern=filename_pattern,
645
+ max_shard_size=max_shard_size)
646
+ else:
647
+ from collections import namedtuple
648
+ StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
649
+ state_dict_split = StateDictSplit(is_sharded=False,
650
+ filename_to_tensors={weights_name: list(state_dict.keys())})
651
+
652
+ # Save the model by shard
653
+ os.makedirs(output_dir, exist_ok=True)
654
+ filename_to_tensors = state_dict_split.filename_to_tensors.items()
655
+ for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
656
+ shard_state_dict = {tensor_name: state_dict[tensor_name] for tensor_name in tensors}
657
+ shard_state_dict = to_torch_tensor(shard_state_dict)
658
+ output_path = os.path.join(output_dir, shard_file)
659
+ if safe_serialization:
660
+ save_file(shard_state_dict, output_path, metadata={"format": "pt"})
661
+ else:
662
+ torch.save(shard_state_dict, output_path)
663
+ # release the memory of current shard
664
+ for tensor_name in list(shard_state_dict.keys()):
665
+ del state_dict[tensor_name]
666
+ del shard_state_dict[tensor_name]
667
+ del shard_state_dict
668
+ gc.collect()
669
+
670
+ # Save index if sharded
671
+ if state_dict_split.is_sharded:
672
+ index = {
673
+ "metadata": state_dict_split.metadata,
674
+ "weight_map": state_dict_split.tensor_to_filename,
675
+ }
676
+ save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
677
+ save_index_file = os.path.join(output_dir, save_index_file)
678
+ with open(save_index_file, "w", encoding="utf-8") as f:
679
+ content = json.dumps(index, indent=2, sort_keys=True) + "\n"
680
+ f.write(content)
681
+
682
+
683
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
684
+ """
685
+ 1. Put the provided model to cpu
686
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
687
+ 3. Load it into the provided model
688
+
689
+ Args:
690
+ - ``model``: the model object to update
691
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
692
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
693
+
694
+ Returns:
695
+ - ``model`: modified model
696
+
697
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
698
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
699
+ conveniently placed for you in the checkpoint folder.
700
+
701
+ A typical usage might be ::
702
+
703
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
704
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
705
+ # submit to model hub or save the model to share with others
706
+
707
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
708
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
709
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
710
+
711
+ """
712
+ logger.info(f"Extracting fp32 weights")
713
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
714
+
715
+ logger.info(f"Overwriting model with fp32 weights")
716
+ model = model.cpu()
717
+ model.load_state_dict(state_dict, strict=False)
718
+
719
+ return model
720
+
721
+
722
+ if __name__ == "__main__":
723
+ parser = argparse.ArgumentParser()
724
+ parser.add_argument("checkpoint_dir",
725
+ type=str,
726
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
727
+ parser.add_argument("output_dir",
728
+ type=str,
729
+ help="directory to the pytorch fp32 state_dict output files"
730
+ "(e.g. path/checkpoint-12-output/)")
731
+ parser.add_argument(
732
+ "--max_shard_size",
733
+ type=str,
734
+ default="5GB",
735
+ help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
736
+ "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
737
+ "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
738
+ "without CPU OOM issues.")
739
+ parser.add_argument(
740
+ "--safe_serialization",
741
+ default=False,
742
+ action='store_true',
743
+ help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
744
+ parser.add_argument("-t",
745
+ "--tag",
746
+ type=str,
747
+ default=None,
748
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
749
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
750
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
751
+ args = parser.parse_args()
752
+
753
+ debug = args.debug
754
+
755
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
756
+ args.output_dir,
757
+ max_shard_size=args.max_shard_size,
758
+ safe_serialization=args.safe_serialization,
759
+ tag=args.tag,
760
+ exclude_frozen_parameters=args.exclude_frozen_parameters)
checkpoint-30000/global_step30000/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:632d98295ee2d46a666ae098a5d5b61e5941505a8445acb615f36b887fbb6e9d
3
+ size 8005108236
checkpoint-30000/global_step30000/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:67072825cf7651c80c2ff760ac6ade13c89867b0766e8e970cfd55eb41a9d8d0
3
+ size 8005064076
checkpoint-30000/global_step30000/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a1c3ffb9ec45b1502eb47c8f6fa3044bb8d65ee2a11a08495f13d121fbef3946
3
+ size 2668900764
checkpoint-30000/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step30000
checkpoint-30000/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7156f353c7ec1e64db9982cea0b52b0a0896b52ec7de1f69676cbd2c892ecd17
3
+ size 17678656921
checkpoint-30000/rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ebaa187979fd0e7a362307fce1e867f92d6316adb00f213536af09466b6d2366
3
+ size 14512
checkpoint-30000/rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f06401741883a3ef54a64db7c0fcee8dcca52c3317069b43de5360893a2e9024
3
+ size 14512
checkpoint-30000/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b73a87e7c1c099f104125fccd174a6666f174c693a596adfa038c7b8267f0a4e
3
+ size 1064
checkpoint-30000/trainer_state.json ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-30000/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:735a552aa1714bfc383df4ff1a42a38cfe32c5c5b2762c0a21b52159da19005f
3
+ size 6904
checkpoint-30000/zero_to_fp32.py ADDED
@@ -0,0 +1,760 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # Copyright (c) Microsoft Corporation.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ # DeepSpeed Team
7
+
8
+ # This script extracts fp32 consolidated weights from a zero 1, 2 and 3 DeepSpeed checkpoints. It gets
9
+ # copied into the top level checkpoint dir, so the user can easily do the conversion at any point in
10
+ # the future. Once extracted, the weights don't require DeepSpeed and can be used in any
11
+ # application.
12
+ #
13
+ # example:
14
+ # python zero_to_fp32.py . output_dir/
15
+ # or
16
+ # python zero_to_fp32.py . output_dir/ --safe_serialization
17
+
18
+ import argparse
19
+ import torch
20
+ import glob
21
+ import math
22
+ import os
23
+ import re
24
+ import gc
25
+ import json
26
+ import numpy as np
27
+ from tqdm import tqdm
28
+ from collections import OrderedDict
29
+ from dataclasses import dataclass
30
+
31
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
32
+ # DeepSpeed data structures it has to be available in the current python environment.
33
+ from deepspeed.utils import logger
34
+ from deepspeed.checkpoint.constants import (DS_VERSION, OPTIMIZER_STATE_DICT, SINGLE_PARTITION_OF_FP32_GROUPS,
35
+ FP32_FLAT_GROUPS, ZERO_STAGE, PARTITION_COUNT, PARAM_SHAPES, BUFFER_NAMES,
36
+ FROZEN_PARAM_SHAPES, FROZEN_PARAM_FRAGMENTS)
37
+
38
+
39
+ @dataclass
40
+ class zero_model_state:
41
+ buffers: dict()
42
+ param_shapes: dict()
43
+ shared_params: list
44
+ ds_version: int
45
+ frozen_param_shapes: dict()
46
+ frozen_param_fragments: dict()
47
+
48
+
49
+ debug = 0
50
+
51
+ # load to cpu
52
+ device = torch.device('cpu')
53
+
54
+
55
+ def atoi(text):
56
+ return int(text) if text.isdigit() else text
57
+
58
+
59
+ def natural_keys(text):
60
+ '''
61
+ alist.sort(key=natural_keys) sorts in human order
62
+ http://nedbatchelder.com/blog/200712/human_sorting.html
63
+ (See Toothy's implementation in the comments)
64
+ '''
65
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
66
+
67
+
68
+ def get_model_state_file(checkpoint_dir, zero_stage):
69
+ if not os.path.isdir(checkpoint_dir):
70
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
71
+
72
+ # there should be only one file
73
+ if zero_stage <= 2:
74
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
75
+ elif zero_stage == 3:
76
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
77
+
78
+ if not os.path.exists(file):
79
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
80
+
81
+ return file
82
+
83
+
84
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
85
+ # XXX: need to test that this simple glob rule works for multi-node setup too
86
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
87
+
88
+ if len(ckpt_files) == 0:
89
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
90
+
91
+ return ckpt_files
92
+
93
+
94
+ def get_optim_files(checkpoint_dir):
95
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
96
+
97
+
98
+ def get_model_state_files(checkpoint_dir):
99
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
100
+
101
+
102
+ def parse_model_states(files):
103
+ zero_model_states = []
104
+ for file in files:
105
+ state_dict = torch.load(file, map_location=device, weights_only=False)
106
+
107
+ if BUFFER_NAMES not in state_dict:
108
+ raise ValueError(f"{file} is not a model state checkpoint")
109
+ buffer_names = state_dict[BUFFER_NAMES]
110
+ if debug:
111
+ print("Found buffers:", buffer_names)
112
+
113
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
114
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
115
+ param_shapes = state_dict[PARAM_SHAPES]
116
+
117
+ # collect parameters that are included in param_shapes
118
+ param_names = []
119
+ for s in param_shapes:
120
+ for name in s.keys():
121
+ param_names.append(name)
122
+
123
+ # update with frozen parameters
124
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
125
+ if frozen_param_shapes is not None:
126
+ if debug:
127
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
128
+ param_names += list(frozen_param_shapes.keys())
129
+
130
+ # handle shared params
131
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
132
+
133
+ ds_version = state_dict.get(DS_VERSION, None)
134
+
135
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
136
+
137
+ z_model_state = zero_model_state(buffers=buffers,
138
+ param_shapes=param_shapes,
139
+ shared_params=shared_params,
140
+ ds_version=ds_version,
141
+ frozen_param_shapes=frozen_param_shapes,
142
+ frozen_param_fragments=frozen_param_fragments)
143
+ zero_model_states.append(z_model_state)
144
+
145
+ return zero_model_states
146
+
147
+
148
+ def parse_optim_states(files, ds_checkpoint_dir):
149
+ total_files = len(files)
150
+ state_dicts = []
151
+ for f in tqdm(files, desc='Loading checkpoint shards'):
152
+ state_dict = torch.load(f, map_location=device, mmap=True, weights_only=False)
153
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
154
+ # and also handle the case where it was already removed by another helper script
155
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
156
+ state_dicts.append(state_dict)
157
+
158
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
159
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
160
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
161
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
162
+
163
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
164
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
165
+ # use the max of the partition_count to get the dp world_size.
166
+
167
+ if type(world_size) is list:
168
+ world_size = max(world_size)
169
+
170
+ if world_size != total_files:
171
+ raise ValueError(
172
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
173
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
174
+ )
175
+
176
+ # the groups are named differently in each stage
177
+ if zero_stage <= 2:
178
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
179
+ elif zero_stage == 3:
180
+ fp32_groups_key = FP32_FLAT_GROUPS
181
+ else:
182
+ raise ValueError(f"unknown zero stage {zero_stage}")
183
+
184
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
185
+ return zero_stage, world_size, fp32_flat_groups
186
+
187
+
188
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
189
+ """
190
+ Returns fp32 state_dict reconstructed from ds checkpoint
191
+
192
+ Args:
193
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
194
+
195
+ """
196
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
197
+
198
+ optim_files = get_optim_files(ds_checkpoint_dir)
199
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
200
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
201
+
202
+ model_files = get_model_state_files(ds_checkpoint_dir)
203
+
204
+ zero_model_states = parse_model_states(model_files)
205
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
206
+
207
+ if zero_stage <= 2:
208
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
209
+ exclude_frozen_parameters)
210
+ elif zero_stage == 3:
211
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
212
+ exclude_frozen_parameters)
213
+
214
+
215
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
216
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
217
+ return
218
+
219
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
220
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
221
+
222
+ if debug:
223
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
224
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
225
+
226
+ wanted_params = len(frozen_param_shapes)
227
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
228
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
229
+ print(f'Frozen params: Have {avail_numel} numels to process.')
230
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
231
+
232
+ total_params = 0
233
+ total_numel = 0
234
+ for name, shape in frozen_param_shapes.items():
235
+ total_params += 1
236
+ unpartitioned_numel = shape.numel()
237
+ total_numel += unpartitioned_numel
238
+
239
+ state_dict[name] = frozen_param_fragments[name]
240
+
241
+ if debug:
242
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
243
+
244
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
245
+
246
+
247
+ def _has_callable(obj, fn):
248
+ attr = getattr(obj, fn, None)
249
+ return callable(attr)
250
+
251
+
252
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
253
+ param_shapes = zero_model_states[0].param_shapes
254
+
255
+ # Reconstruction protocol:
256
+ #
257
+ # XXX: document this
258
+
259
+ if debug:
260
+ for i in range(world_size):
261
+ for j in range(len(fp32_flat_groups[0])):
262
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
263
+
264
+ # XXX: memory usage doubles here (zero2)
265
+ num_param_groups = len(fp32_flat_groups[0])
266
+ merged_single_partition_of_fp32_groups = []
267
+ for i in range(num_param_groups):
268
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
269
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
270
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
271
+ avail_numel = sum(
272
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
273
+
274
+ if debug:
275
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
276
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
277
+ # not asserting if there is a mismatch due to possible padding
278
+ print(f"Have {avail_numel} numels to process.")
279
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
280
+
281
+ # params
282
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
283
+ # out-of-core computing solution
284
+ total_numel = 0
285
+ total_params = 0
286
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
287
+ offset = 0
288
+ avail_numel = full_single_fp32_vector.numel()
289
+ for name, shape in shapes.items():
290
+
291
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
292
+ total_numel += unpartitioned_numel
293
+ total_params += 1
294
+
295
+ if debug:
296
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
297
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
298
+ offset += unpartitioned_numel
299
+
300
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
301
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
302
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
303
+ # live optimizer object, so we are checking that the numbers are within the right range
304
+ align_to = 2 * world_size
305
+
306
+ def zero2_align(x):
307
+ return align_to * math.ceil(x / align_to)
308
+
309
+ if debug:
310
+ print(f"original offset={offset}, avail_numel={avail_numel}")
311
+
312
+ offset = zero2_align(offset)
313
+ avail_numel = zero2_align(avail_numel)
314
+
315
+ if debug:
316
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
317
+
318
+ # Sanity check
319
+ if offset != avail_numel:
320
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
321
+
322
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
323
+
324
+
325
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
326
+ exclude_frozen_parameters):
327
+ state_dict = OrderedDict()
328
+
329
+ # buffers
330
+ buffers = zero_model_states[0].buffers
331
+ state_dict.update(buffers)
332
+ if debug:
333
+ print(f"added {len(buffers)} buffers")
334
+
335
+ if not exclude_frozen_parameters:
336
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
337
+
338
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
339
+
340
+ # recover shared parameters
341
+ for pair in zero_model_states[0].shared_params:
342
+ if pair[1] in state_dict:
343
+ state_dict[pair[0]] = state_dict[pair[1]]
344
+
345
+ return state_dict
346
+
347
+
348
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
349
+ remainder = unpartitioned_numel % world_size
350
+ padding_numel = (world_size - remainder) if remainder else 0
351
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
352
+ return partitioned_numel, padding_numel
353
+
354
+
355
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
356
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
357
+ return
358
+
359
+ if debug:
360
+ for i in range(world_size):
361
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
362
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
363
+
364
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
365
+ wanted_params = len(frozen_param_shapes)
366
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
367
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
368
+ print(f'Frozen params: Have {avail_numel} numels to process.')
369
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
370
+
371
+ total_params = 0
372
+ total_numel = 0
373
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
374
+ total_params += 1
375
+ unpartitioned_numel = shape.numel()
376
+ total_numel += unpartitioned_numel
377
+
378
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
379
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
380
+
381
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
382
+
383
+ if debug:
384
+ print(
385
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
386
+ )
387
+
388
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
389
+
390
+
391
+ class GatheredTensor:
392
+ """
393
+ A pseudo tensor that collects partitioned weights.
394
+ It is more memory efficient when there are multiple groups.
395
+ """
396
+
397
+ def __init__(self, flat_groups, flat_groups_offset, offset, partitioned_numel, shape):
398
+ self.flat_groups = flat_groups
399
+ self.flat_groups_offset = flat_groups_offset
400
+ self.offset = offset
401
+ self.partitioned_numel = partitioned_numel
402
+ self.shape = shape
403
+ self.dtype = self.flat_groups[0][0].dtype
404
+
405
+ def contiguous(self):
406
+ """
407
+ Merge partitioned weights from flat_groups into a single tensor.
408
+ """
409
+ end_idx = self.offset + self.partitioned_numel
410
+ world_size = len(self.flat_groups)
411
+ pad_flat_param_chunks = []
412
+
413
+ for rank_i in range(world_size):
414
+ # for each rank, we need to collect weights from related group/groups
415
+ flat_groups_at_rank_i = self.flat_groups[rank_i]
416
+ start_group_id = None
417
+ end_group_id = None
418
+ for group_id in range(len(self.flat_groups_offset)):
419
+ if self.flat_groups_offset[group_id] <= self.offset < self.flat_groups_offset[group_id + 1]:
420
+ start_group_id = group_id
421
+ if self.flat_groups_offset[group_id] < end_idx <= self.flat_groups_offset[group_id + 1]:
422
+ end_group_id = group_id
423
+ break
424
+ # collect weights from related group/groups
425
+ for group_id in range(start_group_id, end_group_id + 1):
426
+ flat_tensor = flat_groups_at_rank_i[group_id]
427
+ start_offset = self.offset - self.flat_groups_offset[group_id]
428
+ end_offset = min(end_idx, self.flat_groups_offset[group_id + 1]) - self.flat_groups_offset[group_id]
429
+ pad_flat_param_chunks.append(flat_tensor[start_offset:end_offset])
430
+
431
+ # collect weights from all ranks
432
+ pad_flat_param = torch.cat(pad_flat_param_chunks, dim=0)
433
+ param = pad_flat_param[:self.shape.numel()].view(self.shape).contiguous()
434
+ return param
435
+
436
+
437
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
438
+ param_shapes = zero_model_states[0].param_shapes
439
+ avail_numel = sum([flat_group.numel() for flat_group in fp32_flat_groups[0]]) * world_size
440
+
441
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
442
+ # param, re-consolidating each param, while dealing with padding if any
443
+
444
+ # merge list of dicts, preserving order
445
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
446
+
447
+ if debug:
448
+ for i in range(world_size):
449
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
450
+
451
+ wanted_params = len(param_shapes)
452
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
453
+ # not asserting if there is a mismatch due to possible padding
454
+ avail_numel = fp32_flat_groups[0].numel() * world_size
455
+ print(f"Trainable params: Have {avail_numel} numels to process.")
456
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
457
+
458
+ # params
459
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
460
+ # out-of-core computing solution
461
+ offset = 0
462
+ total_numel = 0
463
+ total_params = 0
464
+ flat_groups_offset = [0] + list(np.cumsum([flat_tensor.numel() for flat_tensor in fp32_flat_groups[0]]))
465
+ for name, shape in tqdm(param_shapes.items(), desc='Gathering sharded weights'):
466
+ unpartitioned_numel = shape.numel()
467
+ total_numel += unpartitioned_numel
468
+ total_params += 1
469
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
470
+
471
+ if debug:
472
+ print(
473
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
474
+ )
475
+
476
+ # memory efficient tensor
477
+ tensor = GatheredTensor(fp32_flat_groups, flat_groups_offset, offset, partitioned_numel, shape)
478
+ state_dict[name] = tensor
479
+ offset += partitioned_numel
480
+
481
+ offset *= world_size
482
+
483
+ # Sanity check
484
+ if offset != avail_numel:
485
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
486
+
487
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
488
+
489
+
490
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
491
+ exclude_frozen_parameters):
492
+ state_dict = OrderedDict()
493
+
494
+ # buffers
495
+ buffers = zero_model_states[0].buffers
496
+ state_dict.update(buffers)
497
+ if debug:
498
+ print(f"added {len(buffers)} buffers")
499
+
500
+ if not exclude_frozen_parameters:
501
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
502
+
503
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
504
+
505
+ # recover shared parameters
506
+ for pair in zero_model_states[0].shared_params:
507
+ if pair[1] in state_dict:
508
+ state_dict[pair[0]] = state_dict[pair[1]]
509
+
510
+ return state_dict
511
+
512
+
513
+ def to_torch_tensor(state_dict, return_empty_tensor=False):
514
+ """
515
+ Convert state_dict of GatheredTensor to torch tensor
516
+ """
517
+ torch_state_dict = {}
518
+ converted_tensors = {}
519
+ for name, tensor in state_dict.items():
520
+ tensor_id = id(tensor)
521
+ if tensor_id in converted_tensors: # shared tensors
522
+ shared_tensor = torch_state_dict[converted_tensors[tensor_id]]
523
+ torch_state_dict[name] = shared_tensor
524
+ else:
525
+ converted_tensors[tensor_id] = name
526
+ if return_empty_tensor:
527
+ torch_state_dict[name] = torch.empty(tensor.shape, dtype=tensor.dtype)
528
+ else:
529
+ torch_state_dict[name] = tensor.contiguous()
530
+ return torch_state_dict
531
+
532
+
533
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
534
+ tag=None,
535
+ exclude_frozen_parameters=False,
536
+ lazy_mode=False):
537
+ """
538
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
539
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
540
+ via a model hub.
541
+
542
+ Args:
543
+ - ``checkpoint_dir``: path to the desired checkpoint folder
544
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in 'latest' file. e.g., ``global_step14``
545
+ - ``exclude_frozen_parameters``: exclude frozen parameters
546
+ - ``lazy_mode``: get state_dict in lazy mode. It returns a dict of pesduo tensor instead of torch tensor, which is more memory efficient.
547
+ Convert the pesduo tensor to torch tensor by ``.contiguous()``
548
+
549
+ Returns:
550
+ - pytorch ``state_dict``
551
+
552
+ A typical usage might be ::
553
+
554
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
555
+ # do the training and checkpoint saving
556
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
557
+ model = model.cpu() # move to cpu
558
+ model.load_state_dict(state_dict)
559
+ # submit to model hub or save the model to share with others
560
+
561
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
562
+ application. i.e. you will need to re-initialize the deepspeed engine, since
563
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
564
+
565
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
566
+
567
+ Note: the above usage may not work if your application doesn't have sufficient free CPU memory.
568
+ You may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
569
+ the checkpoint. Or you can load state_dict in lazy mode ::
570
+
571
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
572
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, lazy_mode=True) # not on cpu
573
+ for name, lazy_tensor in state_dict.item():
574
+ tensor = lazy_tensor.contiguous() # to cpu
575
+ print(name, tensor)
576
+ # del tensor to release memory if it no longer in use
577
+ """
578
+ if tag is None:
579
+ latest_path = os.path.join(checkpoint_dir, 'latest')
580
+ if os.path.isfile(latest_path):
581
+ with open(latest_path, 'r') as fd:
582
+ tag = fd.read().strip()
583
+ else:
584
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
585
+
586
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
587
+
588
+ if not os.path.isdir(ds_checkpoint_dir):
589
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
590
+
591
+ state_dict = _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
592
+ if lazy_mode:
593
+ return state_dict
594
+ else:
595
+ return to_torch_tensor(state_dict)
596
+
597
+
598
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
599
+ output_dir,
600
+ max_shard_size="5GB",
601
+ safe_serialization=False,
602
+ tag=None,
603
+ exclude_frozen_parameters=False):
604
+ """
605
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
606
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
607
+
608
+ Args:
609
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
610
+ - ``output_dir``: directory to the pytorch fp32 state_dict output files
611
+ - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
612
+ - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
613
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
614
+ - ``exclude_frozen_parameters``: exclude frozen parameters
615
+ """
616
+
617
+ # Dependency pre-check
618
+ if safe_serialization:
619
+ try:
620
+ from safetensors.torch import save_file
621
+ except ImportError:
622
+ print('If you want to use `safe_serialization`, please `pip install safetensors`')
623
+ raise
624
+ if max_shard_size is not None:
625
+ try:
626
+ from huggingface_hub import split_torch_state_dict_into_shards
627
+ except ImportError:
628
+ print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
629
+ raise
630
+
631
+ # Convert zero checkpoint to state_dict
632
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
633
+ tag,
634
+ exclude_frozen_parameters,
635
+ lazy_mode=True)
636
+
637
+ # Shard the model if it is too big.
638
+ weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
639
+ if max_shard_size is not None:
640
+ filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
641
+ # an memory-efficient approach for sharding
642
+ empty_state_dict = to_torch_tensor(state_dict, return_empty_tensor=True)
643
+ state_dict_split = split_torch_state_dict_into_shards(empty_state_dict,
644
+ filename_pattern=filename_pattern,
645
+ max_shard_size=max_shard_size)
646
+ else:
647
+ from collections import namedtuple
648
+ StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
649
+ state_dict_split = StateDictSplit(is_sharded=False,
650
+ filename_to_tensors={weights_name: list(state_dict.keys())})
651
+
652
+ # Save the model by shard
653
+ os.makedirs(output_dir, exist_ok=True)
654
+ filename_to_tensors = state_dict_split.filename_to_tensors.items()
655
+ for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
656
+ shard_state_dict = {tensor_name: state_dict[tensor_name] for tensor_name in tensors}
657
+ shard_state_dict = to_torch_tensor(shard_state_dict)
658
+ output_path = os.path.join(output_dir, shard_file)
659
+ if safe_serialization:
660
+ save_file(shard_state_dict, output_path, metadata={"format": "pt"})
661
+ else:
662
+ torch.save(shard_state_dict, output_path)
663
+ # release the memory of current shard
664
+ for tensor_name in list(shard_state_dict.keys()):
665
+ del state_dict[tensor_name]
666
+ del shard_state_dict[tensor_name]
667
+ del shard_state_dict
668
+ gc.collect()
669
+
670
+ # Save index if sharded
671
+ if state_dict_split.is_sharded:
672
+ index = {
673
+ "metadata": state_dict_split.metadata,
674
+ "weight_map": state_dict_split.tensor_to_filename,
675
+ }
676
+ save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
677
+ save_index_file = os.path.join(output_dir, save_index_file)
678
+ with open(save_index_file, "w", encoding="utf-8") as f:
679
+ content = json.dumps(index, indent=2, sort_keys=True) + "\n"
680
+ f.write(content)
681
+
682
+
683
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
684
+ """
685
+ 1. Put the provided model to cpu
686
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
687
+ 3. Load it into the provided model
688
+
689
+ Args:
690
+ - ``model``: the model object to update
691
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
692
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
693
+
694
+ Returns:
695
+ - ``model`: modified model
696
+
697
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
698
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
699
+ conveniently placed for you in the checkpoint folder.
700
+
701
+ A typical usage might be ::
702
+
703
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
704
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
705
+ # submit to model hub or save the model to share with others
706
+
707
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
708
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
709
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
710
+
711
+ """
712
+ logger.info(f"Extracting fp32 weights")
713
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
714
+
715
+ logger.info(f"Overwriting model with fp32 weights")
716
+ model = model.cpu()
717
+ model.load_state_dict(state_dict, strict=False)
718
+
719
+ return model
720
+
721
+
722
+ if __name__ == "__main__":
723
+ parser = argparse.ArgumentParser()
724
+ parser.add_argument("checkpoint_dir",
725
+ type=str,
726
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
727
+ parser.add_argument("output_dir",
728
+ type=str,
729
+ help="directory to the pytorch fp32 state_dict output files"
730
+ "(e.g. path/checkpoint-12-output/)")
731
+ parser.add_argument(
732
+ "--max_shard_size",
733
+ type=str,
734
+ default="5GB",
735
+ help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
736
+ "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
737
+ "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
738
+ "without CPU OOM issues.")
739
+ parser.add_argument(
740
+ "--safe_serialization",
741
+ default=False,
742
+ action='store_true',
743
+ help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
744
+ parser.add_argument("-t",
745
+ "--tag",
746
+ type=str,
747
+ default=None,
748
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
749
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
750
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
751
+ args = parser.parse_args()
752
+
753
+ debug = args.debug
754
+
755
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
756
+ args.output_dir,
757
+ max_shard_size=args.max_shard_size,
758
+ safe_serialization=args.safe_serialization,
759
+ tag=args.tag,
760
+ exclude_frozen_parameters=args.exclude_frozen_parameters)
checkpoint-38184/global_step38184/bf16_zero_pp_rank_0_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b4b0b3d9a3254f5fb1fa36f48ee0b4369cf2adf515ed69633e275a71239360a
3
+ size 8005108236
checkpoint-38184/global_step38184/bf16_zero_pp_rank_1_mp_rank_00_optim_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3f743b9666fc49c1ebad272eb3b3a306976b05a44bc70f4ae430c07746997b07
3
+ size 8005064076
checkpoint-38184/global_step38184/mp_rank_00_model_states.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ee01562a9abcafeb7e92730b0b4b3c1c0bc72cbe8340f803c512f21535e4c3b
3
+ size 2668900764
checkpoint-38184/latest ADDED
@@ -0,0 +1 @@
 
 
1
+ global_step38184
checkpoint-38184/pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc827c4f5058ad23551269a1859f36e04fd1e515f2966286362625492420b8cd
3
+ size 17678656921
checkpoint-38184/rng_state_0.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0faedd604098d980819b9489442d3db984f874373123ca7de95e1996ccf996bc
3
+ size 14448
checkpoint-38184/rng_state_1.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:38eccbe5fbf40dd28f8fa55d327041e9a8e750e58b94ecccee67f1a3976d5937
3
+ size 14448
checkpoint-38184/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2d0b21313f367e0a9c14d8f2843af0f0aacb8598eb346c719a4da16e9d4a5a21
3
+ size 1064
checkpoint-38184/trainer_state.json ADDED
The diff for this file is too large to render. See raw diff
 
checkpoint-38184/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:735a552aa1714bfc383df4ff1a42a38cfe32c5c5b2762c0a21b52159da19005f
3
+ size 6904
checkpoint-38184/zero_to_fp32.py ADDED
@@ -0,0 +1,760 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+
3
+ # Copyright (c) Microsoft Corporation.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ # DeepSpeed Team
7
+
8
+ # This script extracts fp32 consolidated weights from a zero 1, 2 and 3 DeepSpeed checkpoints. It gets
9
+ # copied into the top level checkpoint dir, so the user can easily do the conversion at any point in
10
+ # the future. Once extracted, the weights don't require DeepSpeed and can be used in any
11
+ # application.
12
+ #
13
+ # example:
14
+ # python zero_to_fp32.py . output_dir/
15
+ # or
16
+ # python zero_to_fp32.py . output_dir/ --safe_serialization
17
+
18
+ import argparse
19
+ import torch
20
+ import glob
21
+ import math
22
+ import os
23
+ import re
24
+ import gc
25
+ import json
26
+ import numpy as np
27
+ from tqdm import tqdm
28
+ from collections import OrderedDict
29
+ from dataclasses import dataclass
30
+
31
+ # while this script doesn't use deepspeed to recover data, since the checkpoints are pickled with
32
+ # DeepSpeed data structures it has to be available in the current python environment.
33
+ from deepspeed.utils import logger
34
+ from deepspeed.checkpoint.constants import (DS_VERSION, OPTIMIZER_STATE_DICT, SINGLE_PARTITION_OF_FP32_GROUPS,
35
+ FP32_FLAT_GROUPS, ZERO_STAGE, PARTITION_COUNT, PARAM_SHAPES, BUFFER_NAMES,
36
+ FROZEN_PARAM_SHAPES, FROZEN_PARAM_FRAGMENTS)
37
+
38
+
39
+ @dataclass
40
+ class zero_model_state:
41
+ buffers: dict()
42
+ param_shapes: dict()
43
+ shared_params: list
44
+ ds_version: int
45
+ frozen_param_shapes: dict()
46
+ frozen_param_fragments: dict()
47
+
48
+
49
+ debug = 0
50
+
51
+ # load to cpu
52
+ device = torch.device('cpu')
53
+
54
+
55
+ def atoi(text):
56
+ return int(text) if text.isdigit() else text
57
+
58
+
59
+ def natural_keys(text):
60
+ '''
61
+ alist.sort(key=natural_keys) sorts in human order
62
+ http://nedbatchelder.com/blog/200712/human_sorting.html
63
+ (See Toothy's implementation in the comments)
64
+ '''
65
+ return [atoi(c) for c in re.split(r'(\d+)', text)]
66
+
67
+
68
+ def get_model_state_file(checkpoint_dir, zero_stage):
69
+ if not os.path.isdir(checkpoint_dir):
70
+ raise FileNotFoundError(f"Directory '{checkpoint_dir}' doesn't exist")
71
+
72
+ # there should be only one file
73
+ if zero_stage <= 2:
74
+ file = os.path.join(checkpoint_dir, "mp_rank_00_model_states.pt")
75
+ elif zero_stage == 3:
76
+ file = os.path.join(checkpoint_dir, "zero_pp_rank_0_mp_rank_00_model_states.pt")
77
+
78
+ if not os.path.exists(file):
79
+ raise FileNotFoundError(f"can't find model states file at '{file}'")
80
+
81
+ return file
82
+
83
+
84
+ def get_checkpoint_files(checkpoint_dir, glob_pattern):
85
+ # XXX: need to test that this simple glob rule works for multi-node setup too
86
+ ckpt_files = sorted(glob.glob(os.path.join(checkpoint_dir, glob_pattern)), key=natural_keys)
87
+
88
+ if len(ckpt_files) == 0:
89
+ raise FileNotFoundError(f"can't find {glob_pattern} files in directory '{checkpoint_dir}'")
90
+
91
+ return ckpt_files
92
+
93
+
94
+ def get_optim_files(checkpoint_dir):
95
+ return get_checkpoint_files(checkpoint_dir, "*_optim_states.pt")
96
+
97
+
98
+ def get_model_state_files(checkpoint_dir):
99
+ return get_checkpoint_files(checkpoint_dir, "*_model_states.pt")
100
+
101
+
102
+ def parse_model_states(files):
103
+ zero_model_states = []
104
+ for file in files:
105
+ state_dict = torch.load(file, map_location=device, weights_only=False)
106
+
107
+ if BUFFER_NAMES not in state_dict:
108
+ raise ValueError(f"{file} is not a model state checkpoint")
109
+ buffer_names = state_dict[BUFFER_NAMES]
110
+ if debug:
111
+ print("Found buffers:", buffer_names)
112
+
113
+ # recover just the buffers while restoring them to fp32 if they were saved in fp16
114
+ buffers = {k: v.float() for k, v in state_dict["module"].items() if k in buffer_names}
115
+ param_shapes = state_dict[PARAM_SHAPES]
116
+
117
+ # collect parameters that are included in param_shapes
118
+ param_names = []
119
+ for s in param_shapes:
120
+ for name in s.keys():
121
+ param_names.append(name)
122
+
123
+ # update with frozen parameters
124
+ frozen_param_shapes = state_dict.get(FROZEN_PARAM_SHAPES, None)
125
+ if frozen_param_shapes is not None:
126
+ if debug:
127
+ print(f"Found frozen_param_shapes: {frozen_param_shapes}")
128
+ param_names += list(frozen_param_shapes.keys())
129
+
130
+ # handle shared params
131
+ shared_params = [[k, v] for k, v in state_dict["shared_params"].items()]
132
+
133
+ ds_version = state_dict.get(DS_VERSION, None)
134
+
135
+ frozen_param_fragments = state_dict.get(FROZEN_PARAM_FRAGMENTS, None)
136
+
137
+ z_model_state = zero_model_state(buffers=buffers,
138
+ param_shapes=param_shapes,
139
+ shared_params=shared_params,
140
+ ds_version=ds_version,
141
+ frozen_param_shapes=frozen_param_shapes,
142
+ frozen_param_fragments=frozen_param_fragments)
143
+ zero_model_states.append(z_model_state)
144
+
145
+ return zero_model_states
146
+
147
+
148
+ def parse_optim_states(files, ds_checkpoint_dir):
149
+ total_files = len(files)
150
+ state_dicts = []
151
+ for f in tqdm(files, desc='Loading checkpoint shards'):
152
+ state_dict = torch.load(f, map_location=device, mmap=True, weights_only=False)
153
+ # immediately discard the potentially huge 2 optimizer states as we only care for fp32 master weights
154
+ # and also handle the case where it was already removed by another helper script
155
+ state_dict["optimizer_state_dict"].pop("optimizer_state_dict", None)
156
+ state_dicts.append(state_dict)
157
+
158
+ if not ZERO_STAGE in state_dicts[0][OPTIMIZER_STATE_DICT]:
159
+ raise ValueError(f"{files[0]} is not a zero checkpoint")
160
+ zero_stage = state_dicts[0][OPTIMIZER_STATE_DICT][ZERO_STAGE]
161
+ world_size = state_dicts[0][OPTIMIZER_STATE_DICT][PARTITION_COUNT]
162
+
163
+ # For ZeRO-2 each param group can have different partition_count as data parallelism for expert
164
+ # parameters can be different from data parallelism for non-expert parameters. So we can just
165
+ # use the max of the partition_count to get the dp world_size.
166
+
167
+ if type(world_size) is list:
168
+ world_size = max(world_size)
169
+
170
+ if world_size != total_files:
171
+ raise ValueError(
172
+ f"Expected {world_size} of '*_optim_states.pt' under '{ds_checkpoint_dir}' but found {total_files} files. "
173
+ "Possibly due to an overwrite of an old checkpoint, or a checkpoint didn't get saved by one or more processes."
174
+ )
175
+
176
+ # the groups are named differently in each stage
177
+ if zero_stage <= 2:
178
+ fp32_groups_key = SINGLE_PARTITION_OF_FP32_GROUPS
179
+ elif zero_stage == 3:
180
+ fp32_groups_key = FP32_FLAT_GROUPS
181
+ else:
182
+ raise ValueError(f"unknown zero stage {zero_stage}")
183
+
184
+ fp32_flat_groups = [state_dicts[i][OPTIMIZER_STATE_DICT][fp32_groups_key] for i in range(len(state_dicts))]
185
+ return zero_stage, world_size, fp32_flat_groups
186
+
187
+
188
+ def _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters):
189
+ """
190
+ Returns fp32 state_dict reconstructed from ds checkpoint
191
+
192
+ Args:
193
+ - ``ds_checkpoint_dir``: path to the deepspeed checkpoint folder (where the optimizer files are)
194
+
195
+ """
196
+ print(f"Processing zero checkpoint '{ds_checkpoint_dir}'")
197
+
198
+ optim_files = get_optim_files(ds_checkpoint_dir)
199
+ zero_stage, world_size, fp32_flat_groups = parse_optim_states(optim_files, ds_checkpoint_dir)
200
+ print(f"Detected checkpoint of type zero stage {zero_stage}, world_size: {world_size}")
201
+
202
+ model_files = get_model_state_files(ds_checkpoint_dir)
203
+
204
+ zero_model_states = parse_model_states(model_files)
205
+ print(f'Parsing checkpoint created by deepspeed=={zero_model_states[0].ds_version}')
206
+
207
+ if zero_stage <= 2:
208
+ return _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
209
+ exclude_frozen_parameters)
210
+ elif zero_stage == 3:
211
+ return _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
212
+ exclude_frozen_parameters)
213
+
214
+
215
+ def _zero2_merge_frozen_params(state_dict, zero_model_states):
216
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
217
+ return
218
+
219
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
220
+ frozen_param_fragments = zero_model_states[0].frozen_param_fragments
221
+
222
+ if debug:
223
+ num_elem = sum(s.numel() for s in frozen_param_shapes.values())
224
+ print(f'rank 0: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
225
+
226
+ wanted_params = len(frozen_param_shapes)
227
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
228
+ avail_numel = sum([p.numel() for p in frozen_param_fragments.values()])
229
+ print(f'Frozen params: Have {avail_numel} numels to process.')
230
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
231
+
232
+ total_params = 0
233
+ total_numel = 0
234
+ for name, shape in frozen_param_shapes.items():
235
+ total_params += 1
236
+ unpartitioned_numel = shape.numel()
237
+ total_numel += unpartitioned_numel
238
+
239
+ state_dict[name] = frozen_param_fragments[name]
240
+
241
+ if debug:
242
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
243
+
244
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
245
+
246
+
247
+ def _has_callable(obj, fn):
248
+ attr = getattr(obj, fn, None)
249
+ return callable(attr)
250
+
251
+
252
+ def _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
253
+ param_shapes = zero_model_states[0].param_shapes
254
+
255
+ # Reconstruction protocol:
256
+ #
257
+ # XXX: document this
258
+
259
+ if debug:
260
+ for i in range(world_size):
261
+ for j in range(len(fp32_flat_groups[0])):
262
+ print(f"{FP32_FLAT_GROUPS}[{i}][{j}].shape={fp32_flat_groups[i][j].shape}")
263
+
264
+ # XXX: memory usage doubles here (zero2)
265
+ num_param_groups = len(fp32_flat_groups[0])
266
+ merged_single_partition_of_fp32_groups = []
267
+ for i in range(num_param_groups):
268
+ merged_partitions = [sd[i] for sd in fp32_flat_groups]
269
+ full_single_fp32_vector = torch.cat(merged_partitions, 0)
270
+ merged_single_partition_of_fp32_groups.append(full_single_fp32_vector)
271
+ avail_numel = sum(
272
+ [full_single_fp32_vector.numel() for full_single_fp32_vector in merged_single_partition_of_fp32_groups])
273
+
274
+ if debug:
275
+ wanted_params = sum([len(shapes) for shapes in param_shapes])
276
+ wanted_numel = sum([sum(shape.numel() for shape in shapes.values()) for shapes in param_shapes])
277
+ # not asserting if there is a mismatch due to possible padding
278
+ print(f"Have {avail_numel} numels to process.")
279
+ print(f"Need {wanted_numel} numels in {wanted_params} params.")
280
+
281
+ # params
282
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
283
+ # out-of-core computing solution
284
+ total_numel = 0
285
+ total_params = 0
286
+ for shapes, full_single_fp32_vector in zip(param_shapes, merged_single_partition_of_fp32_groups):
287
+ offset = 0
288
+ avail_numel = full_single_fp32_vector.numel()
289
+ for name, shape in shapes.items():
290
+
291
+ unpartitioned_numel = shape.numel() if _has_callable(shape, 'numel') else math.prod(shape)
292
+ total_numel += unpartitioned_numel
293
+ total_params += 1
294
+
295
+ if debug:
296
+ print(f"{name} full shape: {shape} unpartitioned numel {unpartitioned_numel} ")
297
+ state_dict[name] = full_single_fp32_vector.narrow(0, offset, unpartitioned_numel).view(shape)
298
+ offset += unpartitioned_numel
299
+
300
+ # Z2 started to align to 2*world_size to improve nccl performance. Therefore both offset and
301
+ # avail_numel can differ by anywhere between 0..2*world_size. Due to two unrelated complex
302
+ # paddings performed in the code it's almost impossible to predict the exact numbers w/o the
303
+ # live optimizer object, so we are checking that the numbers are within the right range
304
+ align_to = 2 * world_size
305
+
306
+ def zero2_align(x):
307
+ return align_to * math.ceil(x / align_to)
308
+
309
+ if debug:
310
+ print(f"original offset={offset}, avail_numel={avail_numel}")
311
+
312
+ offset = zero2_align(offset)
313
+ avail_numel = zero2_align(avail_numel)
314
+
315
+ if debug:
316
+ print(f"aligned offset={offset}, avail_numel={avail_numel}")
317
+
318
+ # Sanity check
319
+ if offset != avail_numel:
320
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
321
+
322
+ print(f"Reconstructed fp32 state dict with {total_params} params {total_numel} elements")
323
+
324
+
325
+ def _get_fp32_state_dict_from_zero2_checkpoint(world_size, fp32_flat_groups, zero_model_states,
326
+ exclude_frozen_parameters):
327
+ state_dict = OrderedDict()
328
+
329
+ # buffers
330
+ buffers = zero_model_states[0].buffers
331
+ state_dict.update(buffers)
332
+ if debug:
333
+ print(f"added {len(buffers)} buffers")
334
+
335
+ if not exclude_frozen_parameters:
336
+ _zero2_merge_frozen_params(state_dict, zero_model_states)
337
+
338
+ _zero2_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
339
+
340
+ # recover shared parameters
341
+ for pair in zero_model_states[0].shared_params:
342
+ if pair[1] in state_dict:
343
+ state_dict[pair[0]] = state_dict[pair[1]]
344
+
345
+ return state_dict
346
+
347
+
348
+ def zero3_partitioned_param_info(unpartitioned_numel, world_size):
349
+ remainder = unpartitioned_numel % world_size
350
+ padding_numel = (world_size - remainder) if remainder else 0
351
+ partitioned_numel = math.ceil(unpartitioned_numel / world_size)
352
+ return partitioned_numel, padding_numel
353
+
354
+
355
+ def _zero3_merge_frozen_params(state_dict, world_size, zero_model_states):
356
+ if zero_model_states[0].frozen_param_shapes is None or len(zero_model_states[0].frozen_param_shapes) == 0:
357
+ return
358
+
359
+ if debug:
360
+ for i in range(world_size):
361
+ num_elem = sum(s.numel() for s in zero_model_states[i].frozen_param_fragments.values())
362
+ print(f'rank {i}: {FROZEN_PARAM_SHAPES}.numel = {num_elem}')
363
+
364
+ frozen_param_shapes = zero_model_states[0].frozen_param_shapes
365
+ wanted_params = len(frozen_param_shapes)
366
+ wanted_numel = sum(s.numel() for s in frozen_param_shapes.values())
367
+ avail_numel = sum([p.numel() for p in zero_model_states[0].frozen_param_fragments.values()]) * world_size
368
+ print(f'Frozen params: Have {avail_numel} numels to process.')
369
+ print(f'Frozen params: Need {wanted_numel} numels in {wanted_params} params')
370
+
371
+ total_params = 0
372
+ total_numel = 0
373
+ for name, shape in zero_model_states[0].frozen_param_shapes.items():
374
+ total_params += 1
375
+ unpartitioned_numel = shape.numel()
376
+ total_numel += unpartitioned_numel
377
+
378
+ param_frags = tuple(model_state.frozen_param_fragments[name] for model_state in zero_model_states)
379
+ state_dict[name] = torch.cat(param_frags, 0).narrow(0, 0, unpartitioned_numel).view(shape)
380
+
381
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
382
+
383
+ if debug:
384
+ print(
385
+ f"Frozen params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
386
+ )
387
+
388
+ print(f"Reconstructed Frozen fp32 state dict with {total_params} params {total_numel} elements")
389
+
390
+
391
+ class GatheredTensor:
392
+ """
393
+ A pseudo tensor that collects partitioned weights.
394
+ It is more memory efficient when there are multiple groups.
395
+ """
396
+
397
+ def __init__(self, flat_groups, flat_groups_offset, offset, partitioned_numel, shape):
398
+ self.flat_groups = flat_groups
399
+ self.flat_groups_offset = flat_groups_offset
400
+ self.offset = offset
401
+ self.partitioned_numel = partitioned_numel
402
+ self.shape = shape
403
+ self.dtype = self.flat_groups[0][0].dtype
404
+
405
+ def contiguous(self):
406
+ """
407
+ Merge partitioned weights from flat_groups into a single tensor.
408
+ """
409
+ end_idx = self.offset + self.partitioned_numel
410
+ world_size = len(self.flat_groups)
411
+ pad_flat_param_chunks = []
412
+
413
+ for rank_i in range(world_size):
414
+ # for each rank, we need to collect weights from related group/groups
415
+ flat_groups_at_rank_i = self.flat_groups[rank_i]
416
+ start_group_id = None
417
+ end_group_id = None
418
+ for group_id in range(len(self.flat_groups_offset)):
419
+ if self.flat_groups_offset[group_id] <= self.offset < self.flat_groups_offset[group_id + 1]:
420
+ start_group_id = group_id
421
+ if self.flat_groups_offset[group_id] < end_idx <= self.flat_groups_offset[group_id + 1]:
422
+ end_group_id = group_id
423
+ break
424
+ # collect weights from related group/groups
425
+ for group_id in range(start_group_id, end_group_id + 1):
426
+ flat_tensor = flat_groups_at_rank_i[group_id]
427
+ start_offset = self.offset - self.flat_groups_offset[group_id]
428
+ end_offset = min(end_idx, self.flat_groups_offset[group_id + 1]) - self.flat_groups_offset[group_id]
429
+ pad_flat_param_chunks.append(flat_tensor[start_offset:end_offset])
430
+
431
+ # collect weights from all ranks
432
+ pad_flat_param = torch.cat(pad_flat_param_chunks, dim=0)
433
+ param = pad_flat_param[:self.shape.numel()].view(self.shape).contiguous()
434
+ return param
435
+
436
+
437
+ def _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states):
438
+ param_shapes = zero_model_states[0].param_shapes
439
+ avail_numel = sum([flat_group.numel() for flat_group in fp32_flat_groups[0]]) * world_size
440
+
441
+ # Reconstruction protocol: For zero3 we need to zip the partitions together at boundary of each
442
+ # param, re-consolidating each param, while dealing with padding if any
443
+
444
+ # merge list of dicts, preserving order
445
+ param_shapes = {k: v for d in param_shapes for k, v in d.items()}
446
+
447
+ if debug:
448
+ for i in range(world_size):
449
+ print(f"{FP32_FLAT_GROUPS}[{i}].shape={fp32_flat_groups[i].shape}")
450
+
451
+ wanted_params = len(param_shapes)
452
+ wanted_numel = sum(shape.numel() for shape in param_shapes.values())
453
+ # not asserting if there is a mismatch due to possible padding
454
+ avail_numel = fp32_flat_groups[0].numel() * world_size
455
+ print(f"Trainable params: Have {avail_numel} numels to process.")
456
+ print(f"Trainable params: Need {wanted_numel} numels in {wanted_params} params.")
457
+
458
+ # params
459
+ # XXX: for huge models that can't fit into the host's RAM we will have to recode this to support
460
+ # out-of-core computing solution
461
+ offset = 0
462
+ total_numel = 0
463
+ total_params = 0
464
+ flat_groups_offset = [0] + list(np.cumsum([flat_tensor.numel() for flat_tensor in fp32_flat_groups[0]]))
465
+ for name, shape in tqdm(param_shapes.items(), desc='Gathering sharded weights'):
466
+ unpartitioned_numel = shape.numel()
467
+ total_numel += unpartitioned_numel
468
+ total_params += 1
469
+ partitioned_numel, partitioned_padding_numel = zero3_partitioned_param_info(unpartitioned_numel, world_size)
470
+
471
+ if debug:
472
+ print(
473
+ f"Trainable params: {total_params} {name} full shape: {shape} partition0 numel={partitioned_numel} partitioned_padding_numel={partitioned_padding_numel}"
474
+ )
475
+
476
+ # memory efficient tensor
477
+ tensor = GatheredTensor(fp32_flat_groups, flat_groups_offset, offset, partitioned_numel, shape)
478
+ state_dict[name] = tensor
479
+ offset += partitioned_numel
480
+
481
+ offset *= world_size
482
+
483
+ # Sanity check
484
+ if offset != avail_numel:
485
+ raise ValueError(f"consumed {offset} numels out of {avail_numel} - something is wrong")
486
+
487
+ print(f"Reconstructed Trainable fp32 state dict with {total_params} params {total_numel} elements")
488
+
489
+
490
+ def _get_fp32_state_dict_from_zero3_checkpoint(world_size, fp32_flat_groups, zero_model_states,
491
+ exclude_frozen_parameters):
492
+ state_dict = OrderedDict()
493
+
494
+ # buffers
495
+ buffers = zero_model_states[0].buffers
496
+ state_dict.update(buffers)
497
+ if debug:
498
+ print(f"added {len(buffers)} buffers")
499
+
500
+ if not exclude_frozen_parameters:
501
+ _zero3_merge_frozen_params(state_dict, world_size, zero_model_states)
502
+
503
+ _zero3_merge_trainable_params(state_dict, world_size, fp32_flat_groups, zero_model_states)
504
+
505
+ # recover shared parameters
506
+ for pair in zero_model_states[0].shared_params:
507
+ if pair[1] in state_dict:
508
+ state_dict[pair[0]] = state_dict[pair[1]]
509
+
510
+ return state_dict
511
+
512
+
513
+ def to_torch_tensor(state_dict, return_empty_tensor=False):
514
+ """
515
+ Convert state_dict of GatheredTensor to torch tensor
516
+ """
517
+ torch_state_dict = {}
518
+ converted_tensors = {}
519
+ for name, tensor in state_dict.items():
520
+ tensor_id = id(tensor)
521
+ if tensor_id in converted_tensors: # shared tensors
522
+ shared_tensor = torch_state_dict[converted_tensors[tensor_id]]
523
+ torch_state_dict[name] = shared_tensor
524
+ else:
525
+ converted_tensors[tensor_id] = name
526
+ if return_empty_tensor:
527
+ torch_state_dict[name] = torch.empty(tensor.shape, dtype=tensor.dtype)
528
+ else:
529
+ torch_state_dict[name] = tensor.contiguous()
530
+ return torch_state_dict
531
+
532
+
533
+ def get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
534
+ tag=None,
535
+ exclude_frozen_parameters=False,
536
+ lazy_mode=False):
537
+ """
538
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated state_dict that can be loaded with
539
+ ``load_state_dict()`` and used for training without DeepSpeed or shared with others, for example
540
+ via a model hub.
541
+
542
+ Args:
543
+ - ``checkpoint_dir``: path to the desired checkpoint folder
544
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in 'latest' file. e.g., ``global_step14``
545
+ - ``exclude_frozen_parameters``: exclude frozen parameters
546
+ - ``lazy_mode``: get state_dict in lazy mode. It returns a dict of pesduo tensor instead of torch tensor, which is more memory efficient.
547
+ Convert the pesduo tensor to torch tensor by ``.contiguous()``
548
+
549
+ Returns:
550
+ - pytorch ``state_dict``
551
+
552
+ A typical usage might be ::
553
+
554
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
555
+ # do the training and checkpoint saving
556
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir) # already on cpu
557
+ model = model.cpu() # move to cpu
558
+ model.load_state_dict(state_dict)
559
+ # submit to model hub or save the model to share with others
560
+
561
+ In this example the ``model`` will no longer be usable in the deepspeed context of the same
562
+ application. i.e. you will need to re-initialize the deepspeed engine, since
563
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
564
+
565
+ If you want it all done for you, use ``load_state_dict_from_zero_checkpoint`` instead.
566
+
567
+ Note: the above usage may not work if your application doesn't have sufficient free CPU memory.
568
+ You may need to use the offline approach using the ``zero_to_fp32.py`` script that is saved with
569
+ the checkpoint. Or you can load state_dict in lazy mode ::
570
+
571
+ from deepspeed.utils.zero_to_fp32 import get_fp32_state_dict_from_zero_checkpoint
572
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, lazy_mode=True) # not on cpu
573
+ for name, lazy_tensor in state_dict.item():
574
+ tensor = lazy_tensor.contiguous() # to cpu
575
+ print(name, tensor)
576
+ # del tensor to release memory if it no longer in use
577
+ """
578
+ if tag is None:
579
+ latest_path = os.path.join(checkpoint_dir, 'latest')
580
+ if os.path.isfile(latest_path):
581
+ with open(latest_path, 'r') as fd:
582
+ tag = fd.read().strip()
583
+ else:
584
+ raise ValueError(f"Unable to find 'latest' file at {latest_path}")
585
+
586
+ ds_checkpoint_dir = os.path.join(checkpoint_dir, tag)
587
+
588
+ if not os.path.isdir(ds_checkpoint_dir):
589
+ raise FileNotFoundError(f"Directory '{ds_checkpoint_dir}' doesn't exist")
590
+
591
+ state_dict = _get_fp32_state_dict_from_zero_checkpoint(ds_checkpoint_dir, exclude_frozen_parameters)
592
+ if lazy_mode:
593
+ return state_dict
594
+ else:
595
+ return to_torch_tensor(state_dict)
596
+
597
+
598
+ def convert_zero_checkpoint_to_fp32_state_dict(checkpoint_dir,
599
+ output_dir,
600
+ max_shard_size="5GB",
601
+ safe_serialization=False,
602
+ tag=None,
603
+ exclude_frozen_parameters=False):
604
+ """
605
+ Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict`` file that can be
606
+ loaded with ``torch.load(file)`` + ``load_state_dict()`` and used for training without DeepSpeed.
607
+
608
+ Args:
609
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
610
+ - ``output_dir``: directory to the pytorch fp32 state_dict output files
611
+ - ``max_shard_size``: the maximum size for a checkpoint before being sharded, default value is 5GB
612
+ - ``safe_serialization``: whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).
613
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
614
+ - ``exclude_frozen_parameters``: exclude frozen parameters
615
+ """
616
+
617
+ # Dependency pre-check
618
+ if safe_serialization:
619
+ try:
620
+ from safetensors.torch import save_file
621
+ except ImportError:
622
+ print('If you want to use `safe_serialization`, please `pip install safetensors`')
623
+ raise
624
+ if max_shard_size is not None:
625
+ try:
626
+ from huggingface_hub import split_torch_state_dict_into_shards
627
+ except ImportError:
628
+ print('If you want to use `max_shard_size`, please `pip install huggingface_hub`')
629
+ raise
630
+
631
+ # Convert zero checkpoint to state_dict
632
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir,
633
+ tag,
634
+ exclude_frozen_parameters,
635
+ lazy_mode=True)
636
+
637
+ # Shard the model if it is too big.
638
+ weights_name = "model.safetensors" if safe_serialization else "pytorch_model.bin"
639
+ if max_shard_size is not None:
640
+ filename_pattern = weights_name.replace(".bin", "{suffix}.bin").replace(".safetensors", "{suffix}.safetensors")
641
+ # an memory-efficient approach for sharding
642
+ empty_state_dict = to_torch_tensor(state_dict, return_empty_tensor=True)
643
+ state_dict_split = split_torch_state_dict_into_shards(empty_state_dict,
644
+ filename_pattern=filename_pattern,
645
+ max_shard_size=max_shard_size)
646
+ else:
647
+ from collections import namedtuple
648
+ StateDictSplit = namedtuple("StateDictSplit", ["is_sharded", "filename_to_tensors"])
649
+ state_dict_split = StateDictSplit(is_sharded=False,
650
+ filename_to_tensors={weights_name: list(state_dict.keys())})
651
+
652
+ # Save the model by shard
653
+ os.makedirs(output_dir, exist_ok=True)
654
+ filename_to_tensors = state_dict_split.filename_to_tensors.items()
655
+ for shard_file, tensors in tqdm(filename_to_tensors, desc="Saving checkpoint shards"):
656
+ shard_state_dict = {tensor_name: state_dict[tensor_name] for tensor_name in tensors}
657
+ shard_state_dict = to_torch_tensor(shard_state_dict)
658
+ output_path = os.path.join(output_dir, shard_file)
659
+ if safe_serialization:
660
+ save_file(shard_state_dict, output_path, metadata={"format": "pt"})
661
+ else:
662
+ torch.save(shard_state_dict, output_path)
663
+ # release the memory of current shard
664
+ for tensor_name in list(shard_state_dict.keys()):
665
+ del state_dict[tensor_name]
666
+ del shard_state_dict[tensor_name]
667
+ del shard_state_dict
668
+ gc.collect()
669
+
670
+ # Save index if sharded
671
+ if state_dict_split.is_sharded:
672
+ index = {
673
+ "metadata": state_dict_split.metadata,
674
+ "weight_map": state_dict_split.tensor_to_filename,
675
+ }
676
+ save_index_file = "model.safetensors.index.json" if safe_serialization else "pytorch_model.bin.index.json"
677
+ save_index_file = os.path.join(output_dir, save_index_file)
678
+ with open(save_index_file, "w", encoding="utf-8") as f:
679
+ content = json.dumps(index, indent=2, sort_keys=True) + "\n"
680
+ f.write(content)
681
+
682
+
683
+ def load_state_dict_from_zero_checkpoint(model, checkpoint_dir, tag=None):
684
+ """
685
+ 1. Put the provided model to cpu
686
+ 2. Convert ZeRO 2 or 3 checkpoint into a single fp32 consolidated ``state_dict``
687
+ 3. Load it into the provided model
688
+
689
+ Args:
690
+ - ``model``: the model object to update
691
+ - ``checkpoint_dir``: path to the desired checkpoint folder. (one that contains the tag-folder, like ``global_step14``)
692
+ - ``tag``: checkpoint tag used as a unique identifier for checkpoint. If not provided will attempt to load tag in the file named ``latest`` in the checkpoint folder, e.g., ``global_step14``
693
+
694
+ Returns:
695
+ - ``model`: modified model
696
+
697
+ Make sure you have plenty of CPU memory available before you call this function. If you don't
698
+ have enough use the ``zero_to_fp32.py`` utility to do the conversion. You will find it
699
+ conveniently placed for you in the checkpoint folder.
700
+
701
+ A typical usage might be ::
702
+
703
+ from deepspeed.utils.zero_to_fp32 import load_state_dict_from_zero_checkpoint
704
+ model = load_state_dict_from_zero_checkpoint(trainer.model, checkpoint_dir)
705
+ # submit to model hub or save the model to share with others
706
+
707
+ Note, that once this was run, the ``model`` will no longer be usable in the deepspeed context
708
+ of the same application. i.e. you will need to re-initialize the deepspeed engine, since
709
+ ``model.load_state_dict(state_dict)`` will remove all the deepspeed magic from it.
710
+
711
+ """
712
+ logger.info(f"Extracting fp32 weights")
713
+ state_dict = get_fp32_state_dict_from_zero_checkpoint(checkpoint_dir, tag)
714
+
715
+ logger.info(f"Overwriting model with fp32 weights")
716
+ model = model.cpu()
717
+ model.load_state_dict(state_dict, strict=False)
718
+
719
+ return model
720
+
721
+
722
+ if __name__ == "__main__":
723
+ parser = argparse.ArgumentParser()
724
+ parser.add_argument("checkpoint_dir",
725
+ type=str,
726
+ help="path to the desired checkpoint folder, e.g., path/checkpoint-12")
727
+ parser.add_argument("output_dir",
728
+ type=str,
729
+ help="directory to the pytorch fp32 state_dict output files"
730
+ "(e.g. path/checkpoint-12-output/)")
731
+ parser.add_argument(
732
+ "--max_shard_size",
733
+ type=str,
734
+ default="5GB",
735
+ help="The maximum size for a checkpoint before being sharded. Checkpoints shard will then be each of size"
736
+ "lower than this size. If expressed as a string, needs to be digits followed by a unit (like `5MB`"
737
+ "We default it to 5GB in order for models to be able to run easily on free-tier google colab instances"
738
+ "without CPU OOM issues.")
739
+ parser.add_argument(
740
+ "--safe_serialization",
741
+ default=False,
742
+ action='store_true',
743
+ help="Whether to save the model using `safetensors` or the traditional PyTorch way (that uses `pickle`).")
744
+ parser.add_argument("-t",
745
+ "--tag",
746
+ type=str,
747
+ default=None,
748
+ help="checkpoint tag used as a unique identifier for checkpoint. e.g., global_step1")
749
+ parser.add_argument("--exclude_frozen_parameters", action='store_true', help="exclude frozen parameters")
750
+ parser.add_argument("-d", "--debug", action='store_true', help="enable debug")
751
+ args = parser.parse_args()
752
+
753
+ debug = args.debug
754
+
755
+ convert_zero_checkpoint_to_fp32_state_dict(args.checkpoint_dir,
756
+ args.output_dir,
757
+ max_shard_size=args.max_shard_size,
758
+ safe_serialization=args.safe_serialization,
759
+ tag=args.tag,
760
+ exclude_frozen_parameters=args.exclude_frozen_parameters)
model_with_lora.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:830f83e72fe36f7ff3d8bf55e01c32865e5896e81178c4534025e3bc874d2540
3
+ size 16628075734
runs/Mar07_05-23-18_886823f2c465/events.out.tfevents.1741292890.886823f2c465.10378.0 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d526448c8130aefc200b80307fa29a6c36ab46d9b699497cbdfe7e93a19cc83d
3
+ size 216297
trainer_state.json ADDED
The diff for this file is too large to render. See raw diff