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

TypeError with torch.finfo() #457

Closed
Tracked by #266
athitten opened this issue May 24, 2024 · 7 comments · Fixed by #759
Closed
Tracked by #266

TypeError with torch.finfo() #457

athitten opened this issue May 24, 2024 · 7 comments · Fixed by #759
Assignees
Labels
bug Something isn't working nemo Issues needed to support NVIDIA NeMo models.

Comments

@athitten
Copy link

athitten commented May 24, 2024

🐛 Bug

NeMo's Stable Diffusion uses HuggingFace Transformers that uses torch.finfo in one of its operations. When thunder.jit is used with Stable Diffusion, it gives an error:

TypeError (note: full exception trace is shown but execution is paused at: _run_module_as_main)
finfo(): argument 'type' (position 1) must be torch.dtype, not floating

although torch supports the dtype in torch.finfo(dtype) to be either torch.float32 or just float32.

CC: @tfogal

cc @tfogal

@athitten athitten added the bug Something isn't working label May 24, 2024
@tfogal
Copy link
Collaborator

tfogal commented May 24, 2024

Not really understanding this one. We don't appear to have a lookaside for torch.finfo; should we?

@tfogal tfogal added nemo Issues needed to support NVIDIA NeMo models. bug Something isn't working and removed bug Something isn't working labels May 24, 2024
@t-vi
Copy link
Collaborator

t-vi commented Jun 3, 2024

Without a traceback, it is hard to guess:

torch.finfo(thunder.dtypes.float32)

gives

TypeError                                 Traceback (most recent call last)
Cell In[14], line 1
----> 1 torch.finfo(thunder.dtypes.float32)

TypeError: finfo(): argument 'type' (position 1) must be torch.dtype, not floating

likely options:

  • fix gap in translating thunder dtypes to torch.dtype transparently,
  • add torch.finfo lookaside

As an aside: Quite likely, it would help debugging these cases if Thunder objects had more Pythonic representations that informed about the fact that they are thunder objects... (ported over #510 for this)

@athitten
Copy link
Author

@athitten to add the full trace.

@tfogal
Copy link
Collaborator

tfogal commented Jul 1, 2024

dropping 'triage review' until the trace comes in, will revisit then.

@t-vi
Copy link
Collaborator

t-vi commented Jul 9, 2024

Repro:

import torch, thunder

def fn(x):
    return torch.finfo(x.dtype).min

a = torch.randn(5, 5)

jfn = thunder.jit(fn)

jfn(a)

Aside from the obvious implementation strategy of implementing finfo: Maybe it would be nice to do a replacement of thunder dtype (and device) to PyTorch when calling opaque functions.

@k223kim
Copy link
Contributor

k223kim commented Jul 9, 2024

Hello Team! FYI I will be working on this issue. (cc. @t-vi )

@t-vi
Copy link
Collaborator

t-vi commented Jul 9, 2024

Thank you @k223kim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working nemo Issues needed to support NVIDIA NeMo models.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants