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.2k stars 80 forks source link

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

Open IvanYashchuk opened 3 months ago

IvanYashchuk commented 3 months 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 3 months ago

triage review:

Tom-Y-Liu commented 2 months 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!