[FIX] Derive constexpr names from JITFunction to fix string annotations#330
[FIX] Derive constexpr names from JITFunction to fix string annotations#330mark14wu wants to merge 6 commits into
Conversation
Verify the sanitizer correctly handles tl.constexpr parameters passed as positional (non-keyword) arguments to a kernel using tl.arange.
Sanitizer Performance Benchmark
Iterations: 1 warmup + 20 measured |
On Python 3.14+ the AST rewriter double-quotes string annotations (e.g. 'tl.constexpr' becomes "'tl.constexpr'"), causing GridExecutor.constexprs to be empty. This makes constexpr parameters go through _implicit_cvt, turning them into tensors, which then causes tl.arange to raise ValueError. Fix: derive constexpr names from the original JITFunction.params (passed via jit_fn kwarg) instead of relying on self.constexprs from the rewritten function.
| # reliable annotation info. The rewritten function's __annotations__ | ||
| # can be corrupted on Python 3.14+ (string annotations get | ||
| # double-quoted), making self.constexprs unreliable. | ||
| if jit_fn is not None and hasattr(jit_fn, "params"): |
There was a problem hiding this comment.
Why not just keep the code in the if path? That is, only checking jit_fn.params
There was a problem hiding this comment.
Good call — removed the fallback. jit_fn is always passed through kwargs from trace.py:run, so the else branch was dead code. Simplified to just {p.name for p in jit_fn.params if p.is_constexpr}.
Always derive constexpr names from jit_fn.params since jit_fn is always available in this code path. Addresses review feedback.
jit_fn is None for nested JIT calls and some Autotune paths. Fall back to self.constexprs when jit_fn is unavailable.
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Closing as stale during PR cleanup. |
Summary
'tl.constexpr'becomes"'tl.constexpr'"), causingGridExecutor.constexprsto be empty. This makes constexpr parameters go through_implicit_cvt, turning them into tensors, which then causestl.arangeto raiseValueError: arange's arguments must be of type tl.constexpr.JITFunction.params(passed viajit_fnkwarg) instead of relying onself.constexprsfrom the rewritten function."tl.constexpr"passed as a positional argument.Test plan
test_constexpr_string_annotation_positional_argpasses with fix, fails without