Skip to content

lightning throws an exception on MacOS when the pytorch default device is set #20696

@reductionnist

Description

@reductionnist

Bug description

If you set the pytorch default device to 'mps' on MacOS, pytorch lightning throws an exception on import.

The expected result is to not throw an exception and also to use the pytorch default device when doing computation.

What version are you seeing the problem on?

v2.5.1

How to reproduce the bug

import torch
torch.set_default_device('mps')
import pytorch_lightning as pl

Error messages and logs

RuntimeError: Placeholder storage has not been allocated on MPS device!

Environment

Current environment
#- PyTorch Lightning Version (e.g., 2.5.0): 2.5.1
#- PyTorch Version (e.g., 2.5): 2.6.0
#- Python version (e.g., 3.12): 3.12.9
#- OS (e.g., Linux): MacOS 15.3.2
#- CUDA/cuDNN version:
#- GPU models and configuration: M1 Max
#- How you installed Lightning(`conda`, `pip`, source): uv

More info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageWaiting to be triaged by maintainersver: 2.5.x

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions