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
CUDApp / evidence / FLASH-NEXT-CODER-FULL-20261118 / summarize.py
| 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. |
| 5 | import collections, glob, hashlib, json, os, re, sys |
| 6 | |
| 7 | OUT, EXP_N, EXP_RAW = sys.argv[1], int(sys.argv[2]), int(sys.argv[3]) |
| 8 | raw = coded = n = rt = flip = 0 |
| 9 | by_layer = collections.defaultdict(lambda: [0, 0]) |
| 10 | by_kind = collections.defaultdict(lambda: [0, 0]) |
| 11 | worst = (0, 1, '') # largest coded/raw |
| 12 | best = (1, 1, '') # smallest coded/raw |
| 13 | seen = set() |
| 14 | h = hashlib.sha256() |
| 15 | files = sorted(glob.glob(os.path.join(OUT, '*.jsonl'))) |
| 16 | for 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']) |
| 35 | ppm = lambda c, r: c * 1000000 // r |
| 36 | print(f'shard_files={len(files)} results_sha256={h.hexdigest()}') |
| 37 | print(f'matrices={n} expected={EXP_N} raw_bytes={raw} expected_raw={EXP_RAW} coded_bytes={coded}') |
| 38 | print(f'ratio_ppm={ppm(coded, raw)} roundtrip_bit_exact={rt}/{n} flipped_bit_detected={flip}/{n}') |
| 39 | print(f'worst_matrix_ppm={ppm(worst[0], worst[1])} {worst[2]}') |
| 40 | print(f'best_matrix_ppm={ppm(best[0], best[1])} {best[2]}') |
| 41 | for 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])}') |
| 43 | lay = sorted((ppm(v[1], v[0]), L) for L, v in by_layer.items()) |
| 44 | print(f'layers={len(lay)} layer_ratio_ppm_min={lay[0]} layer_ratio_ppm_max={lay[-1]}') |
| 45 | print('per_layer_ppm ' + ' '.join(f'{L}:{ppm(by_layer[L][1], by_layer[L][0])}' for L in sorted(by_layer))) |
| 46 | ok = (n == EXP_N and raw == EXP_RAW and rt == n and flip == n) |
| 47 | print('VERDICT', 'COMPLETE' if ok else 'INCOMPLETE_OR_FAILED') |
| 48 | sys.exit(0 if ok else 1) |