diff --git a/.github/workflows/_legacy-checkpoints.yml b/.github/workflows/_legacy-checkpoints.yml index 99f592da2ade2..73386c71dbf71 100644 --- a/.github/workflows/_legacy-checkpoints.yml +++ b/.github/workflows/_legacy-checkpoints.yml @@ -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 @@ -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 @@ -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 diff --git a/docs/source-pytorch/past_versions.rst b/docs/source-pytorch/past_versions.rst index 3b036ae5fbefd..7314dd56bd079 100644 --- a/docs/source-pytorch/past_versions.rst +++ b/docs/source-pytorch/past_versions.rst @@ -19,7 +19,9 @@ TO help you with keeping up to spead, check :doc:`Migration guide <./upgrade/mig - `1.9.0 `_, `1.9.1 `_, `1.9.2 `_, - `1.9.3 `_ + `1.9.3 `_, + `1.9.4 `_, + `1.9.5 `_ - :doc:`from 1.9 to 2.0 ` * - `1.8 `_ diff --git a/tests/legacy/back-compatible-versions.txt b/tests/legacy/back-compatible-versions.txt index b6c18738712ce..c2bc418eecd93 100644 --- a/tests/legacy/back-compatible-versions.txt +++ b/tests/legacy/back-compatible-versions.txt @@ -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 diff --git a/tests/legacy/generate_checkpoints.sh b/tests/legacy/generate_checkpoints.sh index 9f597161acfc9..7873daf3fe56f 100644 --- a/tests/legacy/generate_checkpoints.sh +++ b/tests/legacy/generate_checkpoints.sh @@ -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 diff --git a/tests/legacy/simple_classif_training.py b/tests/legacy/simple_classif_training.py index fd62bc0963c0f..00e51627efad9 100644 --- a/tests/legacy/simple_classif_training.py +++ b/tests/legacy/simple_classif_training.py @@ -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"]) diff --git a/tests/tests_pytorch/helpers/simple_models.py b/tests/tests_pytorch/helpers/simple_models.py index 4e82ba00f1900..36b0c7bcd7177 100644 --- a/tests/tests_pytorch/helpers/simple_models.py +++ b/tests/tests_pytorch/helpers/simple_models.py @@ -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):