Download code/tt_moge/tools_opt/dev_ops.py from changh95/moge-2-p150: direct link, hf CLI and curl.
- Browser
- Download file 1.39 kB
-
https://huggingface.co/changh95/moge-2-p150/resolve/main/code/tt_moge/tools_opt/dev_ops.py
- Command line
-
hf download hf://changh95/moge-2-p150/code/tt_moge/tools_opt/dev_ops.py
-
curl -L -o dev_ops.py https://huggingface.co/changh95/moge-2-p150/resolve/main/code/tt_moge/tools_opt/dev_ops.py
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()) | |