interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / om / q38-head / replay.py

43 lines · 1855 bytes Raw Blame History
1#!/usr/bin/env python3
2# SPDX-License-Identifier: Apache-2.0
3"""External replay against independently captured full GPU scores."""
4import ctypes as C
5import json
6from pathlib import Path
7import statistics
8import sys
9import time
10
11N,H=248320,5120
12lib=C.CDLL(str(Path(sys.argv[1]).resolve()))
13call=lib.omega_q38select
14call.restype=C.c_uint32
15call.argtypes=[C.POINTER(C.c_uint64),C.c_void_p,C.c_uint64,C.c_void_p,C.c_uint64,C.c_void_p,C.c_uint64,C.c_void_p,C.c_uint64,C.c_uint64]
16cap,data=Path(sys.argv[2]),Path(sys.argv[3])
17def read(path,n):
18 b=path.read_bytes()
19 assert len(b)==n*4
20 return (C.c_float*n).from_buffer_copy(b)
21coef=read(data/'coef.f32',N)
22rows=[]
23meta=json.loads((cap/'capture.json').read_text())
24assert not meta['mismatches']
25for item in meta['rows']:
26 pos=item['pos']
27 h=read(cap/f'{pos}-hidden.f32',H)
28 s=read(data/f'{pos}-screen.f32',N)
29 gpu=read(cap/f'{pos}-logits.f32',N)
30 mask=(C.c_ubyte*N)(); result=C.c_uint64()
31 t=time.perf_counter_ns()
32 rc=call(C.byref(result),h,H,s,N,coef,N,mask,N,N)
33 elapsed=time.perf_counter_ns()-t
34 assert rc==0
35 candidates=[i for i in range(N) if mask[i]]
36 assert len(candidates)==result.value and candidates
37 # max retains the first index on ties because candidates are ascending.
38 picked=max(candidates,key=lambda i:gpu[i])
39 assert picked==item['argmax'] and picked==max(range(N),key=lambda i:gpu[i])
40 rows.append({'position':pos,'candidates':len(candidates),'winner_retained':True,'selector_ns':elapsed})
41print(json.dumps({'status':'PASS','scope':'native Omega selector with host compact scores and captured full GPU scores',
42 'rows':rows,'median_selector_ns':statistics.median(r['selector_ns'] for r in rows),
43 'calculation':'median wall nanoseconds over eight replay calls; host overhead only; not end-to-end or uncontended timing'},indent=2))