From f66c089f0bdfd364d809bd8f9b3273e45b84bbd5 Mon Sep 17 00:00:00 2001 From: Sebastian Raschka Date: Sat, 27 Jul 2024 15:09:02 -0500 Subject: [PATCH] Test with PyTorch 2.0 and 2.4 (#290) * Test with PyTorch 2.0 and 2.4 * Update basic-tests-old-pytorch.yml * skip version cell --- .github/workflows/basic-tests-old-pytorch.yml | 54 +++++++++++++++++++ ch02/01_main-chapter-code/dataloader.ipynb | 3 +- 2 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/basic-tests-old-pytorch.yml diff --git a/.github/workflows/basic-tests-old-pytorch.yml b/.github/workflows/basic-tests-old-pytorch.yml new file mode 100644 index 0000000..4319589 --- /dev/null +++ b/.github/workflows/basic-tests-old-pytorch.yml @@ -0,0 +1,54 @@ +name: Test PyTorch 2.0 and 2.4 + +on: + push: + branches: [ main ] + paths: + - '**/*.py' # Run workflow for changes in Python files + - '**/*.ipynb' + - '**/*.yaml' + - '**/*.yml' + - '**/*.sh' + pull_request: + branches: [ main ] + paths: + - '**/*.py' + - '**/*.ipynb' + - '**/*.yaml' + - '**/*.yml' + - '**/*.sh' + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + pytorch-version: [ 2.0.1, 2.4.0 ] + + steps: + - uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pytest nbval + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + pip install torch==${{ matrix.pytorch-version }} + + - name: Test Selected Python Scripts + run: | + pytest setup/02_installing-python-libraries/tests.py + pytest ch04/01_main-chapter-code/tests.py + pytest ch05/01_main-chapter-code/tests.py + pytest ch06/01_main-chapter-code/tests.py + + - name: Validate Selected Jupyter Notebooks + run: | + pytest --nbval ch02/01_main-chapter-code/dataloader.ipynb + pytest --nbval ch03/01_main-chapter-code/multihead-attention.ipynb + pytest --nbval ch02/04_bonus_dataloader-intuition/dataloader-intuition.ipynb diff --git a/ch02/01_main-chapter-code/dataloader.ipynb b/ch02/01_main-chapter-code/dataloader.ipynb index 93c3811..a6371c5 100644 --- a/ch02/01_main-chapter-code/dataloader.ipynb +++ b/ch02/01_main-chapter-code/dataloader.ipynb @@ -62,6 +62,7 @@ } ], "source": [ + "# NBVAL_SKIP\n", "from importlib.metadata import version\n", "\n", "print(\"torch version:\", version(\"torch\"))\n", @@ -188,7 +189,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.10.6" } }, "nbformat": 4,