Skip to content

Commit 22d76ca

Browse files
committed
Refactor test.yml so that the build is a composite workflow to be shared for benchmarking
stack-info: PR: #540, branch: oulgen/stack/68
1 parent a28bcba commit 22d76ca

File tree

2 files changed

+77
-57
lines changed

2 files changed

+77
-57
lines changed

.github/workflows/build.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Run Tests
2+
description: Common build steps
3+
4+
inputs:
5+
python-version:
6+
required: true
7+
runtime-version:
8+
required: true
9+
should-cache:
10+
required: true
11+
12+
runs:
13+
using: 'composite'
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v4
17+
18+
- name: Install uv
19+
uses: astral-sh/setup-uv@v6
20+
with:
21+
python-version: ${{ inputs.python-version }}
22+
enable-cache: true
23+
24+
- name: Create virtual environment
25+
run: |
26+
uv venv --python ${{ inputs.python-version }}
27+
28+
- name: Get current month
29+
id: date
30+
run: echo "month=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
31+
32+
- name: Cache dependencies
33+
if: $${{ inputs.should-cache }} == 'true'
34+
id: cache
35+
uses: actions/cache@v4
36+
with:
37+
path: |
38+
~/.cache/uv
39+
~/.venv
40+
key: ${{ inputs.python-version }}-${{ inputs.runtime-version }}-${{ hashFiles('.github/workflows/build.yml, 'requirements.txt') }}-${{ steps.date.outputs.month }}
41+
42+
- name: Install PyTorch
43+
run: |
44+
source .venv/bin/activate
45+
uv pip install -U --pre torch --index-url https://download.pytorch.org/whl/nightly/${{ inputs.runtime-version }}
46+
47+
- name: Install Triton
48+
if: steps.cache.outputs.cache-hit != 'true'
49+
run: |
50+
set -x
51+
source .venv/bin/activate
52+
apt-get update
53+
apt-get install -y git
54+
apt-get install -y clang-14 clang++-14 zlib1g-dev
55+
export CC=clang-14
56+
export CXX=clang++-14
57+
mkdir -p /tmp/$USER
58+
cd /tmp/$USER
59+
uv pip uninstall triton pytorch-triton || true
60+
rm -rf triton/ || true
61+
git clone https://github.com/triton-lang/triton.git
62+
cd triton/
63+
uv pip install -r python/requirements.txt
64+
MAX_JOBS=$(nproc) TRITON_PARALLEL_LINK_JOBS=2 uv pip install .
65+
cd /tmp/$USER
66+
rm -rf triton/
67+
python -c "import triton; print(f'Triton version: {triton.__version__}')"
68+
69+
- name: Install Requirements
70+
run: |
71+
source .venv/bin/activate
72+
uv pip install -r requirements.txt
73+
uv pip install pytest-timeout

.github/workflows/test.yml

Lines changed: 4 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -47,64 +47,11 @@ jobs:
4747
shell: bash -l {0}
4848

4949
steps:
50-
- name: Check out code
51-
uses: actions/checkout@v4
52-
53-
- name: Install uv
54-
uses: astral-sh/setup-uv@v6
55-
with:
56-
python-version: ${{ matrix.python-version }}
57-
enable-cache: true
58-
59-
- name: Create virtual environment
60-
run: |
61-
uv venv --python ${{ matrix.python-version }}
62-
63-
- name: Get current month
64-
id: date
65-
run: echo "month=$(date +'%Y-%m')" >> $GITHUB_OUTPUT
66-
67-
- name: Cache dependencies
68-
id: cache
69-
uses: actions/cache@v4
50+
- uses: .github/workflows/build.yml
7051
with:
71-
path: |
72-
~/.cache/uv
73-
~/.venv
74-
key: ${{ matrix.python-version }}-${{ matrix.runtime-version }}-${{ hashFiles('.github/workflows/test.yml', 'requirements.txt') }}-${{ steps.date.outputs.month }}
75-
76-
- name: Install PyTorch
77-
run: |
78-
source .venv/bin/activate
79-
uv pip install -U --pre torch --index-url https://download.pytorch.org/whl/nightly/${{ matrix.runtime-version }}
80-
81-
- name: Install Triton
82-
if: steps.cache.outputs.cache-hit != 'true'
83-
run: |
84-
set -x
85-
source .venv/bin/activate
86-
apt-get update
87-
apt-get install -y git
88-
apt-get install -y clang-14 clang++-14 zlib1g-dev
89-
export CC=clang-14
90-
export CXX=clang++-14
91-
mkdir -p /tmp/$USER
92-
cd /tmp/$USER
93-
uv pip uninstall triton pytorch-triton || true
94-
rm -rf triton/ || true
95-
git clone https://github.com/triton-lang/triton.git
96-
cd triton/
97-
uv pip install -r python/requirements.txt
98-
MAX_JOBS=$(nproc) TRITON_PARALLEL_LINK_JOBS=2 uv pip install .
99-
cd /tmp/$USER
100-
rm -rf triton/
101-
python -c "import triton; print(f'Triton version: {triton.__version__}')"
102-
103-
- name: Install Requirements
104-
run: |
105-
source .venv/bin/activate
106-
uv pip install -r requirements.txt
107-
uv pip install pytest-timeout
52+
python-version: ${{ matrix.runtime-version }}
53+
runtime-version: ${{ matrix.runtime-version }}
54+
should-cache: true
10855

10956
- name: Run Tests
11057
run: |

0 commit comments

Comments
 (0)