RFC-0051-Structured-call_hierarchy-metadata-for-FX-nodes#92
RFC-0051-Structured-call_hierarchy-metadata-for-FX-nodes#92andrewd-aws wants to merge 1 commit intopytorch:masterfrom
Conversation
|
Hi @andrewd-aws! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
|
||
| The implementation builds on existing Dynamo infrastructure. During proxy creation, `stack_trace` is already built by walking the InstructionTranslator (tx) parent chain. `call_hierarchy` is built during the same walk: at each frame, if `nn_module_stack` has new keys compared to the previous frame, the frame is a module entry; otherwise it is a function entry (filtered for torch-internal and non-meaningful frames). Because both module and function entries come from the same ordered traversal, the interleaving is correct by construction. This works regardless of how modules override `__call__` or `forward`. Module invocation counts come from `nn_module_stack`'s existing `@N` key suffix. Function invocation counts are tracked via a `function_call_counts` dict shared across the tx chain, incremented when `InliningInstructionTranslator` is created. | ||
|
|
||
| We can gate the feature by `torch._dynamo.config.record_call_hierarchy` (default `False`). When disabled, zero additional work is performed. Or, if overhead is low enough have it on by default. |
There was a problem hiding this comment.
I think this is an interesting callout - from the prototyped implementation, do we have a feeling for the runtime overhead?
There was a problem hiding this comment.
We're actively working on getting some numbers on this
|
|
||
| ## Alternatives | ||
|
|
||
| - Parse `stack_trace` strings at consumption time. This is what consumers do today and it is fragile, lacks invocation counts, and cannot be correctly interleaved with `nn_module_stack`. |
There was a problem hiding this comment.
I'mm interested in why this is fragile. stack_trace gives you the exact line, which one can use for line-level profiling and etc. Can you give a little more detail on why the new proposal would be easier to use than stack_trace?
There was a problem hiding this comment.
Would be helpful if you can describe a concrete use-case for the new node meta.
RFC for call hierarchy metadata