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/train/omega-llm/tools/combined/experiment/fixture.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 / train / omega-llm / tools / combined / experiment / fixture.py` 182 lines ยท 10414 bytes Raw Blame History 1 """Frozen CPU-only development and held-out tasks. Only the experiment judge imports ref().""" 2 import argparse 3 from collections import Counter 4 import hashlib 5 import json 6 from pathlib import Path 7 import random 8 9 U64 = (1 << 64) - 1 10 MANIFEST = Path(__file__).with_name("manifest.json") 11 SIGNATURE = {1: "a ulong", 2: "a ulong b ulong", 3: "a ulong b ulong c ulong", 12 4: "a view ulong 8 n ulong", 5: "a edit ulong 8 n ulong"} 13 14 # Variants of a template always stay in the same split. K is interpolated in prose and 15 # passed to a separate reference implementation. Each evaluation family has four variants. 16 FAMILIES = [ 17 ("eval","branch","threshold-gap",2,"if the first argument exceeds the second by more than {k}, return their difference, otherwise return the second argument"), 18 ("eval","branch","equal-offset",2,"return the sum of the arguments when the first equals the second plus {k}, and the smaller argument otherwise"), 19 ("eval","branch","minimum-offset",3,"return the third argument when the first plus {k} is below the second, otherwise return the first"), 20 ("eval","branch","masked-choice",3,"return the second argument when the first has bit {k} set, and the third argument otherwise"), 21 ("eval","branch","residue-choice",2,"return the first argument if its remainder modulo {k} equals the second argument, and their sum otherwise"), 22 ("eval","arithmetic","scaled-sum",2,"return {k} times the first argument plus the second"), 23 ("eval","arithmetic","product-offset",2,"return the product of the first argument plus {k} and the second argument plus one"), 24 ("eval","arithmetic","floor-before-add",2,"return the first argument divided by {k}, rounded down, plus the second argument"), 25 ("eval","arithmetic","binary-mix",2,"return the bitwise exclusive or of the first argument and the second argument multiplied by {k}"), 26 ("eval","arithmetic","paired-residue",2,"return the sum of the two remainders after dividing each argument by {k}"), 27 ("eval","read","stride-total",4,"sum values at indexes divisible by {k} in the first n items"), 28 ("eval","read","larger-step-count",4,"count consecutive pairs in the first n items where the right value exceeds the left value by at least {k}"), 29 ("eval","read","scaled-alternates",4,"sum the first n items, multiplying each odd-indexed value by {k} first"), 30 ("eval","read","clipped-total",4,"sum the first n values after capping each at {k}"), 31 ("eval","read","index-class",4,"count values among the first n whose remainder modulo {k} equals their index modulo {k}"), 32 ("eval","rewrite","shifted-index-xor",5,"exclusive-or each of the first n items with its index plus {k}"), 33 ("eval","rewrite","alternating-scale",5,"multiply odd-indexed items among the first n by {k} and preserve the others"), 34 ("eval","rewrite","pairwise-swap-offset",5,"swap each complete adjacent pair among the first n and add {k} to the new left member; preserve any unpaired item"), 35 ("eval","rewrite","local-peaks",5,"add {k} to each strict interior local maximum of the original first n items; leave the endpoints alone"), 36 ("eval","rewrite","clipped-gap",5,"replace each of the first n items by its excess above {k}, or by zero if it does not exceed {k}"), 37 ("dev","branch","sum-cutoff",2,"return the larger argument if their sum is above {k} and zero otherwise"), 38 ("dev","branch","sign-choice",3,"if the first argument is smaller than the second return the third plus {k}, otherwise return the third"), 39 ("dev","arithmetic","unary-square",1,"return the square of the argument plus {k}"), 40 ("dev","arithmetic","squared-distance",2,"return the squared difference of the arguments plus {k}"), 41 ("dev","read","residue-total",4,"sum the remainders modulo {k} of the first n items"), 42 ("dev","read","large-item-count",4,"count the first n items that exceed {k}"), 43 ("dev","rewrite","adjacent-add",5,"add {k} times the next original item to each of the first n items except the last"), 44 ("dev","rewrite","anchor-add",5,"add {k} times the original first item to every item among the first n"), 45 ("dev","rewrite","constant-add",5,"add {k} to each of the first n items"), 46 ("dev","rewrite","constant-xor",5,"apply bitwise exclusive or with {k} to each of the first n items"), 47 ("dev","rewrite","constant-fill",5,"fill the first n items with {k}"), 48 ("dev","rewrite","prefix-high",5,"set each of the first n items to the largest original value up to that point plus {k}"), 49 ] 50 51 52 def scalar(f, k, x): 53 a, b, c = (*x, 0, 0)[:3] 54 if f == "threshold-gap": return a-b if a > b+k else b 55 if f == "equal-offset": return a+b if a == b+k else min(a,b) 56 if f == "minimum-offset": return c if a+k < b else a 57 if f == "masked-choice": return b if a & (1<k else 0 65 if f == "sign-choice": return c+k if a=left+k for left,right in zip(active,active[1:])) 77 if f == "scaled-alternates": return sum(active[::2])+k*sum(active[1::2]) 78 if f == "clipped-total": return sum(min(v,k) for v in active) 79 if f == "index-class": return sum(v%k == i%k for i,v in enumerate(active)) 80 if f == "residue-total": return sum(v%k for v in active) 81 if f == "large-item-count": return sum(v>k for v in active) 82 raise KeyError(f) 83 out = list(a) 84 for i, v in enumerate(active): 85 if f == "shifted-index-xor": out[i] = v^(i+k) 86 elif f == "alternating-scale": out[i] = k*v if i%2 else v 87 elif f == "pairwise-swap-offset": 88 if i%2: out[i] = a[i-1] 89 elif i+1a[i+1]: out[i] = v+k 92 elif f == "clipped-gap": out[i] = max(0,v-k) 93 elif f == "adjacent-add": out[i] = v+(k*a[i+1] if i+1=20 164 probes=t["pool"]+t["score"] 165 signature=(t["shape"],tuple(ref(t,x) for x in probes)) 166 assert signature not in observed,t["id"] 167 observed.add(signature) 168 if t["shape"]==5: 169 assert {x[0] for x in t["score"]}==set(range(9)) 170 assert all(ref(t,x)[x[0]:]==x[1+x[0]:] for x in probes) 171 print("Verified",len(dev),"development and",len(ev),"evaluation tasks.", 172 "Manifest SHA-256",hashlib.sha256(MANIFEST.read_bytes()).hexdigest()) 173 174 175 if __name__=="__main__": 176 p=argparse.ArgumentParser() 177 p.add_argument("--create",action="store_true") 178 if p.parse_args().create: 179 with MANIFEST.open("x") as out: 180 json.dump(make(),out,separators=(",",":")) 181 out.write("\n") 182 check()