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
CUDApp / evidence / amd-speed-20261114 / raw / unpacked / amd-launch-gap / card / gap-evidence / logs / gap-hip.py
| 1 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 2 | """Instrument (not Omega): the published HIP graph arm, lighthouse-oracle.py mode `graph`, keeping the |
| 3 | per-step decode times and all 256 ids instead of only the median. Same driver, Card, kernels and timer: |
| 4 | real2 Card.forward begins perf_counter before hipGraphLaunch and stops after hipStreamSynchronize; host |
| 5 | readback of logits and the token id happen after the timer stops. |
| 6 | Usage: gap-hip.py DRIVER WEIGHTS FIXTURE OUT.json CAPACITY""" |
| 7 | import hashlib,importlib.util,json,os,sys |
| 8 | from pathlib import Path |
| 9 | |
| 10 | driver,weights,fixture_path,out,cap=Path(sys.argv[1]),Path(sys.argv[2]),Path(sys.argv[3]),Path(sys.argv[4]),int(sys.argv[5]) |
| 11 | fixture=json.loads(fixture_path.read_bytes()) |
| 12 | P,G=fixture['prompt_ids'],fixture['generated_ids'] |
| 13 | os.environ['AMDSERVE_WEIGHTS']=str(weights);os.environ['AMDSERVE_OUTPUT']=str(out)+'.log' |
| 14 | spec=importlib.util.spec_from_file_location('real2driver',driver);drv=importlib.util.module_from_spec(spec);spec.loader.exec_module(drv) |
| 15 | drv.GOLD=dict(drv.GOLD,prompt_ids=list(P),generated_ids=list(G),top5=[[(0,0.0)]]*len(G)) |
| 16 | drv.top5_difference=lambda logits,expected:None |
| 17 | if cap<len(P)+len(G):raise SystemExit('capacity below prompt+generated') |
| 18 | drv.Card.cap=property(lambda self:cap,lambda self,value:None) |
| 19 | import torch |
| 20 | drv.prepare() |
| 21 | with torch.inference_mode():r=drv.measure(torch,'omega-graph') |
| 22 | res=dict(mode='graph',capacity=cap,ids=r['ids'],decode_ms=r['decode_ms'],decode_ms_median=r['decode_ms_median'], |
| 23 | capture_ms=r['capture_ms'],timing_mode=r['timing_mode'],fixture_sha256=hashlib.sha256(fixture_path.read_bytes()).hexdigest(), |
| 24 | driver=str(driver),driver_sha256=hashlib.sha256(driver.read_bytes()).hexdigest()) |
| 25 | out.write_text(json.dumps(res)+'\n') |
| 26 | print('GAPHIP',json.dumps({k:v for k,v in res.items() if k not in ('ids','decode_ms')})) |