omega-tool-model
First-party Omega tool-use model source, serving harnesses, and verification records
Brought by drakestapleton
omega-tool-model / deployment / fast / build_cache.py
| 1 | import os |
| 2 | """External preparation of cached launch scheduling, with a byte-for-byte audit build.""" |
| 3 | from pathlib import Path |
| 4 | import subprocess,hashlib,json,difflib |
| 5 | R=Path(__file__).resolve().parent |
| 6 | C=(Path(os.path.expanduser('~')) / '/handoffs/omega-llm-20261101/omega-mv/seed/out/omc'.lstrip('/')) |
| 7 | src=(R/'server-head.om').read_text() |
| 8 | out=src |
| 9 | a='gkbuild id gx gy gz\nput gkt 0' |
| 10 | assert out.count(a)==1;out=out.replace(a,'cachebuild id gx gy gz\nput gkt 0') |
| 11 | a='r = mapwrite get gbmem 0 0 gbcmd 0 n\nput nvstage 0 41' |
| 12 | b='''r = long 0 |
| 13 | if eq get cslot 1 1 |
| 14 | r = mapwrite get gbmem 0 0 cbytes mul get cslot 0 4096 n |
| 15 | else |
| 16 | r = mapwrite get gbmem 0 0 gbcmd 0 n |
| 17 | end |
| 18 | put cslot 0 add get cslot 0 1 |
| 19 | put nvstage 0 41''' |
| 20 | assert out.count(a)==1;out=out.replace(a,b) |
| 21 | a='fn gsnext to ulong\nggupb' |
| 22 | assert out.count(a)==1;out=out.replace(a,'fn gsnext to ulong\nput cslot 0 0\nggupb') |
| 23 | decl='''global cbytes uchar 1048576 |
| 24 | global ckeys uint 10240 |
| 25 | global ckey uint 40 |
| 26 | global clen ulong 256 |
| 27 | global cslot ulong 2 |
| 28 | global ccnt ulong 2 |
| 29 | ''' |
| 30 | out=decl+out+'\n'+(R/'cache.om').read_text() |
| 31 | receipt={} |
| 32 | for 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') |
| 42 | print('Built checked and release cache candidates; submission, waits and kernels unchanged.') |