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 / card-evidence / uxl-stock.py

33 lines · 2350 bytes Raw Blame History
1import json,time,statistics,sys,traceback
2import torch,transformers
3from transformers import pipeline, StoppingCriteria, StoppingCriteriaList
4OUT='/workspace/uxl/uxl-stock.json'
5R={'what':'AMD stock notebook configuration: transformers pipeline image-text-to-text, Qwen/Qwen3.8-27B BF16, device_map=cuda; lighthouse prompt; greedy; 256 new tokens','torch':torch.__version__,'transformers':transformers.__version__,'rows':[]}
6def save(): open(OUT,'w').write(json.dumps(R,indent=1))
7try:
8 req=json.load(open('/workspace/uxl/CUDApp/evidence/amd-qwen38-native-refusal-20261113/spark-baseline/decode1.request.json'))
9 prompt=req['messages'][0]['content']; R['prompt']=prompt
10 t0=time.perf_counter()
11 pipe=pipeline("image-text-to-text", model="Qwen/Qwen3.8-27B", device_map="cuda")
12 R['load_s']=time.perf_counter()-t0; R['dtype']=str(next(pipe.model.parameters()).dtype); save()
13 msgs=[{"role":"user","content":[{"type":"text","text":prompt}]}]
14 class T(StoppingCriteria):
15 def __init__(s): s.t=[]; s.ids=None; s.first_len=None
16 def __call__(s,input_ids,scores,**k):
17 torch.cuda.synchronize(); s.t.append(time.perf_counter())
18 if s.first_len is None: s.first_len=int(input_ids.shape[1])
19 s.ids=input_ids[0]
20 return False
21 for label in ['warmup','run1','run2','run3','run4','run5']:
22 tc=T(); torch.cuda.synchronize(); b=time.perf_counter()
23 o=pipe(text=msgs, max_new_tokens=256, min_new_tokens=256, do_sample=False, return_full_text=False, generate_kwargs={'stopping_criteria':StoppingCriteriaList([tc])})
24 torch.cuda.synchronize(); e=time.perf_counter()
25 d=[(y-x)*1000 for x,y in zip(tc.t,tc.t[1:])]
26 row={'label':label,'total_s':e-b,'calls':len(tc.t)}
27 if d:
28 row.update(first_token_s=tc.t[0]-b,decode_ms_median=statistics.median(d),decode_ms_min=min(d),decode_ms_max=max(d),decode_ms=d,prompt_tokens=tc.first_len-1,generated_ids=tc.ids[tc.first_len-1:].tolist())
29 row['text_head']=str(o[0].get('generated_text'))[:160]
30 R['rows'].append(row); save(); print(label,row.get('decode_ms_median'),row['total_s'],flush=True)
31 R['vram_peak_bytes']=torch.cuda.max_memory_allocated(); R['status']='complete'; save()
32except Exception:
33 R['status']='exception'; R['error']=traceback.format_exc(); save(); raise