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

symbolic cache policy can't handle string inputs properly. #1710

Open
jjsjann123 opened this issue Jan 28, 2025 · 0 comments
Open

symbolic cache policy can't handle string inputs properly. #1710

jjsjann123 opened this issue Jan 28, 2025 · 0 comments
Assignees

Comments

@jjsjann123
Copy link
Collaborator

🐛 Bug

import thunder
import torch
 
device = "cuda"
 
def foo(b):
    # TODO: 'device=device' doesn't work for "symbolic values" cache policy
    a = torch.arange(24, device=device).reshape(3, 8)
    return a + b
 
jfoo = thunder.jit(foo, cache="symbolic values")
 
out = jfoo(5)

The script hits

  File "/volume/thunder_jit.py", line 9, in foo
    a = torch.arange(24, device=device).reshape(3, 8)
^^^^^^^^^^^^^^^^^^
  File "/opt/pytorch/lightning-thunder/thunder/core/interpreter.py", line 1302, in wrapping_wrapper
    res = ufn(*uargs, **ukwargs)
          ^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/pytorch/lightning-thunder/thunder/core/jit_ext.py", line 374, in wrapper
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/pytorch/lightning-thunder/thunder/core/symbol.py", line 323, in __call__
    result = self.meta(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/pytorch/lightning-thunder/thunder/core/langctxs.py", line 136, in _fn
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/opt/pytorch/lightning-thunder/thunder/torch/__init__.py", line 573, in arange
    device = maybe_get_default_device(device)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/pytorch/lightning-thunder/thunder/torch/__init__.py", line 130, in maybe_get_default_device
    return device or get_default_device()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/pytorch/lightning-thunder/thunder/core/proxies.py", line 333, in __bool__
    raise NotImplementedError(f"__bool__ is not implemented for {type(self)}")
NotImplementedError: __bool__ is not implemented for <class 'thunder.core.proxies.StringProxy'>

inline device="cuda", the issue goes away. It also only errors out with symbolic values cache, which is not surprising since the other cache would hard code the string as a constant.

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

No branches or pull requests

1 participant