Skip to content

Commit 447ffe3

Browse files
authored
Remove triton submodule and add triton-hash.txt to track the triton commit ID (#344)
This PR removes the Triton submodule and replaces it with a hash file (`triton-hash.txt`) to track the Triton version. This change provides greater flexibility in the Triton versions that triton-shared can be built with. All relevant files have been updated accordingly. After this PR is landed, the installation steps will be ```sh export TRITON_PLUGIN_DIRS=$(pwd)/triton_shared git clone https://github.com/microsoft/triton-shared.git triton_shared git clone https://github.com/triton-lang/triton.git cd triton && git checkout $(cat ../triton_shared/triton-hash.txt) ... // follow the same steps as before to build Triton ```
1 parent 6b0f5a0 commit 447ffe3

File tree

13 files changed

+84
-33
lines changed

13 files changed

+84
-33
lines changed

.clang-format

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/test-plugin.yml

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,18 @@ jobs:
3939
with:
4040
ref: ${{ inputs.triton-shared-ref }}
4141
path: triton_shared
42-
# Also checkout triton submodule
43-
submodules: recursive
42+
43+
- name: Checkout triton based on triton-hash.txt
44+
run: |
45+
git clone https://github.com/triton-lang/triton.git triton
46+
cd triton
47+
HASH="$(cat ../triton_shared/triton-hash.txt)"
48+
echo "Checking out Triton commit: ${HASH}"
49+
git checkout "${HASH}"
4450
4551
- name: Checkout triton at ${{ inputs.triton-ref }}
4652
if: ${{ inputs.triton-ref }}
47-
working-directory: triton_shared/triton
53+
working-directory: triton
4854
run: |
4955
git checkout ${{ inputs.triton-ref }}
5056
git log -1
@@ -58,13 +64,13 @@ jobs:
5864
echo "PATH=${HOME}/.local/bin:${PATH}" >> "${GITHUB_ENV}"
5965
6066
- name: Check pre-commit
61-
working-directory: triton_shared/triton
67+
working-directory: triton
6268
run: |
6369
python3 -m pip install --upgrade pre-commit
6470
python3 -m pre_commit run --all-files --verbose
6571
6672
- name: Build/Install Triton
67-
working-directory: triton_shared/triton
73+
working-directory: triton
6874
run: |
6975
python3 -m pip install --upgrade pip
7076
python3 -m pip install cmake==3.24 ninja pytest-xdist pybind11 setuptools
@@ -74,7 +80,7 @@ jobs:
7480
TRITON_BUILD_WITH_CLANG_LLD=true TRITON_BUILD_WITH_CCACHE=true python3 -m pip install --no-build-isolation -vvv '.[tests]'
7581
7682
- name: Run shared middle-layer lit tests
77-
working-directory: triton_shared/triton
83+
working-directory: triton
7884
run: |
7985
python3 -m pip install lit
8086
LIT_TEST_DIR="build/$(ls build | grep -i cmake)/third_party/triton_shared/test"
@@ -89,7 +95,7 @@ jobs:
8995
python3 -m pip install pytest
9096
9197
- name: Prepare CPU backend environment
92-
working-directory: triton_shared/triton
98+
working-directory: triton
9399
run: |
94100
CMAKE_BUILD_DIR=$(ls $(pwd)/build | grep -i cmake)
95101
LLVM_BINARY_DIR=$(find ${HOME}/.triton/llvm/ -name bin | head -1)
@@ -117,7 +123,14 @@ jobs:
117123
with:
118124
ref: ${{ inputs.triton-shared-ref }}
119125
path: triton_shared
120-
submodules: recursive
126+
127+
- name: Checkout triton based on triton-hash.txt
128+
run: |
129+
git clone https://github.com/triton-lang/triton.git triton
130+
cd triton
131+
HASH="$(cat ../triton_shared/triton-hash.txt)"
132+
echo "Checking out Triton commit: ${HASH}"
133+
git checkout "${HASH}"
121134
122135
- name: Clear Triton Cache
123136
run: |
@@ -132,13 +145,13 @@ jobs:
132145
echo "PATH=${HOME}/.local/bin:${PATH}" >> "${GITHUB_ENV}"
133146
134147
- name: Check pre-commit
135-
working-directory: triton_shared/triton
148+
working-directory: triton
136149
run: |
137150
python3 -m pip install --upgrade pre-commit
138151
python3 -m pre_commit run --all-files --verbose
139152
140153
- name: Build/Install Triton
141-
working-directory: triton_shared/triton
154+
working-directory: triton
142155
run: |
143156
python3 -m pip install --upgrade pip
144157
python3 -m pip install cmake==3.24 ninja pytest-xdist pybind11 setuptools
@@ -148,7 +161,7 @@ jobs:
148161
TRITON_BUILD_WITH_CLANG_LLD=true TRITON_BUILD_WITH_CCACHE=true python3 -m pip install --no-build-isolation -vvv '.[tests]'
149162
150163
- name: Run shared middle-layer lit tests
151-
working-directory: triton_shared/triton
164+
working-directory: triton
152165
run: |
153166
python3 -m pip install lit
154167
LIT_TEST_DIR="build/$(ls build | grep -i cmake)/third_party/triton_shared/test"
@@ -163,7 +176,7 @@ jobs:
163176
python3 -m pip install pytest
164177
165178
- name: Prepare CPU backend environment
166-
working-directory: triton_shared/triton
179+
working-directory: triton
167180
run: |
168181
CMAKE_BUILD_DIR=$(ls $(pwd)/build | grep -i cmake)
169182
LLVM_BINARY_DIR=$(find ${HOME}/.triton/llvm/ -name bin | head -1)

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
.cache
33
compile_commands.json
44
build/*
5-
.vscode/*
5+
.vscode/*
6+
/.clang-format
7+
test_core.py
8+
test_annotations.py

CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) # Tablegen'd files
99
include_directories(${Python3_INCLUDE_DIR})
1010
include_directories(${pybind11_INCLUDE_DIR})
1111

12+
function(add_symlink source_file link_name)
13+
if (EXISTS ${source_file})
14+
file(CREATE_LINK ${source_file} ${link_name} SYMBOLIC)
15+
else()
16+
message(WARNING "${source_file} not found. Skipping symlink creation for ${link_name}.")
17+
endif()
18+
endfunction()
19+
1220
add_subdirectory(include)
1321
add_subdirectory(lib)
1422
add_subdirectory(test)
@@ -18,3 +26,16 @@ if (TRITON_SHARED_BUILD_CPU_BACKEND)
1826
add_triton_plugin(TritonShared ${CMAKE_CURRENT_SOURCE_DIR}/triton_shared.cc LINK_LIBS TritonSharedAnalysis TritonToLinalg TritonTilingExtIR)
1927
target_link_libraries(TritonShared PRIVATE Python3::Module pybind11::headers)
2028
endif()
29+
30+
# Add symlinks to selected pytest files and the clang-format setting in triton. The tests are imported into triton-shared’s test folder to
31+
# run under triton-shared's conftest configuration, and the clang-format link ensures consistent code style enforcement across both repositories.
32+
cmake_path(APPEND CMAKE_CURRENT_SOURCE_DIR "python" "examples" "test_core.py" OUTPUT_VARIABLE TRITON_SHARED_TEST_CORE)
33+
cmake_path(APPEND CMAKE_CURRENT_SOURCE_DIR "python" "examples" "test_annotations.py" OUTPUT_VARIABLE TRITON_SHARED_TEST_ANNOTATIONS)
34+
cmake_path(APPEND CMAKE_CURRENT_SOURCE_DIR ".clang-format" OUTPUT_VARIABLE TRITON_SHARED_CLANG_FORMAT_SETTING)
35+
cmake_path(APPEND CMAKE_SOURCE_DIR "python" "test" "unit" "language" "test_core.py" OUTPUT_VARIABLE TRITON_TEST_CORE)
36+
cmake_path(APPEND CMAKE_SOURCE_DIR "python" "test" "unit" "language" "test_annotations.py" OUTPUT_VARIABLE TRITON_TEST_ANNOTATIONS)
37+
cmake_path(APPEND CMAKE_SOURCE_DIR ".clang-format" OUTPUT_VARIABLE TRITON_CLANG_FORMAT_SETTING)
38+
39+
add_symlink(${TRITON_TEST_CORE} ${TRITON_SHARED_TEST_CORE})
40+
add_symlink(${TRITON_TEST_ANNOTATIONS} ${TRITON_SHARED_TEST_ANNOTATIONS})
41+
add_symlink(${TRITON_CLANG_FORMAT_SETTING} ${TRITON_SHARED_CLANG_FORMAT_SETTING})

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ You need to set the `TRITON_PLUGIN_DIRS` environment variable to the location of
2525
```
2626
export TRITON_PLUGIN_DIRS=$(pwd)/triton_shared
2727
28-
git clone --recurse-submodules https://github.com/microsoft/triton-shared.git triton_shared
29-
cd triton_shared/triton
28+
git clone https://github.com/microsoft/triton-shared.git triton_shared
29+
git clone https://github.com/triton-lang/triton.git
30+
cd triton && git checkout $(cat ../triton_shared/triton-hash.txt)
3031
```
3132

3233
To build with Clang:

python/examples/test_annotations.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

python/examples/test_core.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

triton

Submodule triton deleted from ec8cb09

triton-hash.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ec8cb09329cf25ac241a7dee1eea5a5d94daef8a

triton-san/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ git clone --recurse-submodules https://github.com/microsoft/triton-shared.git
3838
triton-shared/triton-san/build.sh
3939
```
4040
**Note: because LLVM takes a long time to build, the initial run of `build.sh` may exceed 20 minutes. On later runs, the build script reuses the Python virtual environment and LLVM binary to speed up the build of `triton`, `triton-shared`, and `triton-san`.**
41+
4142
After installation, `build.sh` generates the following folders alongside the `triton-shared` repository.
4243
```
43-
llvm triton-san triton-shared venv
44+
llvm triton triton-san triton-shared venv
4445
```
4546
- `llvm`: the custom LLVM source and binary,
46-
- `venv`: Python environment with TritonSan-enabled Triton package installed,
47+
- `triton` the triton source and binary,
4748
- `triton-san`: TritonSan driver script and associated files.
49+
- `venv`: Python environment with TritonSan-enabled Triton package installed,
4850

4951
## Usage
5052
To use TritonSan, run the TritonSan driver script (`triton-san/triton-san`) with the target Triton program and its corresponding inputs. We also provide two sample Triton programs containing known bugs, which `build.sh` installs into the `triton-san/examples` directory.

0 commit comments

Comments
 (0)