{"record":{"id":"2fb9e945523a8f81","repo":"Lightning-AI/pytorch-lightning","slug":"you-passed-in-a-path-to-a-deepspeed-config-but-the","errorCode":null,"errorMessage":"You passed in a path to a DeepSpeed config but the path does not exist: {config}","messagePattern":"You passed in a path to a DeepSpeed config but the path does not exist: (.+?)","errorType":"error_code","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"src/lightning/fabric/strategies/deepspeed.py","lineNumber":836,"sourceCode":"                        strict=True,\n                        missing_keys=missing_keys,\n                        unexpected_keys=unexpected_keys,\n                        error_msgs=error_msgs,\n                    )\n\n            for name, child in module._modules.items():\n                if child is not None:\n                    load(child, prefix + name + \".\")\n\n        load(module, prefix=\"\")\n\n    def _load_config(self, config: Optional[Union[_PATH, dict[str, Any]]]) -> Optional[dict[str, Any]]:\n        if config is None and self.DEEPSPEED_ENV_VAR in os.environ:\n            rank_zero_info(f\"Loading DeepSpeed config from set {self.DEEPSPEED_ENV_VAR} environment variable\")\n            config = os.environ[self.DEEPSPEED_ENV_VAR]\n        if isinstance(config, (str, Path)):\n            if not os.path.isfile(config):\n                raise FileNotFoundError(\n                    f\"You passed in a path to a DeepSpeed config but the path does not exist: {config}\"\n                )\n            with open(config) as f:\n                config = json.load(f)\n        assert isinstance(config, dict) or config is None\n        return config\n\n\ndef _get_deepspeed_engines_from_state(state: dict[str, Any]) -> list[\"DeepSpeedEngine\"]:\n    from deepspeed import DeepSpeedEngine\n\n    modules = chain(*(module.modules() for module in state.values() if isinstance(module, Module)))\n    return [engine for engine in modules if isinstance(engine, DeepSpeedEngine)]\n\n\ndef _validate_state_keys(state: dict[str, Any]) -> None:\n    # DeepSpeed merges the client state into its internal engine state when saving, but it does not check for\n    # colliding keys from the user. We explicitly check it here:","sourceCodeStart":818,"sourceCodeEnd":854,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/strategies/deepspeed.py#L818-L854","documentation":"When DeepSpeedStrategy receives a string/Path config, _load_config checks os.path.isfile and raises FileNotFoundError if it does not exist, then would json.load it. This is an early, explicit failure so the user knows the config path is wrong rather than getting a cryptic DeepSpeed error later.","triggerScenarios":"DeepSpeedStrategy(config=\"path/that/does/not/exist.json\") where the file was deleted, the relative path is resolved from a different CWD, or the path is a directory/URL instead of a file.","commonSituations":"Relative path issues when launching from a different working directory (SLURM, torchrun, docker entrypoint); typo in filename; file not committed/copied into a container.","solutions":["Use an absolute path or resolve relative to the script: Path(__file__).parent / \"ds_config.json\"","Verify the file exists: assert Path(config).is_file()","If the config is remote, download it locally first or pass a dict instead of a path","Check for typos in the path string"],"exampleFix":"# before\nstrategy = DeepSpeedStrategy(config=\"configs/ds_config.json\")\n\n# after\nfrom pathlib import Path\nstrategy = DeepSpeedStrategy(config=Path(__file__).parent / \"configs\" / \"ds_config.json\")","handlingStrategy":"validation","validationCode":"from pathlib import Path\ncfg = Path(__file__).parent / \"ds_config.json\"\nassert cfg.is_file(), f\"DeepSpeed config missing: {cfg}\"\nstrategy = DeepSpeedStrategy(config=cfg)","typeGuard":null,"tryCatchPattern":"try:\n    strategy = DeepSpeedStrategy(config=cfg_path)\nexcept FileNotFoundError:\n    strategy = DeepSpeedStrategy(config=default_cfg_dict)  # fallback","preventionTips":["Anchor config paths to __file__","Copy config files into containers/working dirs in Dockerfile"],"tags":["deepspeed","config","file-not-found","path"],"backgroundTag":"file-not-found","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}