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

[BUG] Typed Tuple Returns in Warp Cause Error #302

Closed
yzx9 opened this issue Sep 1, 2024 · 2 comments
Closed

[BUG] Typed Tuple Returns in Warp Cause Error #302

yzx9 opened this issue Sep 1, 2024 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@yzx9
Copy link

yzx9 commented Sep 1, 2024

Bug Description

Warp supports multi-value returns, but it seems that they cannot be properly typed.

Reproduction Steps

import warp as wp


@wp.kernel
def kernel():
    i, j = wp.tid()
    mod(i, j + 1)


@wp.func
def mod(a: int, b: int) -> tuple[int, int]:
    return a // b, a % b


wp.launch(kernel, dim=(100, 10))

Actual Outcome

The code fails with the following error message:

Warp NVRTC compilation error 6: NVRTC_ERROR_COMPILATION (/builds/omniverse/warp/warp/native/warp.cu:2577)
default_program(96): error: namespace "wp" has no member "tuple"
          wp::tuple var_4;
              ^

default_program(104): error: too few arguments in function call
          var_4 = mod(var_0, var_3);
                                  ^

default_program(121): error: namespace "wp" has no member "tuple"
          wp::tuple var_4;
              ^

default_program(128): error: namespace "wp" has no member "tuple"
          wp::tuple adj_4 = {};
              ^

default_program(136): error: too few arguments in function call
          var_4 = mod(var_0, var_3);
                                  ^

default_program(139): error: too few arguments in function call
          adj_mod(var_0, var_3, adj_0, adj_3, adj_4);
                                                   ^

6 errors detected in the compilation of "default_program".
Module __main__ b019979 load on device 'cuda:0' took 70.02 ms  (error)
Traceback (most recent call last):
  File "/home/yzx9/git/morphtesser/morphtesser/test.py", line 15, in <module>
    wp.launch(kernel, dim=(100, 10))
  File "/home/yzx9/.cache/pypoetry/virtualenvs/morphtesser-EpsGKO6L-py3.12/lib/python3.12/site-packages/warp/context.py", line 4693, i
n launch
    if not module.load(device):
           ^^^^^^^^^^^^^^^^^^^
  File "/home/yzx9/.cache/pypoetry/virtualenvs/morphtesser-EpsGKO6L-py3.12/lib/python3.12/site-packages/warp/context.py", line 1828, i
n load
    raise (e)
  File "/home/yzx9/.cache/pypoetry/virtualenvs/morphtesser-EpsGKO6L-py3.12/lib/python3.12/site-packages/warp/context.py", line 1816, i
n load
    warp.build.build_cuda(
  File "/home/yzx9/.cache/pypoetry/virtualenvs/morphtesser-EpsGKO6L-py3.12/lib/python3.12/site-packages/warp/build.py", line 30, in bu
ild_cuda
    raise Exception(f"CUDA kernel build failed with error code {err}")
Exception: CUDA kernel build failed with error code 6

Change tuple to typing.Tuple receive same results. However, if the typing is removed, the code works as expected.

Excepted

The code should work correctly with typed multi-value returns.

System Information

Warp 1.3.1 initialized:
CUDA Toolkit 12.5, Driver 12.5
Devices:
"cpu" : "CPU"
"cuda:0" : "NVIDIA GeForce RTX 4090" (24 GiB, sm_89, mempool enabled)
Kernel cache:
/home/yzx9/.cache/warp/1.3.1

@yzx9 yzx9 added the bug Something isn't working label Sep 1, 2024
@christophercrouzet christophercrouzet self-assigned this Sep 1, 2024
@christophercrouzet
Copy link
Member

Hi @yzx9, thanks for reporting this issue, we'll look into it!

shi-eric pushed a commit that referenced this issue Sep 5, 2024
shi-eric pushed a commit that referenced this issue Sep 5, 2024
Fix `wp.func` With `Tuple` As a Return Type Hint

Closes GH-302

See merge request omniverse/warp!719
@christophercrouzet
Copy link
Member

Hi @yzx9, this has now been addressed with commit e539355 which has been merged to main and will be included in a future release. Please let us know if you find any other issue!

HydrogenSulfate pushed a commit to HydrogenSulfate/warp that referenced this issue Sep 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants