Skip to content

Separate TLS for InferenceMode#55238

Closed
ailzhang wants to merge 3 commits intogh/ailzhang/58/basefrom
gh/ailzhang/58/head
Closed

Separate TLS for InferenceMode#55238
ailzhang wants to merge 3 commits intogh/ailzhang/58/basefrom
gh/ailzhang/58/head

Conversation

@ailzhang
Copy link
Contributor

@ailzhang ailzhang commented Apr 2, 2021

Stack from ghstack:

I tried to avoid creating new TLS, but InferenceMode::is_enabeld()
is in perf critical path (TensorImpl constructor) so it seems
worth adding one for it.
This PR reduces one sources of instruction count increased by
#55008.

 λ ~ python compare.py
<torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310>
     100  0x0000000004854750
    -100  0x0000000004854760
   -4400  c10::impl::tls_is_dispatch_key_included(...)

Differential Revision: D27539230

I tried to avoid creating new TLS, but InferenceMode::is_enabeld()
is in perf critical path (TensorImpl constructor) so it seems
worth adding one for it.
This PR reduces one sources of instruction count increased by
#55008.
```
 λ ~ python compare.py
<torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310>
     100  0x0000000004854750
    -100  0x0000000004854760
   -4400  c10::impl::tls_is_dispatch_key_included(...)
```

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

facebook-github-bot commented Apr 2, 2021

💊 CI failures summary and remediations

As of commit 739fede (more details on the Dr. CI page):


  • 3/3 failures possibly* introduced in this PR
    • 1/3 non-scanned failure(s)

🕵️ 1 new failure recognized by patterns

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

See CircleCI build pytorch_linux_xenial_cuda10_2_cudnn7_py3_gcc7_test1 (1/1)

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

Apr 05 22:09:08 AssertionError: 0 not greater than or equal to 1
Apr 05 22:09:08   File "/opt/conda/lib/python3.6/site-packages/torch/testing/_internal/common_distributed.py", line 323, in wrapper
Apr 05 22:09:08     fn()
Apr 05 22:09:08   File "/opt/conda/lib/python3.6/site-packages/torch/testing/_internal/distributed/distributed_test.py", line 3652, in test_ddp_logging_data_cpu
Apr 05 22:09:08     model_DDP = self._test_ddp_logging_data(is_gpu=False)
Apr 05 22:09:08   File "/opt/conda/lib/python3.6/site-packages/torch/testing/_internal/distributed/distributed_test.py", line 3625, in _test_ddp_logging_data
Apr 05 22:09:08     self.assertGreaterEqual(ddp_logging_data.forward_compute_time, 1)
Apr 05 22:09:08   File "/opt/conda/lib/python3.6/unittest/case.py", line 1227, in assertGreaterEqual
Apr 05 22:09:08     self.fail(self._formatMessage(msg, standardMsg))
Apr 05 22:09:08   File "/opt/conda/lib/python3.6/unittest/case.py", line 670, in fail
Apr 05 22:09:08     raise self.failureException(msg)
Apr 05 22:09:08 AssertionError: 0 not greater than or equal to 1
Apr 05 22:09:08 
Apr 05 22:09:08 
Apr 05 22:09:08 
Apr 05 22:09:08 ----------------------------------------------------------------------
Apr 05 22:09:08 Ran 182 tests in 284.505s
Apr 05 22:09:08 
Apr 05 22:09:08 FAILED (errors=1, skipped=71)
Apr 05 22:09:08 
Apr 05 22:09:08 Generating XML reports...
Apr 05 22:09:08 Generated XML report: test-reports/dist-gloo/distributed.test_distributed_fork/TEST-TestDistBackendWithFork-20210405220424.xml

1 failure not recognized by patterns:

Job Step Action
CircleCI pytorch_ios_12_0_0_x86_64_lite_interpreter_build Build 🔁 rerun

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.

@ailzhang ailzhang requested review from bhosmer, ezyang and robieta April 2, 2021 18:18
I tried to avoid creating new TLS, but InferenceMode::is_enabeld()
is in perf critical path (TensorImpl constructor) so it seems
worth adding one for it.
This PR reduces one sources of instruction count increased by
#55008.
```
 λ ~ python compare.py
<torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310>
     100  0x0000000004854750
    -100  0x0000000004854760
   -4400  c10::impl::tls_is_dispatch_key_included(...)
```

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

