Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/CUDApp/blob/main/evidence/amd-speed-20261114/recompute/check_report.py # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `CUDApp / evidence / amd-speed-20261114 / recompute / check_report.py` 102 lines · 4987 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # Check REPORT.md against numbers.json. What is checked, exactly: 3 # 1. Every decimal number outside code spans equals, to its printed precision, some value in numbers.json. 4 # 2. A decimal followed by a unit word (ms, us, percent, times, TB/s, GB, tokens per second, tokens per pass) must equal a 5 # value of that unit class, so a figure cannot be matched by an unrelated value in another unit. 6 # 3. Bound claims (claims.json): each regex must match the report, and every captured number (integers included) must 7 # equal the named numbers.json value. These cover the headline figures and ratios and the counts of runs, launches 8 # and gate cases. 9 # 4. No em or en dashes. 10 # Integers other than the bound claims, and decimals inside tables without a unit word, are checked only by rule 1 or not 11 # at all. --selftest applies known one-number mutations to a copy and requires each to fail. 12 # Usage: check_report.py REPORT.md numbers.json claims.json [--selftest] 13 import json, re, sys 14 from pathlib import Path 15 16 UNITS = [(r'ms\b', {'ms/token', 'ms', 'ms/row'}), (r'(?:us|\u00b5s)\b', {'us', 'us/step'}), (r'percent\b', {'%'}), 17 (r'times\b', {'x'}), (r'TB/s', {'TB/s'}), (r'GB\b', {'GB', 'B'}), (r'tokens per second\b', {'tokens/s'}), 18 (r'tokens per pass\b', {'tokens/pass'})] 19 20 21 def load_values(nums): 22 vals = [] 23 for n in nums: 24 v = n['value'] 25 for x in (v if isinstance(v, list) else [v]): 26 if isinstance(x, (int, float)) and not isinstance(x, bool): 27 vals.append((float(x), n.get('unit', ''))) 28 if n.get('unit') == 'B': 29 vals.append((float(x) / 1e9, 'B')) 30 return vals 31 32 33 def check(report, nums, claims, quiet=False): 34 vals = load_values(nums) 35 byid = {n['id']: n['value'] for n in nums} 36 text = re.sub(r'```.*?```', lambda m: ' ' * len(m.group(0)), report, flags=re.S) 37 text = re.sub(r'`[^`\n]*`', lambda m: ' ' * len(m.group(0)), text) 38 bad, seen, bound = [], 0, 0 39 for m in re.finditer(r'(? 0.5 * 10 ** -nd + 1e-12: 73 bad.append(f'CLAIM MISMATCH {g} != {cid}={want} (line {report.count(chr(10), 0, m.start()) + 1})') 74 dash = [i + 1 for i, l in enumerate(report.splitlines()) if '\u2013' in l or '\u2014' in l] 75 if not quiet: 76 print(f'CHECK-REPORT decimals={seen} unit-bound={bound} claims={nclaims} MISMATCH {len(bad)} dashes={len(dash)}') 77 for x in bad: 78 print(' ' + x) 79 for d in dash: 80 print(' DASH line', d) 81 return not bad and not dash 82 83 84 MUTATIONS = [('16.226', '16.326'), ('1.674 times', '1.829 times'), ('173 completed', '171 completed'), 85 ('Spark gate: 318 checks', 'Spark gate: 316 checks'), ('5 of the 10 planned', '6 of the 10 planned')] 86 87 if __name__ == '__main__': 88 report = Path(sys.argv[1]).read_text() 89 nums = json.loads(Path(sys.argv[2]).read_text())['numbers'] 90 claims = json.loads(Path(sys.argv[3]).read_text()) 91 if '--selftest' in sys.argv: 92 ok = check(report, nums, claims, quiet=True) 93 caught = 0 94 for old, new in MUTATIONS: 95 if old not in report: 96 print(f' SELFTEST mutation target missing: {old}') 97 continue 98 caught += not check(report.replace(old, new, 1), nums, claims, quiet=True) 99 res = ok and caught == len(MUTATIONS) 100 print(f'CHECK-SELFTEST {"PASS" if res else "FAIL"} original={"pass" if ok else "fail"} mutations caught={caught}/{len(MUTATIONS)}') 101 sys.exit(0 if res else 1) 102 sys.exit(0 if check(report, nums, claims) else 1)