Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backports v0.13.6 #3016

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,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
15 changes: 10 additions & 5 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 @@ -209,10 +209,15 @@ def train_model(
ckpt_path=ckpt_path,
)

logger.info(f"Loading best model from {checkpoint.best_model_path}")
best_model = training_network.load_from_checkpoint(
checkpoint.best_model_path
)
if checkpoint.best_model_path != "":
logger.info(
f"Loading best model from {checkpoint.best_model_path}"
)
best_model = training_network.__class__.load_from_checkpoint(
checkpoint.best_model_path
)
else:
best_model = training_network

return TrainOutput(
transformation=transformation,
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
Loading