Skip to content

Commit 21403f4

Browse files
committed
Enhance Triton installation script with improved logging, pre-flight checks, and error handling; update GitHub Actions workflow to ensure jq availability and handle commit fetching errors gracefully
1 parent 60db4e0 commit 21403f4

File tree

2 files changed

+71
-20
lines changed

2 files changed

+71
-20
lines changed

.ci/install-triton.sh

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,35 @@
55

66
set -e
77

8-
echo "Installing Triton from source..."
8+
echo "🚀 Installing Triton from source..."
9+
START_TIME=$(date +%s)
10+
11+
# Function to show elapsed time
12+
show_elapsed() {
13+
CURRENT_TIME=$(date +%s)
14+
ELAPSED=$((CURRENT_TIME - START_TIME))
15+
echo "⏱️ Elapsed time: ${ELAPSED}s"
16+
}
17+
18+
# Pre-flight checks
19+
echo "🔍 Running pre-flight checks..."
20+
921

1022
# Set Triton version/commit for cache consistency
1123
TRITON_COMMIT=${TRITON_COMMIT:-"main"}
12-
echo "Target Triton commit/branch: $TRITON_COMMIT"
24+
echo "🎯 Target Triton commit/branch: $TRITON_COMMIT"
1325
TRITON_CACHE_DIR="/tmp/triton-cache"
1426
TRITON_SOURCE_DIR="/tmp/triton"
1527

28+
# Check disk space (need at least 10GB for Triton compilation)
29+
AVAILABLE_SPACE=$(df /tmp | tail -1 | awk '{print $4}')
30+
REQUIRED_SPACE=10485760 # 10GB in KB
31+
if [ "$AVAILABLE_SPACE" -lt "$REQUIRED_SPACE" ]; then
32+
echo "⚠️ WARNING: Low disk space. Available: $(($AVAILABLE_SPACE/1024/1024))GB, Recommended: 10GB"
33+
else
34+
echo "✅ Sufficient disk space available: $(($AVAILABLE_SPACE/1024/1024))GB"
35+
fi
36+
1637
# Ensure we're in the conda environment
1738
if [ -z "$CONDA_ENV" ]; then
1839
echo "ERROR: CONDA_ENV is not set"
@@ -82,13 +103,24 @@ else
82103
fi
83104

84105
echo "Cloning Triton repository..."
85-
git clone https://github.com/triton-lang/triton.git "$TRITON_SOURCE_DIR"
106+
if ! git clone https://github.com/triton-lang/triton.git "$TRITON_SOURCE_DIR"; then
107+
echo "❌ ERROR: Failed to clone Triton repository"
108+
echo "This might be due to network issues or GitHub rate limiting"
109+
exit 1
110+
fi
111+
86112
cd "$TRITON_SOURCE_DIR"
87113

88114
# Checkout specific commit for reproducibility
89-
git checkout "$TRITON_COMMIT"
115+
echo "Checking out commit: $TRITON_COMMIT"
116+
if ! git checkout "$TRITON_COMMIT"; then
117+
echo "❌ ERROR: Failed to checkout commit $TRITON_COMMIT"
118+
echo "This might be due to an invalid commit hash or network issues"
119+
exit 1
120+
fi
121+
90122
ACTUAL_COMMIT=$(git rev-parse HEAD)
91-
echo "Using Triton commit: $ACTUAL_COMMIT"
123+
echo "Using Triton commit: $ACTUAL_COMMIT"
92124
fi
93125

94126
# Install build dependencies
@@ -115,21 +147,31 @@ else
115147
echo "This will take 30-50 minutes for compilation"
116148
fi
117149
pip install -e .
150+
show_elapsed
118151

119152
# Verify Triton installation
120153
echo "Verifying Triton installation..."
121-
python -c "import triton; print(f'Triton version: {triton.__version__}')" || {
122-
echo "ERROR: Failed to import triton"
154+
if python -c "import triton; print(f'Triton version: {triton.__version__}')" 2>/dev/null; then
155+
python -c "import triton; print(f'Triton path: {triton.__file__}')"
156+
echo "✅ Triton installation verified successfully"
157+
158+
# Only save commit info after successful verification
159+
echo "$ACTUAL_COMMIT" >"$TRITON_CACHE_DIR/commit"
160+
echo "✅ Cache information saved"
161+
162+
show_elapsed
163+
echo "🎉 Triton installation completed successfully!"
164+
else
165+
echo "❌ ERROR: Failed to import triton"
123166
echo "This might be due to libstdc++ version issues"
124167
echo "Checking system libstdc++ version:"
125-
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX | tail -5
168+
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX | tail -5 || echo "Could not check system libstdc++"
126169
echo "Checking conda libstdc++ version:"
127-
strings /opt/miniconda3/envs/tritonparse/lib/libstdc++.so.6 | grep GLIBCXX | tail -5
170+
strings /opt/miniconda3/envs/tritonparse/lib/libstdc++.so.6 | grep GLIBCXX | tail -5 || echo "Could not check conda libstdc++"
171+
172+
# Clean up cache on failure to prevent corruption
173+
echo "🧹 Cleaning up cache due to installation failure..."
174+
rm -f "$TRITON_CACHE_DIR/commit"
175+
128176
exit 1
129-
}
130-
python -c "import triton; print(f'Triton path: {triton.__file__}')"
131-
132-
# Save commit info for cache validation
133-
echo "$ACTUAL_COMMIT" >"$TRITON_CACHE_DIR/commit"
134-
135-
echo "Triton installation completed successfully!"
177+
fi

.github/workflows/test.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,27 @@ jobs:
4545
- name: Get Triton latest commit
4646
id: triton-commit
4747
run: |
48-
COMMIT=$(curl -s --max-time 30 https://api.github.com/repos/triton-lang/triton/commits/main | jq -r .sha)
48+
# Check if jq is available
49+
if ! command -v jq &> /dev/null; then
50+
echo "jq not found, installing..."
51+
sudo apt-get update && sudo apt-get install -y jq
52+
fi
53+
54+
# Get commit with error handling
55+
echo "Fetching latest Triton commit..."
56+
COMMIT=$(curl -s --max-time 30 --retry 3 https://api.github.com/repos/triton-lang/triton/commits/main | jq -r .sha 2>/dev/null || echo "")
57+
4958
if [ -n "$COMMIT" ] && [ "$COMMIT" != "null" ]; then
5059
echo "commit=$COMMIT" >> $GITHUB_OUTPUT
5160
echo "cache-key=$COMMIT" >> $GITHUB_OUTPUT
52-
echo "Using Triton commit: $COMMIT"
61+
echo "Using Triton commit: $COMMIT"
5362
else
54-
echo "Failed to get Triton commit, using 'main' as fallback"
63+
echo "Failed to get Triton commit, using 'main' as fallback"
5564
# Force cache miss by using timestamp when API fails
5665
TIMESTAMP=$(date +%Y%m%d%H%M%S)
5766
echo "commit=main" >> $GITHUB_OUTPUT
5867
echo "cache-key=main-fallback-$TIMESTAMP" >> $GITHUB_OUTPUT
59-
echo "Using fallback cache key with timestamp: main-fallback-$TIMESTAMP"
68+
echo "⚠️ Using fallback cache key: main-fallback-$TIMESTAMP"
6069
fi
6170
6271
- name: Cache Triton source and build

0 commit comments

Comments
 (0)