-
Notifications
You must be signed in to change notification settings - Fork 24.7k
[MPS] Expose MPSProfiler::start/stopCapture
to Python
#144561
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/144561
Note: Links to docs will display an error until the docs builds have been completed. ⏳ 13 Pending, 1 Unrelated FailureAs of commit 5bf42fd with merge base a222029 ( UNSTABLE - The following job failed but was likely due to flakiness present on trunk and has been marked as unstable:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
torch._C._mps_startCapture(fname) | ||
yield | ||
finally: | ||
torch.mps.synchronize() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this call to synchronize distort times in any way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the contrary, it ensures that everything that is submitted asynchronously will be captured
Could you add documentation for this new feature? |
MPSProfiler::start/stopCapture
to Python
Generates docs are in: https://docs-preview.pytorch.org/pytorch/pytorch/144561/mps.html#mps-profiler Will submit a followup to improve the docs later on |
@pytorchbot merge -f "Lint + MPS is green" |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Stack from ghstack (oldest at bottom):
MPSProfiler::start/stopCapture
to Python #144561I.e. when
MTL_CAPTURE_ENABLED
environment variable is set to 1, one should be able to invoke wrap the code withtorch.mps.profiler.capture_metal
to generate gputrace for shaders invoked inside the context manager.For example, code below:
should capture the execution of a

torch.compile
generated shader