{"record":{"id":"e3c415be16304779","repo":"Lightning-AI/pytorch-lightning","slug":"pytorch-2-6-requires-deepspeed-0-16-0-detec","errorCode":null,"errorMessage":"PyTorch >= 2.6 requires DeepSpeed >= 0.16.0. Detected DeepSpeed version: {deepspeed_version}. Please upgrade by running `pip install -U 'deepspeed>=0.16.0'`.","messagePattern":"PyTorch >= 2\\.6 requires DeepSpeed >= 0\\.16\\.0\\. Detected DeepSpeed version: (.+?)\\. Please upgrade by running `pip install -U 'deepspeed>=0\\.16\\.0'`\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"critical","filePath":"src/lightning/fabric/strategies/deepspeed.py","lineNumber":253,"sourceCode":"                per worker.\n\n            exclude_frozen_parameters: Exclude frozen parameters when saving checkpoints.\n\n        \"\"\"\n        if not _DEEPSPEED_AVAILABLE:\n            raise ImportError(\n                \"To use the `DeepSpeedStrategy`, you must have DeepSpeed installed.\"\n                \" Install it by running `pip install -U deepspeed`.\"\n            )\n\n        if _TORCH_GREATER_EQUAL_2_6 and not _DEEPSPEED_GREATER_EQUAL_0_16:\n            # Starting with PyTorch 2.6, `torch.load` defaults to `weights_only=True` when loading full checkpoints.\n            # DeepSpeed added support for this behavior in version 0.16.0.\n            import deepspeed\n\n            deepspeed_version = deepspeed.__version__\n\n            raise ImportError(\n                f\"PyTorch >= 2.6 requires DeepSpeed >= 0.16.0. \"\n                f\"Detected DeepSpeed version: {deepspeed_version}. \"\n                \"Please upgrade by running `pip install -U 'deepspeed>=0.16.0'`.\"\n            )\n\n        super().__init__(\n            accelerator=accelerator,\n            parallel_devices=parallel_devices,\n            cluster_environment=cluster_environment,\n            precision=precision,\n            process_group_backend=process_group_backend,\n        )\n        self._backward_sync_control = None  # DeepSpeed handles gradient accumulation internally\n        self._timeout: Optional[timedelta] = timeout\n\n        self.config = self._load_config(config)\n        if self.config is None:\n            # User has not overridden config, set defaults","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/Lightning-AI/pytorch-lightning/blob/9fed5c27d2a62ff0efd6c3573599921d6ff67c14/src/lightning/fabric/strategies/deepspeed.py#L235-L271","documentation":"PyTorch 2.6 changed torch.load to default to weights_only=True, and DeepSpeed only supported that in 0.16.0+. If the env has torch>=2.6 with an older deepspeed, DeepSpeedStrategy.__init__ raises ImportError demanding an upgrade, because loading full checkpoints would otherwise break.","triggerScenarios":"torch >= 2.6 installed together with deepspeed < 0.16.0, then constructing DeepSpeedStrategy (even if you never load a full checkpoint).","commonSituations":"Upgrading torch to 2.6+ in an env with a pinned old deepspeed; stale lockfiles after a base-image torch bump.","solutions":["pip install -U 'deepspeed>=0.16.0'","Or pin torch<2.6 until deepspeed can be upgraded","Add a version-compatibility check to your environment setup so mismatches fail early with context"],"exampleFix":"# before\ntorch==2.6.0, deepspeed==0.15.4\n# after (shell)\npip install -U 'deepspeed>=0.16.0'","handlingStrategy":"validation","validationCode":"import torch\nfrom importlib.metadata import version\nif tuple(int(x) for x in torch.__version__.split(\".\")[:2]) >= (2, 6) \\\n        and tuple(int(x) for x in version(\"deepspeed\").split(\".\")[:2]) < (0, 16):\n    raise RuntimeError(\"upgrade deepspeed: pip install -U 'deepspeed>=0.16.0'\")","typeGuard":"def deepspeed_torch_compatible() -> bool:\n    import torch\n    try:\n        from importlib.metadata import version\n        ds = tuple(int(x) for x in version(\"deepspeed\").split(\".\")[:2])\n    except Exception:\n        return False\n    t = tuple(int(x) for x in torch.__version__.split(\".\")[:2])\n    return not (t >= (2, 6) and ds < (0, 16))","tryCatchPattern":"try:\n    strategy = DeepSpeedStrategy()\nexcept ImportError as e:\n    raise RuntimeError(f\"environment incompatible: {e}\") from e","preventionTips":["Upgrade torch and deepspeed together","Pin compatible ranges in requirements (torch>=2.6 -> deepspeed>=0.16)"],"tags":["deepspeed","version-mismatch","pytorch-upgrade","pytorch-lightning"],"backgroundTag":"dependency-version-incompatibility","analyzedSha":"9fed5c27d2a62ff0efd6c3573599921d6ff67c14","analyzedAt":"2026-08-28T11:52:41.083Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}