Skip to content

Commit d943357

Browse files
Stonepiapytorchmergebot
authored andcommitted
[XPU] Add xpu support of make triton (#126513)
This PR is to add XPU support for `make triton`. If a user wishes to use Triton with XPU support, the user needs to install the [intel-xpu-backend-for-triton](https://github.com/intel/intel-xpu-backend-for-triton). This PR allows the user to easily install Triton for xpu backend support: ``` # clone the pytorch repo export USE_XPU=1 make triton ``` The XPU version of triton will always be built from the source. It will cat the commit id from `.ci/docker/ci_commit_pins/triton-xpu.txt`, for example, `b8c64f64c18d8cac598b3adb355c21e7439c21de`. So the final call would be like: ``` pip install --force-reinstall "git+https://github.com/intel/intel-xpu-backend-for-triton@b8c64f64c18d8cac598b3adb355c21e7439c21de#subdirectory=python" ``` Pull Request resolved: pytorch/pytorch#126513 Approved by: https://github.com/EikanWang, https://github.com/atalman
1 parent 68cc63a commit d943357

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ conda install -c pytorch magma-cuda121 # or the magma-cuda* that matches your C
213213

214214
# (optional) If using torch.compile with inductor/triton, install the matching version of triton
215215
# Run from the pytorch directory after cloning
216+
# For Intel GPU support, please explicitly `export USE_XPU=1` before running command.
216217
make triton
217218
```
218219

scripts/install_triton_wheel.sh

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
#!/bin/bash
22
# Updates Triton to the pinned version for this copy of PyTorch
33
BRANCH=$(git rev-parse --abbrev-ref HEAD)
4-
TRITON_VERSION="pytorch-triton==$(cat .ci/docker/triton_version.txt)"
5-
DOWNLOAD_PYTORCH_ORG="https://download.pytorch.org/whl"
64

7-
if [[ "$BRANCH" =~ .*release.* ]]; then
8-
pip install --index-url ${DOWNLOAD_PYTORCH_ORG}/test/ $TRITON_VERSION
5+
if [[ -z "${USE_XPU}" ]]; then
6+
# Default install from PyTorch source
7+
8+
TRITON_VERSION="pytorch-triton==$(cat .ci/docker/triton_version.txt)"
9+
DOWNLOAD_PYTORCH_ORG="https://download.pytorch.org/whl"
10+
if [[ "$BRANCH" =~ .*release.* ]]; then
11+
pip install --index-url ${DOWNLOAD_PYTORCH_ORG}/test/ $TRITON_VERSION
12+
else
13+
pip install --index-url ${DOWNLOAD_PYTORCH_ORG}/nightly/ $TRITON_VERSION+$(head -c 10 .ci/docker/ci_commit_pins/triton.txt)
14+
fi
915
else
10-
pip install --index-url ${DOWNLOAD_PYTORCH_ORG}/nightly/ $TRITON_VERSION+$(head -c 10 .ci/docker/ci_commit_pins/triton.txt)
16+
# Always install Triton for XPU from source
17+
18+
TRITON_XPU_REPO="https://github.com/intel/intel-xpu-backend-for-triton"
19+
TRITON_XPU_COMMIT_ID="$(cat .ci/docker/ci_commit_pins/triton-xpu.txt)"
20+
21+
# force-reinstall to ensure the pinned version is installed
22+
pip install --force-reinstall "git+${TRITON_XPU_REPO}@${TRITON_XPU_COMMIT_ID}#subdirectory=python"
1123
fi

0 commit comments

Comments
 (0)