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

Implement Tensor.type #273

Merged
merged 17 commits into from
May 10, 2024
Merged

Conversation

k223kim
Copy link
Contributor

@k223kim k223kim commented Apr 25, 2024

Before submitting
  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure to update the docs?
  • Did you write any new necessary tests?

What does this PR do?

Fixes #177. At the moment, I did not implement non_blocking=True. Any suggestions would be appreciated! Also, the current CI test that fails seems irrelevant to this PR.

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

As always 🚀

@k223kim k223kim changed the title feat: initial implementation of type Implement Tensor.type Apr 25, 2024
@k223kim
Copy link
Contributor Author

k223kim commented Apr 26, 2024

Hey @mruberry, would you be able to check this draft out? Would appreciate it :)

thunder/torch/__init__.py Outdated Show resolved Hide resolved
thunder/torch/__init__.py Outdated Show resolved Hide resolved
thunder/torch/__init__.py Outdated Show resolved Hide resolved
thunder/torch/__init__.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool stuff, @k223kim! I left some comments for you review. These old torch typestrings are a pain, right? I'm glad torch moved away from them.

I look forward to hearing your thoughts!

@k223kim
Copy link
Contributor Author

k223kim commented Apr 26, 2024

Hi @mruberry thank you for carefully going through my code despite the fact that it may not be needed at all. I should have discussed this earlier before implementing it, but again, thanks for the detailed comments.
I do agree that handling strings is a pain and is not good coding (as pr @t-vi ). Let me remove the current implementation and throw an NotImplementedError for cases where dtype is string. I guess now, I am really questioning if this implementation is needed at all. Cause, if we don't accept strings, how is it different from to? 🤔

@mruberry
Copy link
Collaborator

Hi @mruberry thank you for carefully going through my code despite the fact that it may not be needed at all. I should have discussed this earlier before implementing it, but again, thanks for the detailed comments. I do agree that handling strings is a pain and is not good coding (as pr @t-vi ). Let me remove the current implementation and throw an NotImplementedError for cases where dtype is string. I guess now, I am really questioning if this implementation is needed at all. Cause, if we don't accept strings, how is it different from to? 🤔

I think you pointed out that the particular use case we're interested in DOES use strings, and this PR already does a lot of the work, so maybe let's keep them? Just because something is rare doesn't mean it never happens

@k223kim k223kim marked this pull request as ready for review April 29, 2024 04:27
@k223kim
Copy link
Contributor Author

k223kim commented Apr 29, 2024

Hey @mruberry! I have updated this PR based on your comments :) Although I am questioning if the string support is needed or not, I have included them. Feel free to drop it if that is not necessary. Would appreciate if you can check this out!

thunder/tests/opinfos.py Outdated Show resolved Hide resolved
thunder/tests/opinfos.py Outdated Show resolved Hide resolved
thunder/torch/__init__.py Outdated Show resolved Hide resolved
thunder/torch/__init__.py Outdated Show resolved Hide resolved
thunder/torch/__init__.py Outdated Show resolved Hide resolved
thunder/torch/__init__.py Outdated Show resolved Hide resolved
thunder/torch/__init__.py Outdated Show resolved Hide resolved
thunder/torch/__init__.py Outdated Show resolved Hide resolved
thunder/torch/__init__.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @k223kim!

Cool stuff! I made some additional comments for refinements. I'm curious how a couple things work currently. Maybe there's an issue with testing? Check it out and let me know!

@k223kim
Copy link
Contributor Author

k223kim commented Apr 30, 2024

Hi @mruberry! Thanks so much for the review! I have answered some comments and updated the code accordingly. Please let me know if there is a better way to do this :) Appreciate your help as always!

@k223kim
Copy link
Contributor Author

k223kim commented May 1, 2024

Hey @mruberry, thanks for the great explanations and my apologies for the confusion. Hope my code is now easier to understand and maintain :) Would appreciate if you can take a look! 🚀

Copy link
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work with a tricky operator, @k223kim!

@Borda or @t-vi may need to merge this

@mruberry
Copy link
Collaborator

mruberry commented May 9, 2024

ping @t-vi

@t-vi t-vi merged commit dee5b3f into Lightning-AI:main May 10, 2024
37 checks passed
@t-vi
Copy link
Collaborator

t-vi commented May 10, 2024

Thank you @k223kim @mruberry

@github-actions github-actions bot deleted the k223kim/add_tensor_type branch August 10, 2024 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Tensor.type
3 participants