Skip to content

Commit 211bca7

Browse files
authored
Merge branch 'master' into patch-1
2 parents e83614e + e721b1f commit 211bca7

38 files changed

+698
-685
lines changed

.mergify.yml

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -12,59 +12,59 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
pull_request_rules:
16-
17-
- name: Automatic merge on approval
18-
conditions:
19-
- base=master
20-
# number of review approvals
21-
- "#approved-reviews-by>=3"
22-
# no waiting or assigned review
23-
- "#review-requested=0"
24-
# no requested chnages from any reviewer
25-
- "#changes-requested-reviews-by=0"
26-
# this serves as ALL check has to pass as we have actually around 40 tests in total
27-
- "#status-success>=54"
28-
# this is just in case since we rely on GPU tests (note: redundand to the above)
29-
- status-success=continuous-integration/drone/pr
30-
- "status-success=ci/circleci: TPU-tests"
31-
# this is patter-like, unofrunatly serves as `any(...)` (note: redundand to the above)
32-
#- "status-success~=^ci/circleci:"
33-
# no conflict with master branch
34-
- -conflict
35-
# was not closed yet
36-
- -closed
37-
# filter-out GH draft PRs
38-
- -draft
39-
actions:
40-
delete_head_branch: {}
41-
merge:
42-
# https://doc.mergify.io/merge-action.html#strict-merge
43-
# (on head branch) $ git merge --no-ff base
44-
# (on head branch) # Wait for CI to go green
45-
# (on head branch) # Squash all commits
46-
# (on base branch) $ git merge --ff head
47-
strict: true
48-
method: squash
49-
comment:
50-
message: Great job! =)
51-
52-
- name: warn on conflicts
53-
conditions:
54-
- conflict
55-
# filter-out GH draft PRs
56-
- -draft
57-
actions:
58-
comment:
59-
message: This pull request is now in conflict... :(
60-
61-
- name: add core reviewer
62-
conditions:
63-
# filter-out GH draft PRs
64-
- -draft
65-
# number of review approvals
66-
- "#approved-reviews-by<3"
67-
actions:
68-
request_reviews:
69-
teams:
70-
- core-contributors
15+
#pull_request_rules:
16+
#
17+
# - name: Automatic merge on approval
18+
# conditions:
19+
# - base=master
20+
# # number of review approvals
21+
# - "#approved-reviews-by>=3"
22+
# # no waiting or assigned review
23+
# - "#review-requested=0"
24+
# # no requested chnages from any reviewer
25+
# - "#changes-requested-reviews-by=0"
26+
# # this serves as ALL check has to pass as we have actually around 40 tests in total
27+
# - "#status-success>=54"
28+
# # this is just in case since we rely on GPU tests (note: redundand to the above)
29+
# - status-success=continuous-integration/drone/pr
30+
# - "status-success=ci/circleci: TPU-tests"
31+
# # this is patter-like, unofrunatly serves as `any(...)` (note: redundand to the above)
32+
# #- "status-success~=^ci/circleci:"
33+
# # no conflict with master branch
34+
# - -conflict
35+
# # was not closed yet
36+
# - -closed
37+
# # filter-out GH draft PRs
38+
# - -draft
39+
# actions:
40+
# delete_head_branch: {}
41+
# merge:
42+
# # https://doc.mergify.io/merge-action.html#strict-merge
43+
# # (on head branch) $ git merge --no-ff base
44+
# # (on head branch) # Wait for CI to go green
45+
# # (on head branch) # Squash all commits
46+
# # (on base branch) $ git merge --ff head
47+
# strict: true
48+
# method: squash
49+
# comment:
50+
# message: Great job! =)
51+
#
52+
# - name: warn on conflicts
53+
# conditions:
54+
# - conflict
55+
# # filter-out GH draft PRs
56+
# - -draft
57+
# actions:
58+
# comment:
59+
# message: This pull request is now in conflict... :(
60+
#
61+
# - name: add core reviewer
62+
# conditions:
63+
# # filter-out GH draft PRs
64+
# - -draft
65+
# # number of review approvals
66+
# - "#approved-reviews-by<3"
67+
# actions:
68+
# request_reviews:
69+
# teams:
70+
# - core-contributors

CHANGELOG.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
66

77

8-
## [unreleased.BugFix] - YYYY-MM-DD
8+
## [1.1.2rc1] - 2020-12-17
99

1010
### Added
1111

12+
- Support number for logging with `sync_dist=True` ([#5080](https://github.com/PyTorchLightning/pytorch-lightning/pull/5080)
13+
1214

1315
### Changed
1416

@@ -18,9 +20,28 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
1820

1921
### Removed
2022

23+
- `enable_pl_optimizer=False` by default to temporarily fix AMP issues ([#5163](https://github.com/PyTorchLightning/pytorch-lightning/pull/5163)
24+
2125

2226
### Fixed
2327

28+
- Metric reduction with Logging ([#5150](https://github.com/PyTorchLightning/pytorch-lightning/pull/5150)
29+
30+
31+
- Remove nan loss in manual optimization ([#5121](https://github.com/PyTorchLightning/pytorch-lightning/pull/5121)
32+
33+
34+
- Un-balanced logging properly supported ([#5119](https://github.com/PyTorchLightning/pytorch-lightning/pull/5119)
35+
36+
37+
- Fix hanging in DDP HPC accelerators ([#5157](https://github.com/PyTorchLightning/pytorch-lightning/pull/5157)
38+
39+
40+
- Fix saved filename in `ModelCheckpoint` if it already exists ([#4861](https://github.com/PyTorchLightning/pytorch-lightning/pull/4861)
41+
42+
43+
- Fix reset `TensorRunningAccum` ([#5106](https://github.com/PyTorchLightning/pytorch-lightning/pull/5106)
44+
2445

2546
## [1.1.1] - 2020-12-15
2647

@@ -34,8 +55,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
3455
- Refactor load in checkpoint connector ([#4593](https://github.com/PyTorchLightning/pytorch-lightning/pull/4593)
3556
- Fixed the saved filename in `ModelCheckpoint` when it already exists ([#4861](https://github.com/PyTorchLightning/pytorch-lightning/pull/4861))
3657

37-
38-
=======
3958
### Removed
4059

4160
- Drop duplicate metrics ([#5014](https://github.com/PyTorchLightning/pytorch-lightning/pull/5014)

benchmarks/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright The PyTorch Lightning team.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
import os
15+
16+
BENCHMARK_ROOT = os.path.dirname(__file__)
17+
PROJECT_ROOT = os.path.dirname(BENCHMARK_ROOT)

benchmarks/generate_comparison.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright The PyTorch Lightning team.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
import os
15+
16+
import matplotlib.pylab as plt
17+
import pandas as pd
18+
19+
from benchmarks.test_basic_parity import lightning_loop, vanilla_loop
20+
from tests.base.models import ParityModuleMNIST, ParityModuleRNN
21+
22+
NUM_EPOCHS = 20
23+
NUM_RUNS = 50
24+
MODEL_CLASSES = (ParityModuleRNN, ParityModuleMNIST)
25+
PATH_HERE = os.path.dirname(__file__)
26+
FIGURE_EXTENSION = '.png'
27+
28+
29+
def _main():
30+
fig, axarr = plt.subplots(nrows=len(MODEL_CLASSES))
31+
32+
for i, cls_model in enumerate(MODEL_CLASSES):
33+
path_csv = os.path.join(PATH_HERE, f'dump-times_{cls_model.__name__}.csv')
34+
if os.path.isfile(path_csv):
35+
df_time = pd.read_csv(path_csv, index_col=0)
36+
else:
37+
vanilla = vanilla_loop(cls_model, num_epochs=NUM_EPOCHS, num_runs=NUM_RUNS)
38+
lightning = lightning_loop(cls_model, num_epochs=NUM_EPOCHS, num_runs=NUM_RUNS)
39+
40+
df_time = pd.DataFrame({'vanilla PT': vanilla['durations'][1:], 'PT Lightning': lightning['durations'][1:]})
41+
df_time /= NUM_RUNS
42+
df_time.to_csv(os.path.join(PATH_HERE, f'dump-times_{cls_model.__name__}.csv'))
43+
# todo: add also relative X-axis ticks to see both: relative and absolute time differences
44+
df_time.plot.hist(
45+
ax=axarr[i],
46+
bins=20,
47+
alpha=0.5,
48+
title=cls_model.__name__,
49+
legend=True,
50+
grid=True,
51+
)
52+
axarr[i].set(xlabel='time [seconds]')
53+
54+
path_fig = os.path.join(PATH_HERE, f'figure-parity-times{FIGURE_EXTENSION}')
55+
fig.tight_layout()
56+
fig.savefig(path_fig)
57+
58+
59+
if __name__ == '__main__':
60+
_main()

benchmarks/test_parity.py renamed to benchmarks/test_basic_parity.py

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
1+
# Copyright The PyTorch Lightning team.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
import time
216

317
import numpy as np
418
import pytest
519
import torch
20+
from tqdm import tqdm
621

722
from pytorch_lightning import seed_everything, Trainer
823
import tests.base.develop_utils as tutils
@@ -15,34 +30,33 @@
1530
(ParityModuleMNIST, 0.25), # todo: lower this thr
1631
])
1732
@pytest.mark.skipif(not torch.cuda.is_available(), reason="test requires GPU machine")
18-
def test_pytorch_parity(tmpdir, cls_model, max_diff):
33+
def test_pytorch_parity(tmpdir, cls_model, max_diff: float, num_epochs: int = 4, num_runs: int = 3):
1934
"""
2035
Verify that the same pytorch and lightning models achieve the same results
2136
"""
22-
num_epochs = 4
23-
num_rums = 3
24-
lightning_outs, pl_times = lightning_loop(cls_model, num_rums, num_epochs)
25-
manual_outs, pt_times = vanilla_loop(cls_model, num_rums, num_epochs)
37+
lightning = lightning_loop(cls_model, num_runs, num_epochs)
38+
vanilla = vanilla_loop(cls_model, num_runs, num_epochs)
2639

2740
# make sure the losses match exactly to 5 decimal places
28-
for pl_out, pt_out in zip(lightning_outs, manual_outs):
41+
for pl_out, pt_out in zip(lightning['losses'], vanilla['losses']):
2942
np.testing.assert_almost_equal(pl_out, pt_out, 5)
3043

3144
# the fist run initialize dataset (download & filter)
32-
tutils.assert_speed_parity_absolute(pl_times[1:], pt_times[1:],
33-
nb_epochs=num_epochs, max_diff=max_diff)
45+
tutils.assert_speed_parity_absolute(
46+
lightning['durations'][1:], vanilla['durations'][1:], nb_epochs=num_epochs, max_diff=max_diff
47+
)
3448

3549

3650
def vanilla_loop(cls_model, num_runs=10, num_epochs=10):
3751
"""
3852
Returns an array with the last loss from each epoch for each run
3953
"""
40-
device = torch.device('cuda' if torch.cuda.is_available() else "cpu")
41-
errors = []
42-
times = []
54+
hist_losses = []
55+
hist_durations = []
4356

57+
device = torch.device('cuda' if torch.cuda.is_available() else "cpu")
4458
torch.backends.cudnn.deterministic = True
45-
for i in range(num_runs):
59+
for i in tqdm(range(num_runs), desc=f'Vanilla PT with {cls_model.__name__}'):
4660
time_start = time.perf_counter()
4761

4862
# set seed
@@ -74,18 +88,21 @@ def vanilla_loop(cls_model, num_runs=10, num_epochs=10):
7488
epoch_losses.append(loss.item())
7589

7690
time_end = time.perf_counter()
77-
times.append(time_end - time_start)
91+
hist_durations.append(time_end - time_start)
7892

79-
errors.append(epoch_losses[-1])
93+
hist_losses.append(epoch_losses[-1])
8094

81-
return errors, times
95+
return {
96+
'losses': hist_losses,
97+
'durations': hist_durations,
98+
}
8299

83100

84101
def lightning_loop(cls_model, num_runs=10, num_epochs=10):
85-
errors = []
86-
times = []
102+
hist_losses = []
103+
hist_durations = []
87104

88-
for i in range(num_runs):
105+
for i in tqdm(range(num_runs), desc=f'PT Lightning with {cls_model.__name__}'):
89106
time_start = time.perf_counter()
90107

91108
# set seed
@@ -108,9 +125,12 @@ def lightning_loop(cls_model, num_runs=10, num_epochs=10):
108125
trainer.fit(model)
109126

110127
final_loss = trainer.train_loop.running_loss.last().item()
111-
errors.append(final_loss)
128+
hist_losses.append(final_loss)
112129

113130
time_end = time.perf_counter()
114-
times.append(time_end - time_start)
131+
hist_durations.append(time_end - time_start)
115132

116-
return errors, times
133+
return {
134+
'losses': hist_losses,
135+
'durations': hist_durations,
136+
}

benchmarks/test_sharded_parity.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# Copyright The PyTorch Lightning team.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
115
import os
216
import platform
317
import time

dockers/base-xla/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ RUN \
9797
python -c "fname = 'requirements.txt' ; lines = [line for line in open(fname).readlines() if not line.startswith('torch')] ; open(fname, 'w').writelines(lines)" && \
9898
# drop Horovod as it is not needed
9999
python -c "fname = 'requirements/extra.txt' ; lines = [line for line in open(fname).readlines() if not line.startswith('horovod')] ; open(fname, 'w').writelines(lines)" && \
100+
# drop fairscale as it is not needed
101+
python -c "fname = 'requirements/extra.txt' ; lines = [line for line in open(fname).readlines() if 'fairscale' not in line] ; open(fname, 'w').writelines(lines)" && \
100102
# drop TorchVision as it was installed with XLA
101103
python -c "fname = 'requirements/examples.txt' ; lines = [line for line in open(fname).readlines() if not line.startswith('torchvision')] ; open(fname, 'w').writelines(lines)" && \
102104
pip install --requirement ./requirements/devel.txt --upgrade-strategy only-if-needed && \

dockers/tpu-tests/Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ COPY ./ ./pytorch-lightning/
2727
RUN \
2828
# Install pytorch-lightning at the current PR, plus dependencies.
2929
#pip install -r pytorch-lightning/requirements.txt --no-cache-dir && \
30-
# drop Horovod
30+
# drop Horovod as it is not needed
3131
python -c "fname = 'pytorch-lightning/requirements/extra.txt' ; lines = [line for line in open(fname).readlines() if not line.startswith('horovod')] ; open(fname, 'w').writelines(lines)" && \
32+
# drop fairscale as it is not needed
33+
python -c "fname = 'pytorch-lightning/requirements/extra.txt' ; lines = [line for line in open(fname).readlines() if 'fairscale' not in line] ; open(fname, 'w').writelines(lines)" && \
3234
pip install -r pytorch-lightning/requirements/devel.txt --no-cache-dir --upgrade-strategy only-if-needed
3335

3436
#RUN python -c "import pytorch_lightning as pl; print(pl.__version__)"
30.8 KB
Loading

0 commit comments

Comments
 (0)