Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-tool-model/blob/main/deployment/fast/build.py # omega-tool-model First-party Omega tool-use model source, serving harnesses, and verification records Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-tool-model / deployment / fast / build.py` 80 lines ยท 3642 bytes Raw Blame History 1 import os 2 """External build instrument. Both shipped programs are native Omega.""" 3 from pathlib import Path 4 import hashlib,json,subprocess,difflib 5 R=Path(__file__).resolve().parent 6 D=(Path(os.path.expanduser('~')) / '/.local/share/omega-tool-model/round40'.lstrip('/')) 7 C=(Path(os.path.expanduser('~')) / '/handoffs/omega-llm-`20261101`/omega-mv/seed/out/omc'.lstrip('/')) 8 def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest() 9 assert sha(C)=='`2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`' 10 manifest=json.loads((D/'DEPLOYED.json').read_text()) 11 assert sha(D/'model.ck')==manifest['checkpoint_sha256'] 12 assert sha(D/'omega-tool-model')==manifest['runtime_sha256'] 13 src=(D/'source.om').read_text() 14 mainstart=src.index('fn main to int\niread') 15 mainend=src.index('text imodel ',mainstart) 16 base=src[:mainstart]+src[mainend:] 17 entry=src[mainend:] 18 cliententry=entry[:entry.index('note Preserve the sampler')] 19 cliententry=cliententry.replace('No tools are executed. No chat service is started.', 'Streams from the resident local model. No tools are executed.') 20 flushstart=base.index('fn oflush to void') 21 flushend=base.index('\nnote v1 checkpoint',flushstart) 22 flush='''fn oflush to void 23 n = get oon 0 24 if eq n 0 25 ret 26 end 27 if lt get nfd 0 0 28 r = write 2 oout 0 n 29 put oon 0 0 30 ret 31 end 32 nheader n 33 for i ulong n 34 put nbuf add i 2 get oout i 35 end 36 if not nsend 0 add n 2 37 put nerr 0 1 38 end 39 put oon 0 0 40 end 41 ''' 42 base=base[:flushstart]+flush+base[flushend:] 43 transport=(R/'transport.om').read_text() 44 server=(R/'server.om').read_text().replace('r = umask 63','put nfd 0 -1\nr = umask 63') 45 resident=transport+'\n'+base+'\n'+server 46 client=transport+'\n'+cliententry+'\n'+(R/'client-entry.om').read_text() 47 head=''' 48 note Only the 32-row tile containing the last context position needs vocabulary scores. 49 note Keep the original kernel, K reduction order, full allocated stride and output row offset. 50 fn gglast x ulong w ulong c ulong to void 51 row = mul div sub get og 9 1 32 32 52 k4 = uint mul get og 2 4 53 n4 = uint mul get og 0 4 54 xx = add x mul row ulong k4 55 cc = add c mul row ulong n4 56 gkopa 0 xx k4 4 0 0 57 gkopa 1 w k4 4 0 0 58 gkopc cc n4 4 0 0 f32 1.0f64 59 ggmm 32 get og 0 get og 2 1 1 false 60 end 61 ''' 62 old='ggxwt z w x get og 0 d false\nend\nfn gsnext' 63 assert resident.count(old)==1 64 optimized=resident.replace(old,'gglast z w x\nend\nfn gsnext')+head 65 sources={'server-base':resident,'server-head':optimized,'client':client} 66 receipts={} 67 for name,source in sources.items(): 68 path=R/(name+'.om');path.write_text(source) 69 p=subprocess.run([str(C)],input=source.encode(),capture_output=True,timeout=60) 70 (R/(name+'.stderr')).write_bytes(p.stderr) 71 assert p.returncode==0,(name,p.returncode,p.stderr.decode()) 72 (R/name).write_bytes(p.stdout);(R/name).chmod(0o700) 73 receipts[name]=dict(source_sha256=sha(path),binary_sha256=sha(R/name),compile_rc=p.returncode) 74 (R/'resident.diff').write_text(''.join(difflib.unified_diff(src.splitlines(True),resident.splitlines(True),fromfile='installed',tofile='resident'))) 75 (R/'projection.diff').write_text(''.join(difflib.unified_diff(resident.splitlines(True),optimized.splitlines(True),fromfile='resident',tofile='last-tile'))) 76 start=src.index('text nvctl ');end=src.index('fn gsforward') 77 for name in ('server-base','server-head'): 78 s=sources[name];assert src[start:end]==s[s.index('text nvctl '):s.index('fn gsforward')] 79 (R/'build.json').write_text(json.dumps(dict(builds=receipts,kernel_source_unchanged=True,pins={str(p):sha(p) for p in (C,D/'source.om',D/'omega-tool-model',D/'model.ck',D/'merges.bin')}),indent=2)+'\n') 80 print('Built native resident baseline, last-tile candidate and streaming client; kernel source unchanged.')