Skip to content
Merged
37 changes: 13 additions & 24 deletions .github/workflows/_legacy-checkpoints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,11 @@ jobs:
env:
PACKAGE_NAME: pytorch
FREEZE_REQUIREMENTS: 1
run: |
pip install . -f https://download.pytorch.org/whl/cpu/torch_stable.html
pip list
run: pip install . -f https://download.pytorch.org/whl/cpu/torch_stable.html
if: inputs.pl_version == ''

- name: Install PL version
run: |
pip install "pytorch-lightning==${{ inputs.pl_version }}" \
-f https://download.pytorch.org/whl/cpu/torch_stable.html
pip list
run: pip install "pytorch-lightning==${{ inputs.pl_version }}" -f https://download.pytorch.org/whl/cpu/torch_stable.html
if: inputs.pl_version != ''

- name: Pull legacy checkpoints
Expand All @@ -86,36 +81,29 @@ jobs:

- name: Decide PL version to create a PR with
id: decide-version
run: |
python -c "import pytorch_lightning as pl; print(f'pl-version={pl.__version__}')" >> $GITHUB_OUTPUT || echo pl-version='' >> $GITHUB_OUTPUT
run: python -c "import pytorch_lightning as pl; print(f'pl-version={pl.__version__}')" >> $GITHUB_OUTPUT || echo pl-version='' >> $GITHUB_OUTPUT

- name: Generate checkpoints
run: |
bash generate_checkpoints.sh ${{ inputs.pl_version }}
run: bash generate_checkpoints.sh ${{ inputs.pl_version }}

- name: Keep artifact
id: keep-artifact
run: python -c "print('DAYS=' + str(30 if '${{ github.event_name }}'.startswith('pull_request') else 0))" >> $GITHUB_OUTPUT
- name: Keep artifact & DryRun
run: |
python -c "print('KEEP_DAYS=' + str(30 if '${{ github.event_name }}'.startswith('pull_request') else 0))" >> $GITHUB_ENV
python -c "print('AWS_RUN=' + str('' if '${{inputs.push_to_s3}}' == 'true' else '--dryrun'))" >> $GITHUB_ENV

- name: Upload checkpoints to GitHub Actions artifact
uses: actions/upload-artifact@v3
with:
name: checkpoints-${{ github.sha }}
path: tests/legacy/checkpoints/
retention-days: ${{ steps.keep-artifact.outputs.DAYS }}

- name: Upload checkpoints to S3 (dryrun)
run: |
aws s3 sync --dryrun checkpoints/ s3://pl-public-data/legacy/checkpoints/
zip -r checkpoints.zip checkpoints
aws s3 cp --dryrun checkpoints.zip s3://pl-public-data/legacy/ --acl public-read
retention-days: ${{ env.KEEP_DAYS }}

- name: Upload checkpoints to S3
run: |
aws s3 sync checkpoints/ s3://pl-public-data/legacy/checkpoints/
aws s3 sync $AWS_RUN checkpoints/ s3://pl-public-data/legacy/checkpoints/
zip -r checkpoints.zip checkpoints
aws s3 cp checkpoints.zip s3://pl-public-data/legacy/ --acl public-read
if: inputs.push_to_s3
aws s3 cp $AWS_RUN checkpoints.zip s3://pl-public-data/legacy/ --acl public-read


adding-ckpt-test:
runs-on: ubuntu-20.04
Expand All @@ -135,5 +123,6 @@ jobs:
title: Adding test for legacy checkpoint created with ${{ needs.create-legacy-ckpts.outputs.pl-version }}
delete-branch: true
labels: |
checkpointing
tests
pl
4 changes: 3 additions & 1 deletion docs/source-pytorch/past_versions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ TO help you with keeping up to spead, check :doc:`Migration guide <./upgrade/mig
- `1.9.0 <https://pytorch-lightning.readthedocs.io/en/1.9.0>`_,
`1.9.1 <https://pytorch-lightning.readthedocs.io/en/1.9.1>`_,
`1.9.2 <https://pytorch-lightning.readthedocs.io/en/1.9.2>`_,
`1.9.3 <https://pytorch-lightning.readthedocs.io/en/1.9.3>`_
`1.9.3 <https://pytorch-lightning.readthedocs.io/en/1.9.3>`_,
`1.9.4 <https://pytorch-lightning.readthedocs.io/en/1.9.4>`_,
`1.9.5 <https://pytorch-lightning.readthedocs.io/en/1.9.5>`_
- :doc:`from 1.9 to 2.0 <upgrade/from_1_9>`

* - `1.8 <https://github.com/Lightning-AI/lightning/releases/tag/1.8.0>`_
Expand Down
6 changes: 6 additions & 0 deletions tests/legacy/back-compatible-versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,9 @@
1.7.6
1.7.7
1.8.0
1.8.1
1.8.2
1.8.3
1.8.4
1.8.5
1.8.6
4 changes: 3 additions & 1 deletion tests/legacy/generate_checkpoints.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ do

# Don't install/update anything before activating venv
# to avoid breaking any existing environment.
rm -rf $ENV_PATH
python -m venv $ENV_PATH
source $ENV_PATH/bin/activate

python -m pip install pytorch_lightning==$pl_ver -r $LEGACY_PATH/requirements.txt -f https://download.pytorch.org/whl/cpu/torch_stable.html
python -m pip install "pytorch_lightning==$pl_ver" -r $LEGACY_PATH/requirements.txt -f https://download.pytorch.org/whl/cpu/torch_stable.html

rm -rf $LEGACY_PATH/checkpoints/$pl_ver
create_and_save_checkpoint

deactivate
Expand Down
6 changes: 4 additions & 2 deletions tests/legacy/simple_classif_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ def main_train(dir_path, max_epochs: int = 20):
deterministic=True,
)

dm = ClassifDataModule()
model = ClassificationModel()
dm = ClassifDataModule(
num_features=24, length=6000, num_classes=3, batch_size=128, n_clusters_per_class=2, n_informative=int(24 / 3)
)
model = ClassificationModel(num_features=24, num_classes=3, lr=0.01)
trainer.fit(model, datamodule=dm)
res = trainer.test(model, datamodule=dm)
assert res[0]["test_loss"] <= 0.85, str(res[0]["test_loss"])
Expand Down
7 changes: 6 additions & 1 deletion tests/tests_pytorch/helpers/simple_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import operator

import torch
import torch.nn.functional as F
from torch import nn
from torchmetrics import Accuracy, MeanSquaredError

from pytorch_lightning import LightningModule
from pytorch_lightning.utilities.imports import _TORCHMETRICS_GREATER_EQUAL_0_11 as _TM_GE_0_11
from pytorch_lightning.utilities.imports import compare_version

# using new API with task
_TM_GE_0_11 = compare_version("torchmetrics", operator.ge, "0.11.0")


class ClassificationModel(LightningModule):
Expand Down