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/emit-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 / emit-plan.py` 190 lines · 11939 bytes Raw Blame History 1 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2 """Harness: write an OMPLAN01 plan (FORMAT.md) from real2's own Card.emit, then decode the file independently and 3 compare it with the recorded launch list. Python never touches weight bytes: buffers name (file, offset, length). 4 Usage: emit-plan.py DRIVER WEIGHTS OUT.plan [--controls] [--capacity=N] [--fixture-json=PATH] 5 --capacity=N sizes the KV cache, RoPE table and attention partitions for N positions (Card's own default is 6 prompt+generated = 48). Prompt, generation and golden ids are unchanged; the override is applied here, not in Card. 7 --fixture-json=PATH replaces the driver's prompt_ids/generated_ids with the fixture's before anything is recorded 8 (Card source untouched); its capacity applies unless --capacity is given. The sidecar records the fixture's identity. 9 """ 10 import ctypes,hashlib,importlib.util,json,lzma,base64,os,struct,sys,types 11 from pathlib import Path 12 import torch 13 14 driver_path,weights,out=Path(sys.argv[1]),Path(sys.argv[2]),Path(sys.argv[3]);controls='--controls' in sys.argv 15 capacity=next((int(a.split('=',1)[1]) for a in sys.argv[4:] if a.startswith('--capacity=')),None) 16 fixture_path=next((Path(a.split('=',1)[1]) for a in sys.argv[4:] if a.startswith('--fixture-json=')),None) 17 fixture=None 18 if fixture_path is not None: 19 fixture_raw=fixture_path.read_bytes();fixture=json.loads(fixture_raw) 20 for k in ('prompt_ids','generated_ids'): 21 if not (isinstance(fixture.get(k),list) and fixture[k] and all(isinstance(t,int) and t>=0 for t in fixture[k])):raise SystemExit('fixture %s: %s must be a non-empty list of token ids'%(fixture_path,k)) 22 if capacity is None:capacity=fixture.get('capacity') 23 os.environ['AMDSERVE_WEIGHTS']=str(weights);os.environ['AMDSERVE_OUTPUT']=str(out)+'.log' 24 25 # Card allocates on 'cuda'; build the same objects on CPU. Weights are zero-stride stand-ins carrying true shape/dtype. 26 _to,_zeros,_tensor=torch.Tensor.to,torch.zeros,torch.tensor 27 def cpu(kw): 28 if str(kw.get('device'))=='cuda':kw['device']='cpu' 29 return kw 30 torch.zeros=lambda *a,**k:_zeros(*a,**cpu(k));torch.tensor=lambda *a,**k:_tensor(*a,**cpu(k)) 31 torch.Tensor.to=lambda self,*a,**k:_to(self,*(('cpu',)+a[1:] if a and str(a[0])=='cuda' else a),**cpu(k)) 32 torch.cuda.init=lambda:None;torch.cuda.synchronize=lambda:None 33 34 index=json.loads((weights/'model.safetensors.index.json').read_text())['weight_map'] 35 headers={} 36 def header(file): 37 if file not in headers: 38 with (weights/file).open('rb') as f: 39 n=struct.unpack('