Support string constexpr kernel args; scope googletest to examples#32
Merged
Conversation
Two independent fixes surfaced while building FlagGems' C++ operators against this library on the Enflame (GCU) backend. 1. String constexpr arguments failed to compile. handle_arg_plain() routes every non-Tensor / non-nullopt argument through a runtime branch whose four handlers all evaluate triton_type<T>::name. For a string argument (e.g. a dtype spelled "tl.float32", passed by FlagGems' GCU mm kernel) triton_type has no specialization, so the template failed to instantiate even though such an argument is always a constexpr Triton parameter at runtime. Add a compile-time `else if constexpr` for const char* / char* / std::string / std::string_view that routes strings straight to handle_constexpr, mirroring the existing nullopt handling, so the specialized / non-constexpr paths are never instantiated for a string type. 2. googletest was fetched unconditionally, even for subdirectory consumers that only build the library. add_subdirectory(src) precedes the fetch, so the library itself never needs gtest -- only the examples do. Move the FetchContent(googletest) inside the TRITON_JIT_BUILD_EXAMPLES guard so FetchContent consumers (e.g. FlagGems) no longer download googletest. Verified: FlagGems' flag-gems-cpp-gcu extension now builds against this library with no string-arg compile error and no googletest download. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
chen98038
approved these changes
Jul 13, 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.
Two independent fixes surfaced while building FlagGems' C++ operators against this library on the Enflame (GCU) backend.
1. String constexpr arguments failed to compile
ArgHandle::handle_arg_plain()routes every non-Tensor / non-nulloptargument through a runtime branch whose handlers (handle_specialized,handle_specialized_no_alignment,handle_non_constexpr) all evaluatetriton_type<T>::name. For a string argument — e.g. a dtype spelled"tl.float32", passed by FlagGems' GCUmmkernel —triton_typehas no specialization, so the template failed to instantiate:even though a string argument is always a constexpr Triton parameter at runtime. The CUDA path never passed a string, so it compiled.
Fix: add a compile-time
else if constexprforconst char*/char*/std::string/std::string_viewthat routes strings straight tohandle_constexpr, mirroring the existingnullopthandling, so the specialized / non-constexpr paths are never instantiated for a string type.2. googletest fetched unconditionally
add_subdirectory(src)precedes the googletest fetch, so the library itself never needs gtest — only the examples do. But theFetchContent(googletest)sat outside theTRITON_JIT_BUILD_EXAMPLESguard, so every subdirectory consumer (e.g. FlagGems viaFetchContent) downloaded googletest anyway.Fix: move the googletest fetch inside the
TRITON_JIT_BUILD_EXAMPLESblock.Verification
FlagGems'
flag-gems-cpp-gcuextension now builds against this library with no string-arg compile error and no googletest download.🤖 Generated with Claude Code