Skip to content

Commit effafaa

Browse files
committed
Update on "propagate debug handle from edge dialect graph back to exported graph"
Using exported graph from torch.export as source of truth for aot intermediate output is our target. Once thing blocking us is the exported graph does not have debug handle, which will not show up in the export flow until DebugHandleGenerationPass, the last step of to_edge(). We need to equip the graph with same debug handle used in ExecuTorch flow. This diff creates a propagate_back_debug_handle function, which propagate debug handle from edge dialect program back to the exported program while maintain the correctness of operator tracing. Differential Revision: [D78051614](https://our.internmc.facebook.com/intern/diff/D78051614/) [ghstack-poisoned]
2 parents 5774995 + 45a6a0d commit effafaa

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

devtools/etrecord/_etrecord.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ def generate_etrecord(
244244
export_graph_id = 0
245245

246246
if exported_program is not None:
247-
# If multiple exported programs are provided, only saved forward method
247+
# If multiple exported programs are provided, only save forward method
248248
if isinstance(exported_program, dict) and "forward" in exported_program:
249249
exported_program = exported_program["forward"]
250250

devtools/inspector/_inspector_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,8 @@ def _equip_debug_handle(node: torch.fx.Node) -> None:
958958
node.meta[DEBUG_HANDLE_KEY] = debug_handle_for_removed_node
959959

960960
bfs_trace_with_node_process(exported_program.graph_module, _find_n_match_node)
961+
962+
# if any node in the edge dialect program has no corresponding node in the exported program, match failed
961963
if n_matched_node != len(export_graph_node_id_to_debug_handle):
962964
return False
963965

devtools/inspector/tests/inspector_utils_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
TimeScale,
4747
)
4848
from executorch.devtools.inspector.numerical_comparator import L1Comparator
49-
from executorch.exir import EdgeCompileConfig, to_edge
49+
from executorch.exir import to_edge
5050
from executorch.exir.debug_handle_utils import DEBUG_HANDLE_KEY
5151
from torch.export import export
5252

0 commit comments

Comments
 (0)