MCPcopy Create free account
hub / github.com/FlashSampling/FlashSampling / print_breakdown

Function print_breakdown

benchmarking/parse_proton_intrakernel.py:74–111  ·  view source on GitHub ↗

Print per-scope runtime breakdown as percentages of kernel time. Raises if any expected scope is missing, since filling 0 would produce a bogus matmul derivation.

(trace: dict)

Source from the content-addressed store, hash-verified

72
73
74def print_breakdown(trace: dict) -> None:
75 """Print per-scope runtime breakdown as percentages of kernel time.
76
77 Raises if any expected scope is missing, since filling 0 would produce
78 a bogus matmul derivation.
79 """
80 scopes = trace["scopes"]
81 counts = trace["counts"]
82 missing = [s for s in EXPECTED_SCOPES if s not in scopes]
83 if missing:
84 raise ValueError(
85 f"Chrome trace is missing scopes: {missing}. "
86 "The TTGIR injection likely failed (compiler renamed variables?). "
87 "Fix insert_proton_records.py patterns and re-run."
88 )
89
90 kernel = scopes["kernel"]
91 setup = scopes["setup"]
92 mask = scopes["mask"]
93 tile_mgmt = scopes["tile-mgmt"]
94 sample = scopes["sample"]
95 store = scopes["store"]
96 matmul = kernel - setup - mask - tile_mgmt - sample - store
97
98 rows = [
99 ("kernel", kernel, counts["kernel"]),
100 ("setup", setup, counts["setup"]),
101 ("matmul*", matmul, None),
102 ("mask", mask, counts["mask"]),
103 ("tile-mgmt", tile_mgmt, counts["tile-mgmt"]),
104 ("sample", sample, counts["sample"]),
105 ("store", store, counts["store"]),
106 ]
107 df = pd.DataFrame(rows, columns=["phase", "cycles", "count"])
108 df["runtime_%"] = (df["cycles"] / kernel * 100).round(1)
109 print(df.to_markdown(index=False))
110 print()
111 print("* matmul = kernel - setup - mask - tile-mgmt - sample - store")
112
113
114if __name__ == "__main__":

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected