Skip to content

Commit 7a68e0a

Browse files
feginpytorchmergebot
authored andcommitted
[DCP][state_dict] Remove the check of FSDP has root (pytorch#121544)
Root may not exist due to FSDP lazy initialization. Pull Request resolved: pytorch#121544 Approved by: https://github.com/Skylion007 ghstack dependencies: pytorch#121273, pytorch#121276, pytorch#121290
1 parent 85dc254 commit 7a68e0a

File tree

1 file changed

+0
-7
lines changed

1 file changed

+0
-7
lines changed

torch/distributed/checkpoint/state_dict.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,9 @@ def _verify_state_dict(
279279
optim_state_dict: OptimizerStateType,
280280
info: _StateDictInfo,
281281
) -> None:
282-
# FSDP root must exist otherwise FSDP state_dict will be incorrect.
283-
has_fsdp_root = False
284282
for module in info.fsdp_modules:
285283
fsdp_state = _get_module_fsdp_state_if_fully_sharded_module(module)
286284
assert fsdp_state is not None, "Expected a fsdp_state with a fsdp module."
287-
if fsdp_state._is_root:
288-
has_fsdp_root = True
289-
break
290-
if info.fsdp_modules and not has_fsdp_root:
291-
raise RuntimeError("The model has FSDP modules but no FSDP root module exists.")
292285

293286
# Verify if the model_state_dict and optim_state_dict are valid. This API
294287
# should give the users an explicit error message to debug or report.

0 commit comments

Comments
 (0)