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/aien-sovereign-core-mv/blob/main/om/ribbon/check_overlap.py # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. 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 `aien-sovereign-core-mv / om / ribbon / check_overlap.py` 82 lines ยท 3054 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 3 """Discrete-event test instrument for the actual compiled Omega controller. 4 5 Ticks are synthetic. These results assert scheduling, never hardware speed. 6 """ 7 import ctypes as c 8 import importlib.util 9 from pathlib import Path 10 import sys 11 12 spec = importlib.util.spec_from_file_location('native', Path(sys.argv[1]) / 'omega_native.py') 13 native = importlib.util.module_from_spec(spec) 14 spec.loader.exec_module(native) 15 16 17 def simulate(buffers, read_ticks, compute_ticks, shared_engine=False): 18 state = (c.c_uint64 * 4096)() 19 now = 0 20 shared_free = 0 21 reads = [] 22 compute = None 23 completed = 0 24 25 def call(op, key=0, size=0, deadline=0, ok=0): 26 q = (c.c_uint64 * 8)(op, key, size, deadline, ok, 0, now, 0) 27 out = (c.c_uint64 * 8)() 28 result = c.c_uint64() 29 assert native.omega_pipeline(c.byref(result), state, 4096, q, 8, out, 8) == 0 30 return result.value, list(out) 31 32 assert call(1, 4, buffers, buffers)[0] == 0 33 for key in range(4): 34 assert call(2, key, 1, 10000)[0] == 0 35 for _ in range(100): 36 if compute is not None and compute[0] <= now: 37 assert call(8, compute[1])[0] == 0 38 assert call(9, compute[1])[0] == 0 39 compute = None 40 completed += 1 41 for end, ticket in list(reads): 42 if end <= now: 43 assert call(4, ticket, ok=1)[0] == 0 44 reads.remove((end, ticket)) 45 if compute is None: 46 code, out = call(5) 47 assert code in (0, 1) 48 if code == 0: 49 assert call(6, out[0], ok=1)[0] == 0 50 assert call(7, out[0])[0] == 0 51 begin = max(now, shared_free) if shared_engine else now 52 compute = (begin + compute_ticks, out[0]) 53 if shared_engine: 54 shared_free = compute[0] 55 if buffers == 2 or compute is None: 56 while True: 57 code, out = call(3) 58 assert code in (0, 1) 59 if code == 1: 60 break 61 begin = max(now, shared_free) if shared_engine else now 62 reads.append((begin + read_ticks, out[0])) 63 if shared_engine: 64 shared_free = reads[-1][0] 65 if completed == 4: 66 return now 67 events = [end for end, _ in reads] 68 if compute is not None: 69 events.append(compute[0]) 70 assert events, 'controller stopped making progress' 71 now = min(events) 72 raise AssertionError('unbounded scheduling loop') 73 74 75 parallel = [simulate(b, 10, 10) for b in (1, 2)] 76 cached = [simulate(b, 0, 10) for b in (1, 2)] 77 serialized = [simulate(b, 10, 10, True) for b in (1, 2)] 78 assert parallel[1] < parallel[0], parallel 79 assert cached[1] == cached[0], cached 80 assert serialized[1] == serialized[0], serialized 81 print('PASS synthetic schedule ticks (one/two):', 82 {'independent_engines': parallel, 'zero_read_cost': cached, 'shared_engine': serialized})