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-train/blob/main/tests/omegallm/kv-check.py # aien-train AIEN training programme: language-model history, GB10 constraints and the route to training on the project engine. Plans and runnable checks are distinguished. 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-train / tests / omegallm / kv-check.py` 108 lines ยท 5524 bytes Raw Blame History 1 #!/usr/bin/env python3 2 """KV-cached decode check for `e993f179` (native/omegallm/model.om okvlcp and okvkv), host CPU only. 3 4 `e993f179` removed okvlcp's guard (any bank-B activation layer, l >= LAA, made ofwdi recompute every 5 row) and made okvlay restore and save each bank-B layer's K/V slices (okvkv) instead of flipping the 6 windows with oaflip. This check builds three ollm binaries with tests/omegallm/build.sh, all at the bx 7 capacities (the only shapes with bank-B layers that init accepts; LAA = 1 for 258 8 16 2 32 4): 8 bx the product, at the bx capacities 9 kvg bx plus the removed guard: the guarded path 10 kvo bx plus `e993f179` without its bank-B slices (old oaflip, no restore): the control 11 and runs `ollm kvcmp CK N PROMPT MERGES` (ofwdi then olast against ofwd 0 then olast, f64 bits of every 12 logit) on each case. Required per case: 13 bx exit 0, ndiff 0, and the cache was used (some step starts past row 0) 14 kvg exit 0, ndiff 0, every step starts at row 0 (so bank-B layers are present), and the same greedy 15 tokens as bx in both passes; ofwd is the same code in both binaries, so bx's incremental 16 logits are bit-identical to the guarded path's 17 kvo exit 43 with ndiff > 0 (the control must be caught) 18 Last line: KV_CHECK PASS cases=C controls=C caught=C, exit 0; else KV_CHECK FAIL ... and exit 1. 19 Env: OMC and CORE are passed to build.sh (its compiler pin is checked there). 20 """ 21 import os 22 from pathlib import Path 23 import re 24 import struct 25 import subprocess 26 import sys 27 import tempfile 28 29 root = Path(__file__).resolve().parents[2] 30 build = root / "tests/omegallm/build.sh" 31 SHAPE = ["258", "8", "16", "2", "32", "4", "1"] 32 SEEDS = ["7", "11"] 33 PROMPTS = ["a", "ab"] 34 STEPS = ["6", "12"] 35 36 37 def fail(msg): 38 print(f"KV_CHECK FAIL {msg}") 39 sys.exit(1) 40 41 42 def merges(path): 43 # a valid OLLM BPE merges file, V = 258 (two merges), as tests/omegallm/ollm_metrics_bench.py writes it 44 payload = struct.pack(" 0: 102 print(f"ok control kvo {case} caught ndiff={o['ndiff']}") 103 caught += 1 104 else: 105 print(f"FAIL control kvo {case} ESCAPED rc={o['rc']} ndiff={o['ndiff']}") 106 if caught != cases: 107 fail(f"cases={cases} controls={cases} caught={caught}") 108 print(f"KV_CHECK PASS cases={cases} controls={cases} caught={caught}")