{"record":{"id":"5785fabe5611e7d0","repo":"Lightning-AI/pytorch-lightning","slug":"the-path-str-file-r-does-not-point-to-valid-sha","errorCode":null,"errorMessage":"The path {str(file)!r} does not point to valid sharded checkpoints. Make sure the path points to a directory with XLAFSDP checkpoint shards.","messagePattern":"The path (.+?) does not point to valid sharded checkpoints\\. Make sure the path points to a directory with XLAFSDP checkpoint shards\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/strategies/xla_fsdp.py","lineNumber":550,"sourceCode":"            )\n\n        # broadcast the path from rank 0 to ensure all the states are loaded from a common path\n        path = Path(self.broadcast(path))\n\n        if isinstance(state, (Module, Optimizer)):\n            raise NotImplementedError(\n                \"Loading a single module or optimizer object from a checkpoint\"\n                \" is not supported yet with the XLAFSDP strategy.\"\n            )\n\n        from torch_xla.distributed.fsdp import XlaFullyShardedDataParallel as XLAFSDP\n\n        modules = {key: module for key, module in state.items() if isinstance(module, XLAFSDP)}\n        optimizers = {key: optim for key, optim in state.items() if isinstance(optim, Optimizer)}\n        if self._state_dict_type == \"sharded\":\n            file = path / f\"checkpoint_rank-{self.global_rank:08d}-of-{self.world_size:08d}.pth\"\n            if not file.is_file():\n                raise ValueError(\n                    f\"The path {str(file)!r} does not point to valid sharded checkpoints. Make sure the path points to\"\n                    \" a directory with XLAFSDP checkpoint shards.\"\n                )\n            if len(modules) == 0:\n                raise ValueError(\n                    \"Could not find a XLAFSDP model in the provided checkpoint state. Please provide the model as\"\n                    \" part of the state like so: `load_checkpoint(..., state={'model': model, ...})`. Make sure\"\n                    \" you set up the model (and optimizers if any) through the strategy before loading the checkpoint.\"\n                )\n            if len(modules) > 1:\n                raise ValueError(\n                    \"Found multiple XLAFSDP modules in the given state. Loading checkpoints with FSDP is\"\n                    \" currently limited to a single model per checkpoint. To load multiple models, call the\"\n                    \" load method for each model separately with a different path.\"\n                )\n\n            _, module = list(modules.items())[0]\n            sharded_ckpt = torch.load(file)","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/strategies/xla_fsdp.py#L532-L568","documentation":"When XLAFSDPStrategy is configured with state_dict_type='sharded', each rank loads its own shard file named checkpoint_rank-{global_rank:08d}-of-{world_size:08d}.pth inside the checkpoint directory. If that per-rank file does not exist at the expected path, loading cannot proceed. Common causes include pointing at the wrong directory, a different world size than when saving, or only full/consolidated checkpoints being present.","triggerScenarios":"Calling load_checkpoint on a path that is not the sharded-checkpoint directory, or where the shard for the current rank/world size is missing (e.g. saved with 8 ranks, loading with 4, or passing a consolidated .ckpt file while state_dict_type='sharded').","commonSituations":"Resuming training after changing TPU/world-size configuration; pointing at the consolidation output file instead of the shards directory; moving checkpoint directories so relative shard files are missing; resuming a 'full' checkpoint with a 'sharded' strategy config (or vice versa).","solutions":["Verify the path is the directory containing checkpoint_rank-XXXXXXXX-of-XXXXXXXX.pth files from the save (check filenames' rank-of-world_size parts match the current run)","Match the world size (and state_dict_type) used at save time, or re-shard/re-save the checkpoint accordingly","If you only have a consolidated full checkpoint, load with state_dict_type='full' instead, or re-generate shards"],"exampleFix":"# before\nstrategy = XLAFSDPStrategy(state_dict_type='sharded')\nfabric.load_checkpoint('ckpt/consolidated.ckpt', state={'model': model})\n\n# after\nstrategy = XLAFSDPStrategy(state_dict_type='full')\nfabric.load_checkpoint('ckpt/consolidated.ckpt', state={'model': model})\n# or point at the shard directory when using 'sharded'\nfabric.load_checkpoint('ckpt/shards/', state={'model': model})","handlingStrategy":"validation","validationCode":"from pathlib import Path\nshard = Path(ckpt_dir) / f\"checkpoint_rank-{rank:08d}-of-{world_size:08d}.pth\"\nif not shard.is_file():\n    raise FileNotFoundError(f'missing shard {shard}; check world_size and checkpoint dir')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Record world_size and state_dict_type alongside checkpoints","Verify shard filenames match the current run's rank/world_size before load_checkpoint","Keep shard directories intact (don't move individual .pth files)"],"tags":["xla","fsdp","checkpoint","load","sharded","file-not-found","lightning-fabric"],"backgroundTag":"checkpoint-file-not-found","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}