changh95's picture
Optimized build (2026-10-03): model call 19.0 ms, trace 17.7 ms
13b4736 verified
Raw History Blame Contribute Delete
1.39 kB
# SPDX-License-Identifier: Apache-2.0
"""Per-op summary of one traced forward from the device-side cpp_device_perf_report.csv
(works without the tracy host capture, which can collide on the shared host's tracy ports).
python -m tt_moge.tools_opt.dev_ops <profiler_dir>/.logs/cpp_device_perf_report.csv [session] [seq]"""
import sys
import pandas as pd
pd.set_option("display.width", 250); pd.set_option("display.max_rows", 400)
d = pd.read_csv(sys.argv[1])
t = d[d["METAL TRACE ID"].notna()]
sess = float(sys.argv[2]) if len(sys.argv) > 2 else t["METAL TRACE REPLAY SESSION ID"].max()
t = t[t["METAL TRACE REPLAY SESSION ID"] == sess].sort_values("DEVICE FW START CYCLE").copy()
t["us"] = t["DEVICE KERNEL DURATION [ns]"] / 1e3
span = (t["DEVICE FW END CYCLE"].max() - t["DEVICE FW START CYCLE"].min()) / 1.35e3
print(f"session {sess}: ops={len(t)} kernel_sum={t.us.sum()/1e3:.2f} ms fw_span={span/1e3:.2f} ms")
g = t.groupby("OP NAME").agg(n=("us", "size"), ms=("us", lambda x: x.sum() / 1e3), avg_us=("us", "mean"),
cores=("CORE COUNT", "median")).sort_values("ms", ascending=False)
print(g.to_string())
if len(sys.argv) > 3:
t["gap_us"] = (t["DEVICE FW START CYCLE"] - t["DEVICE FW END CYCLE"].shift(1)) / 1.35e3
t["cum_ms"] = t["us"].cumsum() / 1e3
print(t[["OP NAME", "CORE COUNT", "us", "gap_us", "cum_ms"]].reset_index(drop=True).to_string())