Skip to content

Commit 6edab95

Browse files
authored
Build Triton and PyTorch once, use in matrix jobs (#4130)
Also split core core to minicore, mxfp, scaled_dot to increase parallelism. Total duration: 50m -> [37m](https://github.com/intel/intel-xpu-backend-for-triton/actions/runs/14894768884) The tutorials (rolling) are in the critical path, to reduce total duration further it makes sense to split tutorials. --------- Signed-off-by: Pavel Chekin <[email protected]>
1 parent fc024d8 commit 6edab95

File tree

2 files changed

+145
-52
lines changed

2 files changed

+145
-52
lines changed

.github/workflows/build-test-reusable.yml

Lines changed: 144 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,132 @@ permissions: read-all
7070
env:
7171
TRITON_DISABLE_LINE_INFO: 1
7272
TEST_UNSKIP: ${{ inputs.enable_unskip }}
73+
# Increase this value to reset cache
74+
PIP_CACHE_NUMBER: 1
7375

7476
jobs:
77+
build:
78+
name: Build
79+
runs-on: ${{ fromJson(inputs.runner_label && format('["linux", "{0}"]', inputs.runner_label) || format('["linux", "{0}", "{1}", "{2}"]', inputs.device, inputs.driver_version, inputs.runner_version)) }}
80+
defaults:
81+
run:
82+
shell: bash -noprofile --norc -eo pipefail -c "source /opt/intel/oneapi/setvars.sh > /dev/null; source {0}"
83+
outputs:
84+
test-triton-command: ${{ steps.test-triton.outputs.command }}
85+
steps:
86+
- name: Print inputs
87+
run: |
88+
cat <<EOF
89+
${{ toJSON(inputs) }}
90+
EOF
91+
- name: Checkout repository
92+
uses: actions/checkout@v4
93+
94+
- name: Load pip cache
95+
id: pip-cache
96+
uses: ./.github/actions/load
97+
with:
98+
path: $HOME/.cache/pip
99+
key: pip-${{ inputs.python_version }}-${{ hashFiles('pyproject.toml', 'setup.py') }}-${{ env.PIP_CACHE_NUMBER }}
100+
101+
- name: Install Python (using actions/setup-python) ${{ inputs.python_version }}
102+
if: ${{ !inputs.use_pyenv_python }}
103+
uses: actions/setup-python@v5
104+
with:
105+
python-version: ${{ inputs.python_version }}
106+
107+
- name: Install Python (from pyenv) ${{ inputs.python_version }}
108+
if: ${{ inputs.use_pyenv_python }}
109+
uses: ./.github/actions/setup-pyenv-python
110+
with:
111+
python-version: ${{ inputs.python_version }}
112+
113+
# Build PyTorch here once, integration tests jobs should load it from cache.
114+
- name: Setup PyTorch
115+
uses: ./.github/actions/setup-pytorch
116+
with:
117+
ref: ${{ inputs.pytorch_ref }}
118+
mode: ${{ inputs.pytorch_mode }}
119+
120+
- name: Build Proton with XPU support
121+
if: inputs.driver_version == 'rolling' && inputs.device == 'max1100'
122+
run: |
123+
echo TRITON_BUILD_PROTON_XPU=1 | tee -a $GITHUB_ENV
124+
125+
- name: Build Triton
126+
uses: ./.github/actions/setup-triton
127+
with:
128+
build_llvm: ${{ inputs.build_llvm }}
129+
use_spirv_backend: ${{ inputs.use_spirv_backend }}
130+
command: >
131+
DEBUG=1
132+
python setup.py bdist_wheel && pip install dist/*.whl
133+
134+
- name: Set test-triton command line
135+
id: test-triton
136+
run: |
137+
skiplist="$GITHUB_WORKSPACE/scripts/skiplist/default"
138+
139+
if [[ -n "${{ inputs.skip_list }}" ]]; then
140+
skiplist="$GITHUB_WORKSPACE/scripts/skiplist/${{ inputs.skip_list }}"
141+
elif [[ -n "${{ inputs.driver_version }}" ]]; then
142+
skiplist="$GITHUB_WORKSPACE/scripts/skiplist/${{ inputs.driver_version }}"
143+
fi
144+
145+
if [ -d "$skiplist" ]; then
146+
skiplist="--skip-list $skiplist"
147+
else
148+
skiplist="--skip-list $GITHUB_WORKSPACE/scripts/skiplist/default"
149+
fi
150+
151+
TRITON_TEST_CMD="bash -x scripts/test-triton.sh --skip-pip-install --warning-reports --skip-pytorch-install --reports-dir $GITHUB_WORKSPACE/reports ${{ inputs.ignore_errors && '--ignore-errors' || '' }} $skiplist"
152+
echo "command=$TRITON_TEST_CMD" | tee -a $GITHUB_OUTPUT
153+
echo "TRITON_TEST_CMD=$TRITON_TEST_CMD" | tee -a $GITHUB_ENV
154+
155+
- name: Install test dependencies
156+
run: |
157+
pip install -r scripts/requirements-test.txt git+https://github.com/kwasd/[email protected]
158+
159+
# Unit tests require `build` directory.
160+
- name: Run unit tests
161+
run: |
162+
${{ env.TRITON_TEST_CMD }} --unit
163+
164+
# Instrumentation tests require `build` directory.
165+
- name: Run instrumentation tests
166+
run: |
167+
${{ env.TRITON_TEST_CMD }} --instrumentation
168+
169+
- name: Save pip cache
170+
if: ${{ steps.pip-cache.outputs.status == 'miss' }}
171+
uses: ./.github/actions/save
172+
with:
173+
path: ${{ steps.pip-cache.outputs.path }}
174+
dest: ${{ steps.pip-cache.outputs.dest }}
175+
176+
- name: Upload Triton wheels
177+
uses: actions/upload-artifact@v4
178+
with:
179+
name: triton-${{ inputs.python_version }}-${{ inputs.runner_label || inputs.driver_version }}
180+
path: dist/*.whl
181+
182+
- name: Upload test reports
183+
uses: actions/upload-artifact@v4
184+
with:
185+
name: test-reports-build-${{ inputs.python_version }}-${{ inputs.runner_label || inputs.driver_version }}
186+
include-hidden-files: true
187+
path: reports
188+
75189
integration-tests:
76190
name: Integration tests
191+
needs: build
77192
strategy:
78193
fail-fast: false
79194
matrix:
80195
suite:
81-
- core
196+
- minicore
197+
- mxfp
198+
- scaled_dot
82199
- rest
83200
timeout-minutes: 720
84201
runs-on: ${{ fromJson(inputs.runner_label && format('["linux", "{0}"]', inputs.runner_label) || format('["linux", "{0}", "{1}", "{2}"]', inputs.device, inputs.driver_version, inputs.runner_version)) }}
@@ -98,12 +215,9 @@ jobs:
98215
- name: Load pip cache
99216
id: pip-cache
100217
uses: ./.github/actions/load
101-
env:
102-
# Increase this value to reset cache
103-
CACHE_NUMBER: 1
104218
with:
105219
path: $HOME/.cache/pip
106-
key: pip-${{ inputs.python_version }}-${{ matrix.suite }}-${{ hashFiles('pyproject.toml', 'setup.py') }}-${{ env.CACHE_NUMBER }}
220+
key: pip-${{ inputs.python_version }}-${{ matrix.suite }}-${{ hashFiles('pyproject.toml', 'setup.py') }}-${{ env.PIP_CACHE_NUMBER }}
107221

108222
- name: Install Python (using actions/setup-python) ${{ inputs.python_version }}
109223
if: ${{ !inputs.use_pyenv_python }}
@@ -123,19 +237,18 @@ jobs:
123237
ref: ${{ inputs.pytorch_ref }}
124238
mode: ${{ inputs.pytorch_mode }}
125239

126-
- name: Build Proton with XPU support
127-
if: matrix.suite == 'rest' && inputs.driver_version == 'rolling' && inputs.device == 'max1100'
128-
run: |
129-
echo TRITON_BUILD_PROTON_XPU=1 | tee -a $GITHUB_ENV
130-
131-
- name: Setup Triton
132-
uses: ./.github/actions/setup-triton
240+
- name: Download Triton wheels
241+
uses: actions/download-artifact@v4
133242
with:
134-
build_llvm: ${{ inputs.build_llvm }}
135-
use_spirv_backend: ${{ inputs.use_spirv_backend }}
243+
name: triton-${{ inputs.python_version }}-${{ inputs.runner_label || inputs.driver_version }}
244+
245+
- name: Install Triton
246+
run: |
247+
pip install triton-*.whl
248+
python -c 'import triton; print(triton.__version__)'
136249
137250
- name: Report environment details
138-
if: matrix.suite == 'core'
251+
if: matrix.suite == 'minicore'
139252
run: |
140253
mkdir -p reports
141254
cat <<EOF | tee reports/.env
@@ -151,47 +264,35 @@ jobs:
151264
EOF
152265
./scripts/capture-hw-details.sh | tee -a reports/.env
153266
154-
- name: Create test-triton command line
155-
run: |
156-
skiplist="$GITHUB_WORKSPACE/scripts/skiplist/default"
157-
158-
if [[ -n "${{ inputs.skip_list }}" ]]; then
159-
skiplist="$GITHUB_WORKSPACE/scripts/skiplist/${{ inputs.skip_list }}"
160-
elif [[ -n "${{ inputs.driver_version }}" ]]; then
161-
skiplist="$GITHUB_WORKSPACE/scripts/skiplist/${{ inputs.driver_version }}"
162-
fi
163-
164-
if [ -d "$skiplist" ]; then
165-
skiplist="--skip-list $skiplist"
166-
else
167-
skiplist="--skip-list $GITHUB_WORKSPACE/scripts/skiplist/default"
168-
fi
169-
170-
{
171-
echo SKIPLIST="$skiplist"
172-
echo TRITON_TEST_CMD="bash -x scripts/test-triton.sh --skip-pip-install --warning-reports --skip-pytorch-install --reports-dir $GITHUB_WORKSPACE/reports ${{ inputs.ignore_errors && '--ignore-errors' || '' }} $skiplist"
173-
} | tee -a $GITHUB_ENV
174-
175267
- name: Install test dependencies
176268
run: |
177269
pip install -r scripts/requirements-test.txt git+https://github.com/kwasd/[email protected]
178270
271+
- name: Set test-triton command line
272+
run: |
273+
echo "TRITON_TEST_CMD=${{ needs.build.outputs.test-triton-command }}" | tee -a $GITHUB_ENV
274+
179275
- name: Run Proton tests
180276
if: matrix.suite == 'rest' && inputs.driver_version == 'rolling' && inputs.device == 'max1100'
181277
run: |
182278
cd third_party/proton/test
183279
pytest test_api.py test_lib.py test_profile.py test_viewer.py test_record.py -s -v
184280
cd ..
185281
186-
- name: Run unit tests
187-
if: matrix.suite == 'rest'
282+
- name: Run minicore tests
283+
if: matrix.suite == 'minicore'
188284
run: |
189-
${{ env.TRITON_TEST_CMD }} --unit
285+
${{ env.TRITON_TEST_CMD }} --minicore
286+
287+
- name: Run mxfp tests
288+
if: matrix.suite == 'mxfp'
289+
run: |
290+
${{ env.TRITON_TEST_CMD }} --mxfp
190291
191-
- name: Run core tests
192-
if: matrix.suite == 'core'
292+
- name: Run scaled_dot tests
293+
if: matrix.suite == 'scaled_dot'
193294
run: |
194-
${{ env.TRITON_TEST_CMD }} --core
295+
${{ env.TRITON_TEST_CMD }} --scaled-dot
195296
196297
- name: Run interpreter tests
197298
if: matrix.suite == 'rest'
@@ -203,11 +304,6 @@ jobs:
203304
run: |
204305
${{ env.TRITON_TEST_CMD }} --tutorial
205306
206-
- name: Run instrumentation tests
207-
if: matrix.suite == 'rest'
208-
run: |
209-
${{ env.TRITON_TEST_CMD }} --instrumentation
210-
211307
- name: Get transformers version
212308
if: matrix.suite == 'rest'
213309
run: |
@@ -255,12 +351,9 @@ jobs:
255351
- name: Load pip cache
256352
id: pip-cache
257353
uses: ./.github/actions/load
258-
env:
259-
# Increase this value to reset cache
260-
CACHE_NUMBER: 1
261354
with:
262355
path: $HOME/.cache/pip
263-
key: pip-${{ inputs.python_version }}-${{ hashFiles('pyproject.toml', 'setup.py') }}-${{ env.CACHE_NUMBER }}
356+
key: pip-${{ inputs.python_version }}-${{ hashFiles('pyproject.toml', 'setup.py') }}-${{ env.PIP_CACHE_NUMBER }}
264357

265358
- name: Download test reports
266359
uses: actions/download-artifact@v4

scripts/test-triton.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ OPTION:
3535
"
3636

3737
err() {
38-
echo $@
38+
echo "$@"
3939
exit 1
4040
}
4141

0 commit comments

Comments
 (0)