From 2aaac3a21d1c4192096ff83d8bbf1791518d34cc Mon Sep 17 00:00:00 2001 From: Ivan Zaitsev Date: Tue, 13 Dec 2022 15:02:51 -0800 Subject: [PATCH 1/4] Validate binary size --- .../validate-repackaged-binary-sizes.yml | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 .github/workflows/validate-repackaged-binary-sizes.yml diff --git a/.github/workflows/validate-repackaged-binary-sizes.yml b/.github/workflows/validate-repackaged-binary-sizes.yml new file mode 100644 index 000000000..722669df8 --- /dev/null +++ b/.github/workflows/validate-repackaged-binary-sizes.yml @@ -0,0 +1,65 @@ +name: Validate manywheel binaries + +on: + pull_request: + +jobs: + validate-binary-size: + runs-on: linux.4xlarge.nvidia.gpu + strategy: + fail-fast: false + matrix: + whl: + - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp310-cp310-linux_x86_64.whl + python: 3.10 +# - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp311-cp311-linux_x86_64.whl +# python: 3.11 +# - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp37-cp37m-linux_x86_64.whl +# python: 3.7 +# - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp38-cp38-linux_x86_64.whl +# python: 3.8 +# - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp39-cp39-linux_x86_64.whl +# python: 3.9 + + env: + GPU_ARCH_TYPE: cuda + GPU_ARCH_VERSION: "11.7" + + steps: + - name: Checkout PyTorch builder + uses: actions/checkout@v3 + + - name: Install patchelf + run: | + chmod a+x common/install_patchelf.sh + sudo common/install_patchelf.sh + + - name: Download torch whl + run: | + wget ${{ matrix.whl.url }} + FILENAME=$(ls -1 *.whl | head -n 1) + echo "::notice::Before repackaging: $(du -h $FILENAME | cut -f1)" + echo "FILENAME=$FILENAME" >> $GITHUB_ENV + + - name: Repackage into manywheel + continue-on-error: true + run: | + release/pypi/prep_binary_for_pypi.sh $FILENAME + NEW_FILENAME=$(ls -1 *.whl | head -n 1) + echo "::notice::After repackaging: $(du -h $NEW_FILENAME | cut -f1)" + echo "NEW_FILENAME=$NEW_FILENAME" >> $GITHUB_ENV + + - name: Run smoke test + continue-on-error: true + run: | + set -ex + # run smoke test to make sure the binary is not broken + conda create -n smoke-test python=${{ matrix.whl.python }} -y + conda activate smoke-test + pip install $NEW_FILENAME + python ./test/smoke_test/smoke_test.py -- --package=torchonly + + - name: Hold runner for 60 minutes or until ssh sessions have drained + timeout-minutes: 60 + run: | + sleep infinity \ No newline at end of file From 2d8c841ea1d1cdf35b5957f73b17d0fe05b00275 Mon Sep 17 00:00:00 2001 From: Ivan Zaitsev Date: Tue, 13 Dec 2022 17:29:22 -0800 Subject: [PATCH 2/4] Validate binary size linux_job --- .../validate-repackaged-binary-sizes.yml | 114 ++++++++++-------- 1 file changed, 63 insertions(+), 51 deletions(-) diff --git a/.github/workflows/validate-repackaged-binary-sizes.yml b/.github/workflows/validate-repackaged-binary-sizes.yml index 722669df8..29d1bdc53 100644 --- a/.github/workflows/validate-repackaged-binary-sizes.yml +++ b/.github/workflows/validate-repackaged-binary-sizes.yml @@ -1,65 +1,77 @@ name: Validate manywheel binaries +# This workflow validates the size of the manywheel binaries after repackaging for PyPi +# Specify the direct URLs to the binaries (from https://download.pytorch.org/whl/test/torch/) in the matrix +# along with the python version. +# +# The workflow will: +# * download the binaries, +# * run release/pypi/prep_binary_for_pypi.sh +# * run smoke tests on the repackaged binaries +# * display the size before and after repackaging + on: pull_request: jobs: validate-binary-size: - runs-on: linux.4xlarge.nvidia.gpu strategy: fail-fast: false matrix: whl: - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp310-cp310-linux_x86_64.whl - python: 3.10 + python: "3.10" # - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp311-cp311-linux_x86_64.whl -# python: 3.11 -# - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp37-cp37m-linux_x86_64.whl -# python: 3.7 -# - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp38-cp38-linux_x86_64.whl -# python: 3.8 -# - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp39-cp39-linux_x86_64.whl -# python: 3.9 - - env: - GPU_ARCH_TYPE: cuda - GPU_ARCH_VERSION: "11.7" - - steps: - - name: Checkout PyTorch builder - uses: actions/checkout@v3 - - - name: Install patchelf - run: | - chmod a+x common/install_patchelf.sh - sudo common/install_patchelf.sh - - - name: Download torch whl - run: | - wget ${{ matrix.whl.url }} - FILENAME=$(ls -1 *.whl | head -n 1) - echo "::notice::Before repackaging: $(du -h $FILENAME | cut -f1)" - echo "FILENAME=$FILENAME" >> $GITHUB_ENV - - - name: Repackage into manywheel - continue-on-error: true - run: | - release/pypi/prep_binary_for_pypi.sh $FILENAME - NEW_FILENAME=$(ls -1 *.whl | head -n 1) - echo "::notice::After repackaging: $(du -h $NEW_FILENAME | cut -f1)" - echo "NEW_FILENAME=$NEW_FILENAME" >> $GITHUB_ENV - - - name: Run smoke test - continue-on-error: true - run: | - set -ex - # run smoke test to make sure the binary is not broken - conda create -n smoke-test python=${{ matrix.whl.python }} -y - conda activate smoke-test - pip install $NEW_FILENAME - python ./test/smoke_test/smoke_test.py -- --package=torchonly +# python: "3.11" + - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp37-cp37m-linux_x86_64.whl + python: "3.7" + - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp38-cp38-linux_x86_64.whl + python: "3.8" + - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp39-cp39-linux_x86_64.whl + python: "3.9" - - name: Hold runner for 60 minutes or until ssh sessions have drained - timeout-minutes: 60 - run: | - sleep infinity \ No newline at end of file + uses: pytorch/test-infra/.github/workflows/linux_job.yml@main + with: + runner: linux.4xlarge.nvidia.gpu + repository: "pytorch/builder" + ref: ${{ github.ref }} + job-name: "Validate binary size" + script: | + set -ex + export ENV_NAME="conda-env-${{ github.run_id }}" + export GPU_ARCH_VER="11.7" + export GPU_ARCH_TYPE="cuda" + export CUDA_VER="11.7" + export DESIRED_PYTHON="${{ matrix.whl.python }}" + export DESIRED_CUDA="cu117" + export PACKAGE_TYPE="wheel" + export TARGET_OS="linux" + export INSTALLATION="" + + # install zip + sudo yum install zip -y + + # install patchelf + chmod a+x common/install_patchelf.sh + sudo common/install_patchelf.sh + + # download torch whl + wget ${{ matrix.whl.url }} + FILENAME=$(ls -1 *.whl | head -n 1) + SIZE_BEFORE=$(du -h $FILENAME | cut -f1) + + # repackage into manywheel + release/pypi/prep_binary_for_pypi.sh $FILENAME + + NEW_FILENAME=$(ls -1 *.whl | head -n 1) + echo "::notice:: $FILENAME before: $SIZE_BEFORE after: $(du -h $NEW_FILENAME | cut -f1)" + + # create conda env + conda create -y -n $ENV_NAME python=$DESIRED_PYTHON + conda activate $ENV_NAME + + # install torch + pip install numpy pillow $NEW_FILENAME + + # run smoke test + python ./test/smoke_test/smoke_test.py --package=torchonly \ No newline at end of file From 64281f4a7cf8c3190b4c318c63ba2805fcfa5fcb Mon Sep 17 00:00:00 2001 From: Ivan Zaitsev Date: Wed, 14 Dec 2022 09:20:41 -0800 Subject: [PATCH 3/4] evaluate the fix from #1231 --- .github/workflows/validate-repackaged-binary-sizes.yml | 10 ++++++---- release/pypi/prep_binary_for_pypi.sh | 9 +++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/validate-repackaged-binary-sizes.yml b/.github/workflows/validate-repackaged-binary-sizes.yml index 29d1bdc53..a87dd3487 100644 --- a/.github/workflows/validate-repackaged-binary-sizes.yml +++ b/.github/workflows/validate-repackaged-binary-sizes.yml @@ -21,21 +21,20 @@ jobs: whl: - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp310-cp310-linux_x86_64.whl python: "3.10" -# - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp311-cp311-linux_x86_64.whl -# python: "3.11" - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp37-cp37m-linux_x86_64.whl python: "3.7" - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp38-cp38-linux_x86_64.whl python: "3.8" - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp39-cp39-linux_x86_64.whl python: "3.9" + # - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp311-cp311-linux_x86_64.whl + # python: "3.11" uses: pytorch/test-infra/.github/workflows/linux_job.yml@main with: runner: linux.4xlarge.nvidia.gpu - repository: "pytorch/builder" - ref: ${{ github.ref }} job-name: "Validate binary size" + upload-artifact: pipy_wheel script: | set -ex export ENV_NAME="conda-env-${{ github.run_id }}" @@ -66,6 +65,9 @@ jobs: NEW_FILENAME=$(ls -1 *.whl | head -n 1) echo "::notice:: $FILENAME before: $SIZE_BEFORE after: $(du -h $NEW_FILENAME | cut -f1)" + # cp to ${RUNNER_ARTIFACT_DIR} + cp $NEW_FILENAME ${RUNNER_ARTIFACT_DIR}/ + # create conda env conda create -y -n $ENV_NAME python=$DESIRED_PYTHON conda activate $ENV_NAME diff --git a/release/pypi/prep_binary_for_pypi.sh b/release/pypi/prep_binary_for_pypi.sh index 639d834a6..872d72bec 100755 --- a/release/pypi/prep_binary_for_pypi.sh +++ b/release/pypi/prep_binary_for_pypi.sh @@ -77,7 +77,15 @@ for whl_file in "$@"; do find "${dist_info_folder}" -type f -exec sed -i "s!${version_with_suffix}!${version_no_suffix}!" {} \; # Moves distinfo from one with a version suffix to one without # Example: torch-1.8.0+cpu.dist-info => torch-1.8.0.dist-info + + echo "Before moving dist_info_folder" + ls -l "${whl_dir}" + mv "${dist_info_folder}" "${dirname_dist_info_folder}/${basename_dist_info_folder/${version_with_suffix}/${version_no_suffix}}" + + echo "After moving dist_info_folder" + ls -l "${whl_dir}" + cd "${whl_dir}" ( @@ -95,6 +103,7 @@ for whl_file in "$@"; do fi ) + rm -rf "${new_whl_file}" zip -qr9 "${new_whl_file}" . ) done From d1c413085163c53010d12657cdd4f0b1b6ecc39e Mon Sep 17 00:00:00 2001 From: Ivan Zaitsev Date: Wed, 14 Dec 2022 12:02:38 -0800 Subject: [PATCH 4/4] Add an optional artifact upload, consolidate fixes to `prep_binary_for_pypi.sh` --- .../validate-repackaged-binary-sizes.yml | 19 ++++++++++++++----- release/pypi/prep_binary_for_pypi.sh | 8 -------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/validate-repackaged-binary-sizes.yml b/.github/workflows/validate-repackaged-binary-sizes.yml index a87dd3487..695c68d3a 100644 --- a/.github/workflows/validate-repackaged-binary-sizes.yml +++ b/.github/workflows/validate-repackaged-binary-sizes.yml @@ -8,10 +8,14 @@ name: Validate manywheel binaries # * download the binaries, # * run release/pypi/prep_binary_for_pypi.sh # * run smoke tests on the repackaged binaries -# * display the size before and after repackaging +# * display the size before and after repackaging as the workflow annotation +# * optionally upload the repackaged binaries as artifacts (for debug or promotion) on: pull_request: + paths: + - .github/workflows/validate-repackaged-binary-sizes.yml + - release/pypi/prep_binary_for_pypi.sh jobs: validate-binary-size: @@ -20,21 +24,26 @@ jobs: matrix: whl: - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp310-cp310-linux_x86_64.whl - python: "3.10" + python: "3.10" # python version to use for smoke tests + upload_artifact: false # upload the repackaged binary as an artifact - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp37-cp37m-linux_x86_64.whl python: "3.7" + artifact: false - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp38-cp38-linux_x86_64.whl python: "3.8" + artifact: false - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp39-cp39-linux_x86_64.whl python: "3.9" - # - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp311-cp311-linux_x86_64.whl - # python: "3.11" + artifact: false + # - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp311-cp311-linux_x86_64.whl + # python: "3.11" + # artifact: false uses: pytorch/test-infra/.github/workflows/linux_job.yml@main with: runner: linux.4xlarge.nvidia.gpu job-name: "Validate binary size" - upload-artifact: pipy_wheel + upload-artifact: ${{ matrix.whl.upload_artifact == 'true' && 'repackaged-binary' || '' }} script: | set -ex export ENV_NAME="conda-env-${{ github.run_id }}" diff --git a/release/pypi/prep_binary_for_pypi.sh b/release/pypi/prep_binary_for_pypi.sh index 872d72bec..f1d9edb6d 100755 --- a/release/pypi/prep_binary_for_pypi.sh +++ b/release/pypi/prep_binary_for_pypi.sh @@ -77,15 +77,7 @@ for whl_file in "$@"; do find "${dist_info_folder}" -type f -exec sed -i "s!${version_with_suffix}!${version_no_suffix}!" {} \; # Moves distinfo from one with a version suffix to one without # Example: torch-1.8.0+cpu.dist-info => torch-1.8.0.dist-info - - echo "Before moving dist_info_folder" - ls -l "${whl_dir}" - mv "${dist_info_folder}" "${dirname_dist_info_folder}/${basename_dist_info_folder/${version_with_suffix}/${version_no_suffix}}" - - echo "After moving dist_info_folder" - ls -l "${whl_dir}" - cd "${whl_dir}" (