Skip to content

Conversation

mikaylagawarecki
Copy link
Contributor

@mikaylagawarecki mikaylagawarecki commented Aug 26, 2022

First step towards #83775

  • only to_padded_tensor is moved to the nested namespace for now
  • following the schema used for special, fft, linalg and other namespaces, nested functions are registered in native_functions.yaml as nested_{function_name} and are bound to the desired Python name in
    torch/nested/__init__.py, and the desired C++ name in torch/csrc/api/include/torch/nested.h.

Question: should we keep the documentation for Tensor.to_padded_tensor or can this deleted since it is shared by torch.nested.to_padded_tensor?

generated nested docs

Stack from ghstack (oldest at bottom):

Differential Revision: D39361148

[ghstack-poisoned]
mikaylagawarecki added a commit that referenced this pull request Aug 26, 2022
ghstack-source-id: f8b46d5
Pull Request resolved: #84102
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Aug 26, 2022

🔗 Helpful links

✅ No Failures (5 Pending)

As of commit 6d9f89f (more details on the Dr. CI page):

Expand to see more

💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Aug 26, 2022
@mikaylagawarecki mikaylagawarecki marked this pull request as draft August 26, 2022 02:18
mikaylagawarecki added a commit that referenced this pull request Aug 26, 2022
ghstack-source-id: fd808c6
Pull Request resolved: #84102
@mikaylagawarecki mikaylagawarecki marked this pull request as ready for review August 26, 2022 20:50
@mikaylagawarecki mikaylagawarecki requested review from bdhirsh, bhosmer and drisspg and removed request for anjali411 and soulitzer August 26, 2022 20:50
@drisspg drisspg added module: nestedtensor NestedTensor tag see issue #25032 release notes: nested tensor Changes that have a direct impact on nested tensors labels Aug 26, 2022
+++++++++++++++++++++++++

The following Tensor methods are related to nested tensors:
The following functions are related to nested tensors:
Copy link
Contributor

Choose a reason for hiding this comment

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

"The following functions are specific to nested tensors:" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, so these will be functions in the nested namespace, hence the change, but they still exist as methods. What do you think would be the best way of putting this across?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that only functions should be here and methods will be documented on the Tensor object directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just to confirm, we still want to_padded_tensor to live as a function in the torch.nested namespace, is that correct?

Copy link
Contributor

Choose a reason for hiding this comment

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

Alban suggested to me that we could potentially remove the method on the tensor base. And use the top level python api to create the method. This python level implementation would under the hood call the torch.nested.to_padded_tensor() function

But yeah I think as long as there is one function exposed in python not having both torch.to_padded_tensor(nt, 0) and torch.nested.to_padded_tensor(nt, 0 ) that is good.


def test_nested_namespace(self):
nt = torch.nested_tensor([torch.randn(2, 3), torch.randn(4, 5)])
result = nt.to_padded_tensor(4)
Copy link
Contributor

Choose a reason for hiding this comment

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

yeah I hope it isn't the pattern duplicate torch.* namespace functions into the aliases because having both feels really wrong

Copy link
Collaborator

Choose a reason for hiding this comment

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

This one is method-only. So there is nothing in torch.*.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ohh see when then added a function that goes in nested namespace? Do we need that? Should only functional variants go in nested namespace?

Copy link
Collaborator

Choose a reason for hiding this comment

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

In general yes because you don't want nested-specific methods on plain Tensor.
But I guess it's too late :p

Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

Sounds good!

+++++++++++++++++++++++++

The following Tensor methods are related to nested tensors:
The following functions are related to nested tensors:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think that only functions should be here and methods will be documented on the Tensor object directly?

