Lightning-AI / lightning-thunder

Make PyTorch models up to 40% faster! Thunder is a source to source compiler for PyTorch. It enables using different hardware executors at once; across one or thousands of GPUs.
Apache License 2.0
1.15k stars 77 forks source link

Make `numel` a method of TensorProxy not a property attribute #925

Open IvanYashchuk opened 1 month ago

IvanYashchuk commented 1 month ago

🐛 Bug

PyTorch uses tensor.numel() while Thunder's TensorProxy and in the codebase it's used as a property tensor.numel. The property attribute makes more sense, but it conflicts with setting PyTorch as the default language context (https://github.com/Lightning-AI/lightning-thunder/pull/924).

Related PR: https://github.com/Lightning-AI/lightning-thunder/pull/278

We should decide what to do with numel and how to avoid the discrepancy with PyTorch.

tfogal commented 1 month ago

triage review:

Tom-Y-Liu commented 2 weeks ago

Hi there,

I would love to take this issue as my first one!

I've been working on replacing .numel with .numel() everywhere, but encounter some errors when I do so. For instance, after making the replacement here, I get the following error information:

TypeError: 'int' object is not callable

I’ve checked, and it doesn't seem like the issue is related to the numel variable defined in the environment. Could you provide any suggestions on how to resolve this error?

Thanks in advance!