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-mv/blob/main/om/gpu/dsv41/decoder/trace-to-csv.py # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / om / gpu / dsv41 / decoder / trace-to-csv.py` 43 lines ยท 1502 bytes Raw Blame History 1 #!/usr/bin/env python3 2 """Convert a native 80-byte binary router trace archive to CSV for lookahead A/B.""" 3 import csv 4 import hashlib 5 import struct 6 import sys 7 8 9 def main(): 10 if len(sys.argv) < 3: 11 sys.exit("Usage: trace-to-csv.py TRACE.bin OUT.csv [EXPECTED_SHA256]") 12 src, dst = sys.argv[1], sys.argv[2] 13 expected = sys.argv[3] if len(sys.argv) > 3 else None 14 raw = open(src, "rb").read() 15 if len(raw) % 80 != 0 or len(raw) == 0: 16 sys.exit(f"Invalid trace size: {len(raw)}") 17 digest = hashlib.sha256(raw).hexdigest() 18 if expected and digest != expected: 19 sys.exit(f"SHA-256 mismatch: got {digest}, expected {expected}") 20 n = len(raw) // 80 21 with open(dst, "w", newline="") as f: 22 w = csv.writer(f) 23 w.writerow(["turn_id", "token_idx", "layer_id", "top_k_experts", "gate_weights", "gate_ready_ns", "expert_need_ns"]) 24 for i in range(n): 25 rec = struct.unpack_from("<4I6I6f2Q", raw, i * 80) 26 turn_id, token_idx, layer_id, _res = rec[:4] 27 ids = rec[4:10] 28 wts = rec[10:16] 29 ready_ns, need_ns = rec[16:18] 30 w.writerow([ 31 turn_id, 32 token_idx, 33 layer_id, 34 " ".join(str(x) for x in ids), 35 " ".join(f"{x:.7g}" for x in wts), 36 ready_ns, 37 need_ns, 38 ]) 39 print(f"CONVERTED records={n} tokens={n // 40} sha256={digest}") 40 41 42 if __name__ == "__main__": 43 main()