save_state(total_limit=...) deletes the newest checkpoint and load_state() resumes from an old one on Windows
With ProjectConfiguration(automatic_checkpoint_naming=True, total_limit=2) on Windows, if any directory above checkpoints\ contains a digit (C:\runs\exp1, or a temp dir like tmpd1pk...), checkpoints are sorted by that digit instead of the checkpoint number. The sort key regex in save_state/load_state only treats / as a separator, so on a \ path it returns the first number in the whole path.
Repro (Windows 11, accelerate main @ 8c83b44, torch 2.14.1+cpu): save 14 times into <tmp>\run1 with total_limit=2. Kept: checkpoint_9, checkpoint_13 (expected checkpoint_12, checkpoint_13). accelerator.load_state() then loads checkpoint_9.
I have a small fix with a regression test and can open a PR.
Thanks for taking the time to report this! We’ve introduced a new contribution guide(https://github.com/huggingface/accelerate/blob/main/CONTRIBUTING.md) and updated our issue forms. We’re closing existing issues as we transition to the new process.
If this issue is still relevant, please review the guide and open a new issue using the updated form, including your use case and a link to this issue.
Thanks for your understanding!