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-20261113/oracle/check-plan.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-20261113 / oracle / check-plan.py` 127 lines · 8543 bytes Raw Blame History 1 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 """Harness check, independent of emit-plan.py: parse PLAN with FORMAT.md rules only, then 3 (1) every file-backed buffer is exactly one checkpoint tensor's byte range (from the safetensors headers), 4 (2) kind 2/4 buffers are 1-D BF16 vectors and their widened values match safetensors' own decoding, 5 (3) the dispatch table obeys every structural rule L1214 validates, 6 (4) negative controls: a plan with one corrupted relocation and one with a misaligned weight range are refused, 7 (5) capacity: the RoPE table, the 32 KV caches, the attention partition grid and every capacity kernel argument 8 agree with the capacity recorded beside the plan; checking against any other capacity is refused. 9 Usage: check-plan.py PLAN WEIGHTS 10 """ 11 import hashlib,json,struct,sys 12 from pathlib import Path 13 import torch 14 from safetensors import safe_open 15 plan_path,weights=Path(sys.argv[1]),Path(sys.argv[2]);summary=json.loads(Path(str(plan_path)+'.json').read_text()) 16 ranges={} 17 for f in summary['files']: 18 with (weights/f).open('rb') as h: 19 n=struct.unpack('=1 and ng>=1 and nf==len(summary['files']) 24 sp,sl,dp,dl=struct.unpack_from('<4Q',p,len(p)-32);assert dp==sp+sl and dp+dl==len(p)-32 25 q=64;codes=[] 26 for i in range(nc): 27 o,l=struct.unpack_from('<2Q',p,q);q+=16;assert o+l<=sl;codes.append(p[sp+o:sp+o+l].decode()) 28 bufs=[struct.unpack_from('<6Q',p,q+48*i) for i in range(nb)];q+=48*nb 29 names=[] 30 for size,kind,fi,off,length,flags in bufs: 31 assert flags in (1,2) 32 if kind==0:assert fi==off==length==0;names.append(None) 33 elif kind==3:assert fi==0 and off+length<=dl and size==length;names.append(None) 34 else: 35 assert kind in (1,2) and fi=4 41 q+=4*npm;q+=(-q)%8 42 for i in range(nd): 43 ci,gx,gy,gz,bx,kb,nr,pad=struct.unpack_from('<8I',p,q);q+=32 44 assert ci=1 and gy>=1 and gz==1 and bx==64 and pad==0 45 blob=p[q:q+kb];q+=kb;slots=set() 46 for j in range(nr): 47 off,bi,bo=struct.unpack_from('=npm+ng 71 sp,sl,dp,dl=struct.unpack_from('<4Q',p,len(p)-32);q=64;codes=[] 72 for i in range(nc):o,l=struct.unpack_from('<2Q',p,q);q+=16;codes.append(p[sp+o:sp+o+l].decode()) 73 bufs=[struct.unpack_from('<6Q',p,q+48*i) for i in range(nb)];q+=48*nb 74 cfg=json.loads((weights/'config.json').read_text())['text_config'];theta=cfg['rope_parameters']['rope_theta'] 75 angles=torch.arange(cap,dtype=torch.float64).unsqueeze(1)/torch.pow(torch.tensor(theta,dtype=torch.float64),torch.arange(32,dtype=torch.float64)*2/64) 76 want=torch.cat((angles.cos(),angles.sin()),dim=1).float().numpy().tobytes() 77 size,kind,fi,off,length,flags=bufs[summary['rope_buffer']];assert kind==3 and length==len(want) and p[dp+off:dp+off+length]==want,'rope table' 78 kv=summary['kv_buffers'];assert len(kv)==2*sum(1 for k in cfg['layer_types'] if k=='full_attention')==32,len(kv) 79 for bi in kv:assert bufs[bi][1]==0 and bufs[bi][0]==4*cap*256*2,('kv size',bi,bufs[bi][0]) 80 q+=4*npm;q+=(-q)%8;seen={} 81 at={'attn256_prep_step':80,'attn256_part_step':48,'attn256_merge_step':48,'step_advance':8} 82 for i in range(nd): 83 ci,gx,gy,gz,bx,kb,nr,pad=struct.unpack_from('<8I',p,q);q+=32;blob=p[q:q+kb];q+=kb+16*nr;q+=(-q)%8;name=codes[ci] 84 if name in at: 85 assert struct.unpack_from('