{"record":{"id":"2e65f0f07c27b455","repo":"Lightning-AI/pytorch-lightning","slug":"the-path-str-path-r-does-not-point-to-a-valid-c-2e65f0","errorCode":null,"errorMessage":"The path {str(path)!r} does not point to a valid checkpoint. Make sure the path points to either a directory with FSDP checkpoint shards, or a single file with a full checkpoint.","messagePattern":"The path (.+?) does not point to a valid checkpoint\\. Make sure the path points to either a directory with FSDP checkpoint shards, or a single file with a full checkpoint\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/strategies/fsdp.py","lineNumber":693,"sourceCode":"                )\n\n            # rank0_only should be false because we need to load the optimizer state on all ranks\n            with _get_full_state_dict_context(self.model, world_size=self.world_size, rank0_only=False):\n                for optimizer, opt_state in zip(self.optimizers, optimizer_states):\n                    if isinstance(list(opt_state[\"state\"].keys())[0], int):\n                        # Handling the case where the optimizer state is saved from a normal optimizer\n                        opt_state = FSDP.rekey_optim_state_dict(opt_state, OptimStateKeyType.PARAM_NAME, self.model)\n\n                    opt_state = FSDP.optim_state_dict_to_load(\n                        optim_state_dict=opt_state,\n                        model=self.model,\n                        optim=optimizer,\n                    )\n                    optimizer.load_state_dict(opt_state)\n\n            return checkpoint\n\n        raise ValueError(\n            f\"The path {str(path)!r} does not point to a valid checkpoint. Make sure the path points to either a\"\n            \" directory with FSDP checkpoint shards, or a single file with a full checkpoint.\"\n        )\n","sourceCodeStart":675,"sourceCodeEnd":697,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/strategies/fsdp.py#L675-L697","documentation":"The FSDP strategy's load_checkpoint could not interpret the given path as an FSDP checkpoint. It expects either a directory containing FSDP checkpoint shards (a distributed checkpoint produced with _save_distributed_checkpoint=True) or a single file holding a full checkpoint. If the path is neither, Lightning raises this ValueError.","triggerScenarios":"Calling trainer.checkpoint_callback / strategy.load_checkpoint('path') where path is a nonexistent file, a non-checkpoint file, or an empty/non-sharded directory; loading a directory of FSDP shards without the matching metadata (__0_0.distcp + .metadata) or loading a full-checkpoint file when the strategy is configured for distributed checkpoints (mismatch).","commonSituations":"Passing a .ckpt saved by a non-FSDP run or a DDP checkpoint; passing a path to a directory that only looks like a sharded checkpoint (e.g. missing .metadata); typo in ckpt_path; resuming with a path saved under a different Lightning version.","solutions":["Verify the path exists and inspect its contents: a sharded dir must contain *.distcp files plus a .metadata file; a full checkpoint must be a loadable torch .pt/.ckpt file","If the checkpoint is a directory of shards, ensure the FSDPStrategy was created with _save_distributed_checkpoint=True (or use torch.distributed.checkpoint loading)","Re-save the checkpoint from the source run in the format matching your loading strategy (sharded dir vs single file)","Check the path spelling / use trainer's ModelCheckpoint last/best path helpers instead of hand-built strings"],"exampleFix":"# before\ntrainer.fit(model, ckpt_path=\"checkpoints/fsdp_run/\")  # dir has no .metadata\n\n# after\n# ensure the dir is a real DCP sharded checkpoint, or point at the full file\ntrainer.fit(model, ckpt_path=\"checkpoints/fsdp_run/last.ckpt\")","handlingStrategy":"validation","validationCode":"from pathlib import Path\np = Path(path)\nis_sharded = p.is_dir() and (p / \".metadata\").exists() and any(p.glob(\"*.distcp\"))\nis_full = p.is_file() and p.suffix in {\".ckpt\", \".pt\", \".pth\"}\nassert is_sharded or is_full, f\"{path} is neither a sharded FSDP dir nor a full checkpoint file\"","typeGuard":null,"tryCatchPattern":"try:\n    strategy.load_checkpoint(path)\nexcept ValueError as e:\n    if \"does not point to a valid checkpoint\" in str(e):\n        # fall back: try alternate dir/file resolution or TorchCheckpointIO\n        ...","preventionTips":["Save checkpoints with ModelCheckpoint and reuse its .best_model_path/.last to avoid hand-built paths","When using distributed FSDP checkpoints, always keep the .metadata file with the shard dir","Validate the path format (dir-with-shards vs single file) matches strategy._save_distributed_checkpoint before resuming"],"tags":["fsdp","checkpoint","load-checkpoint","pytorch-lightning"],"backgroundTag":"invalid-checkpoint-path","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}