{"record":{"id":"9cea74478706e84e","repo":"Lightning-AI/pytorch-lightning","slug":"the-path-str-path-r-does-not-point-to-a-valid-c","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":"error_code","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/strategies/fsdp.py","lineNumber":654,"sourceCode":"                with _get_full_state_dict_context(module, world_size=self.world_size, rank0_only=False):\n                    temp_state_dict = _rekey_optimizer_state_if_needed(checkpoint.pop(optim_key), module)\n                    optim_state_dict = FSDP.optim_state_dict_to_load(\n                        optim_state_dict=temp_state_dict,\n                        model=module,\n                        optim=optim,\n                    )\n                    optim.load_state_dict(optim_state_dict)\n\n            requested_metadata_keys = state.keys() - modules.keys() - optimizers.keys()\n            _validate_keys_for_strict_loading(requested_metadata_keys, checkpoint.keys(), strict=strict)\n\n            # Load metadata (anything not a module or optimizer)\n            _move_state_into(source=checkpoint, destination=state, keys=requested_metadata_keys)\n\n            # return the remaining metadata that wasn't requested as part of `state`\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\n    @classmethod\n    @override\n    def register_strategies(cls, strategy_registry: _StrategyRegistry) -> None:\n        if not torch.distributed.is_available():\n            return\n\n        strategy_registry.register(\n            \"fsdp\",\n            cls,\n            description=\"Fully Sharded Data Parallel (FSDP) training\",\n        )\n        strategy_registry.register(\n            \"fsdp_cpu_offload\",\n            cls,","sourceCodeStart":636,"sourceCodeEnd":672,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/strategies/fsdp.py#L636-L672","documentation":"After attempting both the distributed-checkpoint path (a directory of shards) and the single-file full checkpoint path, the loader found neither a valid __1_0.distcp-style shard directory nor a loadable single file. The path exists but its contents match neither layout, or the file is corrupt/not a checkpoint.","triggerScenarios":"Passing a path that is an empty or wrong-content directory, a .ckpt saved by a different mechanism (e.g. torch.save of a raw state_dict), a truncated download, or a file that torch.load cannot read.","commonSituations":"Downloading checkpoints with interrupted transfers; pointing at a directory that only contains .metadata or partial shards; using a full-state-dict file with the sharded loader path; wrong path string (typos, missing rank subfolder).","solutions":["Verify the target: a valid sharded checkpoint is a directory containing .distcp shard files plus metadata; a full checkpoint is one file loadable with torch.load","If the file is a plain state_dict saved with torch.save, load it manually with torch.load and module.load_state_dict","Re-download or re-save the checkpoint and confirm file sizes/shard count match world size","Check for path typos and that all ranks resolve the same path"],"exampleFix":"# before\nstrategy.load_checkpoint('ckpt.dir', state={'model': model})  # empty dir\n# after\nimport os\nassert os.path.isdir('ckpt.dir') and any(f.endswith('.distcp') for f in os.listdir('ckpt.dir'))\nstrategy.load_checkpoint('ckpt.dir', state={'model': model})","handlingStrategy":"validation","validationCode":"import os, torch\n\ndef valid_ckpt(p):\n    if os.path.isdir(p):\n        return any(f.endswith('.distcp') or f == '.metadata' for f in os.listdir(p))\n    if os.path.isfile(p):\n        try:\n            torch.load(p, map_location='meta', weights_only=False)\n            return True\n        except Exception:\n            return False\n    return False\n\nassert valid_ckpt(path), f'{path} is not a valid FSDP checkpoint'","typeGuard":"def is_fsdp_sharded_dir(p: str) -> bool:\n    import os\n    return os.path.isdir(p) and any(f.endswith('.distcp') for f in os.listdir(p))","tryCatchPattern":"try:\n    strategy.load_checkpoint(path, state=state)\nexcept ValueError as e:\n    if 'does not point to a valid checkpoint' in str(e):\n        state_dict = torch.load(path, map_location='cpu')\n        model.load_state_dict(state_dict['model'])","preventionTips":["Verify shard count matches world size before distributed loads","Checksum downloaded checkpoints","Keep save and load paths symmetric (dir for sharded, file for full)"],"tags":["fsdp","checkpoint","load","file-validation","distributed"],"backgroundTag":"invalid-checkpoint-file","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}