Do memory analysis from Trace files#223
Draft
payoto wants to merge 21 commits into
Draft
Conversation
| & (df["name"] == "[memory]") | ||
| & (df["cat"] == "cpu_instant_event") | ||
| ) | ||
| df.loc[is_memory_event, "dur"] = 0 |
Contributor
There was a problem hiding this comment.
qq we are just turning the "dur" to 0 here , how does that keep the memoy events, i thought they are already retained
Author
There was a problem hiding this comment.
Memory events have no duration as they are "instantaneous" - as a consequence "dur" is set to na but the following lines do:
# drop rows with null values
df.dropna(axis=0, subset=["dur", "cat"], inplace=True)Which dropped them.
| raw_name: Device Type | ||
| value_type: Int | ||
| default_value: 0 | ||
| memory::ev_idx: |
Contributor
There was a problem hiding this comment.
I think ev_idx is already there above see "index::ev_idx"
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.
What does this PR do?
This PR makes it possible to analyse memory events from the Trace files to allow fine-grained analysis of memory allocations and to relate them to other events.
At the moment the memory timelines can be processed from the Pytorch profiler's export_memory_timeline. This output classifies the memory events in one of 7 categories during the export, however the categories are poorly documented and can be incorrect for more complex applications that use Pytorch distributed and torch.compile.
Instead this loads events in the trace dataframes:
Sample usage of the feature - detailed usage in
memory_analysis_demo_2.ipynb:Before submitting