Skip to content

Commit 922df73

Browse files
FindHaofacebook-github-bot
authored andcommitted
Add Parallel CI for Pip-Installed Triton and Update Docs (#48)
Summary: Pre-built Triton has been upgraded to 3.4.0! So TritonParse can work out-of-box rather than compiling triton from source now! This PR introduces parallel CI testing for Triton installed via pip and updates the documentation to recommend pip for standard installations, ensuring broader compatibility and easier setup for users. ## Summary of Changes ### CI/CD Workflow Enhancements - **Added Parallel CI Job for Pip-Installed Triton**: - The main GitHub Actions workflow in `.github/workflows/test.yml` has been updated to include two parallel testing jobs: 1. `test-from-source`: The existing job, which tests against the latest Triton commit compiled from source. 2. `test-from-pip`: A new job that tests against the latest Triton version installed from PyPI. - This parallel setup ensures that `tritonparse` remains compatible with both source-built and pip-installed Triton environments. - **New CI Script for Pip Installation**: - Created a new script, `.ci/install-triton-pip.sh`, to handle the installation of Triton from PyPI in the new `test-from-pip` CI job. ### Documentation Updates - **Recommended Pip for Standard Installation**: - Updated the root `README.md` to recommend `pip install triton` as the standard installation method, removing the requirement to build from source. - Updated the wiki documentation, including `01.-Installation.md` and `04.-Developer-Guide.md`, to reflect that Triton should be installed via pip. Instructions for building from source have been replaced with the simpler pip command. These changes improve the project by simplifying the installation process for users and expanding CI coverage to validate compatibility with official Triton releases from PyPI. Pull Request resolved: #48 Reviewed By: adamomainz Differential Revision: D79290083 Pulled By: FindHao fbshipit-source-id: 9c7049b077f8c8d09812ac71f744efa0aa1deb4f
1 parent 18a2adf commit 922df73

File tree

4 files changed

+117
-4
lines changed

4 files changed

+117
-4
lines changed

.ci/install-triton-pip.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/bin/bash
2+
3+
# Install Triton from pip
4+
# This script installs the latest version of Triton from PyPI.
5+
6+
set -e
7+
8+
echo "🚀 Installing Triton from pip..."
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+
21+
# Ensure we're in the conda environment
22+
if [ -z "$CONDA_ENV" ]; then
23+
echo "ERROR: CONDA_ENV is not set"
24+
exit 1
25+
fi
26+
27+
# Activate conda environment
28+
source /opt/miniconda3/etc/profile.d/conda.sh
29+
conda activate "$CONDA_ENV"
30+
31+
# Uninstall existing triton to avoid conflicts
32+
echo "Uninstalling existing Triton versions..."
33+
pip uninstall -y pytorch-triton triton || true
34+
35+
# Install Triton from pip
36+
echo "Installing the latest Triton from PyPI..."
37+
pip install triton
38+
39+
show_elapsed
40+
41+
# Verify Triton installation
42+
echo "Verifying Triton installation..."
43+
if python -c "import triton; print(f'Triton version: {triton.__version__}')" 2>/dev/null; then
44+
python -c "import triton; print(f'Triton path: {triton.__file__}')"
45+
echo "✅ Triton installation verified successfully"
46+
show_elapsed
47+
echo "🎉 Triton installation completed successfully!"
48+
else
49+
echo "❌ ERROR: Failed to import Triton"
50+
exit 1
51+
fi

.github/workflows/test.yml

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
run: |
5757
make lint-check || (echo "❌ Linting failed. Please run 'make format' to fix formatting issues, then commit the changes." && echo "📖 For detailed formatting guide, see: https://github.com/pytorch-labs/tritonparse/wiki/05.-Code-Formatting" && exit 1)
5858
59-
test:
59+
test-from-source:
6060
runs-on: 4-core-ubuntu-gpu-t4
6161
timeout-minutes: 120
6262
steps:
@@ -156,3 +156,58 @@ jobs:
156156
COVERAGE: ${{ github.event.inputs.coverage || 'false' }}
157157
run: |
158158
bash .ci/run-tests.sh
159+
160+
test-from-pip:
161+
runs-on: 4-core-ubuntu-gpu-t4
162+
timeout-minutes: 120
163+
steps:
164+
- uses: actions/checkout@v4
165+
166+
- name: Set up Python 3.11
167+
uses: actions/setup-python@v4
168+
with:
169+
python-version: "3.11"
170+
171+
- name: Get daily cache timestamp
172+
id: daily-cache
173+
run: |
174+
# Calculate date (e.g., 2024-01-15) for daily cache expiration
175+
DATE_STAMP=$(date +"%Y-%m-%d")
176+
echo "date=$DATE_STAMP" >> $GITHUB_OUTPUT
177+
echo "Using daily cache stamp: $DATE_STAMP"
178+
179+
- name: Cache pip dependencies
180+
uses: actions/cache@v3
181+
with:
182+
path: ~/.cache/pip
183+
key: ${{ runner.os }}-pip-3.11-${{ steps.daily-cache.outputs.date }}
184+
restore-keys: |
185+
${{ runner.os }}-pip-3.11-
186+
187+
- name: Setup environment
188+
env:
189+
CONDA_ENV: tritonparse-pip
190+
PYTHON_VERSION: "3.11"
191+
CUDA_VERSION: "12.8"
192+
run: |
193+
bash .ci/setup.sh
194+
195+
- name: Install Triton from pip
196+
env:
197+
CONDA_ENV: tritonparse-pip
198+
run: |
199+
bash .ci/install-triton-pip.sh
200+
201+
- name: Install project dependencies
202+
env:
203+
CONDA_ENV: tritonparse-pip
204+
run: |
205+
bash .ci/install-project.sh
206+
207+
- name: Run tests
208+
env:
209+
CONDA_ENV: tritonparse-pip
210+
TEST_TYPE: ${{ github.event.inputs.test-type || 'all' }}
211+
COVERAGE: ${{ github.event.inputs.coverage || 'false' }}
212+
run: |
213+
bash .ci/run-tests.sh

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,12 @@ cd tritonparse
6969
pip install -e .
7070
```
7171

72-
**Prerequisites:** Python ≥ 3.10, Triton > 3.3.1 ([install from source](https://github.com/triton-lang/triton)), GPU required (NVIDIA/AMD)
72+
**Prerequisites:** Python ≥ 3.10, Triton 3.4.0, GPU required (NVIDIA/AMD)
7373

74-
TritonParse relies on new features in Triton > 3.3.1. Please install Triton from source for now.
74+
TritonParse relies on new features in Triton. Please install the latest version of Triton:
75+
```bash
76+
pip install triton
77+
```
7578

7679
## 📚 Complete Documentation
7780

tritonparse/structured_logging.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,11 @@ def extract_python_source_info(trace_data: Dict[str, Any], source):
351351
return
352352

353353
# Get the original Python source code for the kernel
354-
if isinstance(fn := source.fn, JITFunction) and hasattr(fn, "starting_line_number"):
354+
if (
355+
isinstance(fn := source.fn, JITFunction)
356+
and hasattr(fn, "starting_line_number")
357+
and hasattr(fn, "raw_src")
358+
):
355359
start_line_number = fn.starting_line_number
356360
source_lines = fn.raw_src
357361
else:

0 commit comments

Comments
 (0)