Skip to content

Commit

Permalink
Move from pytorch_lightning to lightning (#3013)
Browse files Browse the repository at this point in the history
  • Loading branch information
shchur authored Oct 16, 2023
1 parent 9be6dfd commit ec2beb9
Show file tree
Hide file tree
Showing 17 changed files with 20 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ To train the model using PyTorch Lightning, we only need to extend the class wit


```python
import pytorch_lightning as pl
import lightning.pytorch as pl
```


Expand Down
4 changes: 3 additions & 1 deletion requirements/requirements-pytorch.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
torch>=1.9,<3
pytorch-lightning>=1.5,<3
lightning>=1.8,<2.2
# Capping `lightning` does not cap `pytorch_lightning`, so we cap manually
pytorch_lightning>=1.8,<2.2
# Need to pin protobuf (for now)
# See: https://github.com/PyTorchLightning/pytorch-lightning/issues/13159
protobuf~=3.19.0
Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/d_linear/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import Optional, Iterable, Dict, Any

import torch
import pytorch_lightning as pl
import lightning.pytorch as pl

from gluonts.core.component import validated
from gluonts.dataset.common import Dataset
Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/d_linear/lightning_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

import pytorch_lightning as pl
import lightning.pytorch as pl
import torch

from gluonts.core.component import validated
Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/deepar/lightning_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

import pytorch_lightning as pl
import lightning.pytorch as pl
import torch
from torch.optim.lr_scheduler import ReduceLROnPlateau

Expand Down
4 changes: 2 additions & 2 deletions src/gluonts/torch/model/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import logging

import numpy as np
import pytorch_lightning as pl
import lightning.pytorch as pl
import torch.nn as nn

from gluonts.core.component import validated
Expand Down Expand Up @@ -217,7 +217,7 @@ def train_model(
logger.info(
f"Loading best model from {checkpoint.best_model_path}"
)
best_model = training_network.load_from_checkpoint(
best_model = training_network.__class__.load_from_checkpoint(
checkpoint.best_model_path
)
else:
Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/lag_tst/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import Optional, Iterable, Dict, Any, List

import torch
import pytorch_lightning as pl
import lightning.pytorch as pl

from gluonts.core.component import validated
from gluonts.dataset.common import Dataset
Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/lag_tst/lightning_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

import pytorch_lightning as pl
import lightning.pytorch as pl
import torch

from gluonts.core.component import validated
Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/lightning_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from packaging import version

import pytorch_lightning as pl
import lightning.pytorch as pl


def has_validation_loop(trainer: pl.Trainer):
Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/mqf2/lightning_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from typing import Dict

import pytorch_lightning as pl
import lightning.pytorch as pl
import torch
from torch.optim.lr_scheduler import ReduceLROnPlateau

Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/patch_tst/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import Optional, Iterable, Dict, Any

import torch
import pytorch_lightning as pl
import lightning.pytorch as pl

from gluonts.core.component import validated
from gluonts.dataset.common import Dataset
Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/patch_tst/lightning_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

import pytorch_lightning as pl
import lightning.pytorch as pl
import torch

from gluonts.core.component import validated
Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/simple_feedforward/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import List, Optional, Iterable, Dict, Any

import torch
import pytorch_lightning as pl
import lightning.pytorch as pl

from gluonts.core.component import validated
from gluonts.dataset.common import Dataset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

import pytorch_lightning as pl
import lightning.pytorch as pl
import torch

from gluonts.core.component import validated
Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/tft/lightning_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

import pytorch_lightning as pl
import lightning.pytorch as pl
import torch
from gluonts.core.component import validated
from gluonts.itertools import select
Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/wavenet/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from typing import Any, Dict, List, Optional, Iterable

import pytorch_lightning as pl
import lightning.pytorch as pl
import torch
import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion src/gluonts/torch/model/wavenet/lightning_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

import pytorch_lightning as pl
import lightning.pytorch as pl
import torch

from gluonts.core.component import validated
Expand Down

0 comments on commit ec2beb9

Please sign in to comment.