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 / fast / build_cache.py

42 lines · 1884 bytes Raw Blame History
1import os
2"""External preparation of cached launch scheduling, with a byte-for-byte audit build."""
3from pathlib import Path
4import subprocess,hashlib,json,difflib
5R=Path(__file__).resolve().parent
6C=(Path(os.path.expanduser('~')) / '/handoffs/omega-llm-20261101/omega-mv/seed/out/omc'.lstrip('/'))
7src=(R/'server-head.om').read_text()
8out=src
9a='gkbuild id gx gy gz\nput gkt 0'
10assert out.count(a)==1;out=out.replace(a,'cachebuild id gx gy gz\nput gkt 0')
11a='r = mapwrite get gbmem 0 0 gbcmd 0 n\nput nvstage 0 41'
12b='''r = long 0
13if eq get cslot 1 1
14r = mapwrite get gbmem 0 0 cbytes mul get cslot 0 4096 n
15else
16r = mapwrite get gbmem 0 0 gbcmd 0 n
17end
18put cslot 0 add get cslot 0 1
19put nvstage 0 41'''
20assert out.count(a)==1;out=out.replace(a,b)
21a='fn gsnext to ulong\nggupb'
22assert out.count(a)==1;out=out.replace(a,'fn gsnext to ulong\nput cslot 0 0\nggupb')
23decl='''global cbytes uchar 1048576
24global ckeys uint 10240
25global ckey uint 40
26global clen ulong 256
27global cslot ulong 2
28global ccnt ulong 2
29'''
30out=decl+out+'\n'+(R/'cache.om').read_text()
31receipt={}
32for name,check in [('server-cache-check',1),('server-cache',0)]:
33 text=f'const CACHECHK ulong {check}\n'+out
34 (R/(name+'.om')).write_text(text)
35 q=subprocess.run([str(C)],input=text.encode(),capture_output=True,timeout=60)
36 (R/(name+'.stderr')).write_bytes(q.stderr)
37 assert q.returncode==0,(name,q.returncode,q.stderr.decode())
38 (R/name).write_bytes(q.stdout);(R/name).chmod(0o700)
39 receipt[name]=dict(sha256=hashlib.sha256(q.stdout).hexdigest(),source_sha256=hashlib.sha256(text.encode()).hexdigest())
40(R/'cache.diff').write_text(''.join(difflib.unified_diff(src.splitlines(True),out.splitlines(True),fromfile='last-tile',tofile='cached-host-build')))
41(R/'cache-build.json').write_text(json.dumps(receipt,indent=2)+'\n')
42print('Built checked and release cache candidates; submission, waits and kernels unchanged.')