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

Function trace_phase_pcts

benchmarking/parse_proton_intrakernel.py:41–68  ·  view source on GitHub ↗

Return {"matmul": pct, "sampling": pct} from a chrome trace. Matmul is derived as kernel - setup - mask - tile-mgmt - sample - store. Sampling aggregates mask + sample + store (tile-mgmt excluded). Raises if any expected scope is missing, since filling 0 would produce a bogus matmu

(trace: dict)

Source from the content-addressed store, hash-verified

39
40
41def trace_phase_pcts(trace: dict) -> dict[str, float]:
42 """Return {"matmul": pct, "sampling": pct} from a chrome trace.
43
44 Matmul is derived as kernel - setup - mask - tile-mgmt - sample - store.
45 Sampling aggregates mask + sample + store (tile-mgmt excluded).
46
47 Raises if any expected scope is missing, since filling 0 would produce
48 a bogus matmul derivation.
49 """
50 scopes = trace["scopes"]
51 missing = [s for s in EXPECTED_SCOPES if s not in scopes]
52 if missing:
53 raise ValueError(
54 f"Chrome trace is missing scopes: {missing}. "
55 "The TTGIR injection likely failed (compiler renamed variables?). "
56 "Fix insert_proton_records.py patterns and re-run."
57 )
58 kernel = scopes["kernel"]
59 setup = scopes["setup"]
60 mask = scopes["mask"]
61 tile_mgmt = scopes["tile-mgmt"]
62 sample = scopes["sample"]
63 store = scopes["store"]
64 matmul = kernel - setup - mask - tile_mgmt - sample - store
65 return {
66 "matmul": matmul / kernel * 100,
67 "sampling": (mask + sample + store) / kernel * 100,
68 }
69
70
71EXPECTED_SCOPES = ["kernel", "setup", "mask", "tile-mgmt", "sample", "store"]

Callers 1

load_dataFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected