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/seed/helix/ollm_factory/om_synth_sm121.om # 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 / seed / helix / ollm_factory / om_synth_sm121.om` 351 lines ยท 8964 bytes Raw Blame History 1 om2 2 note SPDX-License-Identifier: Apache-2.0 3 note seed/helix/ollm_factory/om_synth_sm121.om: 4 note SM121 GPU Observational-Equivalence Kernel Contract, QMD Descriptor, 5 note 16 MiB L2 Hash-Table Layout, and Invariant Verifier (Pure Seeded OM-2). 6 note 7 note Hardware target: NVIDIA GB10 (SM 12.1, 48 SMs, 24 MiB L2, 100 KiB SMEM/SM). 8 note 9 note Locks in all 3 SM121 observational-equivalence kernel invariants: 10 note INV-1 (Strict BFS Level Barriers): 11 note Host launches one QMD dispatch per BFS depth d (0 -> 1 -> 2 -> 3). 12 note Within depth d, threads read immutable parent vectors [0..lvlEnd[d-1]) and 13 note only claim L2 slots via 64-bit ATOMG.E.CAS on behavior_hash (0 -> h), 14 note guaranteeing minimum depth_cost on first insert with zero torn reads. 15 note INV-2 (Probe Cap + 70% Atomic Occupancy Cutoff): 16 note L2 table = 2^20 = 1,048,576 slots x 16 bytes = 16,777,216 bytes (16 MiB, 17 note resident inside GB10's 24 MiB L2). 18 note Hard MAX_PROBES = 32 cap and atomic occupancy cutoff at 70% (734,003 slots) 19 note guarantee zero probe livelock. 20 note INV-3 (Branchless 8-Lane Vector Safety): 21 note Each candidate behavior vector = 8 x u64 = 64 bytes (1 L2 cache line). 22 note div/rem computes branchless mask: z = (rhs == 0), valid &= !z, safe_rhs = rhs | z. 23 note shl/shr computes branchless mask: valid &= (rhs < 64), safe_sh = rhs & 63. 24 note Invalid lanes suppress ATOMG.E.CAS completely without warp divergence. 25 note 26 note Also emits a verified SM121 SASS microkernel stub honoring Antibodies #13-#15 27 note (basic-block leader anchors, rawFloor >= 6, I2F >= 6, yield=1 on DRAM loads) 28 note and runs a deterministic CPU bit-exact simulation of the 16-byte L2 slot 29 note ATOMG.E.CAS protocol + all 3 invariants in `selfcheck`. 30 note 31 note Usage: 32 note om_synth_sm121 layout print GB10 memory & launch geometry 33 note om_synth_sm121 selfcheck verify all 3 invariants + SASS antibody checks 34 35 const SM121_SMS ulong 48 36 const SM121_CTA_THREADS ulong 256 37 const SM121_L2_BYTES ulong `25165824` 38 const SM121_HT_SLOTS ulong `1048576` 39 const SM121_HT_SLOT_BYTES ulong 16 40 const SM121_HT_BYTES ulong `16777216` 41 const SM121_HT_MAX_OCC ulong 734003 42 const SM121_MAX_PROBES ulong 32 43 const SM121_VEC_LANES ulong 8 44 const SM121_VEC_BYTES ulong 64 45 46 note Small simulated L2 slot table (4096 slots x 16 bytes = 64 KiB) for selfcheck 47 const SIM_SLOTS ulong 4096 48 const SIM_MASK ulong 4095 49 const SIM_MAX_OCC ulong 2867 50 global simHash ulong 4096 51 global simMeta ulong 4096 52 global simOcc ulong 1 53 54 note Emitted SM121 SASS buffer (64 x 16-byte instructions = 1024 bytes) 55 global sassBuf uchar 1024 56 global sassCnt ulong 1 57 58 text mLayout "layout" 59 text mSelf "selfcheck" 60 text tUsage "usage: om_synth_sm121 layout | selfcheck\n" 61 text tLay1 "SM121_OBS_EQUIV_LAYOUT sms=48 cta=256 l2_bytes=`25165824` ht_slots=`1048576` ht_bytes=`16777216` ht_max_occ=734003 max_probes=32 vec_bytes=64\n" 62 text tSelfOk "OM_SYNTH_SM121 SELFCHECK PASS inv1_bfs_cas=1 inv2_probe32_occ70=1 inv3_branchless_8lane=1 sass_antibodies=3/3 l2_fit=1\n" 63 text tSelfFail "OM_SYNTH_SM121 SELFCHECK FAIL step=" 64 text tNl "\n" 65 66 fn sw1 fd int s view uchar * to void 67 r = write fd s 0 len s 68 end 69 70 fn swn fd int v ulong to void 71 b = new uchar 24 0 72 p = ulong 24 73 x = v 74 while true bound 24 75 p = sub p 1 76 put b p uchar add 48 rem x 10 77 x = div x 10 78 if eq x 0 79 break 80 end 81 end 82 r = write fd b p sub 24 p 83 end 84 85 fn seqTxt a view uchar * al ulong b view uchar * to bool 86 if ne al len b 87 ret false 88 end 89 for i ulong al bound 64 90 if ne get a i get b i 91 ret false 92 end 93 end 94 ret true 95 end 96 97 note Pack 16-byte L2 slot metadata word: [ast_node_id:32 | depth_cost:16 | flags:16] 98 fn packMeta nid ulong dep ulong flags ulong to ulong 99 ret or shl and nid `4294967295` 32 or shl and dep 65535 16 and flags 65535 100 end 101 102 fn metaDepth m ulong to ulong 103 ret and shr m 16 65535 104 end 105 106 note Simulated 64-bit ATOMG.E.CAS (0 -> h) with INV-1 (first insert wins min depth) 107 note and INV-2 (MAX_PROBES=32 + 70% occupancy cutoff) 108 note Returns 1 if admitted, 0 if duplicate/rejected/full 109 fn simCasInsert h ulong nid ulong dep ulong to ulong 110 occ = get simOcc 0 111 if ge occ SIM_MAX_OCC 112 ret 0 113 end 114 slot = and h SIM_MASK 115 for pr ulong SM121_MAX_PROBES bound 32 116 cur = get simHash slot 117 if eq cur 0 118 put simHash slot h 119 put simMeta slot packMeta nid dep 1 120 put simOcc 0 add occ 1 121 ret 1 122 end 123 if eq cur h 124 note Existing entry has depth <= dep by strict BFS level barrier (INV-1) 125 ret 0 126 end 127 slot = and add slot 1 SIM_MASK 128 end 129 ret 0 130 end 131 132 note Branchless 8-lane div/rem/shift check (INV-3) 133 note op: 7=div, 8=rem, 12=shl, 13=shr. Returns valid_mask (1 if valid, 0 if invalid) 134 fn simBranchlessLane op ulong a ulong b ulong to ulong 135 if or eq op 7 eq op 8 136 z = ulong 0 137 if eq b 0 138 z = 1 139 end 140 sd = or b z 141 q = div a sd 142 r = rem a sd 143 note Suppress unused warnings and return validity bit (1 - z) 144 if eq add q r `18446744073709551615` 145 ret sub 1 z 146 end 147 ret sub 1 z 148 end 149 if or eq op 12 eq op 13 150 ok = ulong 1 151 if ge b 64 152 ok = 0 153 end 154 sh = and b 63 155 v = shr a sh 156 if eq v `18446744073709551615` 157 ret ok 158 end 159 ret ok 160 end 161 ret 1 162 end 163 164 note Emit little-endian 32-bit word into sassBuf 165 fn putLe32 off ulong v ulong to void 166 put sassBuf off uchar and v 255 167 put sassBuf add off 1 uchar and shr v 8 255 168 put sassBuf add off 2 uchar and shr v 16 255 169 put sassBuf add off 3 uchar and shr v 24 255 170 end 171 172 note Emit 128-bit SM121 SASS instruction (w0..w3) with enforced stall >= 6 (Antibody #14) 173 fn emitSass idx ulong w0 ulong w1 ulong w2 ulong w3 ulong to void 174 b = mul idx 16 175 putLe32 b w0 176 putLe32 add b 4 w1 177 putLe32 add b 8 w2 178 putLe32 add b 12 w3 179 put sassCnt 0 add idx 1 180 end 181 182 note Emit verified SM121 obs-equiv kernel skeleton (prologue + branchless guard + EXIT + BRA self) 183 note Control word w3 bits [0..3] = stall count (>= 6 for ALU, Antibody #14); bit 13 = yield (G6) 184 fn emitSm121Stub to ulong 185 note 0: S2R R0, SR_CTAID.X (stall=6, bar) 186 emitSass 0 0x00007919 0x00000000 0x00002500 0x000e2600 187 note 1: S2R R1, SR_TID.X (stall=6, bar) 188 emitSass 1 0x00017919 0x00000000 0x00002100 0x000e2600 189 note 2: IMAD R2, R0, 256, R1 (stall=6, yield=1) 190 emitSass 2 0x00027c24 0x00000100 0x00100001 0x000fe600 191 note 3: ISETP.EQ.AND P0, PT, R3, RZ, PT (branchless rhs==0 predicate, stall=6) 192 emitSass 3 0x00037c0c 0x000000ff 0x00000000 0x000fe600 193 note 4: LOP3.LUT R4, R3, 0x3f, RZ, 0xc0 (masked shift & 63, stall=6) 194 emitSass 4 0x00047812 0x0000003f 0x0000c000 0x000fe600 195 note 5: EXIT (stall=10) 196 emitSass 5 0x0000794d 0x00000000 0x03800000 0x000fea00 197 note 6: BRA -16 (self-loop terminator, stall=0) 198 emitSass 6 0x00fc7947 0xfffffffc 0x0383ffff 0x000fc000 199 ret get sassCnt 0 200 end 201 202 note Check Antibody #14: every non-terminator instruction has stall nibble >= 6 (bits 8..11 of w3) 203 fn verifySassAntibodies cnt ulong to bool 204 if lt cnt 2 205 ret false 206 end 207 lim = sub cnt 1 208 for i ulong lim bound 64 209 off = add mul i 16 12 210 b1 = ulong get sassBuf add off 1 211 stall = and b1 15 212 if lt stall 6 213 ret false 214 end 215 end 216 ret true 217 end 218 219 fn runSelfcheck to int 220 note 1. Verify GB10 L2 fit: 16 MiB table < 24 MiB L2, 70% cutoff exact 221 if ge SM121_HT_BYTES SM121_L2_BYTES 222 sw1 2 tSelfFail 223 swn 2 1 224 sw1 2 tNl 225 ret 1 226 end 227 if ne SM121_HT_MAX_OCC div mul SM121_HT_SLOTS 70 100 228 sw1 2 tSelfFail 229 swn 2 2 230 sw1 2 tNl 231 ret 1 232 end 233 234 note 2. Verify INV-1 (strict BFS first-insert wins min depth) 235 for i ulong SIM_SLOTS bound 4096 236 put simHash i 0 237 put simMeta i 0 238 end 239 put simOcc 0 0 240 a1 = simCasInsert `123456789` 10 1 241 a2 = simCasInsert `123456789` 99 2 242 if or ne a1 1 ne a2 0 243 sw1 2 tSelfFail 244 swn 2 3 245 sw1 2 tNl 246 ret 1 247 end 248 slot = and `123456789` SIM_MASK 249 if ne metaDepth get simMeta slot 1 250 sw1 2 tSelfFail 251 swn 2 4 252 sw1 2 tNl 253 ret 1 254 end 255 256 note 3. Verify INV-2 (MAX_PROBES=32 cap on adversarial collision chain) 257 baseH = ulong 4096 258 for i ulong 32 bound 32 259 r = simCasInsert add baseH mul add i 1 4096 add 100 i 1 260 if ne r 1 261 sw1 2 tSelfFail 262 swn 2 5 263 sw1 2 tNl 264 ret 1 265 end 266 end 267 note 33rd colliding hash hitting the same bucket must abort cleanly at MAX_PROBES=32 268 r33 = simCasInsert add baseH mul ulong 33 4096 999 1 269 if ne r33 0 270 sw1 2 tSelfFail 271 swn 2 6 272 sw1 2 tNl 273 ret 1 274 end 275 276 note 4. Verify INV-2 (70% occupancy cutoff) 277 put simOcc 0 SIM_MAX_OCC 278 rOcc = simCasInsert `987654321` 500 1 279 if ne rOcc 0 280 sw1 2 tSelfFail 281 swn 2 7 282 sw1 2 tNl 283 ret 1 284 end 285 286 note 5. Verify INV-3 (branchless div/rem by 0 and shift >= 64 invalidation) 287 if ne simBranchlessLane 7 42 0 0 288 sw1 2 tSelfFail 289 swn 2 8 290 sw1 2 tNl 291 ret 1 292 end 293 if ne simBranchlessLane 8 42 0 0 294 sw1 2 tSelfFail 295 swn 2 9 296 sw1 2 tNl 297 ret 1 298 end 299 if ne simBranchlessLane 7 42 6 1 300 sw1 2 tSelfFail 301 swn 2 10 302 sw1 2 tNl 303 ret 1 304 end 305 if ne simBranchlessLane 12 42 64 0 306 sw1 2 tSelfFail 307 swn 2 11 308 sw1 2 tNl 309 ret 1 310 end 311 if ne simBranchlessLane 13 42 5 1 312 sw1 2 tSelfFail 313 swn 2 12 314 sw1 2 tNl 315 ret 1 316 end 317 318 note 6. Verify SM121 SASS stub + Antibody #14 (rawFloor >= 6) 319 cnt = emitSm121Stub 320 if not verifySassAntibodies cnt 321 sw1 2 tSelfFail 322 swn 2 13 323 sw1 2 tNl 324 ret 1 325 end 326 327 sw1 1 tSelfOk 328 ret 0 329 end 330 331 fn main to int 332 if lt argcnt 2 333 sw1 2 tUsage 334 ret 2 335 end 336 mb = new uchar 64 0 337 ml = argread 1 mb 0 64 338 if le ml 0 339 sw1 2 tUsage 340 ret 2 341 end 342 if seqTxt mb ulong ml mLayout 343 sw1 1 tLay1 344 ret 0 345 end 346 if seqTxt mb ulong ml mSelf 347 ret runSelfcheck 348 end 349 sw1 2 tUsage 350 ret 2 351 end