omega-tool-model
First-party Omega tool-use model source, serving harnesses, and verification records
Brought by drakestapleton
omega-tool-model / deployment / fast / build_rows.py
| 1 | import os |
| 2 | """External construction of two isolated inference-only optimization trials.""" |
| 3 | from pathlib import Path |
| 4 | import json,hashlib,subprocess,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-cache.om').read_text() |
| 8 | upload=''' |
| 9 | note Inference consumes input tokens only. Targets and backward counting-sort data are not read. |
| 10 | fn gsupload to void |
| 11 | h = get gbmem 5 |
| 12 | xo = get gga 2 |
| 13 | for i ulong get og 1 |
| 14 | m = mapset h add xo mul i 4 4 get obx i |
| 15 | end |
| 16 | put gkinv 0 1 |
| 17 | end |
| 18 | ''' |
| 19 | a='fn gsnext to ulong\nput cslot 0 0\nggupb' |
| 20 | assert src.count(a)==1 |
| 21 | lean=src.replace(a,'fn gsnext to ulong\nput cslot 0 0\ngsupload')+upload |
| 22 | rows='global sactive ulong 1\n'+lean |
| 23 | a='fn ggr to ulong\nret mul get og 6 get og 1\nend' |
| 24 | assert rows.count(a)==1 |
| 25 | rows=rows.replace(a,'''fn ggr to ulong |
| 26 | if ne get sactive 0 0 |
| 27 | ret mul div add get og 9 31 32 32 |
| 28 | end |
| 29 | ret mul get og 6 get og 1 |
| 30 | end''') |
| 31 | a='fn gsnext to ulong\nput cslot 0 0' |
| 32 | rows=rows.replace(a,'fn gsnext to ulong\nput sactive 0 1\nput cslot 0 0') |
| 33 | receipt={} |
| 34 | for name,text in [('server-lean',lean),('server-rows',rows),('server-rows-check',rows.replace('const CACHECHK ulong 0','const CACHECHK ulong 1'))]: |
| 35 | (R/(name+'.om')).write_text(text) |
| 36 | p=subprocess.run([str(C)],input=text.encode(),capture_output=True,timeout=60) |
| 37 | (R/(name+'.stderr')).write_bytes(p.stderr) |
| 38 | assert p.returncode==0,(name,p.returncode,p.stderr.decode()) |
| 39 | (R/name).write_bytes(p.stdout);(R/name).chmod(0o700) |
| 40 | receipt[name]=dict(source_sha256=hashlib.sha256(text.encode()).hexdigest(),binary_sha256=hashlib.sha256(p.stdout).hexdigest()) |
| 41 | (R/'rows-build.json').write_text(json.dumps(receipt,indent=2)+'\n') |
| 42 | (R/'rows.diff').write_text(''.join(difflib.unified_diff(src.splitlines(True),rows.splitlines(True),fromfile='cached-launch',tofile='active-rows'))) |
| 43 | print('Built inference-only upload and active-row variants, including checked launch-cache variant.') |