Skip to content

Commit

Permalink
Move from pytorch_lightning to lightning
Browse files Browse the repository at this point in the history
  • Loading branch information
shchur committed Oct 13, 2023
1 parent 9be6dfd commit bb70cc5
Show file tree
Hide file tree
Showing 19 changed files with 21 additions and 23 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
2 changes: 1 addition & 1 deletion docs/tutorials/advanced_topics/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```{toctree}
:maxdepth: 1
howto_pytorch_lightning
howto_lightning.pytorch
hp_tuning_with_optuna
trainer_callbacks
```
3 changes: 2 additions & 1 deletion requirements/requirements-pytorch.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
torch>=1.9,<3
pytorch-lightning>=1.5,<3
lightning>=1.8,<2.2
lightning.pytorch>=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
5 changes: 1 addition & 4 deletions src/gluonts/dataset/repository/_lstnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,7 @@ def generate_lstnet_dataset(
pd.read_csv(ds_info.url, header=None), # type: ignore
)

assert df.shape == (
ds_info.num_time_steps,
ds_info.num_series,
), (
assert df.shape == (ds_info.num_time_steps, ds_info.num_series,), (
"expected num_time_steps/num_series"
f" {(ds_info.num_time_steps, ds_info.num_series)} but got {df.shape}"
)
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 bb70cc5

Please sign in to comment.