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 / FLASH-NEXT-CODER-FULL-20261118 / summarize.py

48 lines · 2614 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2# summarize.py: fold the per-shard JSONL files written by fullcover.py into one summary.
3# usage: python3 -I summarize.py OUT_DIR EXPECTED_MATRICES EXPECTED_RAW_BYTES
4# Integer arithmetic only for the totals; the ratio is printed as coded/raw and as parts per million.
5import collections, glob, hashlib, json, os, re, sys
6
7OUT, EXP_N, EXP_RAW = sys.argv[1], int(sys.argv[2]), int(sys.argv[3])
8raw = coded = n = rt = flip = 0
9by_layer = collections.defaultdict(lambda: [0, 0])
10by_kind = collections.defaultdict(lambda: [0, 0])
11worst = (0, 1, '') # largest coded/raw
12best = (1, 1, '') # smallest coded/raw
13seen = set()
14h = hashlib.sha256()
15files = sorted(glob.glob(os.path.join(OUT, '*.jsonl')))
16for p in files:
17 data = open(p, 'rb').read()
18 h.update(os.path.basename(p).encode() + b'\0' + data)
19 for line in data.splitlines():
20 d = json.loads(line)
21 if 'done' in d:
22 continue
23 assert d['name'] not in seen, d['name']
24 seen.add(d['name'])
25 m = re.search(r'layers\.(\d+)\.mlp\.experts\.(\d+)\.(\w+)\.weight$', d['name'])
26 L, kind = int(m.group(1)), m.group(3)
27 raw += d['raw']; coded += d['coded']; n += 1
28 rt += d['roundtrip']; flip += d['flip_detected']
29 by_layer[L][0] += d['raw']; by_layer[L][1] += d['coded']
30 by_kind[kind][0] += d['raw']; by_kind[kind][1] += d['coded']
31 if d['coded'] * worst[1] > worst[0] * d['raw']:
32 worst = (d['coded'], d['raw'], d['name'])
33 if d['coded'] * best[1] < best[0] * d['raw']:
34 best = (d['coded'], d['raw'], d['name'])
35ppm = lambda c, r: c * 1000000 // r
36print(f'shard_files={len(files)} results_sha256={h.hexdigest()}')
37print(f'matrices={n} expected={EXP_N} raw_bytes={raw} expected_raw={EXP_RAW} coded_bytes={coded}')
38print(f'ratio_ppm={ppm(coded, raw)} roundtrip_bit_exact={rt}/{n} flipped_bit_detected={flip}/{n}')
39print(f'worst_matrix_ppm={ppm(worst[0], worst[1])} {worst[2]}')
40print(f'best_matrix_ppm={ppm(best[0], best[1])} {best[2]}')
41for k in sorted(by_kind):
42 print(f'kind {k}: raw={by_kind[k][0]} coded={by_kind[k][1]} ratio_ppm={ppm(by_kind[k][1], by_kind[k][0])}')
43lay = sorted((ppm(v[1], v[0]), L) for L, v in by_layer.items())
44print(f'layers={len(lay)} layer_ratio_ppm_min={lay[0]} layer_ratio_ppm_max={lay[-1]}')
45print('per_layer_ppm ' + ' '.join(f'{L}:{ppm(by_layer[L][1], by_layer[L][0])}' for L in sorted(by_layer)))
46ok = (n == EXP_N and raw == EXP_RAW and rt == n and flip == n)
47print('VERDICT', 'COMPLETE' if ok else 'INCOMPLETE_OR_FAILED')
48sys.exit(0 if ok else 1)