Skip to content

Commit 05941d4

Browse files
pre-commit-ci[bot]zhixiangli
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 64cbf19 commit 05941d4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

tests/tests_pytorch/strategies/test_fsdp.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ class _CPUFSDPTrainableModel(BoringModel):
208208
209209
If ``params_to_compare`` is given, the (already resharded) parameters are asserted to match it at the start of
210210
training. This is used to verify that a checkpoint written after training reads back with identical weights.
211+
211212
"""
212213

213214
def __init__(self, params_to_compare: Optional[list[torch.Tensor]] = None):
@@ -262,6 +263,7 @@ def test_fsdp_cpu_trainable(state_dict_type, tmp_path):
262263
Exercises both the ``full`` (single-file) and ``sharded`` (per-rank directory) checkpoint formats: the module is
263264
genuinely FSDP-wrapped, the loss drops sharply over 15 epochs, and the checkpoint written after training reads back
264265
with identical sharded parameters.
266+
265267
"""
266268

267269
def _make_trainer(max_epochs: int) -> Trainer:
@@ -299,9 +301,11 @@ def _make_trainer(max_epochs: int) -> Trainer:
299301

300302
# the two formats must produce genuinely different on-disk layouts
301303
if state_dict_type == "sharded":
302-
assert ckpt_path.is_dir() and _is_sharded_checkpoint(ckpt_path)
304+
assert ckpt_path.is_dir()
305+
assert _is_sharded_checkpoint(ckpt_path)
303306
else:
304-
assert ckpt_path.is_file() and not _is_sharded_checkpoint(ckpt_path)
307+
assert ckpt_path.is_file()
308+
assert not _is_sharded_checkpoint(ckpt_path)
305309

306310
# snapshot the trained local shards on this rank for a read-back comparison
307311
trained_params = deepcopy(list(trainer.model.parameters()))

0 commit comments

Comments
 (0)