Skip to content

Commit cc8d20c

Browse files
authored
PyPi binary validation and size check (#1230)
* Validate binary size * Validate binary size linux_job * evaluate the fix from #1231 * Add an optional artifact upload, consolidate fixes to `prep_binary_for_pypi.sh`
1 parent f52bc92 commit cc8d20c

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Validate manywheel binaries
2+
3+
# This workflow validates the size of the manywheel binaries after repackaging for PyPi
4+
# Specify the direct URLs to the binaries (from https://download.pytorch.org/whl/test/torch/) in the matrix
5+
# along with the python version.
6+
#
7+
# The workflow will:
8+
# * download the binaries,
9+
# * run release/pypi/prep_binary_for_pypi.sh
10+
# * run smoke tests on the repackaged binaries
11+
# * display the size before and after repackaging as the workflow annotation
12+
# * optionally upload the repackaged binaries as artifacts (for debug or promotion)
13+
14+
on:
15+
pull_request:
16+
paths:
17+
- .github/workflows/validate-repackaged-binary-sizes.yml
18+
- release/pypi/prep_binary_for_pypi.sh
19+
20+
jobs:
21+
validate-binary-size:
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
whl:
26+
- url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp310-cp310-linux_x86_64.whl
27+
python: "3.10" # python version to use for smoke tests
28+
upload_artifact: false # upload the repackaged binary as an artifact
29+
- url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp37-cp37m-linux_x86_64.whl
30+
python: "3.7"
31+
artifact: false
32+
- url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp38-cp38-linux_x86_64.whl
33+
python: "3.8"
34+
artifact: false
35+
- url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp39-cp39-linux_x86_64.whl
36+
python: "3.9"
37+
artifact: false
38+
# - url: https://download.pytorch.org/whl/test/cu117_pypi_cudnn/torch-1.13.1%2Bcu117.with.pypi.cudnn-cp311-cp311-linux_x86_64.whl
39+
# python: "3.11"
40+
# artifact: false
41+
42+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
43+
with:
44+
runner: linux.4xlarge.nvidia.gpu
45+
job-name: "Validate binary size"
46+
upload-artifact: ${{ matrix.whl.upload_artifact == 'true' && 'repackaged-binary' || '' }}
47+
script: |
48+
set -ex
49+
export ENV_NAME="conda-env-${{ github.run_id }}"
50+
export GPU_ARCH_VER="11.7"
51+
export GPU_ARCH_TYPE="cuda"
52+
export CUDA_VER="11.7"
53+
export DESIRED_PYTHON="${{ matrix.whl.python }}"
54+
export DESIRED_CUDA="cu117"
55+
export PACKAGE_TYPE="wheel"
56+
export TARGET_OS="linux"
57+
export INSTALLATION=""
58+
59+
# install zip
60+
sudo yum install zip -y
61+
62+
# install patchelf
63+
chmod a+x common/install_patchelf.sh
64+
sudo common/install_patchelf.sh
65+
66+
# download torch whl
67+
wget ${{ matrix.whl.url }}
68+
FILENAME=$(ls -1 *.whl | head -n 1)
69+
SIZE_BEFORE=$(du -h $FILENAME | cut -f1)
70+
71+
# repackage into manywheel
72+
release/pypi/prep_binary_for_pypi.sh $FILENAME
73+
74+
NEW_FILENAME=$(ls -1 *.whl | head -n 1)
75+
echo "::notice:: $FILENAME before: $SIZE_BEFORE after: $(du -h $NEW_FILENAME | cut -f1)"
76+
77+
# cp to ${RUNNER_ARTIFACT_DIR}
78+
cp $NEW_FILENAME ${RUNNER_ARTIFACT_DIR}/
79+
80+
# create conda env
81+
conda create -y -n $ENV_NAME python=$DESIRED_PYTHON
82+
conda activate $ENV_NAME
83+
84+
# install torch
85+
pip install numpy pillow $NEW_FILENAME
86+
87+
# run smoke test
88+
python ./test/smoke_test/smoke_test.py --package=torchonly

release/pypi/prep_binary_for_pypi.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ for whl_file in "$@"; do
9595
fi
9696
)
9797

98+
rm -rf "${new_whl_file}"
9899
zip -qr9 "${new_whl_file}" .
99100
)
100101
done

0 commit comments

Comments
 (0)