Skip to content

Conversation

@Varal7
Copy link
Contributor

@Varal7 Varal7 commented Jun 24, 2021

Stack from ghstack:

Summary:
This PR is part of a stack aimed to address #58512.
Saves the hooks as a field of SavedVariable with type std::unique_ptr<SavedVariableHooks>.
At this point, from the perspective of the user, register_hooks is still a no-op.
The purpose of the PR is to create the class that will store the hooks. The logic of packing / unpacking will be added in the next PR.

Differential Revision: D29466223

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jun 24, 2021

💊 CI failures summary and remediations

As of commit c3fd243 (more details on the Dr. CI page and at hud.pytorch.org/pr/60663):


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


Preview docs built from this PR

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

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

Click here to manually regenerate this comment.

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jun 24, 2021
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: a0b693f
Pull Request resolved: #60663
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
@Varal7 Varal7 mentioned this pull request Jun 24, 2021
Varal7 added a commit that referenced this pull request Jun 24, 2021
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 42155f0
Pull Request resolved: #60663
@Varal7 Varal7 marked this pull request as draft June 24, 2021 20:33
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
Varal7 added a commit to Varal7/pytorch that referenced this pull request Jun 28, 2021
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 9554de6
Pull Request resolved: pytorch#60663
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jun 28, 2021
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: c01d8fd
Pull Request resolved: #60663
@Varal7 Varal7 marked this pull request as ready for review June 28, 2021 23:49
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jun 29, 2021
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

ghstack-source-id: 4ee05db
Pull Request resolved: #60663
Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

[ghstack-poisoned]
@Varal7
Copy link
Contributor Author

Varal7 commented Jun 29, 2021

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

Summary:

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
**Summary**: 
This PR is part of a stack aimed to address #58512.
Saves the hooks as a field of `SavedVariable` with type `std::unique_ptr<SavedVariableHooks>`. 
At this point,  from the perspective of the user, `register_hooks` is still a no-op. 
The purpose of the PR is to create the class that will store the hooks. The logic of packing / unpacking will be added in the next PR.


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

[ghstack-poisoned]
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.

Looks good on my end.
I'll let @soulitzer get a final look

Copy link
Contributor

@soulitzer soulitzer left a comment

Choose a reason for hiding this comment

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

Looks good to me also!

@soulitzer
Copy link
Contributor

Also what's up with the TORCH_API/THP_CLASS macros, I noticed that you were tweaking that in the past couple iterations. What was the idea behind those changes?

**Summary**: 
This PR is part of a stack aimed to address #58512.
Saves the hooks as a field of `SavedVariable` with type `std::unique_ptr<SavedVariableHooks>`. 
At this point,  from the perspective of the user, `register_hooks` is still a no-op. 
The purpose of the PR is to create the class that will store the hooks. The logic of packing / unpacking will be added in the next PR.


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

[ghstack-poisoned]
@Varal7
Copy link
Contributor Author

Varal7 commented Jul 14, 2021

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

@Varal7
Copy link
Contributor Author

Varal7 commented Jul 14, 2021

Thanks for the review @soulitzer and thank you @albanD for helping me debug this PR.

So TORCH_API is the macro we use to set the visibility of classes / methods for windows builds. However, each library uses its own *something*_API. For instance,TORCH_API is only for libtorch_core but we need to have our python_saved_variable_hooks.h in libtorch_python. There is no such thing as TORCH_PYTHON_API but THP_API is used in things like python_variable.h. Sadly, this failed too for the reason that Alban stated above: py::function is not exposed by pybind, so more visibility problems.
The current form bypasses all problems.

For posterity: if you have linking problems with symbols not found:
1./Try adding a TORCH_API
2/ Move your method definitions outside the header and into the body (cpp file)
3/ Make sure build_variables.bzl and BUILD.bazel are correct
4/ Are you using the incorrect *library*_API macro, should you move your file to a different library?

If you want to debug windows builds and want to ssh
1/ If you have a visibility / linking problem, see above.
2/ You can tag your PR with the ci/master label which triggers CircleCI tests and allows for "rerun with SSH"

**Summary**: 
This PR is part of a stack aimed to address #58512.
Saves the hooks as a field of `SavedVariable` with type `std::unique_ptr<SavedVariableHooks>`. 
At this point,  from the perspective of the user, `register_hooks` is still a no-op. 
The purpose of the PR is to create the class that will store the hooks. The logic of packing / unpacking will be added in the next PR.


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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 15, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 15, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
@Varal7
Copy link
Contributor Author

Varal7 commented Jul 15, 2021

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

Varal7 added a commit that referenced this pull request Jul 15, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 15, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 15, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 15, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 15, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 15, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in ee5a97d.

Varal7 added a commit that referenced this pull request Jul 16, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.
Inplace operations done by the pack_hook on the original tensor (in the case `leaf || !output`) will be caught if the Saved tensor is used by another op.
Inplace operations done by unpack_hook will unfortunately not be caught. We will add a warning in the docs that follows this PR.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 16, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.
Inplace operations done by the pack_hook on the original tensor (in the case `leaf || !output`) will be caught if the Saved tensor is used by another op.
Inplace operations done by unpack_hook will unfortunately not be caught. We will add a warning in the docs that follows this PR.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 16, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.
Inplace operations done by the pack_hook on the original tensor (in the case `leaf || !output`) will be caught if the Saved tensor is used by another op.
Inplace operations done by unpack_hook will unfortunately not be caught. We will add a warning in the docs that follows this PR.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 16, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.
Inplace operations done by the pack_hook on the original tensor (in the case `leaf || !output`) will be caught if the Saved tensor is used by another op.
Inplace operations done by unpack_hook will unfortunately not be caught. We will add a warning in the docs that follows this PR.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 16, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.
Inplace operations done by the pack_hook on the original tensor (in the case `leaf || !output`) will be caught if the Saved tensor is used by another op.
Inplace operations done by unpack_hook will unfortunately not be caught. We will add a warning in the docs that follows this PR.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 16, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.
Inplace operations done by the pack_hook on the original tensor (in the case `leaf || !output`) will be caught if the Saved tensor is used by another op.
Inplace operations done by unpack_hook will unfortunately not be caught. We will add a warning in the docs that follows this PR.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 16, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.
Inplace operations done by the pack_hook on the original tensor (in the case `leaf || !output`) will be caught if the Saved tensor is used by another op.
Inplace operations done by unpack_hook will unfortunately not be caught. We will add a warning in the docs that follows this PR.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
Varal7 added a commit that referenced this pull request Jul 16, 2021
Summary: Fixes #58512
Uses the hooks introduced in #60663: upon registering, the pack hook is called and the returned python object is stored. From then on, whenever we need to unpack it, we will use that python object in combination with the unpack hook.
The packing can be done with gradient tracking disabled as we will add back the correct grad_fn during unpacking.
Inplace operations done by the pack_hook on the original tensor (in the case `leaf || !output`) will be caught if the Saved tensor is used by another op.
Inplace operations done by unpack_hook will unfortunately not be caught. We will add a warning in the docs that follows this PR.


Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

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

[ghstack-poisoned]
@facebook-github-bot facebook-github-bot deleted the gh/varal7/13/head branch July 19, 2021 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants