Skip to content

Modernize LoggingTensorMode #77667

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

Closed
wants to merge 6 commits into from
Closed

Conversation

soulitzer
Copy link
Contributor

@soulitzer soulitzer commented May 17, 2022

This PR:

  • updates LoggingTensorMode to use the new PythonDispatchMode
  • updates some tests that use LoggingTensorMode to properly use the new version

Open questions:

  • why is the old python mode still working? Do we intend to keep it? (a small bit of additional logic is necessary to support it)
    • This PR updates some of the tests that test old python mode behavior (e.g., all outputs are wrapped). If we intend to support old python mode long term we should bring it back, and just add new tests instead.

TODO (this PR):

  • Test nesting behavior

Stack from ghstack:

See #77544

[ghstack-poisoned]
soulitzer added a commit that referenced this pull request May 17, 2022
ghstack-source-id: 9a73890
Pull Request resolved: #77667
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented May 17, 2022

🔗 Helpful links

❌ 2 New Failures

As of commit 60b4ec8 (more details on the Dr. CI page):

Expand to see more
  • 2/2 failures introduced in this PR

🕵️ 2 new failures recognized by patterns

The following CI failures do not appear to be due to upstream breakages

See GitHub Actions build pull / linux-xenial-py3.7-gcc5.4 / test (backwards_compat, 1, 1, linux.2xlarge) (1/2)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-05-24T01:37:20.0827200Z The PR is introduc...m to confirm whether this change is wanted or not.
2022-05-24T01:37:20.0813984Z processing existing schema:  text(__torch__.torch.classes.profiling.SourceRef _0) -> (str _0)
2022-05-24T01:37:20.0815304Z processing existing schema:  count(__torch__.torch.classes.profiling.InstructionStats _0) -> (int _0)
2022-05-24T01:37:20.0816408Z processing existing schema:  duration_ns(__torch__.torch.classes.profiling.InstructionStats _0) -> (int _0)
2022-05-24T01:37:20.0817833Z processing existing schema:  source(__torch__.torch.classes.profiling.SourceStats _0) -> (__torch__.torch.classes.profiling.SourceRef _0)
2022-05-24T01:37:20.0819431Z processing existing schema:  line_map(__torch__.torch.classes.profiling.SourceStats _0) -> (Dict(int, __torch__.torch.classes.profiling.InstructionStats) _0)
2022-05-24T01:37:20.0820769Z processing existing schema:  __init__(__torch__.torch.classes.profiling._ScriptProfile _0) -> (NoneType _0)
2022-05-24T01:37:20.0821460Z processing existing schema:  enable(__torch__.torch.classes.profiling._ScriptProfile _0) -> (NoneType _0)
2022-05-24T01:37:20.0822869Z processing existing schema:  disable(__torch__.torch.classes.profiling._ScriptProfile _0) -> (NoneType _0)
2022-05-24T01:37:20.0824454Z processing existing schema:  _dump_stats(__torch__.torch.classes.profiling._ScriptProfile _0) -> (__torch__.torch.classes.profiling.SourceStats[] _0)
2022-05-24T01:37:20.0826953Z processing existing schema:  __init__(__torch__.torch.classes.dist_rpc.WorkerInfo _0, str _1, int _2) -> (NoneType _0)
2022-05-24T01:37:20.0827200Z The PR is introducing backward incompatible changes to the operator library. Please contact PyTorch team to confirm whether this change is wanted or not. 
2022-05-24T01:37:20.0827221Z 
2022-05-24T01:37:20.0827294Z Broken ops: [
2022-05-24T01:37:20.0827541Z 	prims::uniform(int[] shape, *, Scalar low, Scalar high, int dtype, Device device) -> (Tensor)
2022-05-24T01:37:20.0827800Z 	prims::empty_strided(int[] shape, int[] strides, *, int dtype, Device device, bool requires_grad) -> (Tensor)
2022-05-24T01:37:20.0828113Z 	prims::var(Tensor inp, int[]? dims, *, int correction, int? output_dtype=None) -> (Tensor)
2022-05-24T01:37:20.0828288Z 	prims::where(Tensor pred, Tensor a, Tensor b) -> (Tensor)
2022-05-24T01:37:20.0828441Z 	prims::cat(Tensor[] tensors, int dim) -> (Tensor)
2022-05-24T01:37:20.0828578Z 	prims::log10(Tensor self) -> (Tensor)
2022-05-24T01:37:20.0828723Z 	prims::fill(Tensor self, Scalar value) -> (Tensor)
2022-05-24T01:37:20.0828901Z 	prims::exp2(Tensor self) -> (Tensor)

See GitHub Actions build pull / linux-bionic-py3.7-clang9 / test (default, 1, 2, linux.2xlarge) (2/2)

Step: "Test" (full log | diagnosis details | 🔁 rerun)

2022-05-24T02:22:07.3712395Z FAIL [10.421s]: test_fs_sharing (__main__.TestMultiprocessing)
2022-05-24T02:22:07.3439826Z   test_non_leaf_variable_sharing (__main__.TestMultiprocessing) ... ok (0.001s)
2022-05-24T02:22:07.3481301Z   test_parameter_sharing (__main__.TestMultiprocessing) ... /opt/conda/lib/python3.7/site-packages/torch/utils/hooks.py:62: UserWarning: backward hook <function TestMultiprocessing._test_autograd_sharing.<locals>.hook at 0x7f2b8fbd5e60> on tensor will not be serialized.  If this is expected, you can decorate the function with @torch.utils.hooks.unserializable_hook to suppress this warning
2022-05-24T02:22:07.3481971Z   "to suppress this warning".format(repr(hook)))
2022-05-24T02:22:07.3530162Z ok (0.009s)
2022-05-24T02:22:07.3574223Z   test_variable_sharing (__main__.TestMultiprocessing) ... /opt/conda/lib/python3.7/site-packages/torch/utils/hooks.py:62: UserWarning: backward hook <function TestMultiprocessing._test_autograd_sharing.<locals>.hook at 0x7f2b8fbb98c0> on tensor will not be serialized.  If this is expected, you can decorate the function with @torch.utils.hooks.unserializable_hook to suppress this warning
2022-05-24T02:22:07.3574878Z   "to suppress this warning".format(repr(hook)))
2022-05-24T02:22:07.3701362Z ok (0.017s)
2022-05-24T02:22:07.3711558Z   test_wrong_cuda_fork (__main__.TestMultiprocessing) ... skip: CUDA not available (0.001s)
2022-05-24T02:22:07.3711933Z 
2022-05-24T02:22:07.3712054Z ======================================================================
2022-05-24T02:22:07.3712395Z FAIL [10.421s]: test_fs_sharing (__main__.TestMultiprocessing)
2022-05-24T02:22:07.3713162Z ----------------------------------------------------------------------
2022-05-24T02:22:07.3713431Z Traceback (most recent call last):
2022-05-24T02:22:07.3713702Z   File "test_multiprocessing.py", line 347, in test_fs_sharing
2022-05-24T02:22:07.3713972Z     self._test_sharing(repeat=TEST_REPEATS)
2022-05-24T02:22:07.3714226Z   File "test_multiprocessing.py", line 288, in _test_sharing
2022-05-24T02:22:07.3714457Z     test_fill()
2022-05-24T02:22:07.3714692Z   File "test_multiprocessing.py", line 258, in test_fill
2022-05-24T02:22:07.3715145Z     self.assertTrue(e.is_set())
2022-05-24T02:22:07.3715357Z AssertionError: False is not true
2022-05-24T02:22:07.3715557Z 

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.

@soulitzer soulitzer changed the title Modernize LoggingTensorMode [WIP] Modernize LoggingTensorMode May 17, 2022
@soulitzer soulitzer changed the title [WIP] Modernize LoggingTensorMode Modernize LoggingTensorMode May 18, 2022
@soulitzer soulitzer requested a review from ezyang May 18, 2022 15:45
This PR:
- updates LoggingTensorMode to use the new PythonDispatchMode
- updates some tests that use LoggingTensorMode to properly use the new version

Open questions:
- why is the old python mode still working? Do we intend to keep it? (a small bit of additional logic is necessary to support it)


See #77544

[ghstack-poisoned]
@ezyang
Copy link
Contributor

ezyang commented May 18, 2022

IMO we should just dump old python mode

@ezyang ezyang requested review from zou3519 and albanD May 18, 2022 16:26

@contextlib.contextmanager
def capture_logs_with_logging_tensor_mode():
with push_torch_dispatch_mode(LoggingTensorMode(inner=None)), capture_logs(True) as logs:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

TODO: shouldn't don't need inner

Copy link
Contributor

Choose a reason for hiding this comment

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

@samdow yeah this looks like we should just support direct constructor lol

Copy link
Contributor

@samdow samdow May 20, 2022

Choose a reason for hiding this comment

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

We should also add a test for this function

I'm pretty sure that as written this will error for the inner reason. Also flags to me that I really dislike that the argument for push_torch_dispatch_mode is going to be a constructor for a Mode while enable_torch_dispatch_mode is going to be the Mode instance. TODO (@samdow): fix that

This PR:
- updates LoggingTensorMode to use the new PythonDispatchMode
- updates some tests that use LoggingTensorMode to properly use the new version

Open questions:
- why is the old python mode still working? Do we intend to keep it? (a small bit of additional logic is necessary to support it)
  - This PR updates some of the tests that test old python mode behavior (e.g., all outputs are wrapped). If we intend to support old python mode long term we should bring it back, and just add new tests instead.

TODO (this PR):
- Test nesting behavior


See #77544

[ghstack-poisoned]
soulitzer added a commit that referenced this pull request May 18, 2022
ghstack-source-id: 277d87e
Pull Request resolved: #77667
This PR:
- updates LoggingTensorMode to use the new PythonDispatchMode
- updates some tests that use LoggingTensorMode to properly use the new version

Open questions:
- why is the old python mode still working? Do we intend to keep it? (a small bit of additional logic is necessary to support it)
  - This PR updates some of the tests that test old python mode behavior (e.g., all outputs are wrapped). If we intend to support old python mode long term we should bring it back, and just add new tests instead.

TODO (this PR):
- Test nesting behavior


See #77544

[ghstack-poisoned]
soulitzer added a commit that referenced this pull request May 18, 2022
ghstack-source-id: efe9d2f
Pull Request resolved: #77667
This PR:
- updates LoggingTensorMode to use the new PythonDispatchMode
- updates some tests that use LoggingTensorMode to properly use the new version

Open questions:
- why is the old python mode still working? Do we intend to keep it? (a small bit of additional logic is necessary to support it)
  - This PR updates some of the tests that test old python mode behavior (e.g., all outputs are wrapped). If we intend to support old python mode long term we should bring it back, and just add new tests instead.

TODO (this PR):
- Test nesting behavior


See #77544

[ghstack-poisoned]
soulitzer added a commit that referenced this pull request May 24, 2022
ghstack-source-id: d2f3c7c
Pull Request resolved: #77667
@soulitzer
Copy link
Contributor Author

@pytorchbot merge this on green

@pytorchmergebot
Copy link
Collaborator

Merge failed due to Matched rule superuser, but PR has not been reviewed yet
Raised by https://github.com/pytorch/pytorch/actions/runs/2374910721

@soulitzer
Copy link
Contributor Author

@pytorchbot merge this

@pytorchmergebot
Copy link
Collaborator

Merge failed due to Matched rule superuser, but PR has not been reviewed yet
Raised by https://github.com/pytorch/pytorch/actions/runs/2379606786

@pytorchmergebot
Copy link
Collaborator

Merge failed due to Matched rule superuser, but PR has not been reviewed yet
Raised by https://github.com/pytorch/pytorch/actions/runs/2379606786

malfet added a commit that referenced this pull request May 24, 2022
When merging stack, it could be confusing to see which PRs are missing
reviews as one can observe in #77667 (comment)

Print PR number in needs-review message
@soulitzer
Copy link
Contributor Author

@pytorchbot merge this

@github-actions
Copy link
Contributor

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

pytorchmergebot pushed a commit that referenced this pull request May 24, 2022
When merging stack, it could be confusing to see which PRs are missing
reviews as one can observe in #77667 (comment)

Print PR number in needs-review message

Pull Request resolved: #78219
Approved by: https://github.com/atalman, https://github.com/kit1980, https://github.com/seemethere
facebook-github-bot pushed a commit that referenced this pull request May 26, 2022
Summary:
Pull Request resolved: #77667

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

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

Reviewed By: mehtanirav

Differential Revision: D36668817

Pulled By: soulitzer

fbshipit-source-id: 0547ef32f770ee82abf4a04b3d8fb9943c97635f
facebook-github-bot pushed a commit that referenced this pull request May 26, 2022
Summary:
When merging stack, it could be confusing to see which PRs are missing
reviews as one can observe in #77667 (comment)

Print PR number in needs-review message

Pull Request resolved: #78219
Approved by: https://github.com/atalman, https://github.com/kit1980, https://github.com/seemethere

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

Reviewed By: mehtanirav

Differential Revision: D36668860

Pulled By: malfet

fbshipit-source-id: fb08f0b747f75ef4bdd9d49a52a33b7ed0022877
@facebook-github-bot facebook-github-bot deleted the gh/soulitzer/80/head branch May 28, 2022 14:17
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.

6 participants