Skip to content

Commit 550a01b

Browse files
authored
Move Validation Framework workflows to test-infra (#6029)
Moves all the worklfows from builder Validation framework except: https://github.com/pytorch/builder/blob/main/.github/workflows/validate-repackaged-binary-sizes.yml Part of pytorch/builder#2054 It needs to be rewritten, followup PR required.
1 parent 1f8c6cc commit 550a01b

16 files changed

+1167
-1
lines changed

.github/scripts/validate_binaries.sh

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
2+
3+
if [[ ${MATRIX_PACKAGE_TYPE} == "libtorch" ]]; then
4+
curl ${MATRIX_INSTALLATION} -o libtorch.zip
5+
unzip libtorch.zip
6+
else
7+
8+
export PYTHON_RUN="python3"
9+
if [[ ${TARGET_OS} == 'windows' ]]; then
10+
export PYTHON_RUN="python"
11+
# Currently xpu env need a helper script to activate
12+
if [[ ${MATRIX_GPU_ARCH_TYPE} == "xpu" ]]; then
13+
export PYTHON_RUN="${SCRIPT_DIR}/xpu_env_helper.bat python"
14+
fi
15+
fi
16+
17+
if [[ ${TARGET_OS} == 'macos-arm64' ]]; then
18+
conda update -y -n base -c defaults conda
19+
elif [[ ${TARGET_OS} != 'linux-aarch64' ]]; then
20+
# Conda pinned see issue: https://github.com/ContinuumIO/anaconda-issues/issues/13350
21+
conda install -y conda=23.11.0
22+
fi
23+
# Please note ffmpeg is required for torchaudio, see https://github.com/pytorch/pytorch/issues/96159
24+
conda create -y -n ${ENV_NAME} python=${MATRIX_PYTHON_VERSION} numpy ffmpeg
25+
conda activate ${ENV_NAME}
26+
27+
# Remove when https://github.com/pytorch/builder/issues/1985 is fixed
28+
if [[ ${MATRIX_GPU_ARCH_TYPE} == 'cuda-aarch64' ]]; then
29+
pip3 install numpy --force-reinstall
30+
fi
31+
32+
INSTALLATION=${MATRIX_INSTALLATION/"conda install"/"conda install -y"}
33+
TEST_SUFFIX=""
34+
35+
# force-reinstall: latest version of packages are reinstalled
36+
if [[ ${USE_FORCE_REINSTALL} == 'true' ]]; then
37+
INSTALLATION=${INSTALLATION/"pip3 install"/"pip3 install --force-reinstall"}
38+
fi
39+
# extra-index-url: extra dependencies are downloaded from pypi
40+
if [[ ${USE_EXTRA_INDEX_URL} == 'true' ]]; then
41+
INSTALLATION=${INSTALLATION/"--index-url"/"--extra-index-url"}
42+
fi
43+
44+
# use-meta-cdn: use meta cdn for pypi download
45+
if [[ ${USE_META_CDN} == 'true' ]]; then
46+
INSTALLATION=${INSTALLATION/"download.pytorch.org"/"d3kup0pazkvub8.cloudfront.net"}
47+
fi
48+
49+
50+
if [[ ${TORCH_ONLY} == 'true' ]]; then
51+
INSTALLATION=${INSTALLATION/"torchvision torchaudio"/""}
52+
TEST_SUFFIX=" --package torchonly"
53+
fi
54+
55+
# if RELESE version is passed as parameter - install speific version
56+
if [[ ! -z ${RELEASE_VERSION} ]]; then
57+
INSTALLATION=${INSTALLATION/"torch "/"torch==${RELEASE_VERSION} "}
58+
INSTALLATION=${INSTALLATION/"-y pytorch "/"-y pytorch==${RELEASE_VERSION} "}
59+
INSTALLATION=${INSTALLATION/"::pytorch "/"::pytorch==${RELEASE_VERSION} "}
60+
61+
if [[ ${USE_VERSION_SET} == 'true' ]]; then
62+
INSTALLATION=${INSTALLATION/"torchvision "/"torchvision==${VISION_RELEASE_VERSION} "}
63+
INSTALLATION=${INSTALLATION/"torchaudio "/"torchaudio==${AUDIO_RELEASE_VERSION} "}
64+
fi
65+
fi
66+
67+
export OLD_PATH=${PATH}
68+
# Workaround macos-arm64 runners. Issue: https://github.com/pytorch/test-infra/issues/4342
69+
if [[ ${TARGET_OS} == 'macos-arm64' ]]; then
70+
export PATH="${CONDA_PREFIX}/bin:${PATH}"
71+
fi
72+
73+
# Make sure we remove previous installation if it exists
74+
if [[ ${MATRIX_PACKAGE_TYPE} == 'wheel' ]]; then
75+
pip3 uninstall -y torch torchaudio torchvision
76+
fi
77+
eval $INSTALLATION
78+
79+
pushd ${PWD}/.ci/pytorch/
80+
81+
if [[ ${MATRIX_GPU_ARCH_VERSION} == "12.6" ]]; then
82+
export DESIRED_DEVTOOLSET="cxx11-abi"
83+
fi
84+
85+
if [[ ${TARGET_OS} == 'linux' ]]; then
86+
export CONDA_LIBRARY_PATH="$(dirname $(which python))/../lib"
87+
export LD_LIBRARY_PATH=$CONDA_LIBRARY_PATH:$LD_LIBRARY_PATH
88+
source ./check_binary.sh
89+
fi
90+
91+
# We are only interested in CUDA tests and Python 3.9-3.11. Not all requirement libraries are available for 3.12 yet.
92+
if [[ ${INCLUDE_TEST_OPS:-} == 'true' && ${MATRIX_GPU_ARCH_TYPE} == 'cuda' && ${MATRIX_PYTHON_VERSION} != "3.13" ]]; then
93+
source ${SCRIPT_DIR}/validate_test_ops.sh
94+
fi
95+
96+
# Regular smoke test
97+
${PYTHON_RUN} ./smoke_test/smoke_test.py ${TEST_SUFFIX}
98+
# For pip install also test with numpy 2.0.0 for python 3.8 or above
99+
if [[ ${MATRIX_PACKAGE_TYPE} == 'wheel' ]]; then
100+
pip3 install numpy==2.0.0 --force-reinstall
101+
${PYTHON_RUN} ./smoke_test/smoke_test.py ${TEST_SUFFIX}
102+
fi
103+
104+
105+
if [[ ${TARGET_OS} == 'macos-arm64' ]]; then
106+
export PATH=${OLD_PATH}
107+
fi
108+
109+
# Use case CUDA_VISIBLE_DEVICES: https://github.com/pytorch/pytorch/issues/128819
110+
if [[ ${MATRIX_GPU_ARCH_TYPE} == 'cuda' ]]; then
111+
python -c "import torch;import os;print(torch.cuda.device_count(), torch.__version__);os.environ['CUDA_VISIBLE_DEVICES']='0';print(torch.empty(2, device='cuda'))"
112+
fi
113+
114+
# this is optional step
115+
if [[ ${TARGET_OS} != linux* ]]; then
116+
conda deactivate
117+
conda env remove -n ${ENV_NAME}
118+
fi
119+
popd
120+
121+
fi

.github/scripts/validate_pipy.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
conda create -yn ${ENV_NAME}_pypi python=${MATRIX_PYTHON_VERSION} numpy ffmpeg
2+
conda activate ${ENV_NAME}_pypi
3+
4+
TEST_SUFFIX=""
5+
RELEASE_SUFFIX=""
6+
# if RELESE version is passed as parameter - install speific version
7+
if [[ ! -z ${RELEASE_VERSION} ]]; then
8+
RELEASE_SUFFIX="==${RELEASE_VERSION}"
9+
fi
10+
11+
if [[ ${TORCH_ONLY} == 'true' ]]; then
12+
TEST_SUFFIX=" --package torchonly"
13+
pip3 install torch${RELEASE_SUFFIX}
14+
else
15+
pip3 install torch${RELEASE_SUFFIX} torchvision torchaudio
16+
fi
17+
18+
python ./test/smoke_test/smoke_test.py ${TEST_SUFFIX} --runtime-error-check disabled
19+
conda deactivate
20+
conda env remove -p ${ENV_NAME}_pypi

.github/scripts/validate_poetry.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
conda create -y -n ${ENV_NAME}_poetry python=${MATRIX_PYTHON_VERSION} numpy ffmpeg
3+
conda activate ${ENV_NAME}_poetry
4+
curl -sSL https://install.python-poetry.org | python3 - --git https://github.com/python-poetry/poetry.git@master
5+
export PATH="/root/.local/bin:$PATH"
6+
7+
poetry --version
8+
poetry new test_poetry
9+
cd test_poetry
10+
11+
TEST_SUFFIX=""
12+
if [[ ${TORCH_ONLY} == 'true' ]]; then
13+
TEST_SUFFIX=" --package torchonly"
14+
fi
15+
16+
RELEASE_SUFFIX=""
17+
# if RELESE version is passed as parameter - install speific version
18+
if [[ ! -z ${RELEASE_VERSION} ]]; then
19+
RELEASE_SUFFIX="@${RELEASE_VERSION}"
20+
fi
21+
22+
if [[ ${TORCH_ONLY} == 'true' ]]; then
23+
poetry --quiet add torch${RELEASE_SUFFIX}
24+
else
25+
poetry --quiet add torch${RELEASE_SUFFIX} torchaudio torchvision
26+
fi
27+
28+
python ../test/smoke_test/smoke_test.py ${TEST_SUFFIX} --runtime-error-check disabled
29+
conda deactivate
30+
conda env remove -p ${ENV_NAME}_poetry
31+
cd ..

.github/scripts/validate_test_ops.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
set -eux -o pipefail
4+
5+
retry () {
6+
$* || (sleep 1 && $*) || (sleep 2 && $*) || (sleep 4 && $*) || (sleep 8 && $*)
7+
}
8+
9+
BRANCH=""
10+
if [[ ${MATRIX_CHANNEL} == "test" || ${MATRIX_CHANNEL} == "release" ]]; then
11+
SHORT_VERSION=${MATRIX_STABLE_VERSION%.*}
12+
BRANCH="--branch release/${SHORT_VERSION}"
13+
fi
14+
15+
16+
# Clone the Pytorch branch
17+
retry git clone ${BRANCH} --depth 1 https://github.com/pytorch/pytorch.git
18+
retry git submodule update --init --recursive
19+
pushd pytorch
20+
21+
pip install expecttest numpy pyyaml jinja2 packaging hypothesis unittest-xml-reporting scipy
22+
23+
# Run pytorch cuda wheels validation
24+
# Detect ReduceLogicKernel (ReduceOp and kernel) IMA
25+
python test/test_ops.py -k test_dtypes_all_cuda
26+
# Detect BinaryMulKernel (elementwise binary functor internal mul) IMA
27+
python test/test_torch.py -k test_index_reduce_reduce_prod_cuda_int32
28+
# Detect BinaryBitwiseOpsKernels (at::native::BitwiseAndFunctor) IMA
29+
python test/test_binary_ufuncs.py -k test_contig_vs_every_other___rand___cuda_int32
30+
# Detect MaxMinElementwiseKernel (maximum) IMA
31+
python test/test_schema_check.py -k test_schema_correctness_clamp_cuda_int8
32+
33+
pushd /tmp
34+
# Detect StepKernel (nextafter) IMA
35+
python -c "import torch; print(torch.nextafter(torch.tensor([-4.5149, -5.9053, -0.9516, -2.3615, 1.5591], device='cuda:0'), torch.tensor(3.8075, device='cuda:0')))"
36+
# Detect BinaryGeometricKernels (atan2) IMA
37+
python -c "import torch; x = (torch.randn((2,1,1), dtype=torch.float, device='cuda')*5).to(torch.float32); y=(torch.randn((), dtype=torch.float, device='cuda')*5).to(torch.float32); print(torch.atan2(x,y))"
38+
popd

.github/scripts/xpu_env_helper.bat

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
call "C:\Program Files (x86)\Intel\oneAPI\setvars.bat"
2+
3+
set args=%1
4+
shift
5+
:start
6+
if [%1] == [] goto done
7+
set args=%args% %1
8+
shift
9+
goto start
10+
11+
:done
12+
if "%args%" == "" (
13+
echo Usage: xpu_env_helper.bat [command] [args]
14+
echo e.g. xpu_env_helper.bat icpx --version
15+
)
16+
17+
%args% || exit /b 1

.github/workflows/generate_binary_build_matrix.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ on:
4242
use-only-dl-pytorch-org:
4343
description: "Use only download.pytorch.org when generating wheel install command?"
4444
default: "false"
45+
required: false
4546
type: string
4647
build-python-only:
4748
description: "Generate binary build matrix for a python only package (i.e. only one python version)"

.github/workflows/generate_docker_release_matrix.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ on:
1515
description: "Test infra reference to use"
1616
default: "main"
1717
type: string
18-
generate_dockerhub_images:
18+
generate_dockerhub_images:
1919
description: "Whether to generate Docker Hub images"
2020
default: "false"
21+
required: false
2122
type: string
2223
outputs:
2324
matrix:

0 commit comments

Comments
 (0)