interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

branch main Branches Tags History

CUDApp / evidence / DECODE-KERNELS-20261027T0612Z / tools / tag.py

56 lines · 2424 bytes Raw Blame History
1#!/usr/bin/env python3
2# DIAGNOSTIC (DecodeKernels A/B, 2026-10-27; evidence tooling, not product code). Usage: tag.py RUN_LOG INFLIGHT_LOG OUT_PREFIX
3# Tags every AB (router) / GAB (expert grid) JSON sample with the 18091 in_flight polls around it. A sample is CLEAN when
4# a poll at or before t0 and a poll at or after t1 exist, every poll from the last one <= t0 to the first one >= t1 reads
5# in_flight == 0, and no gap between consecutive polls in that span exceeds 200 ms. Writes OUT_PREFIX.tagged.jsonl (all
6# samples + clean flag) and OUT_PREFIX.clean.tsv (key, value_ns) for the Wolfram medians; prints counts per key.
7# It computes no statistic: medians and ratios are Wolfram's (AB-PLAN.md).
8import bisect, collections, json, sys
9
10run, infl, out = sys.argv[1:4]
11polls = []
12for l in open(infl):
13 p = l.split()
14 if len(p) == 2:
15 polls.append((int(p[0]), int(p[1])))
16polls.sort()
17ts = [p[0] for p in polls]
18GAP = 200_000_000
19
20
21def clean(t0, t1):
22 i = bisect.bisect_right(ts, t0) - 1
23 j = bisect.bisect_left(ts, t1)
24 if i < 0 or j >= len(ts):
25 return False, "no bracketing poll"
26 span = polls[i:j + 1]
27 if any(f != 0 for _, f in span):
28 return False, "in_flight>0"
29 if any(b[0] - a[0] > GAP for a, b in zip(span, span[1:])):
30 return False, "poll gap>200ms"
31 return True, ""
32
33
34n = collections.Counter(); c = collections.Counter(); why = collections.Counter(); wrong = 0
35with open(out + ".tagged.jsonl", "w") as tj, open(out + ".clean.tsv", "w") as tv:
36 for l in open(run):
37 if l.startswith("AB {"):
38 j = json.loads(l[3:]); key = "router arm%d ctas%d" % (j["arm"], j["ctas"]); val = j["chip_ns"]
39 elif l.startswith("GAB {"):
40 j = json.loads(l[4:]); key = "shape%d arm%d %d:%d" % (j["shape"], j["arm"], j["ctas"], j["warps"]); val = j["mean_ns"]
41 else:
42 continue
43 ok, r = clean(j["t0_ns"], j["t1_ns"])
44 if not j["exact"]:
45 wrong += 1
46 j["clean"] = ok; j["discard"] = r; j["key"] = key
47 tj.write(json.dumps(j) + "\n")
48 n[key] += 1
49 if ok:
50 c[key] += 1; tv.write("%s\t%d\n" % (key, val))
51 else:
52 why[r] += 1
53tot = sum(n.values()); cl = sum(c.values())
54print("samples %d clean %d discarded %d %s; not exact %d" % (tot, cl, tot - cl, dict(why), wrong))
55for k in sorted(n):
56 print("%-28s total %4d clean %4d" % (k, n[k], c[k]))