-
Notifications
You must be signed in to change notification settings - Fork 471
154 lines (146 loc) · 5.44 KB
/
build_linux_wheels.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Custom Build Linux Wheels
on:
pull_request:
push:
branches:
- pkg-for-wheel
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
generate-matrix:
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
with:
package-type: wheel
os: linux
test-infra-repository: pytorch/test-infra
test-infra-ref: main
with-cuda: disable
with-rocm: disable
build:
needs: generate-matrix
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
env:
PYTHON_VERSION: ${{ matrix.python_version }}
PACKAGE_TYPE: wheel
REPOSITORY: pytorch/torchtune
PACKAGE_NAME: torchtune
REF: pkg-for-wheel
CU_VERSION: ${{ matrix.desired_cuda }}
UPLOAD_TO_BASE_BUCKET: ${{ matrix.upload_to_base_bucket }}
ARCH: x86_64
name: ${{ matrix.build_name }}
runs-on: ${{ matrix.validation_runner }}
container:
image: ${{ matrix.container_image }}
options: ${{ matrix.gpu_arch_type == 'cuda' && '--gpus all' || ' ' }}
# If a build is taking longer than 60 minutes on these runners we need
# to have a conversation
timeout-minutes: 120
steps:
- name: Clean workspace
shell: bash -l {0}
run: |
set -euxo pipefail
echo "::group::Cleanup debug output"
rm -rf "${GITHUB_WORKSPACE}"
mkdir -p "${GITHUB_WORKSPACE}"
if [[ "${{ env.ARCH }}" = "aarch64" ]]; then
rm -rf "${RUNNER_TEMP}/*"
fi
echo "::endgroup::"
- uses: actions/checkout@v3
with:
# Support the use case where we need to checkout someone's fork
repository: pytorch/test-infra
ref: main
path: test-infra
- uses: pytorch/test-infra/.github/actions/set-channel@main
- name: Set PYTORCH_VERSION
if: ${{ env.CHANNEL == 'test' }}
run: |
# When building RC, set the version to be the current candidate version,
# otherwise, leave it alone so nightly will pick up the latest
echo "PYTORCH_VERSION=${{ matrix.stable_version }}" >> "${GITHUB_ENV}"
- uses: pytorch/test-infra/.github/actions/setup-binary-builds@main
env:
PLATFORM: ${{ env.ARCH == 'aarch64' && 'linux-aarch64' || ''}}
with:
repository: ${{ env.REPOSITORY }}
ref: ${{ env.REF }}
setup-miniconda: true
python-version: ${{ env.PYTHON_VERSION }}
cuda-version: ${{ env.CU_VERSION }}
arch: ${{ env.ARCH }}
- name: Install torch dependency
run: |
set -euxo pipefail
# shellcheck disable=SC1090
source "${BUILD_ENV_FILE}"
# shellcheck disable=SC2086
${CONDA_RUN} ${PIP_INSTALL_TORCH}
- name: Install python build dependency
run: |
set -euxo pipefail
# shellcheck disable=SC1090
source "${BUILD_ENV_FILE}"
# shellcheck disable=SC2086
${CONDA_RUN} python -m pip install build
- name: Build the wheel (bdist_wheel)
working-directory: ${{ env.REPOSITORY }}
shell: bash -l {0}
run: |
set -euxo pipefail
source "${BUILD_ENV_FILE}"
export PYTORCH_VERSION="$(${CONDA_RUN} pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
${CONDA_RUN} python -m build --wheel
- name: Smoke Test
shell: bash -l {0}
env:
PACKAGE_NAME: ${{ env.PACKAGE_NAME }}
SMOKE_TEST_SCRIPT: ""
run: |
set -euxo pipefail
source "${BUILD_ENV_FILE}"
WHEEL_NAME=$(ls "${{ env.REPOSITORY }}/dist/")
echo "$WHEEL_NAME"
${CONDA_RUN} pip install "${{ env.REPOSITORY }}/dist/$WHEEL_NAME"
# Checking that we have a pinned version of torch in our dependency tree
(
pushd "${RUNNER_TEMP}"
unzip -o "${GITHUB_WORKSPACE}/${{ env.REPOSITORY }}/dist/$WHEEL_NAME"
# Ensure that pytorch version is pinned, should output file where it was found
grep "Requires-Dist: torch (==.*)" -r .
)
if [[ (! -f "${{ env.REPOSITORY }}"/${SMOKE_TEST_SCRIPT}) ]]; then
echo "${{ env.REPOSITORY }}/${SMOKE_TEST_SCRIPT} not found"
${CONDA_RUN} python -c "import ${PACKAGE_NAME}; print('package version is ', ${PACKAGE_NAME}.__version__)"
else
echo "${{ env.REPOSITORY }}/${SMOKE_TEST_SCRIPT} found"
${CONDA_RUN} python "${{ env.REPOSITORY }}/${SMOKE_TEST_SCRIPT}"
fi
# NB: Only upload to GitHub after passing smoke tests
- name: Upload wheel to GitHub
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.REPOSITORY }}/dist/
upload:
needs: build
uses: pytorch/test-infra/.github/workflows/_binary_upload.yml@main
if: always()
with:
repository: pytorch/torchtune
ref: pkg-for-wheel
test-infra-repository: pytorch/test-infra
test-infra-ref: main
build-matrix: ${{ needs.build.needs.generate-matrix.outputs.matrix }}
architecture: x86_64
trigger-event: ${{ github.event_name }}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-pytorch/torchtune-${{ github.event_name == 'workflow_dispatch' }}
cancel-in-progress: true