From 6724051c5766fe5bff71ed4b5df5c9dd590a2329 Mon Sep 17 00:00:00 2001 From: Ryan Rock Date: Thu, 30 Jul 2026 22:05:19 -0500 Subject: [PATCH] [CI/Build][AMD] Install triton_kernels via CMake (#50328) Signed-off-by: Ryan Rock Co-authored-by: Andreas Karatzas Co-authored-by: depthfirst-app[bot] <184448029+depthfirst-app[bot]@users.noreply.github.com> Co-authored-by: root --- cmake/external_projects/triton_kernels.cmake | 17 ++++++---- docker/Dockerfile.rocm_base | 2 -- .../experts/gpt_oss_triton_kernels_moe.py | 31 ++++++------------- 3 files changed, 20 insertions(+), 30 deletions(-) diff --git a/cmake/external_projects/triton_kernels.cmake b/cmake/external_projects/triton_kernels.cmake index 2966c78030..8312c1f7ca 100644 --- a/cmake/external_projects/triton_kernels.cmake +++ b/cmake/external_projects/triton_kernels.cmake @@ -1,7 +1,5 @@ # Install OpenAI triton_kernels from https://github.com/triton-lang/triton/tree/main/python/triton_kernels -set(DEFAULT_TRITON_KERNELS_TAG "v3.5.1") - # Set TRITON_KERNELS_SRC_DIR for use with local development with vLLM. We expect TRITON_KERNELS_SRC_DIR to # be directly set to the triton_kernels python directory. if (DEFINED ENV{TRITON_KERNELS_SRC_DIR}) @@ -12,13 +10,20 @@ if (DEFINED ENV{TRITON_KERNELS_SRC_DIR}) ) else() - set(TRITON_GIT "https://github.com/triton-lang/triton.git") - message (STATUS "[triton_kernels] Fetch from ${TRITON_GIT}:${DEFAULT_TRITON_KERNELS_TAG}") + if (VLLM_TARGET_DEVICE STREQUAL "rocm") + set(TRITON_GIT "https://github.com/ROCm/triton.git") + # Pinned from release/internal/3.6.x + set(TRITON_KERNELS_TAG "0f380657dbf3ee86eb57558ff71df24f03b5d4e7") + else() + set(TRITON_GIT "https://github.com/triton-lang/triton.git") + set(TRITON_KERNELS_TAG "v3.5.1") + endif() + message (STATUS "[triton_kernels] Fetch from ${TRITON_GIT}:${TRITON_KERNELS_TAG}") FetchContent_Declare( triton_kernels # TODO (varun) : Fetch just the triton_kernels directory from Triton - GIT_REPOSITORY https://github.com/triton-lang/triton.git - GIT_TAG ${DEFAULT_TRITON_KERNELS_TAG} + GIT_REPOSITORY ${TRITON_GIT} + GIT_TAG ${TRITON_KERNELS_TAG} GIT_PROGRESS TRUE SOURCE_SUBDIR python/triton_kernels/triton_kernels ) diff --git a/docker/Dockerfile.rocm_base b/docker/Dockerfile.rocm_base index a1e2f3c1ce..d923693d11 100644 --- a/docker/Dockerfile.rocm_base +++ b/docker/Dockerfile.rocm_base @@ -121,8 +121,6 @@ RUN cd triton \ && if [ ! -f setup.py ]; then cd python; fi \ && python3 setup.py bdist_wheel --dist-dir=dist \ && mkdir -p /app/install && cp dist/*.whl /app/install -RUN if [ -d triton/python/triton_kernels ]; then pip install build && cd triton/python/triton_kernels \ - && python3 -m build --wheel && cp dist/*.whl /app/install; fi ### diff --git a/vllm/model_executor/layers/fused_moe/experts/gpt_oss_triton_kernels_moe.py b/vllm/model_executor/layers/fused_moe/experts/gpt_oss_triton_kernels_moe.py index 4b0a0b8eca..da2628277d 100644 --- a/vllm/model_executor/layers/fused_moe/experts/gpt_oss_triton_kernels_moe.py +++ b/vllm/model_executor/layers/fused_moe/experts/gpt_oss_triton_kernels_moe.py @@ -80,28 +80,15 @@ def _patch_make_bitmatrix_metadata() -> None: import triton.language as tl try: - if current_platform.is_rocm(): - from triton_kernels.tensor_details import bitmatrix as _bm - from triton_kernels.tensor_details.bitmatrix import ( - BitmatrixMetadata, - _keyed_add, - cdiv, - ) - from triton_kernels.tensor_details.bitmatrix_details.sum_bitmatrix_rows import ( # noqa: E501 - sum_bitmatrix_rows, - ) - else: - from vllm.third_party.triton_kernels.tensor_details import ( - bitmatrix as _bm, - ) - from vllm.third_party.triton_kernels.tensor_details.bitmatrix import ( - BitmatrixMetadata, - _keyed_add, - cdiv, - ) - from vllm.third_party.triton_kernels.tensor_details.bitmatrix_details.sum_bitmatrix_rows import ( # noqa: E501 - sum_bitmatrix_rows, - ) + from triton_kernels.tensor_details import bitmatrix as _bm + from triton_kernels.tensor_details.bitmatrix import ( + BitmatrixMetadata, + _keyed_add, + cdiv, + ) + from triton_kernels.tensor_details.bitmatrix_details.sum_bitmatrix_rows import ( # noqa: E501 + sum_bitmatrix_rows, + ) except ImportError: return