"torch.multiprocessing.spawn": [
"Optional"
],
"torch.nested": [
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do you need this since you already have a __all__ there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TestCorrectModuleNames seemed to fail with just the __all__ before adding it here. I'll check again to make sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Double checked this, test_public_bindings.py:test_correct_module_names seems to fail without this


def test_nested_namespace(self):
nt = torch.nested_tensor([torch.randn(2, 3), torch.randn(4, 5)])
result = nt.to_padded_tensor(4)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This one is method-only. So there is nothing in torch.*.

First step towards #83775
- only `to_padded_tensor` is moved to the nested namespace for now
- following the schema used for `special`, `fft`, `linalg` and other namespaces, nested functions are registered in native_functions.yaml as `nested_{function_name}` and are bound to the desired Python name in
`torch/nested/__init__.py`, and the desired C++ name in `torch/csrc/api/include/torch/nested.h`.

**Question**: should we keep the documentation for `Tensor.to_padded_tensor` or can this deleted since it is shared by `torch.nested.to_padded_tensor`?

[generated nested docs](https://docs-preview.pytorch.org/84102/nested.html?highlight=nested#module-torch.nested)




[ghstack-poisoned]
First step towards #83775
- only `to_padded_tensor` is moved to the nested namespace for now
- following the schema used for `special`, `fft`, `linalg` and other namespaces, nested functions are registered in native_functions.yaml as `nested_{function_name}` and are bound to the desired Python name in
`torch/nested/__init__.py`, and the desired C++ name in `torch/csrc/api/include/torch/nested.h`.

**Question**: should we keep the documentation for `Tensor.to_padded_tensor` or can this deleted since it is shared by `torch.nested.to_padded_tensor`?

[generated nested docs](https://docs-preview.pytorch.org/84102/nested.html?highlight=nested#module-torch.nested)




[ghstack-poisoned]
@mikaylagawarecki
Copy link
Contributor Author

@pytorchbot rebase -s

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a rebase job. Check the current status here

@pytorchmergebot
Copy link
Collaborator

Tried to rebase and push PR #84102, but it was already up to date

@mikaylagawarecki
Copy link
Contributor Author

@pytorchbot rebase -s

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a rebase job. Check the current status here

First step towards #83775
- only `to_padded_tensor` is moved to the nested namespace for now
- following the schema used for `special`, `fft`, `linalg` and other namespaces, nested functions are registered in native_functions.yaml as `nested_{function_name}` and are bound to the desired Python name in
`torch/nested/__init__.py`, and the desired C++ name in `torch/csrc/api/include/torch/nested.h`.

~~**Question**: should we keep the documentation for `Tensor.to_padded_tensor` or can this deleted since it is shared by `torch.nested.to_padded_tensor`?~~

[generated nested docs](https://docs-preview.pytorch.org/84102/nested.html?highlight=nested#module-torch.nested)


Differential Revision: [D39361148](https://our.internmc.facebook.com/intern/diff/D39361148)

[ghstack-poisoned]
@pytorchmergebot
Copy link
Collaborator

Successfully rebased gh/mikaylagawarecki/80/orig onto refs/remotes/origin/viable/strict, please pull locally before adding more changes (for example, via ghstack checkout https://github.com/pytorch/pytorch/pull/84102)

pytorchmergebot pushed a commit that referenced this pull request Sep 12, 2022
ghstack-source-id: 1a09181
Pull Request resolved: #84102
@mikaylagawarecki
Copy link
Contributor Author

@mikaylagawarecki has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@pytorchbot merge

(Initiating merge automatically since Phabricator Diff has merged)

@pytorchmergebot
Copy link
Collaborator

@pytorchbot successfully started a merge job. Check the current status here.
The merge job was triggered without a flag. This means that your change will be merged once all checks on your PR have passed (ETA: 0-4 Hours). If this is not the intended behavior, feel free to use some of the other merge options in the wiki.
Please reach out to the PyTorch DevX Team with feedback or questions!

@github-actions
Copy link
Contributor

Hey @mikaylagawarecki.
You've committed this PR, but it does not have both a 'release notes: ...' and 'topics: ...' label. Please add one of each to the PR. The 'release notes: ...' label should represent the part of PyTorch that this PR changes (fx, autograd, distributed, etc) and the 'topics: ...' label should represent the kind of PR it is (not user facing, new feature, bug fix, perf improvement, etc). The list of valid labels can be found here for the 'release notes: ...' and here for the 'topics: ...'.
For changes that are 'topic: not user facing' there is no need for a release notes label.

facebook-github-bot pushed a commit that referenced this pull request Sep 12, 2022
Summary:
Pull Request resolved: #84102

First step towards #83775
- only `to_padded_tensor` is moved to the nested namespace for now
- following the schema used for `special`, `fft`, `linalg` and other namespaces, nested functions are registered in native_functions.yaml as `nested_{function_name}` and are bound to the desired Python name in
`torch/nested/__init__.py`, and the desired C++ name in `torch/csrc/api/include/torch/nested.h`.

~~**Question**: should we keep the documentation for `Tensor.to_padded_tensor` or can this deleted since it is shared by `torch.nested.to_padded_tensor`?~~

[generated nested docs](https://docs-preview.pytorch.org/84102/nested.html?highlight=nested#module-torch.nested)

Test Plan: Imported from OSS

Reviewed By: drisspg

Differential Revision: D39361148

Pulled By: mikaylagawarecki

fbshipit-source-id: add218c3e05a6922735b32c248adde4463dd3f4d
@mikaylagawarecki mikaylagawarecki added the topic: docs topic category label Sep 12, 2022
@facebook-github-bot facebook-github-bot deleted the gh/mikaylagawarecki/80/head branch June 8, 2023 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged module: nestedtensor NestedTensor tag see issue #25032 oncall: jit Add this issue/PR to JIT oncall triage queue release notes: nested tensor Changes that have a direct impact on nested tensors topic: docs topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants