From c56757e0ea9a6d1907a8762828d8fc33ff804519 Mon Sep 17 00:00:00 2001 From: Omkar Salpekar Date: Thu, 29 Jun 2023 15:57:21 -0700 Subject: [PATCH 01/15] Apple Silicon Support for TorchRL --- .github/workflows/wheels.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ac55aaacf0f..131b51cc7c1 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -84,6 +84,38 @@ jobs: name: torchrl-batch.whl path: dist/*.whl + build-wheel-m1: + runs-on: macos-m1-12 + strategy: + matrix: + python_version: [["3.7", "3.7"], ["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] + steps: + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version[1] }} + architecture: x64 + - name: Checkout torchrl + uses: actions/checkout@v2 + - name: Install PyTorch RC + run: | + python3 -mpip install torch --extra-index-url https://download.pytorch.org/whl/cpu + - name: Build wheel + run: | + export CC=clang CXX=clang++ + python3 -mpip install wheel + BUILD_VERSION=0.1.1 python3 setup.py bdist_wheel + - name: Upload wheel for the test-wheel job + uses: actions/upload-artifact@v2 + with: + name: torchrl-mac-${{ matrix.python_version[0] }}.whl + path: dist/torchrl-*.whl + - name: Upload wheel for download + uses: actions/upload-artifact@v2 + with: + name: torchrl-batch.whl + path: dist/*.whl + build-wheel-windows: runs-on: windows-latest strategy: From b255559ed594521bc147cb1e75a8e373e8e7e613 Mon Sep 17 00:00:00 2001 From: vmoens Date: Wed, 30 Aug 2023 06:14:14 -0400 Subject: [PATCH 02/15] remove 3.7 --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 420fc062ccc..aa9fa0bc5e0 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -88,7 +88,7 @@ jobs: runs-on: macos-m1-12 strategy: matrix: - python_version: [["3.7", "3.7"], ["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] + python_version: [["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] steps: - name: Setup Python uses: actions/setup-python@v2 From 5b19daef484393f6ab533cb40c80c48bf6a31122 Mon Sep 17 00:00:00 2001 From: vmoens Date: Wed, 30 Aug 2023 06:21:03 -0400 Subject: [PATCH 03/15] add 3.11 --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index aa9fa0bc5e0..e0097057ef2 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -88,7 +88,7 @@ jobs: runs-on: macos-m1-12 strategy: matrix: - python_version: [["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] + python_version: [["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"], ["3.11", "3.11"]] steps: - name: Setup Python uses: actions/setup-python@v2 From 3c3418909b70ea3ac96c15079e4db8d383094c61 Mon Sep 17 00:00:00 2001 From: Omkar Salpekar Date: Thu, 29 Jun 2023 15:57:21 -0700 Subject: [PATCH 04/15] Apple Silicon Support for TorchRL --- .github/workflows/wheels.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ca3075e7baa..420fc062ccc 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -84,6 +84,38 @@ jobs: name: torchrl-batch.whl path: dist/*.whl + build-wheel-m1: + runs-on: macos-m1-12 + strategy: + matrix: + python_version: [["3.7", "3.7"], ["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] + steps: + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python_version[1] }} + architecture: x64 + - name: Checkout torchrl + uses: actions/checkout@v2 + - name: Install PyTorch RC + run: | + python3 -mpip install torch --extra-index-url https://download.pytorch.org/whl/cpu + - name: Build wheel + run: | + export CC=clang CXX=clang++ + python3 -mpip install wheel + BUILD_VERSION=0.1.1 python3 setup.py bdist_wheel + - name: Upload wheel for the test-wheel job + uses: actions/upload-artifact@v2 + with: + name: torchrl-mac-${{ matrix.python_version[0] }}.whl + path: dist/torchrl-*.whl + - name: Upload wheel for download + uses: actions/upload-artifact@v2 + with: + name: torchrl-batch.whl + path: dist/*.whl + build-wheel-windows: runs-on: windows-latest strategy: From 7d6dcfe0aab2386179be1aa3121b7a034bebacbb Mon Sep 17 00:00:00 2001 From: vmoens Date: Wed, 30 Aug 2023 06:14:14 -0400 Subject: [PATCH 05/15] remove 3.7 --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 420fc062ccc..aa9fa0bc5e0 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -88,7 +88,7 @@ jobs: runs-on: macos-m1-12 strategy: matrix: - python_version: [["3.7", "3.7"], ["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] + python_version: [["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] steps: - name: Setup Python uses: actions/setup-python@v2 From 0d605189b7beb9ee3772331bbec4b8f7213d5aca Mon Sep 17 00:00:00 2001 From: vmoens Date: Wed, 30 Aug 2023 06:21:03 -0400 Subject: [PATCH 06/15] add 3.11 --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index aa9fa0bc5e0..e0097057ef2 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -88,7 +88,7 @@ jobs: runs-on: macos-m1-12 strategy: matrix: - python_version: [["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"]] + python_version: [["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"], ["3.11", "3.11"]] steps: - name: Setup Python uses: actions/setup-python@v2 From 6bb0b0a9530d519bba6812c3d3a5ee0c5549fb9d Mon Sep 17 00:00:00 2001 From: Omkar Salpekar Date: Wed, 30 Aug 2023 13:52:53 -0700 Subject: [PATCH 07/15] Try adding M1 Nova Wheels --- .github/workflows/build-wheels-m1.yml | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/build-wheels-m1.yml diff --git a/.github/workflows/build-wheels-m1.yml b/.github/workflows/build-wheels-m1.yml new file mode 100644 index 00000000000..24a740c3793 --- /dev/null +++ b/.github/workflows/build-wheels-m1.yml @@ -0,0 +1,42 @@ +name: Build M1 Wheels + +on: + pull_request: + push: + branches: + - nightly + - main + - release/* + tags: + # NOTE: Binary build pipelines should only get triggered on release candidate builds + # Release candidate tags look like: v1.11.0-rc1 + - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ + workflow_dispatch: + +jobs: + generate-matrix: + uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main + with: + package-type: wheel + os: macos-arm64 + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build: + needs: generate-matrix + name: pytorch/rl + uses: pytorch/test-infra/.github/workflows/build_wheels_macos.yml@main + with: + repository: pytorch/rl + ref: "" + test-infra-repository: pytorch/test-infra + test-infra-ref: main + build-matrix: ${{ needs.generate-matrix.outputs.matrix }} + pre-script: "" + post-script: "" + package-name: torchrl + runner-type: macos-m1-12 + smoke-test-script: "" + trigger-event: ${{ github.event_name }} + secrets: + AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID: ${{ secrets.AWS_PYTORCH_UPLOADER_ACCESS_KEY_ID }} + AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY: ${{ secrets.AWS_PYTORCH_UPLOADER_SECRET_ACCESS_KEY }} From 14093a7c5927f15e8eec5d1c9d0e38cc05cfa5fa Mon Sep 17 00:00:00 2001 From: Omkar Salpekar Date: Wed, 30 Aug 2023 14:47:28 -0700 Subject: [PATCH 08/15] pre build script for installing tensordict from main --- .github/scripts/pre_build_script_m1.sh | 3 +++ .github/workflows/build-wheels-m1.yml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .github/scripts/pre_build_script_m1.sh diff --git a/.github/scripts/pre_build_script_m1.sh b/.github/scripts/pre_build_script_m1.sh new file mode 100644 index 00000000000..d309e316134 --- /dev/null +++ b/.github/scripts/pre_build_script_m1.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +python3 -mpip install git+https://github.com/pytorch-labs/tensordict.git diff --git a/.github/workflows/build-wheels-m1.yml b/.github/workflows/build-wheels-m1.yml index 24a740c3793..e9350fd1393 100644 --- a/.github/workflows/build-wheels-m1.yml +++ b/.github/workflows/build-wheels-m1.yml @@ -31,7 +31,7 @@ jobs: test-infra-repository: pytorch/test-infra test-infra-ref: main build-matrix: ${{ needs.generate-matrix.outputs.matrix }} - pre-script: "" + pre-script: .github/scripts/pre_build_script_m1.sh post-script: "" package-name: torchrl runner-type: macos-m1-12 From 8f70cba00eed6359cf298a9909453b3cc67dd3a0 Mon Sep 17 00:00:00 2001 From: Omkar Salpekar Date: Wed, 30 Aug 2023 15:32:54 -0700 Subject: [PATCH 09/15] build M1 wheel in conda env --- .github/workflows/wheels.yml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index e0097057ef2..26c1a077268 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -90,21 +90,32 @@ jobs: matrix: python_version: [["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"], ["3.11", "3.11"]] steps: - - name: Setup Python - uses: actions/setup-python@v2 + - name: Setup miniconda (for pytorch_pkg_helpers) + uses: conda-incubator/setup-miniconda@v2.1.1 with: - python-version: ${{ matrix.python_version[1] }} - architecture: x64 + miniconda-version: "py39_4.12.0" + python-version: 3.9 + - name: Create Conda Environment for Binary Build + run: | + set -euxo pipefail + conda clean --all --quiet --yes + conda create + --yes \ + --quiet \ + -n buildenv \ + python="${matrix.python_version[0]}" + + echo "CONDA_RUN=conda run -p buildenv" >> "${GITHUB_ENV}" - name: Checkout torchrl uses: actions/checkout@v2 - name: Install PyTorch RC run: | - python3 -mpip install torch --extra-index-url https://download.pytorch.org/whl/cpu + "${CONDA_RUN}" python3 -mpip install torch --extra-index-url https://download.pytorch.org/whl/cpu - name: Build wheel run: | - export CC=clang CXX=clang++ - python3 -mpip install wheel - BUILD_VERSION=0.1.1 python3 setup.py bdist_wheel + "${CONDA_RUN}" export CC=clang CXX=clang++ + "${CONDA_RUN}" python3 -mpip install wheel + "${CONDA_RUN}" BUILD_VERSION=0.1.1 python3 setup.py bdist_wheel - name: Upload wheel for the test-wheel job uses: actions/upload-artifact@v2 with: From 87e2789053cf03d3ba82c46998845422d8299b95 Mon Sep 17 00:00:00 2001 From: Omkar Salpekar Date: Wed, 30 Aug 2023 16:35:15 -0700 Subject: [PATCH 10/15] conda already installed on runner? --- .github/workflows/wheels.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 26c1a077268..a8b419630c2 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -90,11 +90,10 @@ jobs: matrix: python_version: [["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"], ["3.11", "3.11"]] steps: - - name: Setup miniconda (for pytorch_pkg_helpers) - uses: conda-incubator/setup-miniconda@v2.1.1 - with: - miniconda-version: "py39_4.12.0" - python-version: 3.9 + # - name: Setup miniconda + # uses: conda-incubator/setup-miniconda@v2.1.1 + # with: + # python-version: 3.9 - name: Create Conda Environment for Binary Build run: | set -euxo pipefail From 0fc6f3a35a29bcdb06eb5a6535cb82c3aff408ec Mon Sep 17 00:00:00 2001 From: Omkar Salpekar Date: Wed, 30 Aug 2023 16:37:37 -0700 Subject: [PATCH 11/15] conda create env typo --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index a8b419630c2..ef519466187 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -98,7 +98,7 @@ jobs: run: | set -euxo pipefail conda clean --all --quiet --yes - conda create + conda create \ --yes \ --quiet \ -n buildenv \ From c1c2d5f0eafd4279c7189a0789d7b0bc405b629d Mon Sep 17 00:00:00 2001 From: Omkar Salpekar Date: Wed, 30 Aug 2023 16:40:09 -0700 Subject: [PATCH 12/15] Change how python version is passed --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ef519466187..f101153f17a 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -102,7 +102,7 @@ jobs: --yes \ --quiet \ -n buildenv \ - python="${matrix.python_version[0]}" + python="${{ matrix.python_version[0] }}" echo "CONDA_RUN=conda run -p buildenv" >> "${GITHUB_ENV}" - name: Checkout torchrl From 41075ec48b06b6d33d9a56c1040dc0552bfe2b3f Mon Sep 17 00:00:00 2001 From: Omkar Salpekar Date: Wed, 30 Aug 2023 16:56:11 -0700 Subject: [PATCH 13/15] expand conda run command --- .github/workflows/wheels.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index f101153f17a..ed1509ea042 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -90,10 +90,6 @@ jobs: matrix: python_version: [["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"], ["3.11", "3.11"]] steps: - # - name: Setup miniconda - # uses: conda-incubator/setup-miniconda@v2.1.1 - # with: - # python-version: 3.9 - name: Create Conda Environment for Binary Build run: | set -euxo pipefail @@ -104,17 +100,16 @@ jobs: -n buildenv \ python="${{ matrix.python_version[0] }}" - echo "CONDA_RUN=conda run -p buildenv" >> "${GITHUB_ENV}" - name: Checkout torchrl uses: actions/checkout@v2 - name: Install PyTorch RC run: | - "${CONDA_RUN}" python3 -mpip install torch --extra-index-url https://download.pytorch.org/whl/cpu + conda run -p buildenv python3 -mpip install torch --extra-index-url https://download.pytorch.org/whl/cpu - name: Build wheel run: | - "${CONDA_RUN}" export CC=clang CXX=clang++ - "${CONDA_RUN}" python3 -mpip install wheel - "${CONDA_RUN}" BUILD_VERSION=0.1.1 python3 setup.py bdist_wheel + conda run -p buildenv export CC=clang CXX=clang++ + conda run -p buildenv python3 -mpip install wheel + conda run -p buildenv BUILD_VERSION=0.1.1 python3 setup.py bdist_wheel - name: Upload wheel for the test-wheel job uses: actions/upload-artifact@v2 with: From 0ca1b99ab79ba8535577bd54c9f303990020093c Mon Sep 17 00:00:00 2001 From: Omkar Salpekar Date: Wed, 30 Aug 2023 17:26:01 -0700 Subject: [PATCH 14/15] whole build in one step --- .github/workflows/wheels.yml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ed1509ea042..98fde5836e6 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -90,7 +90,9 @@ jobs: matrix: python_version: [["3.8", "3.8"], ["3.9", "3.9"], ["3.10", "3.10.3"], ["3.11", "3.11"]] steps: - - name: Create Conda Environment for Binary Build + - name: Checkout torchrl + uses: actions/checkout@v2 + - name: Binary Build in Conda Environment run: | set -euxo pipefail conda clean --all --quiet --yes @@ -98,18 +100,17 @@ jobs: --yes \ --quiet \ -n buildenv \ - python="${{ matrix.python_version[0] }}" + python=${{ matrix.python_version[1] }} - - name: Checkout torchrl - uses: actions/checkout@v2 - - name: Install PyTorch RC - run: | - conda run -p buildenv python3 -mpip install torch --extra-index-url https://download.pytorch.org/whl/cpu - - name: Build wheel - run: | - conda run -p buildenv export CC=clang CXX=clang++ - conda run -p buildenv python3 -mpip install wheel - conda run -p buildenv BUILD_VERSION=0.1.1 python3 setup.py bdist_wheel + conda activate buildenv + + # Install PyTorch RC + python3 -mpip install torch --extra-index-url https://download.pytorch.org/whl/cpu + + # Build Wheel + export CC=clang CXX=clang++ + python3 -mpip install wheel + BUILD_VERSION=0.1.1 python3 setup.py bdist_wheel - name: Upload wheel for the test-wheel job uses: actions/upload-artifact@v2 with: From 04a6916492be49a0c2562bb7b44969bc968f4b80 Mon Sep 17 00:00:00 2001 From: Omkar Salpekar Date: Thu, 31 Aug 2023 13:19:00 -0700 Subject: [PATCH 15/15] setup miniconda --- .github/workflows/wheels.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 98fde5836e6..3c0d5796b13 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -92,6 +92,9 @@ jobs: steps: - name: Checkout torchrl uses: actions/checkout@v2 + - uses: conda-incubator/setup-miniconda@v2 + with: + python-version: ${{ matrix.python-version[1] }} - name: Binary Build in Conda Environment run: | set -euxo pipefail