From 30d7e7a1cd1b1a4b5a65bef80278afffe0cbb2ba Mon Sep 17 00:00:00 2001 From: Stonepia Date: Thu, 22 Aug 2024 23:18:44 +0000 Subject: [PATCH] [XPU] Fix patch for old llvm package error for triton xpu (#134204) Fixes #134199 The PR #133694 does a workaround to replace the str `"https://tritonlang.blob.core.windows.net/llvm-builds/"` with `"https://oaitriton.blob.core.windows.net/public/llvm-builds/"` in `triton/python/setup.py`. However, in [newer version of Triton](https://github.com/triton-lang/triton/commit/06e6799f4eba6035ec35c528e8fefd3d4d724b6f), it has already been changed to `"https://oaitriton.blob.core....` and don't need to be replaced. But formerly, this will throw a runtime error. This PR makes the `check_and_replace` logic won't fail in such a scenario. Both the old link and the newer link could work. Also note that the `.ci/docker/common/install_triton.sh` does not need the fix, because its `sed` command won't be in effect if there is no such pattern. Pull Request resolved: https://github.com/pytorch/pytorch/pull/134204 Approved by: https://github.com/chuanqi129, https://github.com/EikanWang, https://github.com/atalman --- .github/scripts/build_triton_wheel.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/scripts/build_triton_wheel.py b/.github/scripts/build_triton_wheel.py index c064b59ad93..7ee2cb4b8e6 100644 --- a/.github/scripts/build_triton_wheel.py +++ b/.github/scripts/build_triton_wheel.py @@ -54,13 +54,19 @@ def patch_init_py( def patch_setup_py(path: Path) -> None: with open(path) as f: orig = f.read() - orig = check_and_replace( - orig, - "https://tritonlang.blob.core.windows.net/llvm-builds/", - "https://oaitriton.blob.core.windows.net/public/llvm-builds/", - ) - with open(path, "w") as f: - f.write(orig) + try: + orig = check_and_replace( + orig, + "https://tritonlang.blob.core.windows.net/llvm-builds/", + "https://oaitriton.blob.core.windows.net/public/llvm-builds/", + ) + with open(path, "w") as f: + f.write(orig) + except RuntimeError as e: + print( + f"Applying patch_setup_py() for llvm-build package failed: {e}.", + "If you are trying to build a newer version of Triton, you can ignore this.", + ) def build_triton(