Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions TraceLens/Reporting/generate_perf_report_pytorch_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,33 @@ def infer_mode_from_captures(num_captures: int):
return


def diag_sweep_unified_perf_summary(df_summary, pct_threshold=4.0):
"""
Sweep the unified perf summary and print DIAG triage warnings for synthetic
and uncategorized ops whose total runtime share (across all shapes/args)
exceeds *pct_threshold* percent.
"""
if df_summary.empty or "Percentage (%)" not in df_summary.columns:
return

synth = df_summary[
df_summary["name"]
.astype(str)
.str.contains(r"\(Synthetic Op\)", regex=True, na=False)
]
for name, pct in synth.groupby("name")["Percentage (%)"].sum().items():
if pct > pct_threshold:
print(f"DIAG: Synthetic op {name} found with total {pct:.2f}% of runtime")

if "op category" in df_summary.columns:
uncat = df_summary[df_summary["op category"].astype(str) == "other"]
for name, pct in uncat.groupby("name")["Percentage (%)"].sum().items():
if pct > pct_threshold:
print(
f"DIAG: uncategorized op {name} found with total {pct:.2f}% of runtime"
)


def get_dfs_short_kernels(
perf_analyzer, short_kernel_threshold_us=10, histogram_bins=100, topk=None
):
Expand Down Expand Up @@ -970,6 +997,7 @@ def generate_perf_report_pytorch(
columns=["call_stack"]
)
dict_name2df["unified_perf_summary"] = df_unified_perf_summary
diag_sweep_unified_perf_summary(df_unified_perf_summary)

if _tracediff_diff_stats is not None and not _tracediff_diff_stats.empty:
from TraceLens.Reporting.tracediff_comparison_extension import (
Expand Down
13 changes: 12 additions & 1 deletion TraceLens/Trace2Tree/trace_capture_merge_experimental.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ def merge_capture_trace_into_graph(
capture_map, capture_batch_sizes = load_capture_folder(
capture_folder, metadata_json_path
)
for execution_root, graph_roots in execution_graph_root_map:
for step, (execution_root, graph_roots) in enumerate(execution_graph_root_map):
print("Processing execution root: {}".format(execution_root["name"]))
if len(graph_roots) == 0:
print(
Expand Down Expand Up @@ -553,6 +553,17 @@ def merge_capture_trace_into_graph(
)

if verify_success == 0:
print(
"DIAG: graph capture merge failed at step {}, capture trace has "
"{} events and {} capture roots and graph trace has {} events "
"and {} graph roots".format(
step,
len(capture_tree.events),
len(capture_roots),
len(graph_tree.events),
len(graph_roots),
)
)
print(
"Warning: subtree events verification failed for capture root {} and graph root {}".format(
c_root["name"], g_root["name"]
Expand Down
Loading