Skip to content

Commit f065ea6

Browse files
Bordatchaton
andauthored
populate some more legacy checkpoints (#5457)
* populate some more legacy checkpoints * . * pt freeze * . * skip Co-authored-by: chaton <[email protected]>
1 parent 8748293 commit f065ea6

File tree

5 files changed

+41
-5
lines changed

5 files changed

+41
-5
lines changed

legacy/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Maintaining back-compatibility with come legacy versions
2+
3+
The aim of this section is set some baselines and workflows/guidelines for maintaining back compatibility with some legacies version of PL
4+
5+
At this moment we focus on ability running old checkpoints, so the flow here is to create a checkpoint with every release and store it in our public AWS storage and so each CI testing will pull this archive and test loading and resuming training with this model.
6+
7+
If you want to pull all saved version-checkpoints for local testing/development, call
8+
```bash
9+
wget https://pl-public-data.s3.amazonaws.com/legacy/checkpoints.zip
10+
unzip -o checkpoints.zip
11+
```
12+
13+
To back populate collection with past version you can use following bash:
14+
```bash
15+
bash generate_checkpoints.sh 1.0.2 1.0.3 1.0.4
16+
zip -r checkpoints.zip checkpoints/
17+
```

legacy/generate_checkpoints.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ do
2121
virtualenv $ENV_PATH --system-site-packages
2222
# activate and install PL version
2323
source "$ENV_PATH/bin/activate"
24-
pip install "pytorch_lightning==$ver" --quiet -U --no-cache-dir
24+
# there are problem to load ckpt in older versions since they are saved the newer versions
25+
pip install "pytorch_lightning==$ver" "torch==1.3" --quiet --no-cache-dir
2526

2627
python --version
2728
pip --version

legacy/zero_training.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def _loss(self, batch, prediction):
4949
def _step(self, batch, batch_idx):
5050
output = self.layer(batch)
5151
loss = self._loss(batch, output)
52-
return loss
52+
# return {'loss': loss} # used for PL<1.0
53+
return loss # used for PL >= 1.0
5354

5455
def training_step(self, batch, batch_idx):
5556
return self._step(batch, batch_idx)

pytorch_lightning/core/lightning.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ def automatic_optimization(self) -> bool:
170170
def automatic_optimization(self, automatic_optimization: bool) -> None:
171171
self._automatic_optimization = automatic_optimization
172172

173-
174173
def print(self, *args, **kwargs) -> None:
175174
r"""
176175
Prints only from process 0. Use this in any distributed mode to log only once.

tests/checkpointing/test_legacy_checkpoints.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,27 @@
2424
CHECKPOINT_EXTENSION = ".ckpt"
2525

2626

27-
# todo: add more legacy checkpoints :]
27+
# todo: add more legacy checkpoints - for < v0.8
2828
@pytest.mark.parametrize("pl_version", [
29-
"0.10.0", "1.0.0", "1.0.1", "1.0.2", "1.0.3", "1.0.4", "1.0.5", "1.0.6", "1.0.7", "1.0.8"
29+
# "0.8.1",
30+
"0.8.3",
31+
"0.8.4",
32+
# "0.8.5", # this version has problem with loading on PT<=1.4 as it seems to be archive
33+
# "0.9.0", # this version has problem with loading on PT<=1.4 as it seems to be archive
34+
"0.10.0",
35+
"1.0.0",
36+
"1.0.1",
37+
"1.0.2",
38+
"1.0.3",
39+
"1.0.4",
40+
"1.0.5",
41+
"1.0.6",
42+
"1.0.7",
43+
"1.0.8",
44+
"1.1.0",
45+
"1.1.1",
46+
"1.1.2",
47+
"1.1.3",
3048
])
3149
def test_resume_legacy_checkpoints(tmpdir, pl_version):
3250
path_dir = os.path.join(LEGACY_CHECKPOINTS_PATH, pl_version)

0 commit comments

Comments
 (0)