Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning a NamedTuple directly is not allowed #6035

Closed
saagarjha opened this issue Feb 27, 2025 · 0 comments · Fixed by #6042
Closed

Returning a NamedTuple directly is not allowed #6035

saagarjha opened this issue Feb 27, 2025 · 0 comments · Fixed by #6042
Labels

Comments

@saagarjha
Copy link
Contributor

Describe the bug

Here's a reproducer:

#!/usr/bin/env python3

import typing
import triton


class Test(typing.NamedTuple):
    test: int


@triton.jit
def create_test():
    return Test(1)


@triton.jit
def test():
    t = create_test()


if __name__ == "__main__":
    test[(1,)]()

Here's the error:

triton.compiler.errors.CompilationError: at 2:4:
def create_test():
    return Test(1)
    ^
AssertionError()

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ubuntu/./test.py", line 22, in <module>
    test[(1,)]()
  File "/home/ubuntu/triton/python/triton/runtime/jit.py", line 336, in <lambda>
    return lambda *args, **kwargs: self.run(grid=grid, warmup=False, *args, **kwargs)
  File "/home/ubuntu/triton/python/triton/runtime/jit.py", line 563, in run
    kernel = self.compile(src, target=target, options=options.__dict__)
  File "/home/ubuntu/triton/python/triton/compiler/compiler.py", line 278, in compile
    module = src.make_ir(options, codegen_fns, module_map, context)
  File "/home/ubuntu/triton/python/triton/compiler/compiler.py", line 81, in make_ir
    return ast_to_ttir(self.fn, self, context=context, options=options, codegen_fns=codegen_fns,
triton.compiler.errors.CompilationError: at 2:8:
def test():
    t = create_test()
        ^

If you assign the tuple to a variable and return that, then it works (but you run into #6034).

Environment details

Triton: main
GPU: GH200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant