Skip to content

Commit 0e2f0b6

Browse files
authored
Merge OpenAI Triton commit 64608f6 (#4061)
This PR change the Triton base from f6b82d7 to 64608f6 (Apr 28). Pass rate: 92.08% Please do not squash and merge this PR.
2 parents 2632cee + d3ec5c1 commit 0e2f0b6

File tree

24 files changed

+876
-1078
lines changed

24 files changed

+876
-1078
lines changed

.github/workflows/build-macos.yml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
name: Build MacOS
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
matrix:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
build-macos:
12+
runs-on: ${{ matrix.runner }}
13+
strategy:
14+
matrix:
15+
runner: ${{ fromJson(inputs.matrix) }}
16+
timeout-minutes: 40
17+
env:
18+
RUNNER_TYPE: ${{ matrix.runner[0] }}
19+
name: Build MacOS
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
submodules: "true"
25+
- name: Install brew dependencies
26+
run: |
27+
brew update
28+
brew install ccache llvm@19 lld coreutils
29+
- name: Compute cache keys
30+
id: cache-key
31+
run: |
32+
llvm_file="cmake/llvm-hash.txt"
33+
nvidia_file="cmake/nvidia-toolchain-version.json"
34+
json_file="cmake/json-version.txt"
35+
36+
# Check if files exist before proceeding
37+
if [[ ! -f "$llvm_file" || ! -f "$nvidia_file" || ! -f "$json_file" ]]; then
38+
echo "Error: Required dependency files are missing."
39+
exit 1
40+
fi
41+
42+
# Process the files if they exist
43+
echo "llvm=$(cat $llvm_file | cut -c 1-8)" >> $GITHUB_OUTPUT
44+
echo "nvidia=$(sha256sum $nvidia_file | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
45+
echo "json=$(cat $json_file)" >> $GITHUB_OUTPUT
46+
echo "datetime=$(date -u -Iseconds)" >> $GITHUB_OUTPUT
47+
shell: bash
48+
- name: Cache build dependencies
49+
uses: actions/cache@v4
50+
with:
51+
# Note that we cannot use environment variables here given there is
52+
# no shell to interpret them in the paths.
53+
path: |
54+
~/.triton/llvm
55+
~/.triton/nvidia
56+
~/.triton/json
57+
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ steps.cache-key.outputs.llvm }}-nvidia-${{ steps.cache-key.outputs.nvidia }}-json-${{ steps.cache-key.outputs.json }}
58+
- # Cache ~/.cache/ccache to speed up compilation.
59+
#
60+
# On branch `main` we always start from an empty cache, i.e. we skip the
61+
# "restore" step. This is to prevent the caches from accumulating stale
62+
# files over time.
63+
name: Restore cache of ccache and Triton compilation artifacts
64+
id: restore-build-cache
65+
if: github.ref != 'refs/heads/main'
66+
uses: actions/cache/restore@v4
67+
with:
68+
path: |
69+
~/.ccache
70+
# Restore the most recent cache entry.
71+
restore-keys: |
72+
triton-artifacts-${{ runner.os }}-${{ runner.arch }}-${{ env.RUNNER_TYPE }}-llvm-${{ steps.cache-key.outputs.llvm }}-
73+
triton-artifacts-${{ runner.os }}-${{ runner.arch }}-${{ env.RUNNER_TYPE }}-
74+
# We expect this cache key never to hit and for us to fall back
75+
# unconditionally to the restore-key, so it doesn't actually matter
76+
# what we put here (so long as it doesn't hit an existing key).
77+
key: triton-artifacts-${{ runner.os }}-${{ runner.arch }}-${{ env.RUNNER_TYPE }}-llvm-${{ steps.cache-key.outputs.llvm }}-${{ steps.cache-key.outputs.datetime }}
78+
- name: Inspect cache directories
79+
run: |
80+
mkdir -p ~/.triton
81+
du -h -d 1 ~/.triton
82+
83+
mkdir -p ~/.ccache
84+
du -h -d 1 ~/.ccache
85+
- name: Update PATH
86+
run: |
87+
echo "$HOME/.local/bin" >> $GITHUB_PATH
88+
echo "/opt/homebrew/opt/llvm/bin" >> $GITHUB_PATH
89+
- name: Create venv
90+
run: |
91+
python3 -m venv ~/.venv
92+
source ~/.venv/bin/activate
93+
python3 -m pip install --upgrade pip
94+
- name: Install Triton
95+
env:
96+
TRITON_BUILD_WITH_O1: "true"
97+
# macos-latest has 3 vcpus and 7GB DRAM, to save memory we limit the number of jobs to 3
98+
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
99+
MAX_JOBS: 3
100+
run: |
101+
source ~/.venv/bin/activate
102+
echo "PATH is '$PATH'"
103+
ccache --zero-stats
104+
make dev-install
105+
- name: CCache Stats
106+
run: ccache --print-stats
107+
- name: Inspect cache directories
108+
run: |
109+
mkdir -p ~/.triton
110+
du -h -d 1 ~/.triton
111+
112+
mkdir -p ~/.ccache
113+
du -h -d 1 ~/.ccache
114+
- # If we're on branch `main`, save the ccache Triton compilation artifacts
115+
# to the cache so they can be used by other (non-main) CI runs.
116+
#
117+
# (It wouldn't be a problem to save the cache on every run, because github
118+
# evicts cache entries LRU, but maybe this saves a bit of time in CI.)
119+
name: Save ccache and Triton compilation artifacts to cache
120+
if: github.ref == 'refs/heads/main'
121+
uses: actions/cache/save@v4
122+
with:
123+
path: |
124+
~/.ccache
125+
key: triton-artifacts-${{ runner.os }}-${{ runner.arch }}-${{ env.RUNNER_TYPE }}-llvm-${{ steps.cache-key.outputs.llvm }}-${{ steps.cache-key.outputs.datetime }}

.github/workflows/ci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Integration Tests
2+
on:
3+
workflow_dispatch:
4+
concurrency:
5+
group: ${{ github.ref }}
6+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
7+
permissions: read-all
8+
env:
9+
TRITON_BUILD_WITH_CCACHE: "true"
10+
TRITON_BUILD_WITH_CLANG_LLD: "TRUE"
11+
TRITON_USE_ASSERT_ENABLED_LLVM: "TRUE"
12+
TRITON_DISABLE_LINE_INFO: 1
13+
PROTON_SKIP_PC_SAMPLING_TEST: 1
14+
PYTHON: "python3"
15+
CCACHE_COMPRESS: "true"
16+
17+
jobs:
18+
19+
runner-preparation:
20+
uses: ./.github/workflows/runner-preparation.yml
21+
22+
pre-commit:
23+
uses: ./.github/workflows/pre-commit.yml
24+
25+
integration-tests-nvidia:
26+
needs: runner-preparation
27+
if: needs.runner-preparation.outputs.matrix-NVIDIA != ''
28+
uses: ./.github/workflows/integration-tests-nvidia.yml
29+
with:
30+
matrix: ${{ needs.runner-preparation.outputs.matrix-NVIDIA }}
31+
32+
integration-tests-amd:
33+
needs: runner-preparation
34+
if: needs.runner-preparation.outputs.matrix-AMD != ''
35+
uses: ./.github/workflows/integration-tests-amd.yml
36+
with:
37+
matrix: ${{ needs.runner-preparation.outputs.matrix-AMD }}
38+
39+
build-macos:
40+
needs: runner-preparation
41+
if: needs.runner-preparation.outputs.matrix-MACOS != ''
42+
uses: ./.github/workflows/build-macos.yml
43+
with:
44+
matrix: ${{ needs.runner-preparation.outputs.matrix-MACOS }}
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: Integration Tests AMD
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
matrix:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
integration-tests-amd:
12+
runs-on: ${{ matrix.runner }}
13+
timeout-minutes: 45
14+
strategy:
15+
matrix:
16+
runner: ${{ fromJson(inputs.matrix) }}
17+
env:
18+
RUNNER_TYPE: ${{ matrix.runner[1] }}
19+
TRITON_BUILD_WITH_CCACHE: "true"
20+
TRITON_BUILD_WITH_CLANG_LLD: "TRUE"
21+
TRITON_USE_ASSERT_ENABLED_LLVM: "TRUE"
22+
TRITON_DISABLE_LINE_INFO: 1
23+
PROTON_SKIP_PC_SAMPLING_TEST: 1
24+
PYTHON: "python3"
25+
CCACHE_COMPRESS: "true"
26+
container:
27+
image: rocm/pytorch:rocm6.2.2_ubuntu22.04_py3.10_pytorch_2.5.1_asan
28+
options: --device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined --group-add video --user root
29+
steps:
30+
- name: Checkout
31+
uses: actions/checkout@v4
32+
with:
33+
submodules: 'true'
34+
- name: Compute cache keys
35+
id: cache-key
36+
run: |
37+
llvm_file="cmake/llvm-hash.txt"
38+
nvidia_file="cmake/nvidia-toolchain-version.json"
39+
json_file="cmake/json-version.txt"
40+
41+
# Check if files exist before proceeding
42+
if [[ ! -f "$llvm_file" || ! -f "$nvidia_file" || ! -f "$json_file" ]]; then
43+
echo "Error: Required dependency files are missing."
44+
exit 1
45+
fi
46+
47+
# Process the files if they exist
48+
echo "llvm=$(cat $llvm_file | cut -c 1-8)" >> $GITHUB_OUTPUT
49+
echo "nvidia=$(sha256sum $nvidia_file | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
50+
echo "json=$(cat $json_file)" >> $GITHUB_OUTPUT
51+
echo "datetime=$(date -u -Iseconds)" >> $GITHUB_OUTPUT
52+
shell: bash
53+
- name: Cache build dependencies
54+
uses: actions/cache@v4
55+
with:
56+
# Note that we cannot use environment variables here given there is
57+
# no shell to interpret them in the paths.
58+
path: |
59+
~/.triton/llvm
60+
~/.triton/nvidia
61+
~/.triton/json
62+
key: ${{ runner.os }}-${{ runner.arch }}-llvm-${{ steps.cache-key.outputs.llvm }}-nvidia-${{ steps.cache-key.outputs.nvidia }}-json-${{ steps.cache-key.outputs.json }}
63+
- # Cache ~/.cache/ccache to speed up compilation.
64+
#
65+
# On branch `main` we always start from an empty cache, i.e. we skip the
66+
# "restore" step. This is to prevent the caches from accumulating stale
67+
# files over time.
68+
name: Restore cache of ccache and Triton compilation artifacts
69+
id: restore-build-cache
70+
if: github.ref != 'refs/heads/main'
71+
uses: actions/cache/restore@v4
72+
with:
73+
path: |
74+
~/.ccache
75+
# Restore the most recent cache entry.
76+
restore-keys: |
77+
triton-artifacts-${{ runner.os }}-${{ runner.arch }}-${{ env.RUNNER_TYPE }}-llvm-${{ steps.cache-key.outputs.llvm }}-
78+
triton-artifacts-${{ runner.os }}-${{ runner.arch }}-${{ env.RUNNER_TYPE }}-
79+
# We expect this cache key never to hit and for us to fall back
80+
# unconditionally to the restore-key, so it doesn't actually matter
81+
# what we put here (so long as it doesn't hit an existing key).
82+
key: triton-artifacts-${{ runner.os }}-${{ runner.arch }}-${{ env.RUNNER_TYPE }}-llvm-${{ steps.cache-key.outputs.llvm }}-${{ steps.cache-key.outputs.datetime }}
83+
- name: Inspect cache directories
84+
run: |
85+
mkdir -p ~/.triton
86+
du -h -d 1 ~/.triton
87+
88+
mkdir -p ~/.ccache
89+
du -h -d 1 ~/.ccache
90+
- name: Update compiler to clang
91+
run: |
92+
export CC=/usr/bin/clang
93+
export CXX=/usr/bin/clang++
94+
- name: Install Triton
95+
id: amd-install-triton
96+
run: |
97+
echo "PATH is '$PATH'"
98+
pip uninstall -y triton pytorch-triton-rocm
99+
ccache --zero-stats
100+
make dev-install
101+
- name: CCache Stats
102+
run: ccache --print-stats
103+
- name: Run lit tests
104+
run: make test-lit
105+
- name: Run python tests on AMD
106+
run: |
107+
INSTRUMENTATION_LIB_DIR="${GITHUB_WORKSPACE}/python/triton/instrumentation"
108+
if [ ! -d "${INSTRUMENTATION_LIB_DIR}" ]; then
109+
echo "Could not find '${INSTRUMENTATION_LIB_DIR}'" ; exit -1
110+
fi
111+
pytest --capture=tee-sys -rfs python/tutorials/06-fused-attention.py
112+
pytest --capture=tee-sys -rfs third_party/amd/python/test/test_extract_slice.py
113+
cd python/test/unit
114+
pytest --capture=tee-sys -rfs -n 12 language runtime \
115+
--ignore=language/test_line_info.py \
116+
--ignore=test_debug.py
117+
# TODO: uncomment
118+
# pytest --capture=tee-sys -rfs test_debug.py
119+
TRITON_ALWAYS_COMPILE=1 TRITON_DISABLE_LINE_INFO=0 LLVM_PASS_PLUGIN_PATH=${INSTRUMENTATION_LIB_DIR}/libGPUInstrumentationTestLib.so \
120+
pytest --capture=tee-sys -rfs -vvv instrumentation/test_gpuhello.py
121+
122+
# Run test_line_info.py separately with TRITON_DISABLE_LINE_INFO=0
123+
TRITON_DISABLE_LINE_INFO=0 python3 -m pytest -s -n 8 language/test_line_info.py
124+
- name: Run asan tests on AMD
125+
if: false
126+
run: |
127+
cd third_party/amd/python/test/
128+
ulimit -s 1024
129+
export PATH=$(find ~/.triton/llvm -name llvm-symbolizer -printf '%h\n'):$PATH
130+
export LD_LIBRARY_PATH=$(find /opt -name libclang_rt.asan-x86_64.so -printf '%h\n'):$LD_LIBRARY_PATH
131+
export LD_LIBRARY_PATH=$(find /opt -type d -wholename *lib/llvm/lib/asan):$LD_LIBRARY_PATH
132+
export LD_LIBRARY_PATH=$(find /usr -name libcaffe2_nvrtc.so -printf '%h\n'):$LD_LIBRARY_PATH
133+
export CLANG_ASAN_LIB=$(find /opt -name libclang_rt.asan-x86_64.so)
134+
export HIP_ASAN_LIB=$(find /opt -wholename *lib/asan/libamdhip64.so)
135+
ASAN_OPTIONS=detect_leaks=0,alloc_dealloc_mismatch=0 \
136+
LD_PRELOAD=$CLANG_ASAN_LIB:$HIP_ASAN_LIB python3 -m pytest -s test_address_sanitizer.py
137+
- name: Run regression tests
138+
run: |
139+
# Reenable test_functional_regression.py once it's fixed
140+
cd python/test/regression
141+
python3 -m pytest -s -n 8 ./test_cast_matmul.py
142+
- name: Run Proton tests
143+
if: ${{ matrix.runner[0] != 'nvidia-gb200' }}
144+
run: make test-proton
145+
- name: Run C++ unittests
146+
run: make test-cpp
147+
- name: Inspect cache directories
148+
run: |
149+
mkdir -p ~/.triton
150+
du -h -d 1 ~/.triton
151+
152+
mkdir -p ~/.ccache
153+
du -h -d 1 ~/.ccache
154+
- # If we're on branch `main`, save the ccache Triton compilation artifacts
155+
# to the cache so they can be used by other (non-main) CI runs.
156+
#
157+
# (It wouldn't be a problem to save the cache on every run, because github
158+
# evicts cache entries LRU, but maybe this saves a bit of time in CI.)
159+
name: Save ccache and Triton compilation artifacts to cache
160+
if: github.ref == 'refs/heads/main'
161+
uses: actions/cache/save@v4
162+
with:
163+
path: |
164+
~/.ccache
165+
key: triton-artifacts-${{ runner.os }}-${{ runner.arch }}-${{ env.RUNNER_TYPE }}-llvm-${{ steps.cache-key.outputs.llvm }}-${{ steps.cache-key.outputs.datetime }}
166+
- name: Clean up caches
167+
# Always cleanup the worker, even if builds or tests failed
168+
if: always()
169+
run: |
170+
rm -rf ~/.triton
171+
rm -rf ~/.ccache

0 commit comments

Comments
 (0)