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/summarize_trace.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 / summarize_trace.py` 55 lines ยท 2348 bytes Raw Blame History 1 #!/usr/bin/env python3 2 # SPDX-License-Identifier: Apache-2.0 3 """Exact interval unions from chip_probe JSON, using its monotonic nanoseconds.""" 4 import json 5 from pathlib import Path 6 import sys 7 8 9 def summarize(row): 10 origin = row['origin_monotonic_ns'] 11 stop = origin + row['wall_ns'] 12 events = {} 13 names = ('read', 'verify', 'copy', 'compute') 14 for span in row['spans']: 15 for i, name in enumerate(names): 16 start, end = span[name] 17 if start == end == 0: 18 continue 19 assert origin <= start <= end <= stop, (name, start, end) 20 events.setdefault(start, [0]*4)[i] += 1 21 events.setdefault(end, [0]*4)[i] -= 1 22 count = [0]*4 23 prev = origin 24 totals = dict.fromkeys(('read_union_ns', 'verify_union_ns', 'copy_union_ns', 25 'compute_union_ns', 'read_verify_compute_overlap_ns', 26 'io_exposed_without_gpu_ns', 'all_active_union_ns'), 0) 27 for when in sorted(events): 28 elapsed = when-prev 29 for i, name in enumerate(names): 30 if count[i]: 31 totals[name+'_union_ns'] += elapsed 32 io = count[0] or count[1] 33 if io and count[3]: 34 totals['read_verify_compute_overlap_ns'] += elapsed 35 if io and not (count[2] or count[3]): 36 totals['io_exposed_without_gpu_ns'] += elapsed 37 if any(count): 38 totals['all_active_union_ns'] += elapsed 39 count = [a+b for a,b in zip(count, events[when])] 40 assert min(count) >= 0 41 prev = when 42 assert count == [0]*4 43 totals['outside_measured_phases_ns'] = row['wall_ns'] - totals['all_active_union_ns'] 44 return {k:row[k] for k in ('trial','buffers','mutant','wall_ns','failed')} | totals 45 46 47 if __name__ == '__main__': 48 # Two concurrent identical reads must count once in wall-time overlap. 49 sample = {'origin_monotonic_ns':1, 'wall_ns':6, 'trial':0, 'buffers':2, 50 'mutant':0, 'failed':0, 'spans':[ 51 {'read':[1,5], 'verify':[0,0], 'copy':[0,0], 'compute':[3,7]}, 52 {'read':[1,5], 'verify':[0,0], 'copy':[0,0], 'compute':[0,0]}]} 53 assert summarize(sample)['read_verify_compute_overlap_ns'] == 2 54 for line in Path(sys.argv[1]).read_text().splitlines(): 55 print(json.dumps(summarize(json.loads(line))))