Skip to content

Commit 05d008d

Browse files
committed
Refactor Triton installation script for improved caching and reproducibility; update GitHub Actions workflow to reflect changes
1 parent e519951 commit 05d008d

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

.ci/install-triton.sh

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ set -e
77

88
echo "Installing Triton from source..."
99

10+
# Set Triton version/commit for cache consistency
11+
TRITON_COMMIT=${TRITON_COMMIT:-"main"}
12+
TRITON_CACHE_DIR="/tmp/triton-cache"
13+
TRITON_SOURCE_DIR="/tmp/triton"
14+
1015
# Ensure we're in the conda environment
1116
if [ -z "$CONDA_ENV" ]; then
1217
echo "ERROR: CONDA_ENV is not set"
@@ -38,14 +43,28 @@ if [ -n "$TRITON_PKG_DIR" ] && [ -d "$TRITON_PKG_DIR" ]; then
3843
rm -rf "$TRITON_PKG_DIR"
3944
fi
4045

41-
# Clone Triton repository
42-
echo "Cloning Triton repository..."
43-
cd /tmp
44-
if [ -d "triton" ]; then
45-
rm -rf triton
46+
# Create cache directory
47+
mkdir -p "$TRITON_CACHE_DIR"
48+
49+
# Clone or update Triton repository
50+
echo "Setting up Triton repository..."
51+
if [ -d "$TRITON_SOURCE_DIR" ]; then
52+
echo "Using cached Triton source..."
53+
cd "$TRITON_SOURCE_DIR"
54+
# Reset to clean state and fetch latest
55+
git reset --hard HEAD
56+
git clean -fd
57+
git fetch origin
58+
else
59+
echo "Cloning Triton repository..."
60+
git clone https://github.com/triton-lang/triton.git "$TRITON_SOURCE_DIR"
61+
cd "$TRITON_SOURCE_DIR"
4662
fi
47-
git clone https://github.com/triton-lang/triton.git
48-
cd triton
63+
64+
# Checkout specific commit for reproducibility
65+
git checkout "$TRITON_COMMIT"
66+
ACTUAL_COMMIT=$(git rev-parse HEAD)
67+
echo "Using Triton commit: $ACTUAL_COMMIT"
4968

5069
# Install build dependencies
5170
echo "Installing build dependencies..."
@@ -79,4 +98,7 @@ python -c "import triton; print(f'Triton version: {triton.__version__}')" || {
7998
}
8099
python -c "import triton; print(f'Triton path: {triton.__file__}')"
81100

101+
# Save commit info for cache validation
102+
echo "$ACTUAL_COMMIT" > "$TRITON_CACHE_DIR/commit"
103+
82104
echo "Triton installation completed successfully!"

.github/workflows/test.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ jobs:
5454
uses: actions/cache@v3
5555
with:
5656
path: |
57-
~/.triton
5857
/tmp/triton
59-
key: ${{ runner.os }}-triton-${{ hashFiles('.ci/install-triton.sh') }}
58+
/tmp/triton-cache
59+
/opt/miniconda3/envs/tritonparse/lib/python3.11/site-packages/triton*
60+
key: ${{ runner.os }}-triton-${{ hashFiles('.ci/install-triton.sh') }}-main
6061
restore-keys: |
62+
${{ runner.os }}-triton-${{ hashFiles('.ci/install-triton.sh') }}-
6163
${{ runner.os }}-triton-
6264
6365
- name: Setup environment

0 commit comments

Comments
 (0)