Skip to content

Save disable_torch_function in ThreadLocalState - #75110

Closed
ezyang wants to merge 2 commits into
gh/ezyang/1113/basefrom
gh/ezyang/1113/head
Closed

ezyang wants to merge 2 commits into
gh/ezyang/1113/basefrom
gh/ezyang/1113/head

Conversation

@ezyang

@ezyang ezyang commented Apr 1, 2022 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

If torch_function was disabled, this TLS should propagate to
other threads.

Although I was thinking about #73942
when I did this, this doesn't actually help solve the problem, because
when I disable torch_function as part of the disabled
torch_function implementation, this is prior to when snapshotting
happens (also snapshotting only happens for Python tensors anyway).

I intend to add some more TLS to this struct soon, which is why it's
a struct and not just a bool.

Testing is not so easy to do because on CPU there isn't an easy way
to get Python code running in another thread.

Signed-off-by: Edward Z. Yang [email protected]

If __torch_function__ was disabled, this TLS should propagate to
other threads.

Although I was thinking about #73942
when I did this, this doesn't actually help solve the problem, because
when I disable __torch_function__ as part of the disabled
__torch_function__ implementation, this is prior to when snapshotting
happens (also snapshotting only happens for Python tensors anyway).

I intend to add some more TLS to this struct soon, which is why it's
a struct and not just a bool.

Testing is not so easy to do because on CPU there isn't an easy way
to get Python code running in another thread.

Signed-off-by: Edward Z. Yang <[email protected]>

[ghstack-poisoned]
@facebook-github-bot

facebook-github-bot commented Apr 1, 2022 •

Copy link
Copy Markdown
Contributor

🔗 Helpful links

💊 CI failures summary and remediations

As of commit 8389bee (more details on the Dr. CI page):


💚 💚 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.

@ezyang
ezyang requested review from albanD and zou3519 April 1, 2022 16:52

@albanD albanD 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.

CI looks like it is in a bad state but the change sounds good.

If __torch_function__ was disabled, this TLS should propagate to
other threads.

Although I was thinking about #73942
when I did this, this doesn't actually help solve the problem, because
when I disable __torch_function__ as part of the disabled
__torch_function__ implementation, this is prior to when snapshotting
happens (also snapshotting only happens for Python tensors anyway).

I intend to add some more TLS to this struct soon, which is why it's
a struct and not just a bool.

Testing is not so easy to do because on CPU there isn't an easy way
to get Python code running in another thread.

Signed-off-by: Edward Z. Yang <ezyangfb.com>

[ghstack-poisoned]
ezyang added a commit that referenced this pull request Apr 1, 2022
If __torch_function__ was disabled, this TLS should propagate to
other threads.

Although I was thinking about #73942
when I did this, this doesn't actually help solve the problem, because
when I disable __torch_function__ as part of the disabled
__torch_function__ implementation, this is prior to when snapshotting
happens (also snapshotting only happens for Python tensors anyway).

I intend to add some more TLS to this struct soon, which is why it's
a struct and not just a bool.

Testing is not so easy to do because on CPU there isn't an easy way
to get Python code running in another thread.

Signed-off-by: Edward Z. Yang <ezyangfb.com>

ghstack-source-id: 90ce891
Pull Request resolved: #75110
@ezyang

ezyang commented Apr 2, 2022

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge this

@github-actions

github-actions Bot commented Apr 2, 2022

Copy link
Copy Markdown
Contributor

Hey @ezyang.
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.

@ezyang ezyang added release notes: composability release notes category topic: bug fixes topic category labels Apr 2, 2022
facebook-github-bot pushed a commit that referenced this pull request Apr 4, 2022
Summary:
If __torch_function__ was disabled, this TLS should propagate to
other threads.

Although I was thinking about #73942
when I did this, this doesn't actually help solve the problem, because
when I disable __torch_function__ as part of the disabled
__torch_function__ implementation, this is prior to when snapshotting
happens (also snapshotting only happens for Python tensors anyway).

I intend to add some more TLS to this struct soon, which is why it's
a struct and not just a bool.

Testing is not so easy to do because on CPU there isn't an easy way
to get Python code running in another thread.

Signed-off-by: Edward Z. Yang <ezyangfb.com>

Pull Request resolved: #75110

Approved by: https://github.com/albanD

Test Plan: contbuild & OSS CI, see https://hud.pytorch.org/commit/pytorch/pytorch/3f108a5cc132f5940553980c2b84947f7d9e1ed2

Reviewed By: atalman

Differential Revision: D35359970

Pulled By: atalman

fbshipit-source-id: 98b3910b05f79f5a4860f12959878d72c6ce6f56
@facebook-github-bot
facebook-github-bot deleted the gh/ezyang/1113/head branch April 5, 2022 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants