{"record":{"id":"cdf61554b43f8470","repo":"Lightning-AI/pytorch-lightning","slug":"the-path-str-path-r-does-not-point-to-a-valid-c-cdf615","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 distributed 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 distributed checkpoint shards, or a single file with a full checkpoint\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/strategies/model_parallel.py","lineNumber":511,"sourceCode":"\n            optimizer_state = _rekey_optimizer_state_if_needed(optimizer_state, module)\n            set_optimizer_state_dict(\n                module,\n                optimizer,\n                optim_state_dict=optimizer_state,\n                options=state_dict_options,\n            )\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 distributed checkpoint shards, or a single file with a full checkpoint.\"\n    )\n\n\ndef _setup_device_mesh(\n    data_parallel_size: int,\n    tensor_parallel_size: int,\n    world_size: int,\n    device: torch.device,\n) -> \"DeviceMesh\":\n    from torch.distributed.device_mesh import init_device_mesh\n\n    if data_parallel_size * tensor_parallel_size != world_size:\n        raise RuntimeError(\n            f\"The sizes `data_parallel_size={data_parallel_size}` and\"\n            f\" `tensor_parallel_size={tensor_parallel_size}` multiplied should equal the world size\"\n            f\" ({world_size}).\"","sourceCodeStart":493,"sourceCodeEnd":529,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/strategies/model_parallel.py#L493-L529","documentation":"After attempting both distributed-sharded and single-file loading paths, _load_checkpoint found neither a directory of dist-Checkpoint shards nor a loadable full checkpoint file at `path`. The final fallback raises this ValueError indicating the path is not a valid checkpoint location.","triggerScenarios":"load_checkpoint called with a path that doesn't exist, is an empty directory, contains neither __0_0.distcp-style shards nor a full checkpoint file, or points to a remote URL whose contents aren't a valid checkpoint.","commonSituations":"Typo'd or stale checkpoint path; resuming a run whose checkpoint files were deleted/moved; pointing at an fsspec/S3 URL where the files are missing; passing a checkpoint saved by a different (non-distributed) mechanism.","solutions":["Verify the path exists and inspect its contents (directory with .distcp shards or a single full file)","If the checkpoint was moved, re-save or update the path; for remote paths check the fsspec filesystem permissions/existence","Re-create the checkpoint with strategy.save_checkpoint under the same ModelParallel strategy","Fall back to torch.load on a regular checkpoint if the run doesn't need distributed loading"],"exampleFix":"# before\nstrategy.load_checkpoint('checkpoints/last', state={'model': model})\n# after\nfrom pathlib import Path\nassert Path('checkpoints/last').exists() and any(Path('checkpoints/last').iterdir()), 'bad checkpoint dir'\nstrategy.load_checkpoint('checkpoints/last', state={'model': model})","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\np = Path(path)\nassert p.exists(), f'checkpoint path missing: {p}'\nif p.is_dir():\n    assert any(p.iterdir()), 'shard directory is empty'\nelse:\n    assert p.is_file() and p.stat().st_size > 0, 'not a valid checkpoint file'","typeGuard":null,"tryCatchPattern":"try:\n    strategy.load_checkpoint(path, state={'model': model})\nexcept ValueError as e:\n    if 'does not point to a valid checkpoint' in str(e):\n        raise FileNotFoundError(path) from e\n    raise","preventionTips":["Validate checkpoint paths (including fsspec URLs) before resume logic","Fail fast on missing checkpoints at startup rather than mid-training"],"tags":["lightning","fabric","checkpoint","invalid-path"],"backgroundTag":"checkpoint-file-not-found","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}