release/3.7.x#9965
Merged
Merged
Conversation
When loading an extension library, it is possible that the library is
reported invalid by `llvm::sys::DynamicLibrary::getPermanentLibrary`;
e.g., if the loaded library has undefined symbols. When trying to add
dialects in [triton-ext], I observed some garbage output when loading
extensions:
```console
$ LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib
TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
LLVM ERROR: {X��J�iij(��h��[ijh��x����������
Aborted (core dumped) LD_LIBRARY_PATH=llvm-27d654c4-linux-x64/lib TRITON_PASS_PLUGIN_PATH=build/lib/libexample.so triton-dacfe7ad-linux-x64/bin/triton-opt
```
I tracked this down to incorrect usage of `llvm::Twine` and
`llvm::createStringError`. Suspecting that the string messages were not
being moved into the error and thus being corrupted by stack movement, I
switched all uses of `llvm::createStringError` to use the pattern I see
in LLVM. This fixes the garbage error string problem so now I see the
proper error:
```
LLVM ERROR: Failed to load plugin library: triton/build/install/lib64/libtriton.so: undefined symbol: _Py_NoneStruct
```
[triton-ext]: https://github.com/triton-lang/triton-ext
(cherry picked from commit 47f9e51)
(cherry picked from commit fa5aea3)
This is to support add pass cases that take arguments like this one: https://github.com/triton-lang/triton/blob/48079178730beab98330d15e7d672fc1abb3193f/third_party/nvidia/backend/compiler.py#L262 ie ```python passes.ttir.add_convert_to_ttgpuir(pm, f"cuda:{capability}", opt.num_warps, 32, opt.num_ctas) ... passes.ttgpuir.add_f32_dot_tc(pm, emuTF32) ... passes.ttgpuir.add_optimize_dot_operands(pm, capability >= 80) ``` This is handled generically by passing a list of strings, so it would work more like: ```python passes.plugin.add_convert_to_ttgpuir(pm, { f"cuda:{capability}", str(opt.num_warps), '32', str(opt.num_ctas) }) ``` This wasn't added to the registerPasses API because these sort of options should be handled using an llvm `cl::opt` (cherry picked from commit 8ecbfb0) (cherry picked from commit 6584c33)
Adds Top level Python DSL Custom Op extensions. This PR fills out the remaining functionality to define a fully out of tree Custom Op and lowering. Co-authored w/ @plotfi --------- Co-authored-by: Puyan Lotfi <puyan@puyan.org> Co-authored-by: Puyan Lotfi <34139736+plotfi@users.noreply.github.com> (cherry picked from commit 152d5f0) (cherry picked from commit e82ae38)
… through TRITON_EXT_ENABLED (triton-lang#9783) (cherry picked from commit 6cb8445) (cherry picked from commit d9f8bb9)
This changes how we pass data between Triton plugins and Triton. Instead of implementing multiple functions with various signatures, we collect all the pointers into a single `struct PluginInfo` and pass this as a pointer across the host-plugin boundary when `tritonGetPluginInfo` is called. This simplifies things on both the host side (Triton has less ABI surface to worry about) and on the plugin side (less intermediate registration into maps). It also ensures that what we pass is `extern "C"`: we now fully rely on the C ABI, which should avoid a whole category of potential problems down the line. This approach--passing a single struct across the API--is taken from how LLVM implements plugins. E.g., MLIR's [`DialectPlugin`] and [`PassPlugin`] do exactly this. Triton's case is a bit more tricky since we can export multiple passes and dialects from a single plugin. But since libraries are loaded via LLVM's `DynamicLibrary::getPermanentLibrary`, we expect these plugins to have a lifetime spanning the entire program. In other words, the `PluginInfo*` pointer would be leaked if we attempted to teardown Triton mid-process (?) but we simply don't do this. This change also allows us to pass multiple plugins to Triton: we replace `TRITON_PASS_PLUGIN_PATH` with a colon-separated `TRITON_PLUGIN_PATHS`. I tested this over in `triton-ext` and it works as expected. For the rationale behind these changes, see the Triton Extensions [RFCv2] document. [`DialectPlugin`]: https://github.com/llvm/llvm-project/blob/80d6e0b8/mlir/include/mlir/Tools/Plugins/DialectPlugin.h [`PassPlugin`]: https://github.com/llvm/llvm-project/blob/80d6e0b8/mlir/include/mlir/Tools/Plugins/PassPlugin.h [RFCv2]: https://docs.google.com/document/d/1XlxNYahzpHgU3gg0Y8ayopTWK7GRy8eQ5ExDtXt6GZ4 (cherry picked from commit 283dc31) (cherry picked from commit 52372e7)
This PR adds version checking. If `TRITON_PLUGIN_VERSION_CHECK` is unset then only the release version will be checked (ie that both the plugin and Triton were built on version say "3.7.0"). However is `TRITON_PLUGIN_VERSION_CHECK=on` then both the release version and the git hash built on will be checked to match, and finally if `TRITON_PLUGIN_VERSION_CHECK=off` no version checking other than the plugin api version itself will be checked. (cherry picked from commit 8497c84) (cherry picked from commit 4ea5b77)
Merged
atalman
added a commit
that referenced
this pull request
Apr 8, 2026
duplicate of #9965 to pre-release branch rel/3.7 for testing --------- Co-authored-by: Andrey Talman <atalman@fb.com> Co-authored-by: Andrew Brown <andrew@kernelize.ai> Co-authored-by: Puyan Lotfi <34139736+plotfi@users.noreply.github.com> Co-authored-by: Puyan Lotfi <puyan@puyan.org>
atalman
approved these changes
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[triton-ext] Update plugin extension changes for release 3.7.x
cherry-picking the following plugin extension changes since January:
PluginInfo *pointer ([triton-ext] Pass a singlePluginInfo *pointer #9748)