Lightning-AI/pytorch-lightning · critical · ImportError

PyTorch >= 2.6 requires DeepSpeed >= 0.16.0. Detected DeepSp

Error message

PyTorch >= 2.6 requires DeepSpeed >= 0.16.0. Detected DeepSpeed version: {deepspeed_version}. Please upgrade by running `pip install -U 'deepspeed>=0.16.0'`.

What it means

With PyTorch >= 2.6, `torch.load` defaults to `weights_only=True`, which breaks loading full DeepSpeed checkpoints unless DeepSpeed supports it. DeepSpeed added that support in 0.16.0, so Lightning raises ImportError when it detects torch>=2.6 paired with deepspeed<0.16.0, printing the detected version.

Source

Thrown at src/lightning/pytorch/strategies/deepspeed.py:274

                per worker.

            exclude_frozen_parameters: Exclude frozen parameters when saving checkpoints.

        """
        if not _DEEPSPEED_AVAILABLE:
            raise MisconfigurationException(
                "To use the `DeepSpeedStrategy`, you must have DeepSpeed installed."
                " Install it by running `pip install -U deepspeed`."
            )

        if _TORCH_GREATER_EQUAL_2_6 and not _DEEPSPEED_GREATER_EQUAL_0_16:
            # Starting with PyTorch 2.6, `torch.load` defaults to `weights_only=True` when loading full checkpoints.
            # DeepSpeed added support for this behavior in version 0.16.0.
            import deepspeed

            deepspeed_version = deepspeed.__version__

            raise ImportError(
                f"PyTorch >= 2.6 requires DeepSpeed >= 0.16.0. "
                f"Detected DeepSpeed version: {deepspeed_version}. "
                "Please upgrade by running `pip install -U 'deepspeed>=0.16.0'`."
            )

        super().__init__(
            accelerator=accelerator,
            parallel_devices=parallel_devices,
            cluster_environment=cluster_environment,
            precision_plugin=precision_plugin,
            process_group_backend=process_group_backend,
        )
        self._timeout: Optional[timedelta] = timeout

        self.config = self._load_config(config)
        if self.config is None:
            # User has not overridden config, set defaults
            self.config = self._create_default_config(

View on GitHub (pinned to 9fed5c27d2)

Solutions

  1. Upgrade DeepSpeed: `pip install -U 'deepspeed>=0.16.0'`
  2. Alternatively downgrade PyTorch below 2.6 if DeepSpeed cannot be upgraded
  3. Pin compatible versions in requirements: `torch>=2.6` together with `deepspeed>=0.16.0`

Example fix

# before
torch==2.6.0
deepspeed==0.12.6

# after
torch==2.6.0
deepspeed>=0.16.0
Defensive patterns

Strategy: validation

Validate before calling

import torch, deepspeed
from packaging.version import Version
if Version(torch.__version__) >= Version("2.6") and Version(deepspeed.__version__) < Version("0.16.0"):
    raise SystemExit("Upgrade: pip install -U 'deepspeed>=0.16.0'")

Prevention

When it happens

Trigger: Constructing `DeepSpeedStrategy` while `torch.__version__ >= 2.6` and `deepspeed.__version__ < 0.16.0` (the code path is guarded by `_TORCH_GREATER_EQUAL_2_6 and not _DEEPSPEED_GREATER_EQUAL_0_16`).

Common situations: Upgrading PyTorch to 2.6+ while keeping an older pinned deepspeed; environments with a requirements file pinning `deepspeed==0.12.x`; CI images with stale deepspeed wheels.

Related errors


AI-assisted analysis of Lightning-AI/pytorch-lightning@9fed5c27d2 (2026-08-28). Data as JSON: /api/errors/622aedd1754873cd. Report an issue: GitHub.