-
Notifications
You must be signed in to change notification settings - Fork 25
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
Adding a memory profiling example #41
Conversation
Hey! |
dispatch_mem_profiler.py
Outdated
def reduce_to_scalar_loss(inp): | ||
return inp.sum() | ||
|
||
from functorch.compile import aot_module, nop, print_compile, min_cut_rematerialization_partition |
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.
Can you move this to the top? Also try running black
formatter just for consistent styling.
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.
The lint should already check that everything is black
compliant:
Line 3 in 4214538
include_patterns = ['**/*.py'] |
Since it passes on the PR, I guess it is good.
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.
Nice utility!
dispatch_mem_profiler.py
Outdated
|
||
def __torch_dispatch__(self, func, types, args=..., kwargs=None): | ||
|
||
global mem_usage, operator_names |
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.
You don't need this since you only write into these dictionaries.
Same for the other functions below except the ones that do set mem_usage
.
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.
Cleaned up global usage
Could you add the new requirements so that we can merge this? |
Added them |
Python builtin Modules don't need to be in there ;) |
@albanD Can we merge this PR if it looks good? |
This example shows how to use torch_dispatch for memory profiling
It shows two ways
It also provides utilities to plot the memory profile and compare it