From 2138b5692ab72fe3bcdb268dd5291af92f5cac73 Mon Sep 17 00:00:00 2001 From: Quinn Pham Date: Thu, 5 Mar 2026 18:10:38 +0000 Subject: [PATCH 1/2] Add option to disable plugin examples, and turn it off on windows, also guard plugin example tests --- CMakeLists.txt | 10 ++++++++++ examples/plugins/CMakeLists.txt | 5 +++++ test/Plugins/test-dialect-plugin.mlir | 2 +- test/Plugins/test-plugin.mlir | 2 +- test/lit.cfg.py | 4 ++++ test/lit.site.cfg.py.in | 1 + 6 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65dd8e9867..7453e5c20e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,11 @@ include(CTest) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(_triton_plugins_default ON) +if (WIN32) + set(_triton_plugins_default OFF) +endif() + # Options option(TRITON_BUILD_PYTHON_MODULE "Build Python Triton bindings" OFF) option(TRITON_BUILD_PROTON "Build the Triton Proton profiler" ON) @@ -23,6 +28,7 @@ option(TRITON_BUILD_WITH_CCACHE "Build with ccache (if available)" ON) option(TRITON_OFFLINE_BUILD "Build without downloading dependencies" OFF) option(LLVM_BUILD_SHARED_LIBS "Build all libraries as shared libraries instead of static" OFF) +option(TRITON_ENABLE_PLUGINS "Enable building Triton plugins" ${_triton_plugins_default}) set(TRITON_CODEGEN_BACKENDS "" CACHE STRING "Enable different codegen backends") set(TRITON_CACHE_PATH "" CACHE PATH "Path to triton cache") @@ -38,6 +44,10 @@ set(TRITON_CUDART_PATH "" CACHE PATH "Path to CUDA Runtime headers") set(TRITON_CUPTI_INCLUDE_PATH "" CACHE PATH "Path to CUPTI headers") set(TRITON_CUPTI_LIB_PATH "" CACHE PATH "Path to CUPTI libraries") +if (WIN32 AND TRITON_ENABLE_PLUGINS) + message(FATAL_ERROR "TRITON_ENABLE_PLUGINS=ON is not supported on Windows.") +endif() + if(NOT TRITON_CACHE_PATH) message(FATAL_ERROR "TRITON_CACHE_PATH must be set or derivable from TRITON_HOME/HOME/USERPROFILE/HOMEPATH.") endif() diff --git a/examples/plugins/CMakeLists.txt b/examples/plugins/CMakeLists.txt index 6b4a14952b..ff47b9a991 100644 --- a/examples/plugins/CMakeLists.txt +++ b/examples/plugins/CMakeLists.txt @@ -1,3 +1,8 @@ +if (NOT TRITON_ENABLE_PLUGINS) + message(STATUS "TRITON_ENABLE_PLUGINS=OFF: skipping Triton example plugin libraries") + return() +endif() + set(LLVM_TARGET_DEFINITIONS Passes.td) mlir_tablegen(Passes.h.inc -gen-pass-decls -name Plugins) add_public_tablegen_target(TritonPluginsIncGen) diff --git a/test/Plugins/test-dialect-plugin.mlir b/test/Plugins/test-dialect-plugin.mlir index 5751e94b5c..da21f002fa 100644 --- a/test/Plugins/test-dialect-plugin.mlir +++ b/test/Plugins/test-dialect-plugin.mlir @@ -1,7 +1,7 @@ // RUN: TRITON_PASS_PLUGIN_PATH=%shlibdir/../plugins/libMLIRDialectPlugin.so triton-opt -split-input-file --convert-plugin-gpu-to-llvm --convert-triton-gpu-to-llvm %s | \ // RUN: FileCheck %s -// REQUIRES: shared-libs +// REQUIRES: plugins, shared-libs #blocked0 = #ttg.blocked<{sizePerThread = [8], threadsPerWarp = [32], warpsPerCTA = [8], order = [0]}> module attributes {"ttg.num-warps" = 8 : i32} { diff --git a/test/Plugins/test-plugin.mlir b/test/Plugins/test-plugin.mlir index f16ef07882..915533fd2c 100644 --- a/test/Plugins/test-plugin.mlir +++ b/test/Plugins/test-plugin.mlir @@ -2,7 +2,7 @@ // RUN: TRITON_PASS_PLUGIN_PATH=%shlibdir/../plugins/libTritonPluginsTestLib.so triton-opt -split-input-file %s | FileCheck %s -allow-unused-prefixes --check-prefix=CHECK-NOFLAG // RUN: triton-opt -split-input-file %s | FileCheck %s -allow-unused-prefixes --check-prefix=CHECK-BASE -// REQUIRES: shared-libs +// REQUIRES: plugins, shared-libs module attributes {"ttg.num-warps" = 4 : i32, "ttg.target" = "cuda:80"} { // CHECK-PLUGIN: func @foo() diff --git a/test/lit.cfg.py b/test/lit.cfg.py index 09044bebe4..d540d8f868 100644 --- a/test/lit.cfg.py +++ b/test/lit.cfg.py @@ -63,6 +63,10 @@ ToolSubst('%PYTHON', config.python_executable, unresolved='ignore'), ] +# Example plugins are not built if TRITON_ENABLE_PLUGINS is OFF. +if config.enable_plugins: + config.available_features.add("plugins") + # Static libraries are not built if LLVM_BUILD_SHARED_LIBS is ON. if config.build_shared_libs: config.available_features.add("shared-libs") diff --git a/test/lit.site.cfg.py.in b/test/lit.site.cfg.py.in index 59b212a4d2..d074500a90 100644 --- a/test/lit.site.cfg.py.in +++ b/test/lit.site.cfg.py.in @@ -15,6 +15,7 @@ config.mlir_binary_dir = "@MLIR_BINARY_DIR@" config.python_executable = "@Python3_EXECUTABLE@" config.enable_bindings_python = @MLIR_ENABLE_BINDINGS_PYTHON@ config.build_shared_libs = @LLVM_BUILD_SHARED_LIBS@ +config.enable_plugins = @TRITON_ENABLE_PLUGINS@ import lit.llvm From d7617a13ee3a9a153bd3177be80613d1de713700 Mon Sep 17 00:00:00 2001 From: Quinn Pham Date: Thu, 5 Mar 2026 19:04:10 +0000 Subject: [PATCH 2/2] fix unquoted expansion --- test/lit.site.cfg.py.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/lit.site.cfg.py.in b/test/lit.site.cfg.py.in index d074500a90..a891cba83f 100644 --- a/test/lit.site.cfg.py.in +++ b/test/lit.site.cfg.py.in @@ -13,9 +13,9 @@ config.llvm_exe_ext = "@EXEEXT@" config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.mlir_binary_dir = "@MLIR_BINARY_DIR@" config.python_executable = "@Python3_EXECUTABLE@" +config.enable_plugins = "@TRITON_ENABLE_PLUGINS@" config.enable_bindings_python = @MLIR_ENABLE_BINDINGS_PYTHON@ config.build_shared_libs = @LLVM_BUILD_SHARED_LIBS@ -config.enable_plugins = @TRITON_ENABLE_PLUGINS@ import lit.llvm