Skip to content

Support torch.Tensor.view(dtype) - #2213

Merged
t-vi merged 11 commits into
mainfrom
view-with-dtype
Aug 22, 2025
Merged

t-vi merged 11 commits into
mainfrom
view-with-dtype

Conversation

@crcrpar

@crcrpar crcrpar commented Jun 10, 2025

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adding bitcast primitive as nvfuser's bitcast op would be used once it's exposed to Python
Fixes #2212

Comment thread thunder/torch/__init__.py Outdated
@crcrpar
crcrpar force-pushed the view-with-dtype branch 2 times, most recently from 282664e to 9acdeb7 Compare June 13, 2025 07:11
@crcrpar
crcrpar force-pushed the view-with-dtype branch 2 times, most recently from 0029bbf to fadb532 Compare June 25, 2025 03:55
@crcrpar
crcrpar force-pushed the view-with-dtype branch from b20b375 to a73c554 Compare July 1, 2025 19:21
@crcrpar

crcrpar commented Jul 2, 2025

Copy link
Copy Markdown
Collaborator Author

@t-vi @lantiga @mruberry could you review this?

t-vi
t-vi previously requested changes Jul 2, 2025

@t-vi t-vi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This needs

  • inplaciness,
  • correct semantics
torch.ones(8, dtype=torch.bool).view(torch.int64)  # tensor([72340172838076673])

Maybe we should also add tests, just incase.

@crcrpar

crcrpar commented Jul 7, 2025

Copy link
Copy Markdown
Collaborator Author

hmm, I now think this deserves a separate independent prim or clang op

@crcrpar

crcrpar commented Jul 10, 2025

Copy link
Copy Markdown
Collaborator Author

@t-vi I introduced a new primitive so that we call Tensor.view(dtype) in torch executor (and nvfuser's bit cast in the near future).
Could you review this again?

Comment thread thunder/tests/opinfos.py
@t-vi
t-vi dismissed their stale review July 10, 2025 08:40

stale

@t-vi

t-vi commented Jul 10, 2025

Copy link
Copy Markdown
Collaborator

I think the test which branch to take needs improving .

@crcrpar

crcrpar commented Jul 10, 2025

Copy link
Copy Markdown
Collaborator Author

I'm working on fixing the failures

Comment thread thunder/tests/test_grad.py
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
Signed-off-by: Masaki Kozuki <mkozuki@nvidia.com>
@crcrpar crcrpar self-assigned this Aug 21, 2025

@t-vi t-vi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you @crcrpar

@t-vi
t-vi merged commit 1e17b43 into main Aug 22, 2025
58 of 62 checks passed
@t-vi
t-vi deleted the view-with-dtype branch August 22, 2025 14:17
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.

torch.Tensor.view(dtype) is not supported

4 participants