{"record":{"id":"bb3c1c15bddd1c23","repo":"Lightning-AI/pytorch-lightning","slug":"you-passed-in-a-path-to-a-deepspeed-config-but-the-bb3c1c","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":"exception","errorClass":"MisconfigurationException","httpStatus":null,"severity":"error","filePath":"src/lightning/pytorch/strategies/deepspeed.py","lineNumber":818,"sourceCode":"        strategy_registry.register(\n            \"deepspeed_stage_3_offload_nvme\",\n            cls,\n            description=\"DeepSpeed ZeRO Stage 3 and NVMe Offload\",\n            stage=3,\n            offload_optimizer=True,\n            offload_parameters=True,\n            remote_device=\"nvme\",\n            offload_params_device=\"nvme\",\n            offload_optimizer_device=\"nvme\",\n        )\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 MisconfigurationException(\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    def _init_config_if_needed(self) -> None:\n        if not self._config_initialized:\n            self._format_config()\n            self._config_initialized = True\n\n    def _format_config(self) -> None:\n        if self.config is None:\n            raise MisconfigurationException(\n                \"To use DeepSpeed you must pass in a DeepSpeed config dict, or a path to a JSON config.\"\n                \" See: https://lightning.ai/docs/pytorch/stable/advanced/model_parallel.html#deepspeed\"\n            )","sourceCodeStart":800,"sourceCodeEnd":836,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/pytorch/strategies/deepspeed.py#L800-L836","documentation":"DeepSpeedStrategy accepts a config as either a dict or a path to a JSON file (or via the DEEPSPEED_ENV_VAR env var). _load_config checks the path with os.path.isfile and raises MisconfigurationException if it does not exist, catching typos and wrong relative paths before training.","triggerScenarios":"`DeepSpeedStrategy(config=\"ds_config.json\")` where the string/Path is not an existing file — wrong relative directory, typo, missing file, or a path on another node not present.","commonSituations":"Running from a different working directory (scripts launched from repo root while config path is relative); launching multi-node jobs where the config was shipped to rank 0 only; `.yaml` config passed where only JSON is supported (path exists check passes only for files — YAML file loads fine as file but json.load then fails; the missing-file case is typo/relative paths).","solutions":["Use an absolute path or resolve it relative to the script: `config=Path(__file__).parent / \"ds_config.json\"`","Verify the filename and extension (.json) with `os.path.isfile(config)` before constructing the strategy","Or pass the config as a dict directly to avoid filesystem issues"],"exampleFix":"# before\nstrategy = DeepSpeedStrategy(config=\"configs/ds_zero3.json\")  # wrong cwd\n\n# after\nfrom pathlib import Path\nstrategy = DeepSpeedStrategy(config=Path(__file__).parent / \"configs\" / \"ds_zero3.json\")","handlingStrategy":"validation","validationCode":"import os\nconfig_path = \"ds_config.json\"\nif not os.path.isfile(config_path):\n    raise FileNotFoundError(f\"missing DeepSpeed config: {config_path}\")\nstrategy = DeepSpeedStrategy(config=config_path)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve config paths relative to __file__, not the working directory","Or pass the config as a dict to remove filesystem dependence","Ship config files to all nodes in multi-node jobs"],"tags":["deepspeed","config-file","file-not-found","paths"],"backgroundTag":"config-file-not-found","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}