Fixes for profiling JIT code#38453
Closed
ilia-cher wants to merge 11 commits intogh/ilia-cher/69/basefrom
Closed
Conversation
Summary: Two fixes: - RecordFunction in JIT interpreter should exist during the execution of the frame, and not just when we enter the frame - When creating a JIT continuation in wait instruction, we'd want to preserve the original thread local context, right now when we resume execution in continuation we preserve the thread local state of the thread that set future value (i.e. executed a forked task) Test Plan: unittest, CI [ghstack-poisoned]
This was referenced May 14, 2020
Closed
Closed
Summary: Two fixes: - RecordFunction in JIT interpreter should exist during the execution of the frame, and not just when we enter the frame - When creating a JIT continuation in wait instruction, we'd want to preserve the original thread local context, right now when we resume execution in continuation we preserve the thread local state of the thread that set future value (i.e. executed a forked task) Test Plan: unittest, CI Differential Revision: [D21565959](https://our.internmc.facebook.com/intern/diff/D21565959) [ghstack-poisoned]
💊 CI failures summary and remediationsAs of commit afe7020 (more details on the Dr. CI page):
Extra GitHub checks: 1 failed
ci.pytorch.org: 1 failedThis 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 on the GitHub issue tracker. This comment has been revised 36 times. |
added 4 commits
May 13, 2020 19:31
Summary: Two fixes: - RecordFunction in JIT interpreter should exist during the execution of the frame, and not just when we enter the frame - When creating a JIT continuation in wait instruction, we'd want to preserve the original thread local context, right now when we resume execution in continuation we preserve the thread local state of the thread that set future value (i.e. executed a forked task) Test Plan: unittest, CI Differential Revision: [D21565959](https://our.internmc.facebook.com/intern/diff/D21565959) [ghstack-poisoned]
Summary: Two fixes: - RecordFunction in JIT interpreter should exist during the execution of the frame, and not just when we enter the frame - When creating a JIT continuation in wait instruction, we'd want to preserve the original thread local context, right now when we resume execution in continuation we preserve the thread local state of the thread that set future value (i.e. executed a forked task) Test Plan: unittest, CI Differential Revision: [D21565959](https://our.internmc.facebook.com/intern/diff/D21565959) [ghstack-poisoned]
Summary: Two fixes: - RecordFunction in JIT interpreter should exist during the execution of the frame, and not just when we enter the frame - When creating a JIT continuation in wait instruction, we'd want to preserve the original thread local context, right now when we resume execution in continuation we preserve the thread local state of the thread that set future value (i.e. executed a forked task) Test Plan: unittest, CI Differential Revision: [D21565959](https://our.internmc.facebook.com/intern/diff/D21565959) [ghstack-poisoned]
Summary: Two fixes: - RecordFunction in JIT interpreter should exist during the execution of the frame, and not just when we enter the frame - When creating a JIT continuation in wait instruction, we'd want to preserve the original thread local context, right now when we resume execution in continuation we preserve the thread local state of the thread that set future value (i.e. executed a forked task) Test Plan: unittest, CI Differential Revision: [D21565959](https://our.internmc.facebook.com/intern/diff/D21565959) [ghstack-poisoned]
added 2 commits
May 14, 2020 13:53
Summary: - RecordFunction in JIT interpreter should exist during the execution of the frame, and not just when we enter the frame - When creating a JIT continuation in wait instruction, we'd want to preserve the original thread local context, right now when we resume execution in continuation we preserve the thread local state of the thread that set future value (i.e. executed a forked task) Test Plan: python test/test_jit.py TestJit.test_profiler CI Differential Revision: [D21565959](https://our.internmc.facebook.com/intern/diff/D21565959) [ghstack-poisoned]
Summary: - RecordFunction in JIT interpreter should exist during the execution of the frame, and not just when we enter the frame - When creating a JIT continuation in wait instruction, we'd want to preserve the original thread local context, right now when we resume execution in continuation we preserve the thread local state of the thread that set future value (i.e. executed a forked task) Test Plan: python test/test_jit.py TestJit.test_profiler CI Differential Revision: [D21565959](https://our.internmc.facebook.com/intern/diff/D21565959) [ghstack-poisoned]
dzhulgakov
approved these changes
May 15, 2020
Collaborator
dzhulgakov
left a comment
There was a problem hiding this comment.
Looks good, minor comments
|
|
||
| namespace at { | ||
| namespace internal { | ||
| namespace internal {// |
| static std::atomic<size_t> num_frames; | ||
|
|
||
| // RecordFunction object associated with this frame | ||
| std::shared_ptr<at::RecordFunction> record_function; |
Collaborator
There was a problem hiding this comment.
looks like it can be a unique_ptr (or even c10::optional)
| int64_t dist_autograd_context_id = 0) | ||
| : state(state_), stack(std::move(stack_)) { | ||
| int64_t dist_autograd_context_id = 0, | ||
| c10::optional<at::ThreadLocalState> tls_state = c10::nullopt) |
Collaborator
There was a problem hiding this comment.
just curious - can you remind me the reason dist_autograd_context is not part of TLS? (I think there was one but I don't recall)
Contributor
Author
There was a problem hiding this comment.
I better refer to #38510 , there's been some ongoing discussion
added 3 commits
May 18, 2020 21:04
Summary: - RecordFunction in JIT interpreter should exist during the execution of the frame, and not just when we enter the frame - When creating a JIT continuation in wait instruction, we'd want to preserve the original thread local context, right now when we resume execution in continuation we preserve the thread local state of the thread that set future value (i.e. executed a forked task) Test Plan: python test/test_jit.py TestJit.test_profiler CI Differential Revision: [D21565959](https://our.internmc.facebook.com/intern/diff/D21565959) [ghstack-poisoned]
Summary: - RecordFunction in JIT interpreter should exist during the execution of the frame, and not just when we enter the frame - When creating a JIT continuation in wait instruction, we'd want to preserve the original thread local context, right now when we resume execution in continuation we preserve the thread local state of the thread that set future value (i.e. executed a forked task) Test Plan: python test/test_jit.py TestJit.test_profiler CI Differential Revision: [D21565959](https://our.internmc.facebook.com/intern/diff/D21565959) [ghstack-poisoned]
Summary: - RecordFunction in JIT interpreter should exist during the execution of the frame, and not just when we enter the frame - When creating a JIT continuation in wait instruction, we'd want to preserve the original thread local context, right now when we resume execution in continuation we preserve the thread local state of the thread that set future value (i.e. executed a forked task) Test Plan: python test/test_jit.py TestJit.test_profiler CI Differential Revision: [D21565959](https://our.internmc.facebook.com/intern/diff/D21565959) [ghstack-poisoned]
Contributor
|
@ilia-cher merged this pull request in 235f624. |
laurentdupin
pushed a commit
to laurentdupin/pytorch
that referenced
this pull request
Apr 24, 2026
Summary: Pull Request resolved: pytorch#38453 Two fixes: - RecordFunction in JIT interpreter should exist during the execution of the frame, and not just when we enter the frame - When creating a JIT continuation in wait instruction, we'd want to preserve the original thread local context, right now when we resume execution in continuation we preserve the thread local state of the thread that set future value (i.e. executed a forked task) Test Plan: unittest, CI Reviewed By: ngimel Differential Revision: D21565959 Pulled By: ilia-cher fbshipit-source-id: 206b98e3bfb0052fc8e4031da778e372cc71afc1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack:
Summary:
of the frame, and not just when we enter the frame
preserve the original thread local context, right now when we resume
execution in continuation we preserve the thread local state of the
thread that set future value (i.e. executed a forked task)
Test Plan:
python test/test_jit.py TestJit.test_profiler
CI
Differential Revision: D21565959