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-qwen38-native-final-20261113/oracle/benchmark-qualified.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-qwen38-native-final-20261113 / oracle / benchmark-qualified.py` 87 lines · 5907 bytes Raw Blame History 1 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 """External experiment: archived Spark prompt, fixed generation length and capacity.""" 3 from pathlib import Path 4 import hashlib,json,os,re,statistics,struct,subprocess,threading,time,traceback 5 D=Path(__file__).resolve().parent 6 S=Path(os.environ['SOURCE_PLAN_DIR']).resolve() 7 F=json.loads((D/'lighthouse256.json').read_text()) 8 P=F['prompt_ids'];G=F['generated_ids'];N=len(P)+len(G)-1 9 HIP_PATH=Path(os.environ['HIP_ORACLE_JSON']).resolve() 10 HIP=json.loads(HIP_PATH.read_text());H=HIP['ids'] 11 assert HIP['capacity']==F['capacity'] and len(H)==len(G) 12 assert HIP['fixture_sha256']==hashlib.sha256((D/'lighthouse256.json').read_bytes()).hexdigest() 13 state={'phase':'prepare','rows':[],'fixture':F,'hip_oracle_sha256':hashlib.sha256(HIP_PATH.read_bytes()).hexdigest(),'qualification':'all IDs equal independent AMD HIP graph; archived Spark agreement reported separately'} 14 source_manifest=json.loads((S/'MANIFEST.json').read_text()) 15 state['binary_sha256']=hashlib.sha256((S/'omega-launch').read_bytes()).hexdigest() 16 assert state['binary_sha256']==source_manifest['omega-launch'] 17 def save(): 18 (D/'state.json').write_text(json.dumps(state,indent=2)) 19 print(json.dumps({'phase':state['phase'],'rows':state['rows']}),flush=True) 20 def patch(name): 21 raw=(S/name).read_bytes() 22 assert hashlib.sha256(raw).hexdigest()==json.loads((S/'MANIFEST.json').read_text())[name] 23 nc,nf,nb,nd,np,ng,tok=struct.unpack_from('<7Q',raw,8) 24 off=64+nc*16+nb*48;end=off+((np*4+7)//8)*8 25 prompt=struct.pack('<'+'I'*len(P),*P);prompt+=bytes((-len(prompt))%8) 26 delta=len(prompt)-(end-off) 27 so,sl,do,dl=struct.unpack_from('<4Q',raw,len(raw)-32) 28 assert so>=end and so+sl==do and do+dl==len(raw)-32 29 result=raw[:40]+struct.pack('<2Q',len(P),len(G))+raw[56:off]+prompt+raw[end:-32]+struct.pack('<4Q',so+delta,sl,do+delta,dl) 30 path=D/name;path.write_bytes(result) 31 meta=json.loads((S/(name+'.json')).read_text()) 32 meta.update(plan=name,bytes=len(result),sha256=hashlib.sha256(result).hexdigest(),prompt=len(P),generate=len(G),fixture_sha256=hashlib.sha256((D/'lighthouse256.json').read_bytes()).hexdigest(),parent_plan_sha256=hashlib.sha256(raw).hexdigest()) 33 (D/(name+'.json')).write_text(json.dumps(meta,indent=2)) 34 return meta 35 def run(label,name,meta): 36 args=[str(S/'omega-launch'),'plan',str(D/name)]+[str(S/'code'/(n+'.hsaco')) for n in sorted(meta['code_objects'])]+[str(Path('/tmp/qwen3.8-27b-fp8')/n) for n in meta['files']] 37 for n,v in meta['code_objects'].items():assert hashlib.sha256((S/'code'/(n+'.hsaco')).read_bytes()).hexdigest()==v['sha256'] 38 start=time.monotonic();marks={};peak={'rss_kib':0,'drm':{}} 39 with (D/(label+'.stderr')).open('w') as err: 40 proc=subprocess.Popen(args,stdout=subprocess.PIPE,stderr=err,text=True,bufsize=1) 41 def deadline(): 42 try:proc.wait(timeout=180) 43 except subprocess.TimeoutExpired:proc.kill() 44 threading.Thread(target=deadline,daemon=True).start() 45 def sample(): 46 while proc.poll() is None: 47 try: 48 q=Path('/proc')/str(proc.pid) 49 for l in (q/'status').read_text().splitlines(): 50 if l.startswith('VmRSS:'):peak['rss_kib']=max(peak['rss_kib'],int(l.split()[1])) 51 for f in (q/'fdinfo').glob('*'): 52 for l in f.read_text().splitlines(): 53 if l.startswith('drm-memory-'): 54 k,v=l.split(':',1);parts=v.split() 55 if parts and parts[0].isdigit() and int(parts[0])>peak['drm'].get(k,{}).get('value',-1):peak['drm'][k]={'value':int(parts[0]),'unit':parts[1] if len(parts)>1 else ''} 56 except (OSError,ValueError):pass 57 time.sleep(.1) 58 threading.Thread(target=sample,daemon=True).start() 59 with (D/(label+'.stdout')).open('w') as out: 60 for line in proc.stdout: 61 out.write(line);out.flush() 62 if line.startswith('OMEGA_PLAN ready'):marks['ready_s']=time.monotonic()-start 63 if line.startswith('OMEGA_STEP '+str(len(P)-1)+' '):marks['first_generated_id_s']=time.monotonic()-start 64 rc=proc.wait() 65 text=(D/(label+'.stdout')).read_text() 66 steps=[tuple(map(int,v)) for v in re.findall(r'^OMEGA_STEP (\d+) tok=(\d+) us=(\d+)$',text,re.M)] 67 m=re.search(r'^OMEGA_PLAN ids=\[([\d, ]+)\]$',text,re.M);ids=list(map(int,m.group(1).split(','))) if m else [] 68 shape=rc==0 and [i for i,t,u in steps]==list(range(N)) and ids==[t for i,t,u in steps[len(P)-1:]] 69 row={'label':label,'exit':rc,'shape_ok':shape,'ids_match':sum(a==b for a,b in zip(ids,G)),'expected_ids':len(G),'first_divergence':next((i for i,(a,b) in enumerate(zip(ids,G)) if a!=b),None),'all_ids_equal':ids==G,'steps':len(steps),'marks':marks,'total_s':time.monotonic()-start,'memory_peak':peak,'prefill_ms':sum(u/1000 for i,t,u in steps[:len(P)]) if shape else None,'decode_ms_median':statistics.median(u/1000 for i,t,u in steps[len(P):]) if shape else None} 70 row.update(ids=ids,hip_ids_equal=ids==H,first_hip_divergence=next((i for i,(a,b) in enumerate(zip(ids,H)) if a!=b),None)) 71 (D/(label+'.json')).write_text(json.dumps(row,indent=2));return row 72 try: 73 metas={n:patch(n) for n in ['real2.plan','real2-controls.plan']} 74 state['plan_hashes']={n:m['sha256'] for n,m in metas.items()} 75 assert all(m['capacity']==F['capacity'] for m in metas.values()) 76 state['phase']='control';save() 77 c=run('control','real2-controls.plan',metas['real2-controls.plan']);state['control']=c;save() 78 assert c['shape_ok'] and not c['hip_ids_equal'] and not c['all_ids_equal'],'control not caught' 79 for label in ['warmup']+['sample'+str(i) for i in range(1,6)]: 80 state['phase']=label;save();r=run(label,'real2.plan',metas['real2.plan']);state['rows'].append(r);save() 81 assert r['shape_ok'] and r['hip_ids_equal'],r 82 state['phase']='complete';save() 83 print('RESULT PASS same archived Spark prompt and capacity, all 256 AMD HIP graph IDs exact in five accepted runs; Spark divergence reported separately',flush=True) 84 except BaseException: 85 state.update(phase='exception',detail=traceback.format_exc());save() 86 print('RESULT FAIL_OR_INCOMPLETE',flush=True) 87 raise