Skip to content

Commit 46989f6

Browse files
authored
Add release scripts and workflow validate-repackaged-size (#6059)
Move release scripts and workflow to validate-repackaged-size of binaries to test Infra
1 parent c9965ce commit 46989f6

14 files changed

+868
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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+
generate-linux-matrix:
22+
uses: ./.github/workflows/generate_binary_build_matrix.yml
23+
with:
24+
package-type: wheel
25+
os: linux
26+
channel: test
27+
with-xpu: disable
28+
with-rocm: disable
29+
30+
validate-binary-size:
31+
needs: generate-linux-matrix
32+
strategy:
33+
matrix: ${{ fromJson(needs.generate-linux-matrix.outputs.matrix) }}
34+
fail-fast: false
35+
uses: ./.github/workflows/linux_job.yml
36+
name: ${{ matrix.build_name }}
37+
with:
38+
runner: ${{ matrix.validation_runner }}
39+
job-name: "Validate binary size"
40+
repository: "pytorch/pytorch"
41+
docker-build-dir: "skip-docker-build"
42+
binary-matrix: ${{ toJSON(matrix) }}
43+
ref: main
44+
script: |
45+
set -ex
46+
47+
# skip testing on cu126
48+
if [[ ${MATRIX_DESIRED_CUDA} == "cu126" ]]; then
49+
exit 0
50+
fi
51+
52+
whl_suffix="linux_x86_64.whl"
53+
pyndt="$(echo $MATRIX_PYTHON_VERSION | tr -d m.u)"
54+
base_url="https://download.pytorch.org/whl/${MATRIX_CHANNEL}/${MATRIX_DESIRED_CUDA}"
55+
whl_url="${base_url}/torch-${MATRIX_STABLE_VERSION}%2B${MATRIX_DESIRED_CUDA}-cp${pyndt}-cp${pyndt}-${whl_suffix}"
56+
57+
export ENV_NAME="conda-env-${{ github.run_id }}"
58+
export ENV_NAME="conda-env-${{ github.run_id }}"
59+
export TARGET_OS="linux"
60+
61+
# install zip
62+
sudo yum install zip -y
63+
64+
# install patchelf
65+
chmod a+x ./.ci/docker/common/install_patchelf.sh
66+
sudo ./.ci/docker/common/install_patchelf.sh
67+
68+
# download torch whl
69+
wget ${whl_url}
70+
FILENAME=$(ls -1 *.whl | head -n 1)
71+
SIZE_BEFORE=$(du -h $FILENAME | cut -f1)
72+
73+
# repackage into manywheel
74+
../../test-infra/release/pypi/prep_binary_for_pypi.sh $FILENAME
75+
76+
NEW_FILENAME=$(ls -1 *.whl | head -n 1)
77+
echo "::notice:: $FILENAME before: $SIZE_BEFORE after: $(du -h $NEW_FILENAME | cut -f1)"
78+
79+
# cp to ${RUNNER_ARTIFACT_DIR}
80+
cp $NEW_FILENAME ${RUNNER_ARTIFACT_DIR}/
81+
82+
# create conda env
83+
conda create -y -n $ENV_NAME python=${MATRIX_PYTHON_VERSION}
84+
conda activate $ENV_NAME
85+
86+
# install torch
87+
pip install numpy pillow $NEW_FILENAME --extra-index-url ${base_url}
88+
89+
pushd ./.ci/pytorch/smoke_test
90+
# run smoke test
91+
python smoke_test.py --package=torchonly --torch-compile-check disabled
92+
popd

release/README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# PyTorch Release Scripts
2+
3+
These are a collection of scripts that are to be used for release activities.
4+
5+
> NOTE: All scripts should do no actual work unless the `DRY_RUN` environment variable is set
6+
> to `disabled`.
7+
> The basic idea being that there should be no potential to do anything dangerous unless
8+
> `DRY_RUN` is explicitly set to `disabled`.
9+
10+
## Requirements to actually run these scripts
11+
* AWS access to pytorch account (META Employees: `bunnylol cloud pytorch`)
12+
* Access to upload conda packages to the [`pytorch`](https://anaconda.org/pytorch) conda channel
13+
* Access to the PyPI repositories (like [torch](https://pypi.org/project/torch))
14+
15+
## Promote pypi to staging
16+
17+
Following steps needed in order to promote pypi to staging:
18+
1. Edit `release_versions.sh` and set correct version
19+
2. Run promote script : `./pypi/promote_pypi_to_staging.sh`
20+
3. Edit and run `../analytics/validate_pypi_staging.py` to perform initial prevalidation of binaries for pypi promotion
21+
4. Manually inspect and spot check binaries staged for pypi promotion by logging into s3 and downloading packages
22+
23+
## Promote
24+
25+
These are scripts related to promotion of release candidates to GA channels, these
26+
can actually be used to promote pytorch, libtorch, and related domain libraries.
27+
28+
> NOTE: Currently the script requires some knowledge on when to comment things out / comment things in
29+
30+
> TODO: Make the script not rely on commenting things out / commenting this in
31+
32+
### Usage
33+
34+
```bash
35+
./promote.sh
36+
```
37+
38+
## Restoring backups
39+
40+
All release candidates from `pytorch/pytorch` are currently backed up
41+
to `s3://pytorch-backup/${TAG_NAME}` and can be restored to the test channels with the
42+
`restore-backup.sh` script.
43+
44+
Which backup to restore from is dictated by the `RESTORE_FROM` environment variable.
45+
46+
### Usage
47+
```bash
48+
RESTORE_FROM=v1.5.0-rc5 ./restore-backup.sh
49+
```

release/promote.sh

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/usr/bin/env bash
2+
3+
set -eou pipefail
4+
5+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
6+
source "${DIR}/release_versions.sh"
7+
8+
# Make sure to update these versions when doing a release first
9+
PYTORCH_VERSION=${PYTORCH_VERSION:-2.3.0}
10+
TORCHVISION_VERSION=${TORCHVISION_VERSION:-0.18.0}
11+
TORCHAUDIO_VERSION=${TORCHAUDIO_VERSION:-2.3.0}
12+
TORCHTEXT_VERSION=${TORCHTEXT_VERSION:-0.18.0}
13+
TORCHREC_VERSION=${TORCHREC_VERSION:-0.8.0}
14+
TENSORRT_VERSION=${TENSORRT_VERSION:-2.2.0}
15+
FBGEMMGPU_VERSION=${FBGEMMGPU_VERSION:-1.0.0}
16+
17+
DRY_RUN=${DRY_RUN:-enabled}
18+
19+
promote_s3() {
20+
local package_name
21+
package_name=$1
22+
local package_type
23+
package_type=$2
24+
local promote_version
25+
promote_version=$3
26+
27+
echo "=-=-=-= Promoting ${package_name}'s v${promote_version} ${package_type} packages' =-=-=-="
28+
(
29+
set -x
30+
TEST_PYTORCH_PROMOTE_VERSION="${promote_version}" \
31+
PACKAGE_NAME="${package_name}" \
32+
PACKAGE_TYPE="${package_type}" \
33+
TEST_WITHOUT_GIT_TAG=1 \
34+
DRY_RUN="${DRY_RUN}" ${DIR}/promote/s3_to_s3.sh
35+
)
36+
echo
37+
}
38+
39+
promote_conda() {
40+
local package_name
41+
package_name=$1
42+
local package_type
43+
package_type=$2
44+
local promote_version
45+
promote_version=$3
46+
echo "=-=-=-= Promoting ${package_name}'s v${promote_version} ${package_type} packages' =-=-=-="
47+
(
48+
ANACONDA="echo + anaconda"
49+
if [[ "${DRY_RUN:-enabled}" = "disabled" ]]; then
50+
ANACONDA="anaconda"
51+
set -x
52+
else
53+
echo "DRY_RUN enabled not actually doing work"
54+
fi
55+
${ANACONDA} copy --to-owner ${PYTORCH_CONDA_TO:-pytorch} ${PYTORCH_CONDA_FROM:-pytorch-test}/${package_name}/${promote_version}
56+
)
57+
echo
58+
}
59+
60+
promote_pypi() {
61+
local package_name
62+
package_name=$1
63+
local promote_version
64+
promote_version=$2
65+
echo "=-=-=-= Promoting ${package_name}'s v${promote_version} to pypi' =-=-=-="
66+
(
67+
set -x
68+
TEST_PYTORCH_PROMOTE_VERSION="${promote_version}" \
69+
PACKAGE_NAME="${package_name}" \
70+
TEST_WITHOUT_GIT_TAG=1 \
71+
DRY_RUN="${DRY_RUN}" ${DIR}/promote/wheel_to_pypi.sh
72+
)
73+
echo
74+
}
75+
76+
# Promote s3 dependencies
77+
# promote_s3 "certifi" whl "2022.12.7"
78+
# promote_s3 "charset_normalizer" whl "2.1.1"
79+
# promote_s3 "cmake" whl "3.25"
80+
# promote_s3 "colorama" whl "0.4.6"
81+
# promote_s3 "triton" whl "2.0.0"
82+
# promote_s3 "pytorch_triton_rocm" whl "2.0.1"
83+
# promote_s3 "tqdm" whl "4.64.1"
84+
# promote_s3 "Pillow" whl "9.3.0"
85+
# for python 3.8-3.11
86+
# promote_s3 "numpy" whl "1.24.1"
87+
# for python 3.7 older pytorch versions
88+
# promote_s3 "numpy" whl "1.21.6"
89+
# promote_s3 "urllib3" whl "1.26.13"
90+
# promote_s3 "lit" whl "15.0.7"
91+
# promote_s3 "sympy" whl "1.11.1"
92+
# promote_s3 "typing_extensions" whl "4.4.0"
93+
# promote_s3 "filelock" whl "3.9.0"
94+
# promote_s3 "mpmath" whl "1.2.1"
95+
# promote_s3 "MarkupSafe" whl "2.1.2"
96+
# promote_s3 "Jinja2" whl "3.1.2"
97+
# promote_s3 "idna" whl "3.4"
98+
# promote_s3 "networkx" whl "3.0"
99+
# promote_s3 "packaging" whl "22.0"
100+
# promote_s3 "requests" whl "2.28.1"
101+
102+
# promote_s3 torch whl "${PYTORCH_VERSION}"
103+
# promote_s3 torchvision whl "${TORCHVISION_VERSION}"
104+
# promote_s3 torchaudio whl "${TORCHAUDIO_VERSION}"
105+
# promote_s3 torchtext whl "${TORCHTEXT_VERSION}"
106+
# promote_s3 torchrec whl "${TORCHREC_VERSION}"
107+
# promote_s3 fbgemm-gpu whl "${FBGEMMGPU_VERSION}"
108+
# promote_s3 "libtorch-*" libtorch "${PYTORCH_VERSION}"
109+
# promote_s3 "torch_tensorrt" whl "${TENSORRT_VERSION}"
110+
111+
# promote_conda torchtriton conda "2.1.0"
112+
# promote_conda pytorch-cuda conda "11.8"
113+
# promote_conda pytorch-cuda conda "12.1"
114+
115+
# promote_conda pytorch conda "${PYTORCH_VERSION}"
116+
# promote_conda torchvision conda "${TORCHVISION_VERSION}"
117+
# promote_conda torchaudio conda "${TORCHAUDIO_VERSION}"
118+
# promote_conda torchtext conda "${TORCHTEXT_VERSION}"
119+
120+
# Uncomment these to promote to pypi
121+
LINUX_VERSION_SUFFIX="%2Bcu102"
122+
WIN_VERSION_SUFFIX="%2Bcpu"
123+
# PLATFORM="linux_x86_64" VERSION_SUFFIX="${LINUX_VERSION_SUFFIX}" promote_pypi torch "${PYTORCH_VERSION}"
124+
# PLATFORM="manylinux2014_aarch64" VERSION_SUFFIX="" promote_pypi torch "${PYTORCH_VERSION}"
125+
# PLATFORM="win_amd64" VERSION_SUFFIX="${WIN_VERSION_SUFFIX}" promote_pypi torch "${PYTORCH_VERSION}"
126+
# PLATFORM="macosx_11_0" VERSION_SUFFIX="" promote_pypi torch "${PYTORCH_VERSION}" # m1 mac
127+
128+
# PLATFORM="linux_x86_64" VERSION_SUFFIX="${LINUX_VERSION_SUFFIX}" promote_pypi torchvision "${TORCHVISION_VERSION}"
129+
# PLATFORM="manylinux2014_aarch64" VERSION_SUFFIX="" promote_pypi torchvision "${TORCHVISION_VERSION}"
130+
# PLATFORM="win_amd64" VERSION_SUFFIX="${WIN_VERSION_SUFFIX}" promote_pypi torchvision "${TORCHVISION_VERSION}"
131+
# PLATFORM="macosx_11_0" VERSION_SUFFIX="" promote_pypi torchvision "${TORCHVISION_VERSION}"
132+
133+
# PLATFORM="linux_x86_64" VERSION_SUFFIX="${LINUX_VERSION_SUFFIX}" promote_pypi torchaudio "${TORCHAUDIO_VERSION}"
134+
# PLATFORM="manylinux2014_aarch64" VERSION_SUFFIX="" promote_pypi torchaudio "${TORCHAUDIO_VERSION}"
135+
# PLATFORM="win_amd64" VERSION_SUFFIX="${WIN_VERSION_SUFFIX}" promote_pypi torchaudio "${TORCHAUDIO_VERSION}"
136+
# PLATFORM="macosx_11_0" VERSION_SUFFIX="" promote_pypi torchaudio "${TORCHAUDIO_VERSION}"

release/promote/common_utils.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
3+
exit_if_not_on_git_tag() {
4+
# Have an override for debugging purposes
5+
if [[ -n "${TEST_WITHOUT_GIT_TAG-}" ]] ;then
6+
>&2 echo "+ WARN: Continuing without being on a git tag"
7+
exit 0
8+
fi
9+
# Exit if we're not currently on a git tag
10+
if ! git describe --tags --exact >/dev/null 2>/dev/null; then
11+
>&2 echo "- ERROR: Attempting to promote on a non-git tag, must have tagged current commit locally first"
12+
exit 1
13+
fi
14+
# Exit if we're currently on an RC
15+
if git describe --tags | grep "-rc" >/dev/null 2>/dev/null; then
16+
>&2 echo "- ERROR: Attempting to promote on a non GA git tag, current tag must be a GA tag"
17+
>&2 echo " Example: v1.5.0"
18+
exit 1
19+
fi
20+
}
21+
22+
get_pytorch_version() {
23+
if [[ -n "${TEST_WITHOUT_GIT_TAG-}" ]];then
24+
if [[ -z "${TEST_PYTORCH_PROMOTE_VERSION-}" ]]; then
25+
>&2 echo "- ERROR: Specified TEST_WITHOUT_GIT_TAG without specifying TEST_PYTORCH_PROMOTE_VERSION"
26+
>&2 echo "- TEST_PYTORCH_PROMOTE_VERSION must be specified"
27+
exit 1
28+
else
29+
echo "${TEST_PYTORCH_PROMOTE_VERSION}"
30+
exit 0
31+
fi
32+
fi
33+
exit_if_not_on_git_tag
34+
# Echo git tag, strip leading v
35+
git describe --tags | sed -e 's/^v//'
36+
}
37+
38+
aws_promote() {
39+
package_name=$1
40+
pytorch_version=$(get_pytorch_version)
41+
# Dry run by default
42+
DRY_RUN=${DRY_RUN:-enabled}
43+
DRY_RUN_FLAG="--dryrun"
44+
if [[ $DRY_RUN = "disabled" ]]; then
45+
DRY_RUN_FLAG=""
46+
fi
47+
AWS=${AWS:-aws}
48+
(
49+
set -x
50+
${AWS} s3 cp ${DRY_RUN_FLAG} \
51+
--only-show-errors \
52+
--acl public-read \
53+
--recursive \
54+
--exclude '*' \
55+
--include "*${package_name}-${pytorch_version}*" \
56+
"${PYTORCH_S3_FROM/\/$//}" \
57+
"${PYTORCH_S3_TO/\/$//}"
58+
)
59+
# ^ We grep for package_name-.*pytorch_version to avoid any situations where domain libraries have
60+
# the same version on our S3 buckets
61+
}

0 commit comments

Comments
 (0)