interplane.Get Omega
Read in your language

omega-tool-model

First-party Omega tool-use model source, serving harnesses, and verification records

Brought by drakestapleton

branch main Branches Tags History

omega-tool-model / deployment / speed / prepare.py

67 lines · 2784 bytes Raw Blame History
1import os
2"""External preparation tool. Only the private measurement copy is edited."""
3from pathlib import Path
4import hashlib,json,subprocess,difflib
5R=Path(__file__).resolve().parent
6D=(Path(os.path.expanduser('~')) / '/.local/share/omega-tool-model/round40'.lstrip('/'))
7C=(Path(os.path.expanduser('~')) / '/handoffs/omega-llm-20261101/omega-mv/seed/out/omc'.lstrip('/'))
8def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest()
9m=json.loads((D/'DEPLOYED.json').read_text())
10assert sha(D/'model.ck')==m['checkpoint_sha256']
11assert sha(D/'omega-tool-model')==m['runtime_sha256']
12assert sha(C)=='2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f'
13src=(D/'source.om').read_text()
14out='global tmarks ulong 180\nglobal tbytes uchar 1440\n'+src
15def change(a,b):
16 global out
17 assert out.count(a)==1,(a,out.count(a))
18 out=out.replace(a,b)
19change('fn main to int\niread\nnn = ulong 160','fn main to int\nput tmarks 0 ulong monons\niread\nput tmarks 1 ulong monons\nnn = ulong 160')
20change('nn = ulong 160\nockload 1','nn = ulong 160\nockload 1\nput tmarks 2 ulong monons')
21change('np = obprompt 3\nif ge np get og 1','np = obprompt 3\nput tmarks 7 np\nput tmarks 3 ulong monons\nif ge np get og 1')
22change('ggopen\nggupw\nfor i ulong nn','ggopen\nggupw\nput tmarks 4 ulong monons\nfor i ulong nn')
23change('c = gsnext\nif eq c 0\nbreak\nend\nobtput c\nocpush c\nend\noflush\nr = nvstop\nret 0', '''c = gsnext
24if eq c 0
25put tmarks 9 1
26break
27end
28put tmarks add i 10 ulong monons
29put tmarks 8 add i 1
30obtput c
31ocpush c
32end
33put tmarks 5 ulong monons
34oflush
35r = nvstop
36put tmarks 6 ulong monons
37timereport
38ret 0''')
39out+='''
40note Emit timing only after model output and device cleanup; 180 little-endian u64 values.
41fn timereport to void
42for i ulong 180
43for j ulong 8
44v = and shr get tmarks i mul j 8 255
45put tbytes add mul i 8 j uchar v
46end
47end
48p = ulong 0
49while lt p len tbytes bound 1440
50r = write 2 tbytes p sub len tbytes p
51if le r 0
52exit 70
53end
54p = add p ulong r
55end
56end
57'''
58(R/'timed.om').write_text(out)
59(R/'timing.diff').write_text(''.join(difflib.unified_diff(src.splitlines(True),out.splitlines(True),fromfile='installed',tofile='instrumented')))
60start=src.index('text nvctl ');end=src.index('fn main to int')
61assert src[start:end]==out[out.index('text nvctl '):out.index('fn main to int')]
62p=subprocess.run([str(C)],input=out.encode(),capture_output=True,timeout=60)
63(R/'compile.stderr').write_bytes(p.stderr)
64assert p.returncode==0,(p.returncode,p.stderr.decode())
65(R/'timed').write_bytes(p.stdout);(R/'timed').chmod(0o700)
66(R/'pins.json').write_text(json.dumps({str(p):sha(p) for p in (D/'model.ck',D/'merges.bin',D/'omega-tool-model',D/'source.om',C,R/'timed.om',R/'timed')},indent=2)+'\n')
67print('Private timing build passed; model and GPU source unchanged.')