Expose Kineto event metadata in PyTorch Profiler events#161624
Expose Kineto event metadata in PyTorch Profiler events#161624mihaipgc wants to merge 9 commits intopytorch:mainfrom
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/161624
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 4bf01ac with merge base a213848 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@pytorchbot label "release notes: profiler" |
torch/csrc/profiler/collection.cpp
Outdated
| if (e) { | ||
| e->visit(c10::overloaded( | ||
| [&](ExtraFields<EventType::TorchOp>& i) { | ||
| if (config_.experimental_config.expose_kineto_event_metadata) { |
There was a problem hiding this comment.
nit but we could just have the expose_kineto_event_metadata on the outside of the e->visit
There was a problem hiding this comment.
Thank you so much for the review, I pushed a change to move the check out of e->visit
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Merge failedReason: 1 jobs have failed, first few of them are: trunk / linux-jammy-rocm-py3.10 / test (default, 1, 2, linux.rocm.gpu.gfx942.1) Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot rebase -b viable/strict |
|
You don't have permissions to rebase this PR since you are a first time contributor. If you think this is a mistake, please contact PyTorch Dev Infra. |
|
@pytorchbot rebase -b viable/strict |
|
@pytorchbot started a rebase job onto refs/remotes/origin/viable/strict. Check the current status here |
|
Rebase failed due to Command Raised by https://github.com/pytorch/pytorch/actions/runs/17992488499 |
… experimental config flag expose torchop metadata to enable testing; add test
e16d56a to
4bf01ac
Compare
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
## Overview
This PR allows the profiler users to access `Kineto` and `TorchOp` metadata in JSON string format through a new `metadata_json` attribute in `FunctionEvent` objects, which is triggered through a new `expose_kineto_event_metadata` flag in `ExperimentalConfig`.
## Testing
A unit test was added to validate functionality.
## Documentation
Added/updated function doc strings where appropriate.
## Example output
```python
import torch
from torch.profiler import profile
with profile(experimental_config=torch._C._profiler._ExperimentalConfig(expose_kineto_event_metadata=True)) as prof:
res = torch.mm(torch.rand(1024, 1024), torch.rand(1024, 1024))
for event in prof.events():
print(f'name: {event.key}, metadata: {event.metadata_json}')
```
```
name: aten::rand, metadata: "Ev Idx": 0
name: aten::empty, metadata: "Ev Idx": 1
name: aten::uniform_, metadata: "Ev Idx": 2
name: aten::rand, metadata: "Ev Idx": 3
name: aten::empty, metadata: "Ev Idx": 4
name: aten::uniform_, metadata: "Ev Idx": 5
name: aten::mm, metadata: "Ev Idx": 6
name: aten::resolve_conj, metadata: "Ev Idx": 7
name: aten::resolve_conj, metadata: "Ev Idx": 8
name: aten::resolve_conj, metadata: "Ev Idx": 9
```
Pull Request resolved: #161624
Approved by: https://github.com/sraikund16
Overview
This PR allows the profiler users to access
KinetoandTorchOpmetadata in JSON string format through a newmetadata_jsonattribute inFunctionEventobjects, which is triggered through a newexpose_kineto_event_metadataflag inExperimentalConfig.Testing
A unit test was added to validate functionality.
Documentation
Added/updated function doc strings where appropriate.
Example output