[ghstack-poisoned]
ailzhang pushed a commit that referenced this pull request Apr 2, 2021
I tried to avoid creating new TLS, but InferenceMode::is_enabeld()
is in perf critical path (TensorImpl constructor) so it seems
worth adding one for it.
This PR reduces one sources of instruction count increased by
#55008.
```
 λ ~ python compare.py
<torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310>
     100  0x0000000004854750
    -100  0x0000000004854760
   -4400  c10::impl::tls_is_dispatch_key_included(...)
```

ghstack-source-id: 96dd9d5
Pull Request resolved: #55238
Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

OK. Note that I probably would have worded the comment a little differently; saying instead that there is an invariant that set_enabled must uphold (this is NBD because it's private so you can enforce the invariant easily anyway)

I tried to avoid creating new TLS, but InferenceMode::is_enabeld()
is in perf critical path (TensorImpl constructor) so it seems
worth adding one for it.
This PR reduces one sources of instruction count increased by
#55008.
```
 λ ~ python compare.py
<torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310>
     100  0x0000000004854750
    -100  0x0000000004854760
   -4400  c10::impl::tls_is_dispatch_key_included(...)
```

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

[ghstack-poisoned]
ailzhang pushed a commit that referenced this pull request Apr 5, 2021
I tried to avoid creating new TLS, but InferenceMode::is_enabeld()
is in perf critical path (TensorImpl constructor) so it seems
worth adding one for it.
This PR reduces one sources of instruction count increased by
#55008.
```
 λ ~ python compare.py
<torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310>
     100  0x0000000004854750
    -100  0x0000000004854760
   -4400  c10::impl::tls_is_dispatch_key_included(...)
```

ghstack-source-id: 84dce14
Pull Request resolved: #55238
ailzhang pushed a commit to ailzhang/pytorch that referenced this pull request Apr 6, 2021
Summary:
Pull Request resolved: pytorch#55238

I tried to avoid creating new TLS, but InferenceMode::is_enabeld()
is in perf critical path (TensorImpl constructor) so it seems
worth adding one for it.
This PR reduces one sources of instruction count increased by
pytorch#55008.
```
 λ ~ python compare.py
<torch.utils.benchmark.utils.valgrind_wrapper.timer_interface.FunctionCounts object at 0x7f59097ef310>
     100  0x0000000004854750
    -100  0x0000000004854760
   -4400  c10::impl::tls_is_dispatch_key_included(...)
```

Test Plan: Imported from OSS

Reviewed By: ezyang

Differential Revision: D27539230

Pulled By: ailzhang

fbshipit-source-id: 54b0c141d59ac569a154a036b284001fca9fc560
@facebook-github-bot
Copy link
Contributor

@ailzhang merged this pull request in bc05867.

@facebook-github-bot facebook-github-bot deleted the gh/ailzhang/58/head branch April 10, 2021 14:17
ailzhang pushed a commit that referenced this pull request Apr 12, 2021
Now that #55238 is landed for a
week and no complains. It seems safe to say FEATURE_TORCH_MOBILE is
always true and we can do some cleanup.

[ghstack-poisoned]
ailzhang pushed a commit that referenced this pull request Apr 12, 2021
Now that #55238 is landed for a
week and no complains. It seems safe to say FEATURE_TORCH_MOBILE is
always true and we can do some cleanup.

ghstack-source-id: 43cbb36
Pull Request resolved: #55835
facebook-github-bot pushed a commit that referenced this pull request Apr 14, 2021
Summary:
Pull Request resolved: #55835

Now that #55238 is landed for a
week and no complains. It seems safe to say FEATURE_TORCH_MOBILE is
always true and we can do some cleanup.

Test Plan: Imported from OSS

Reviewed By: ezyang, walterddr

Differential Revision: D27721284

Pulled By: ailzhang

fbshipit-source-id: 4896bc5f736373d0922cfbe8eed0d16df62f0fa1
krshrimali pushed a commit to krshrimali/pytorch that referenced this pull request May 19, 2021
Summary:
Pull Request resolved: pytorch#55835

Now that pytorch#55238 is landed for a
week and no complains. It seems safe to say FEATURE_TORCH_MOBILE is
always true and we can do some cleanup.

Test Plan: Imported from OSS

Reviewed By: ezyang, walterddr

Differential Revision: D27721284

Pulled By: ailzhang

fbshipit-source-id: 4896bc5f736373d0922cfbe8eed0d16df62f0fa1
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.

3 participants