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 / amd-qwen38-native-20261113 / verify.py

39 lines · 2989 bytes Raw Blame History
1# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2# External evidence verifier, not a production dependency.
3from pathlib import Path
4import ast,hashlib,json,math,re,subprocess,sys
5D=Path(__file__).resolve().parent
6hashes=json.loads((D/'SHA256.json').read_text())
7actual={str(f.relative_to(D)) for f in D.rglob('*') if f.is_file() and f.name!='SHA256.json'}
8assert actual==set(hashes),(actual-set(hashes),set(hashes)-actual)
9for name,digest in hashes.items():assert hashlib.sha256((D/name).read_bytes()).hexdigest()==digest,name
10for name,entry in json.loads((D/'oracle/ORIGINAL_SCRIPTS.json').read_text()).items():
11 raw=(D/name).read_bytes();prefix=entry['portable_prefix'].encode();assert raw.startswith(prefix)
12 assert hashlib.sha256(raw[len(prefix):]).hexdigest()==entry['original_sha256'],name
13v=json.loads((D/'native/state.json').read_text());h=json.loads((D/'numerical/graph.json').read_text());f=json.loads((D/'oracle/lighthouse256.json').read_text())
14assert h['capacity']==f['capacity']==131072 and len(h['ids'])==256
15assert h['fixture_sha256']==hashlib.sha256((D/'oracle/lighthouse256.json').read_bytes()).hexdigest()
16assert h['first_divergence']==109
17for token,top in zip(h['ids'],h['top5']):
18 assert token==top[0][0] and all(math.isfinite(score) for _,score in top)
19for label in ['control']+[r['label'] for r in v['rows']]:
20 row=v['control'] if label=='control' else next(r for r in v['rows'] if r['label']==label)
21 raw=(D/'native'/(label+'.stdout')).read_text()
22 steps=[tuple(map(int,t)) for t in re.findall(r'^OMEGA_STEP (\d+) tok=(\d+) us=(\d+)$',raw,re.M)]
23 ids=list(map(int,re.search(r'^OMEGA_PLAN ids=\[([\d, ]+)\]$',raw,re.M).group(1).split(',')))
24 assert row['exit']==0 and [i for i,t,u in steps]==list(range(285))
25 assert ids==[t for i,t,u in steps[29:]]==row['ids']
26 assert (ids==h['ids'])==(label!='control')
27 assert (ids==f['generated_ids'])==row['all_ids_equal']
28 assert next((i for i,(a,b) in enumerate(zip(ids,f['generated_ids'])) if a!=b),None)==row['first_divergence']
29gold=next(ast.literal_eval(n.value) for n in ast.parse((D/'oracle/driver-real2.py').read_text()).body if isinstance(n,ast.Assign) and any(isinstance(t,ast.Name) and t.id=='GOLD' for t in n.targets))
30c=json.loads((D/'coding24/coding24.json').read_text());assert c['phase']=='complete' and c['expected']==gold['generated_ids']
31assert c['binary_sha256']==v['binary_sha256']==json.loads((D/'host/qualification.json').read_text())['binary_sha256']
32for row in c['rows']:
33 raw=(D/'coding24'/(row['label']+'.stdout')).read_text()
34 ids=list(map(int,re.search(r'^OMEGA_PLAN ids=\[([\d, ]+)\]$',raw,re.M).group(1).split(',')))
35 assert ids==row['ids'] and row['exit']==0
36 assert (ids==gold['generated_ids'])==(row['label']=='coding24')
37calc=json.loads(subprocess.check_output([sys.executable,str(D/'calculate.py')]))
38assert calc==json.loads((D/'calculations.json').read_text())
39print('EVIDENCE PASS',len(hashes),'hashed files; raw steps/IDs; independent graph; reference coding24; calculations')