|
7 | 7 |
|
8 | 8 | echo "Installing Triton from source..."
|
9 | 9 |
|
| 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 | + |
10 | 15 | # Ensure we're in the conda environment
|
11 | 16 | if [ -z "$CONDA_ENV" ]; then
|
12 | 17 | echo "ERROR: CONDA_ENV is not set"
|
@@ -38,14 +43,28 @@ if [ -n "$TRITON_PKG_DIR" ] && [ -d "$TRITON_PKG_DIR" ]; then
|
38 | 43 | rm -rf "$TRITON_PKG_DIR"
|
39 | 44 | fi
|
40 | 45 |
|
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" |
46 | 62 | 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" |
49 | 68 |
|
50 | 69 | # Install build dependencies
|
51 | 70 | echo "Installing build dependencies..."
|
@@ -79,4 +98,7 @@ python -c "import triton; print(f'Triton version: {triton.__version__}')" || {
|
79 | 98 | }
|
80 | 99 | python -c "import triton; print(f'Triton path: {triton.__file__}')"
|
81 | 100 |
|
| 101 | +# Save commit info for cache validation |
| 102 | +echo "$ACTUAL_COMMIT" > "$TRITON_CACHE_DIR/commit" |
| 103 | + |
82 | 104 | echo "Triton installation completed successfully!"
|
0 commit comments