[triton] Python typing improvements#10048
Merged
Merged
Conversation
Contributor
|
Thanks. To confirm it hasn't fixed constexpr problems like the following, right?
|
peterbell10
reviewed
Apr 16, 2026
Collaborator
Author
No, I haven't gotten to that yet. |
peterbell10
approved these changes
Apr 16, 2026
raymondtay
pushed a commit
to raymondtay/triton
that referenced
this pull request
Apr 18, 2026
bingyizh233
pushed a commit
to bingyizh233/triton
that referenced
this pull request
Apr 20, 2026
Contributor
|
We also have diff --git a/python/triton/runtime/jit.py b/python/triton/runtime/jit.py
index eaaffdfbd..0a5460e01 100644
--- a/python/triton/runtime/jit.py
+++ b/python/triton/runtime/jit.py
@@ -10,7 +10,7 @@ import textwrap
from collections import defaultdict
from dataclasses import dataclass
from functools import cached_property
-from typing import Callable, Generic, Iterable, Optional, ParamSpec, TypeVar, overload, Dict, Any, Tuple
+from typing import Callable, Concatenate, Generic, Iterable, Optional, ParamSpec, TYPE_CHECKING, TypeVar, overload, Dict, Any, Tuple
from triton.backends import BaseBackend
from types import ModuleType
@@ -29,6 +29,7 @@ INDENT_PATTERN = re.compile(r"^(?P<indent>[ \t]*)def\s+\w+\s*\(", re.MULTILINE)
T = TypeVar("T")
P = ParamSpec("P")
R = TypeVar("R")
+U = TypeVar("U")
# -----------------------------------------------------------------------------
# Dependencies Finder
@@ -907,6 +908,20 @@ class JITFunction(JITCallable, KernelInterface[T]):
def __call__(self: "JITFunction[Callable[P, R]]", *args: P.args, **kwargs: P.kwargs) -> R:
raise RuntimeError("Cannot call @triton.jit'd outside of the scope of a kernel")
+ if TYPE_CHECKING:
+
+ @overload
+ def __get__(self: "JITFunction[Callable[Concatenate[U, P], R]]", instance: U,
+ owner: Optional[type] = None) -> Callable[P, R]:
+ ...
+
+ @overload
+ def __get__(self, instance: None, owner: Optional[type] = None) -> "JITFunction[T]":
+ ...
+
+ def __get__(self, instance, owner=None):
+ ...
+
def __repr__(self):
return f"JITFunction({self.module}:{self.fn.__qualname__})"to fix member functions on aggregates |
Collaborator
|
PR plz |
5 tasks
leijurv
added a commit
to leijurv/triton
that referenced
this pull request
Apr 23, 2026
Co-authored-by: Saagar Jha <saagar@saagarjha.com>
leijurv
added a commit
to leijurv/triton
that referenced
this pull request
Apr 23, 2026
Co-authored-by: Saagar Jha <saagar@saagarjha.com> Co-authored-by: Claude <noreply@anthropic.com>
peterbell10
pushed a commit
that referenced
this pull request
Apr 29, 2026
@jeffniu-openai said `PR plz` here: #10048 (comment) Co-authored-by: Saagar Jha <saagar@saagarjha.com>
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.
No description provided.