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] calling wp.printf() without arguments causes a KeyError for a missing 'args' key #333

Open
g1n0st opened this issue Oct 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@g1n0st
Copy link

g1n0st commented Oct 25, 2024

Bug Description

import warp as wp

wp.init()

@wp.kernel
def test():
    wp.printf("ok")

wp.launch(test, dim=1)

wp.synchronize()

Error:

Warp 1.4.1 initialized:
   CUDA Toolkit 12.6, Driver 12.2
   Devices:
     "cpu"      : "x86_64"
     "cuda:0"   : "NVIDIA H100 NVL" (93 GiB, sm_90, mempool enabled)
   Kernel cache:
     /home/chang/.cache/warp/1.4.1
Module __main__ 964fa97 load on device 'cuda:0' took 0.29 ms
Traceback (most recent call last):
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 960, in build
    adj.eval(adj.tree.body[0])
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 2628, in eval
    return emit_node(adj, node)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 1548, in emit_FunctionDef
    adj.eval(f)
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 2628, in eval
    return emit_node(adj, node)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 2074, in emit_Expr
    return adj.eval(node.value)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 2628, in eval
    return emit_node(adj, node)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 2192, in emit_Call
    out = adj.add_call(func, args, kwargs, type_args, min_outputs=min_outputs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 1288, in add_call
    func_args, template_args = func.dispatch_func(func.input_types, return_type, bound_args)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/builtins.py", line 2982, in printf_dispatch_func
    func_args = (args["fmt"], *args["args"])
                               ~~~~^^^^^^^^
KeyError: 'args'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/chang/bug.py", line 9, in <module>
    wp.launch(test, dim=1)
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/context.py", line 5003, in launch
    module_exec = kernel.module.load(device)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/context.py", line 1949, in load
    builder = ModuleBuilder(self, self.options, hasher=self.hasher)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/context.py", line 1549, in __init__
    self.build_kernel(kernel)
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/context.py", line 1578, in build_kernel
    kernel.adj.build(self)
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 970, in build
    raise e
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 960, in build
    adj.eval(adj.tree.body[0])
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 2628, in eval
    return emit_node(adj, node)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 1548, in emit_FunctionDef
    adj.eval(f)
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 2628, in eval
    return emit_node(adj, node)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 2074, in emit_Expr
    return adj.eval(node.value)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 2628, in eval
    return emit_node(adj, node)
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 2192, in emit_Call
    out = adj.add_call(func, args, kwargs, type_args, min_outputs=min_outputs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/codegen.py", line 1288, in add_call
    func_args, template_args = func.dispatch_func(func.input_types, return_type, bound_args)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chang/miniconda3/lib/python3.12/site-packages/warp/builtins.py", line 2982, in printf_dispatch_func
    func_args = (args["fmt"], *args["args"])
                               ~~~~^^^^^^^^
KeyError: 'Error while parsing function "test" at /home/chang/bug.py:7:\n    wp.printf("ok")\n;args'

System Information

Warp 1.4.1 initialized:
CUDA Toolkit 12.6, Driver 12.2

@g1n0st g1n0st added the bug Something isn't working label Oct 25, 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

1 participant