Skip to content

Commit 7c775c1

Browse files
authored
Merge pull request #1280 from jdb78/maintenance/update-dependencies
Maintenance/update-dependencies
2 parents 66299a3 + 58a8a1c commit 7c775c1

48 files changed

Lines changed: 10979 additions & 9467 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PYTORCH_ENABLE_MPS_FALLBACK=1

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ jobs:
7272
shell: bash
7373
run: poetry install -E "github-actions graph mqf2"
7474

75-
- name: Install pytorch geometric dependencies
76-
shell: bash
77-
run: poetry run pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-1.12.1+cpu.html
75+
# - name: Install pytorch geometric dependencies
76+
# shell: bash
77+
# run: poetry run pip install pyg_lib torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://data.pyg.org/whl/torch-2.0.0+cpu.html
7878

7979
- name: Run pytest
8080
shell: bash

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ celerybeat.pid
104104
*.sage.py
105105

106106
# Environments
107-
.env
107+
# .env
108108
.venv
109109
env/
110110
venv/

.pre-commit-config.yaml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v4.1.0
5+
rev: v4.4.0
66
hooks:
7-
- id: trailing-whitespace
8-
- id: end-of-file-fixer
9-
- id: check-yaml
10-
- id: check-ast
11-
- repo: https://gitlab.com/pycqa/flake8
12-
rev: "3.9.2"
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-yaml
10+
- id: check-ast
11+
- repo: https://github.com/pycqa/flake8
12+
rev: 6.0.0
1313
hooks:
14-
- id: flake8
14+
- id: flake8
1515
- repo: https://github.com/pre-commit/mirrors-isort
1616
rev: v5.10.1
1717
hooks:
18-
- id: isort
18+
- id: isort
1919
- repo: https://github.com/psf/black
20-
rev: 22.3.0
20+
rev: 23.1.0
2121
hooks:
22-
- id: black
22+
- id: black
2323
- repo: https://github.com/nbQA-dev/nbQA
24-
rev: 1.3.1
24+
rev: 1.6.4
2525
hooks:
2626
- id: nbqa-black
2727
- id: nbqa-isort

CHANGELOG.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# Release Notes
22

3-
## v0.10.4 UNRELEASED (xx/xx/xxxx)
3+
## v1.0.0 Update to pytorch 2.0 (10/04/2023)
4+
5+
6+
### Breaking Changes
7+
8+
- Upgraded to pytorch 2.0 and lightning 2.0. This brings a couple of changes, such as configuration of trainers. See the [lightning upgrade guide](https://lightning.ai/docs/pytorch/latest/upgrade/migration_guide.html). For PyTorch Forecasting, this particularly means if you are developing own models, the class method `epoch_end` has been renamed to `on_epoch_end` and replacing `model.summarize()` with `ModelSummary(model, max_depth=-1)` and `Tuner(trainer)` is its own class, so `trainer.tuner` needs replacing. (#1280)
9+
- Changed the `predict()` interface returning named tuple - see tutorials.
10+
11+
### Changes
12+
13+
- The predict method is now using the lightning predict functionality and allows writing results to disk (#1280).
414

515
### Fixed
616

@@ -81,7 +91,7 @@
8191

8292
### Added
8393

84-
- Added support for running `pytorch_lightning.trainer.test` (#759)
94+
- Added support for running `lightning.trainer.test` (#759)
8595

8696
### Fixed
8797

@@ -402,7 +412,7 @@ This release has only one purpose: Allow usage of PyTorch Lightning 1.0 - all te
402412
- Using `LearningRateMonitor` instead of `LearningRateLogger`
403413
- Use `EarlyStopping` callback in trainer `callbacks` instead of `early_stopping` argument
404414
- Update metric system `update()` and `compute()` methods
405-
- Use `trainer.tuner.lr_find()` instead of `trainer.lr_find()` in tutorials and examples
415+
- Use `Tuner(trainer).lr_find()` instead of `trainer.lr_find()` in tutorials and examples
406416
- Update poetry to 1.1.0
407417

408418
---

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ Specifically, the package provides
3434
- Multiple neural network architectures for timeseries forecasting that have been enhanced
3535
for real-world deployment and come with in-built interpretation capabilities
3636
- Multi-horizon timeseries metrics
37-
- Ranger optimizer for faster model training
3837
- Hyperparameter tuning with [optuna](https://optuna.readthedocs.io/)
3938

4039
The package is built on [pytorch-lightning](https://pytorch-lightning.readthedocs.io/) to allow training on CPUs, single and multiple GPUs out-of-the-box.
@@ -86,11 +85,12 @@ Networks can be trained with the [PyTorch Lighning Trainer](https://pytorch-ligh
8685

8786
```python
8887
# imports for training
89-
import pytorch_lightning as pl
90-
from pytorch_lightning.loggers import TensorBoardLogger
91-
from pytorch_lightning.callbacks import EarlyStopping, LearningRateMonitor
88+
import lightning.pytorch as pl
89+
from lightning.pytorch.loggers import TensorBoardLogger
90+
from lightning.pytorch.callbacks import EarlyStopping, LearningRateMonitor
9291
# import dataset, network to train and metric to optimize
9392
from pytorch_forecasting import TimeSeriesDataSet, TemporalFusionTransformer, QuantileLoss
93+
from lightning.pytorch.tuner import Tuner
9494

9595
# load data: this is pandas dataframe with at least a column for
9696
# * the target (what you want to predict)
@@ -133,7 +133,7 @@ early_stop_callback = EarlyStopping(monitor="val_loss", min_delta=1e-4, patience
133133
lr_logger = LearningRateMonitor()
134134
trainer = pl.Trainer(
135135
max_epochs=100,
136-
gpus=0, # run on CPU, if on multiple GPUs, use accelerator="ddp"
136+
accelerator="auto", # run on CPU, if on multiple GPUs, use strategy="ddp"
137137
gradient_clip_val=0.1,
138138
limit_train_batches=30, # 30 batches per epoch
139139
callbacks=[lr_logger, early_stop_callback],
@@ -160,7 +160,7 @@ tft = TemporalFusionTransformer.from_dataset(
160160
print(f"Number of parameters in network: {tft.size()/1e3:.1f}k")
161161

162162
# find the optimal learning rate
163-
res = trainer.lr_find(
163+
res = Tuner(trainer).lr_find(
164164
tft, train_dataloaders=train_dataloader, val_dataloaders=val_dataloader, early_stop_threshold=1000.0, max_lr=0.3,
165165
)
166166
# and plot the result - always visually confirm that the suggested learning rate makes sense

docs/requirements.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ nbsphinx
33
pandoc
44
docutils
55
pydata-sphinx-theme
6-
pytorch-lightning>=0.9.0
6+
lightning>=2.0.0
77
cloudpickle
8-
torch>=1.6
9-
optuna>=2.0
8+
torch>=2.0
9+
optuna>=3.1.0
1010
scipy
11-
pandas>=1.0
12-
scikit-learn>0.23
11+
pandas>=1.3
12+
scikit-learn>1.2
1313
matplotlib
1414
statsmodels
1515
ipython
1616
nbconvert>=6.3.0
1717
recommonmark>=0.7.1
18+
pytorch-optimizer>=2.5.1
19+
fastapi>0.80

docs/source/api.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ API
1111
data
1212
models
1313
metrics
14-
optim
1514
utils

docs/source/getting-started.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The general setup for training and testing a model is
4646
directly if you do not wish to load the entire training dataset at inference time.
4747

4848
#. Instantiate a model using the its ``.from_dataset()`` method.
49-
#. Create a ``pytorch_lightning.Trainer()`` object.
49+
#. Create a ``lightning.Trainer()`` object.
5050
#. Find the optimal learning rate with its ``.tuner.lr_find()`` method.
5151
#. Train the model with early stopping on the training dataset and use the tensorboard logs
5252
to understand if it has converged with acceptable accuracy.
@@ -65,9 +65,9 @@ Example
6565

6666
.. code-block:: python
6767
68-
import pytorch_lightning as pl
69-
from pytorch_lightning.callbacks import EarlyStopping, LearningRateMonitor
70-
68+
import lightning.pytorch as pl
69+
from lightning.pytorch.callbacks import EarlyStopping, LearningRateMonitor
70+
from lightning.pytorch.tuner import Tuner
7171
from pytorch_forecasting import TimeSeriesDataSet, TemporalFusionTransformer
7272
7373
# load data
@@ -105,7 +105,7 @@ Example
105105
lr_logger = LearningRateMonitor()
106106
trainer = pl.Trainer(
107107
max_epochs=100,
108-
gpus=0,
108+
accelerator="auto",
109109
gradient_clip_val=0.1,
110110
limit_train_batches=30,
111111
callbacks=[lr_logger, early_stop_callback],
@@ -127,7 +127,7 @@ Example
127127
print(f"Number of parameters in network: {tft.size()/1e3:.1f}k")
128128
129129
# find optimal learning rate (set limit_train_batches to 1.0 and log_interval = -1)
130-
res = trainer.tuner.lr_find(
130+
res = Tuner(trainer).lr_find(
131131
tft, train_dataloaders=train_dataloader, val_dataloaders=val_dataloader, early_stop_threshold=1000.0, max_lr=0.3,
132132
)
133133

docs/source/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ Specifically, the package provides
2727
* Multiple neural network architectures for timeseries forecasting that have been enhanced
2828
for real-world deployment and come with in-built interpretation capabilities
2929
* Multi-horizon timeseries metrics
30-
* Ranger optimizer for faster model training
3130
* Hyperparameter tuning with `optuna <https://optuna.readthedocs.io/>`_
3231

3332
The package is built on `PyTorch Lightning <https://pytorch-lightning.readthedocs.io/>`_ to allow

0 commit comments

Comments
 (0)