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-speed-20261114 / raw / amd-launch-gap / card / run2 / final / logs / gap-hip.py

26 lines · 1841 bytes Raw Blame History
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
3per-step decode times and all 256 ids instead of only the median. Same driver, Card, kernels and timer:
4real2 Card.forward begins perf_counter before hipGraphLaunch and stops after hipStreamSynchronize; host
5readback of logits and the token id happen after the timer stops.
6Usage: gap-hip.py DRIVER WEIGHTS FIXTURE OUT.json CAPACITY"""
7import hashlib,importlib.util,json,os,sys
8from pathlib import Path
9
10driver,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])
11fixture=json.loads(fixture_path.read_bytes())
12P,G=fixture['prompt_ids'],fixture['generated_ids']
13os.environ['AMDSERVE_WEIGHTS']=str(weights);os.environ['AMDSERVE_OUTPUT']=str(out)+'.log'
14spec=importlib.util.spec_from_file_location('real2driver',driver);drv=importlib.util.module_from_spec(spec);spec.loader.exec_module(drv)
15drv.GOLD=dict(drv.GOLD,prompt_ids=list(P),generated_ids=list(G),top5=[[(0,0.0)]]*len(G))
16drv.top5_difference=lambda logits,expected:None
17if cap<len(P)+len(G):raise SystemExit('capacity below prompt+generated')
18drv.Card.cap=property(lambda self:cap,lambda self,value:None)
19import torch
20drv.prepare()
21with torch.inference_mode():r=drv.measure(torch,'omega-graph')
22res=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())
25out.write_text(json.dumps(res)+'\n')
26print('GAPHIP',json.dumps({k:v for k,v in res.items() if k not in ('ids','decode_ms')}))