-
Notifications
You must be signed in to change notification settings - Fork 608
Add configurable event tracing names for method execution #8033
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
Add configurable event tracing names for method execution #8033
Conversation
- Updated Method::execute to accept optional block and profile event names - Modified Module::execute to pass method-specific event names to method execution
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/8033
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 605d0f1 with merge base 3eea1f1 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
added @shoumikhin and @tarun292 |
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 core runtime API already lets users pass a different EventTracer instance to each Method via Program::load_method(). I'd rather find some way to have the tracer instance record that a given trace is for a specific method, instead of modifying core runtime APIs.
The higher-level Module interface could construct a tracer for each method, and could pass the method name to each tracer instance.
@dbort is there any chance to log the method name for the event tracer in |
Sure we could do something like that. The question is: what's the best way to log it? @tarun292 ? Would it make sense to update the EventTracer API to have a hook like The main pain is that if we want to construct a string with the method, like "Method(NAME)::execute" then we'd need to do so in a stack buffer like
which would take some extra time, so we'd want to be sure to avoid it when no event tracer is installed, and possibly compile it out if profiling is disabled. |
So, looking back at this, I do not have a full understanding of the Event Tracer design / thought process. For the use case of Executorch programs with multiple graphs/ methods is the thought process that one would generate an ET_Dump for each method independently? IE method_1.etdump method_2.etdump? Or would this all get collapsed into a single etdump, with internal separation based on the block_name/ profile_name / (is there some other separation possibility?) |
I believe so; in fact I think it's typical to generate a separate dump for each execution of a given method. @tarun292 or @Gasoonjia would know better |
Correct. Each ETDump file corresponds to a method's inference; every time a method is executed, all debug/runtime related data will be stored in a single ETDump. |
If my understanding is correct, the best way to handle this is to create and pass an independent event tracer instance for each method that gets called. The way my current code works is that I end up adding an additional abstraction layer and wrapping the module class. This wrapping class calls load_method on all methods. I guess additionally during this stage, my wrapper should (optionally) create and pass event tracers for each method, storing them for later write-out. (I am currently doing this for the root event tracer only) This seems easy and if this is the recommended method, I can close out this as nothing in executorch needs to change. The only real downside is that I end up with multiple-files per program. Side-note:I have made some changes on the python side to etrecord generation/inspector, which are similar to this issue, but again the question is what is the recommended approach? |
Summary
This is kind of a quality of life thing when working with exported modules with multiple methods.
The Issue:
By default, all methods of a module use the same profiling event and event block. This is fine, when one only has a single method exported, however the profiling data becomes less meaningful if there are multiple methods.
This is related to #8030 where I am exporting multiple methods on a single module and having them all share internal state.
The change:
In Method::execute, allow the caller to optionally pass in
const char*
block name and profiling event name.By default these are the same as what was hardcoded internally.
Additionally change the behavior of Module::execute to pass in the name of the current method.
This does change the current behavior of Module, as anyone using that api will no longer get the previous hardcoded "Method::execute" names.
cc @JacobSzwejbka @dbort