Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DCP] Update DCP to use the updated FSDP optim state_dict APIs #95303

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/distributed/checkpoint/test_2d_fsdp_dt_checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def _test_fsdp_dt_checkpoint(self, fsdp_pg=None) -> None:
with FSDP.state_dict_type(model, StateDictType.SHARDED_STATE_DICT):
state_dict = {
"model": model.state_dict(),
"optim": FSDP.sharded_optim_state_dict(model, optim),
"optim": FSDP.optim_state_dict(model, optim),
}

dist_cp.save_state_dict(
Expand Down Expand Up @@ -181,7 +181,7 @@ def _test_fsdp_dt_checkpoint(self, fsdp_pg=None) -> None:
optimizer_key="optim",
storage_reader=dist_cp.FileSystemReader(CHECKPOINT_DIR),
)
flattened_osd = FSDP.flatten_sharded_optim_state_dict(
flattened_osd = FSDP.optim_state_dict_to_load(
optim_state["optim"], model_2, optim_2
)
optim_2.load_state_dict(flattened_osd)
Expand Down
4 changes: 2 additions & 2 deletions test/distributed/checkpoint/test_fsdp_optim_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_distributed_tensor_planner(self) -> None:
with FSDP.state_dict_type(model, StateDictType.SHARDED_STATE_DICT):
state_dict = {
"model": model.state_dict(),
"optim": FSDP.sharded_optim_state_dict(model, optim),
"optim": FSDP.optim_state_dict(model, optim),
}

dist_cp.save_state_dict(
Expand Down Expand Up @@ -80,7 +80,7 @@ def test_distributed_tensor_planner(self) -> None:
storage_reader=dist_cp.FileSystemReader(CHECKPOINT_DIR),
)

flattened_osd = FSDP.flatten_sharded_optim_state_dict(
flattened_osd = FSDP.optim_state_dict_to_load(
optim_state["optim"], model_2, optim_2
)
optim_2.load_state_dict(flattened_osd)
Expand Down
4 changes: 2 additions & 2 deletions torch/distributed/checkpoint/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def load_sharded_optimizer_state_dict(
>>>
>>> with FSDP.state_dict_type(model, StateDictType.SHARDED_STATE_DICT):
>>> state_dict = {
>>> "optimizer": FSDP.sharded_optim_state_dict(model, optim, optim_params),
>>> "optimizer": FSDP.optim_state_dict(model, optim),
>>> "model": model.state_dict()
>>> }
>>> dist_cp.save_state_dict(
Expand Down Expand Up @@ -241,7 +241,7 @@ def load_sharded_optimizer_state_dict(
>>> storage_reader=dist_cp.FileSystemReader("checkpoint"),
>>> )
>>>
>>> flattened_osd = FSDP.flatten_sharded_optim_state_dict(
>>> flattened_osd = FSDP.optim_state_dict_to_load(
>>> optim_state["optimizer"], model, optim
>>> )
>>>
Expand Down