Using pytorch_lightning from lightning import

Hey there,
I saw in the installation guideline, that I should install lightning instead of pytorch_lightning.
Now I have a script where I use a lightning module and a trainer.
How do I import them from the lightning module?

@aUser

Yes, the name of the package changed from pytorch_lightning to lightning, but all the common imports in the docs and in your existing code should still work.
You can always choose to either

from pytorch_lightning.x.y import z

or (new)

from lightning.pytorch.x.y import z

For example:

from lightning.pytorch import Trainer, LightningModule

# or
import lightning.pytorch as pl

pl.Trainer
pl.LightningModule

Hope this helps, cheers

Hi, I just updated my environment to PyTorch 2.1.1 and Lightning 2.1.2 with python 3.11. I realize this post is old, but it is relevant to my question. The docs are unclear on the difference between using lightning or pytorch_lightning. I installed lightning (latest stable version) using conda and have a few clarification question:

  1. Are there any differences in using the trainer, LightningDataModule or LightningModule between the 2?

  2. Does torch.compile work the same on both?

  3. Is there any difference in the packages being imported (old vs new) when using
    import lightning.pytorch or import pytorch_lightning? I ask because when they are installed as different packages.

In [1]: import lightning
In [2]: lightning.__version__
Out[2]: '2.1.2'
In [3]: import pytorch_lightning
In [4]: pytorch_lightning.__version__
Out[4]: '2.1.1'
In [5]: import torch
In [6]: torch.__version__
Out[6]: '2.1.1'

I have reviewed the migration guide and made any changes in my code accordingly.