Skip to content

fix: add DefaultLoadPlanner to FSDP2 + SHARDED_STATE_DICT optimizer checkpoint loading#3972

Open
iavinas wants to merge 1 commit intohuggingface:mainfrom
iavinas:fix/fsdp2-optimizer-load-planner
Open

fix: add DefaultLoadPlanner to FSDP2 + SHARDED_STATE_DICT optimizer checkpoint loading#3972
iavinas wants to merge 1 commit intohuggingface:mainfrom
iavinas:fix/fsdp2-optimizer-load-planner

Conversation

@iavinas
Copy link

@iavinas iavinas commented Mar 11, 2026

Without the planner, dist_cp.load() cannot resolve nested optimizer state keys (e.g. optimizer.state.0.step), causing a RuntimeError on checkpoint load with SHARDED_STATE_DICT + fsdp_version 2.

What does this PR do?

Fixes # (issue) #3971

  • Adds DefaultLoadPlanner() to dist_cp.load() in load_fsdp_optimizer, matching the DefaultSavePlanner() already used on the save side

Test plan

  • Verified with FSDP2 + SHARDED_STATE_DICT config on 2x T4 GPUs

Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? Please add a link
    to it if that's the case.
  • Did you make sure to update the documentation with your changes? Here are the
    documentation guidelines, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

Without the planner, dist_cp.load() cannot resolve nested optimizer
state keys (e.g. optimizer.state.0.step), causing a RuntimeError on
checkpoint load with SHARDED_STATE_DICT + fsdp_version 2.
@iavinas
Copy link
Author

iavinas commented Mar 13, 2026

@SunMarc Could you please take a look when you have time?

I found this bug while digging into issue #3968 to better understand it. Happy to address any feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant