yang
This project has not described itself yet.
Brought by drakestapleton
yang / src / ufbi_obs_synth.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note src/ufbi_obs_synth.om: Pure Seeded-OM-2 Lattice Gauge-Invariant CentralObs |
| 3 | note Observational-Equivalence Synthesizer (4D SU(2), L=6, 8-Lane Batch). |
| 4 | note |
| 5 | note Directly adapts seed/helix/ollm_factory/om_synth.om + om_synth_sm121.om: |
| 6 | note - INV-1: Strict BFS level barriers (depth 0 -> 1 -> 2), first insert wins min depth. |
| 7 | note - INV-2: Open-addressed L2-model hash table with MAX_PROBES=32 + 70% occupancy cutoff. |
| 8 | note - INV-3: Branchless denominator guard for Creutz/ratio combinators. |
| 9 | note - Gauge-Invariance Gate: Every candidate is evaluated on (U_0..U_7) AND random local |
| 10 | note gauge-transformed twins (U_0^g..U_7^g); any |O(U) - O(U^g)| > 1e-4 is killed! |
| 11 | note - Quantized Bucket Hash + L-inf Tolerance Check collapses gauge-equivalent and |
| 12 | note algebraically redundant loop combinations to their shortest representative. |
| 13 | note |
| 14 | note Composed after: src/ufbi_math.om |
| 15 | |
| 16 | const OS_SLOT_F ulong 20736 |
| 17 | const OS_HT_MASK ulong 4095 |
| 18 | const OS_HT_MAX_OCC ulong 2867 |
| 19 | const OS_MAX_PROBES ulong 32 |
| 20 | const OS_MAX_NODES ulong 1024 |
| 21 | |
| 22 | note 5 lattice slots x 20736 f32 = 103680 f32: |
| 23 | note slot 0 = Cur (U), slot 1 = Tmp (U^g / smear scratch), slot 2 = Sm1, slot 3 = Sm2, slot 4 = Sm4 |
| 24 | global osBuf f32 103680 |
| 25 | global osG f32 5184 |
| 26 | |
| 27 | note Primitive response tables: 2 (0=U, 1=U^g) x 15 primitives x 8 configs = 240 f64 |
| 28 | global osPrim f64 240 |
| 29 | global osAcc f64 16 |
| 30 | |
| 31 | note Synthesizer AST node pool (SoA matching om_synth.om / om_synth_sm121.om) |
| 32 | note op: 0=PRIM, 1=CHI1, 2=SQ, 3=SUB, 4=ADD, 5=MUL, 6=RATIO |
| 33 | global osOp uchar 1024 |
| 34 | global osL ulong 1024 |
| 35 | global osR ulong 1024 |
| 36 | global osDep uchar 1024 |
| 37 | global osVec f64 8192 |
| 38 | global osGVec f64 8192 |
| 39 | |
| 40 | note Candidate scratch vectors & open-addressed L2-contract hash table |
| 41 | global osCandV f64 8 |
| 42 | global osCandG f64 8 |
| 43 | global osHtH ulong 4096 |
| 44 | global osHtN ulong 4096 |
| 45 | global osSt ulong 16 |
| 46 | global osLvlS ulong 8 |
| 47 | global osLvlE ulong 8 |
| 48 | |
| 49 | text tOsHdr "=== UFBI CENTRALOBS SYNTHESIZER: 4D SU(2) GAUGE-INVARIANT OBS-EQUIV SEARCH (PURE OM-2) ===\n" |
| 50 | text tOsStat "OBS_SYNTH_STATS nodes=" |
| 51 | text tOsGRej " gauge_killed=" |
| 52 | text tOsEPrun " equiv_pruned=" |
| 53 | text tOsBrG " inv3_guards=" |
| 54 | text tOsOcc " ht_occ=" |
| 55 | text tOsMPr " max_probes=" |
| 56 | text tOsCol "id\tdepth\texpr\tgauge_err\tcold_b24\ttwist_b24\tcold_b30\ttwist_b30\tdelta_twist\tbulk_snr\tuv_score\n" |
| 57 | text tOsTab "\t" |
| 58 | text tOsNl "\n" |
| 59 | text tOsPass "OBS_SYNTH_DONE status=PASS gauge_controls_killed=2/2 dup_plaq_collapsed=1\n" |
| 60 | |
| 61 | text tP0 "RAW_LINK_0" |
| 62 | text tP1 "RAW_LINK_SUM" |
| 63 | text tP2 "PLAQ1x1_S0" |
| 64 | text tP3 "PLAQ1x1_S1" |
| 65 | text tP4 "PLAQ1x1_S2" |
| 66 | text tP5 "PLAQ1x1_S4" |
| 67 | text tP6 "RECT1x2_S0" |
| 68 | text tP7 "RECT1x2_S2" |
| 69 | text tP8 "RECT2x2_S2" |
| 70 | text tP9 "CHAIR6_S2" |
| 71 | text tP10 "ADJ_PLAQ_S0" |
| 72 | text tP11 "ADJ_PLAQ_S2" |
| 73 | text tP12 "ADJ_RECT_S2" |
| 74 | text tP13 "CLOVER_S2" |
| 75 | text tP14 "PLAQ1x1_S0_T" |
| 76 | |
| 77 | text tOpChi "chi1(" |
| 78 | text tOpSq "sq(" |
| 79 | text tOpSub "sub(" |
| 80 | text tOpAdd "add(" |
| 81 | text tOpMul "mul(" |
| 82 | text tOpDiv "ratio(" |
| 83 | text tComma "," |
| 84 | text tRp ")" |
| 85 | |
| 86 | note ========================================================================= |
| 87 | note Quaternion SU(2) arithmetic helpers (zero globals passed as array args) |
| 88 | note ========================================================================= |
| 89 | fn qOff slot ulong site ulong mu ulong to ulong |
| 90 | ret add mul slot OS_SLOT_F mul add mul site 4 mu 4 |
| 91 | end |
| 92 | |
| 93 | fn qLoad slot ulong site ulong mu ulong dst edit f32 4 to void |
| 94 | b = qOff slot site mu |
| 95 | put dst 0 get osBuf b |
| 96 | put dst 1 get osBuf add b 1 |
| 97 | put dst 2 get osBuf add b 2 |
| 98 | put dst 3 get osBuf add b 3 |
| 99 | end |
| 100 | |
| 101 | fn qStore slot ulong site ulong mu ulong src view f32 4 to void |
| 102 | b = qOff slot site mu |
| 103 | put osBuf b get src 0 |
| 104 | put osBuf add b 1 get src 1 |
| 105 | put osBuf add b 2 get src 2 |
| 106 | put osBuf add b 3 get src 3 |
| 107 | end |
| 108 | |
| 109 | fn qConj q edit f32 4 to void |
| 110 | put q 1 neg get q 1 |
| 111 | put q 2 neg get q 2 |
| 112 | put q 3 neg get q 3 |
| 113 | end |
| 114 | |
| 115 | fn qMul a view f32 4 b view f32 4 o edit f32 4 to void |
| 116 | v = mul get a 0 get b 0 |
| 117 | v = sub v mul get a 1 get b 1 |
| 118 | v = sub v mul get a 2 get b 2 |
| 119 | v = sub v mul get a 3 get b 3 |
| 120 | put o 0 v |
| 121 | v = mul get a 0 get b 1 |
| 122 | v = add v mul get a 1 get b 0 |
| 123 | v = add v mul get a 2 get b 3 |
| 124 | v = sub v mul get a 3 get b 2 |
| 125 | put o 1 v |
| 126 | v = mul get a 0 get b 2 |
| 127 | v = sub v mul get a 1 get b 3 |
| 128 | v = add v mul get a 2 get b 0 |
| 129 | v = add v mul get a 3 get b 1 |
| 130 | put o 2 v |
| 131 | v = mul get a 0 get b 3 |
| 132 | v = add v mul get a 1 get b 2 |
| 133 | v = sub v mul get a 2 get b 1 |
| 134 | v = add v mul get a 3 get b 0 |
| 135 | put o 3 v |
| 136 | end |
| 137 | |
| 138 | fn qDot4 a view f32 4 b view f32 4 to f32 |
| 139 | d = mul get a 0 get b 0 |
| 140 | d = add d mul get a 1 get b 1 |
| 141 | d = add d mul get a 2 get b 2 |
| 142 | ret add d mul get a 3 get b 3 |
| 143 | end |
| 144 | |
| 145 | fn qNorm q edit f32 4 to void |
| 146 | n2 = mul get q 0 get q 0 |
| 147 | n2 = add n2 mul get q 1 get q 1 |
| 148 | n2 = add n2 mul get q 2 get q 2 |
| 149 | n2 = add n2 mul get q 3 get q 3 |
| 150 | if le n2 0.0000000001f32 |
| 151 | put q 0 1.0f32 |
| 152 | put q 1 0.0f32 |
| 153 | put q 2 0.0f32 |
| 154 | put q 3 0.0f32 |
| 155 | ret |
| 156 | end |
| 157 | inv = f32 div 1.0f64 uSqrt64 f64 n2 |
| 158 | for c ulong 4 |
| 159 | put q c mul get q c inv |
| 160 | end |
| 161 | end |
| 162 | |
| 163 | fn qRand dst edit f32 4 to void |
| 164 | put dst 0 f32 uRngNorm64 |
| 165 | put dst 1 f32 uRngNorm64 |
| 166 | put dst 2 f32 uRngNorm64 |
| 167 | put dst 3 f32 uRngNorm64 |
| 168 | qNorm dst |
| 169 | end |
| 170 | |
| 171 | fn nb6 site ulong dir ulong delta ulong to ulong |
| 172 | c3 = rem site 6 |
| 173 | c2 = rem div site 6 6 |
| 174 | c1 = rem div site 36 6 |
| 175 | c0 = div site 216 |
| 176 | if eq dir 0 |
| 177 | c0 = rem add c0 delta 6 |
| 178 | end |
| 179 | if eq dir 1 |
| 180 | c1 = rem add c1 delta 6 |
| 181 | end |
| 182 | if eq dir 2 |
| 183 | c2 = rem add c2 delta 6 |
| 184 | end |
| 185 | if eq dir 3 |
| 186 | c3 = rem add c3 delta 6 |
| 187 | end |
| 188 | r = add mul c0 6 c1 |
| 189 | r = add mul r 6 c2 |
| 190 | ret add mul r 6 c3 |
| 191 | end |
| 192 | |
| 193 | fn isBdry6 site ulong to bool |
| 194 | c3 = rem site 6 |
| 195 | c2 = rem div site 6 6 |
| 196 | c1 = rem div site 36 6 |
| 197 | c0 = div site 216 |
| 198 | if or eq c0 0 eq c0 5 |
| 199 | ret true |
| 200 | end |
| 201 | if or eq c1 0 eq c1 5 |
| 202 | ret true |
| 203 | end |
| 204 | if or eq c2 0 eq c2 5 |
| 205 | ret true |
| 206 | end |
| 207 | if or eq c3 0 eq c3 5 |
| 208 | ret true |
| 209 | end |
| 210 | ret false |
| 211 | end |
| 212 | |
| 213 | fn isInt6 site ulong to bool |
| 214 | c3 = rem site 6 |
| 215 | c2 = rem div site 6 6 |
| 216 | c1 = rem div site 36 6 |
| 217 | c0 = div site 216 |
| 218 | if or lt c0 2 gt c0 3 |
| 219 | ret false |
| 220 | end |
| 221 | if or lt c1 2 gt c1 3 |
| 222 | ret false |
| 223 | end |
| 224 | if or lt c2 2 gt c2 3 |
| 225 | ret false |
| 226 | end |
| 227 | if or lt c3 2 gt c3 3 |
| 228 | ret false |
| 229 | end |
| 230 | ret true |
| 231 | end |
| 232 | |
| 233 | fn stapleAddOne slot ulong site ulong mu ulong nu ulong isBack bool dst edit f32 4 to void |
| 234 | t1 = new f32 4 0.0f32 |
| 235 | t2 = new f32 4 0.0f32 |
| 236 | t3 = new f32 4 0.0f32 |
| 237 | p1 = new f32 4 0.0f32 |
| 238 | p2 = new f32 4 0.0f32 |
| 239 | xp = nb6 site mu 1 |
| 240 | if not isBack |
| 241 | qLoad slot site nu t1 |
| 242 | qLoad slot nb6 site nu 1 mu t2 |
| 243 | qLoad slot xp nu t3 |
| 244 | qConj t3 |
| 245 | else |
| 246 | xm = nb6 site nu 5 |
| 247 | qLoad slot xm nu t1 |
| 248 | qConj t1 |
| 249 | qLoad slot xm mu t2 |
| 250 | qLoad slot nb6 xp nu 5 nu t3 |
| 251 | end |
| 252 | qMul t1 t2 p1 |
| 253 | qMul p1 t3 p2 |
| 254 | for c ulong 4 |
| 255 | put dst c add get dst c get p2 c |
| 256 | end |
| 257 | end |
| 258 | |
| 259 | fn staple6 slot ulong site ulong mu ulong dst edit f32 4 to void |
| 260 | for c ulong 4 |
| 261 | put dst c 0.0f32 |
| 262 | end |
| 263 | for nu ulong 4 |
| 264 | if ne nu mu |
| 265 | stapleAddOne slot site mu nu false dst |
| 266 | stapleAddOne slot site mu nu true dst |
| 267 | end |
| 268 | end |
| 269 | end |
| 270 | |
| 271 | fn sweepSu2 beta f64 nSweeps ulong to void |
| 272 | st = new f32 4 0.0f32 |
| 273 | u = new f32 4 0.0f32 |
| 274 | cand = new f32 4 0.0f32 |
| 275 | for sw ulong nSweeps bound 64 |
| 276 | for site ulong 1296 |
| 277 | if not isBdry6 site |
| 278 | for mu ulong 4 |
| 279 | staple6 0 site mu st |
| 280 | qLoad 0 site mu u |
| 281 | for mh ulong 3 |
| 282 | for c ulong 4 |
| 283 | put cand c add get u c mul 0.35f32 f32 uRngNorm64 |
| 284 | end |
| 285 | qNorm cand |
| 286 | dS = mul beta f64 sub qDot4 cand st qDot4 u st |
| 287 | if or ge dS 0.0f64 lt uRngUnit64 uExp64 dS |
| 288 | for c ulong 4 |
| 289 | put u c get cand c |
| 290 | end |
| 291 | end |
| 292 | end |
| 293 | qNorm st |
| 294 | dot = qDot4 u st |
| 295 | for c ulong 4 |
| 296 | put u c sub mul mul 2.0f32 dot get st c get u c |
| 297 | end |
| 298 | qNorm u |
| 299 | qStore 0 site mu u |
| 300 | end |
| 301 | end |
| 302 | end |
| 303 | end |
| 304 | end |
| 305 | |
| 306 | fn apeStep srcSlot ulong dstSlot ulong alpha f32 to void |
| 307 | st = new f32 4 0.0f32 |
| 308 | u = new f32 4 0.0f32 |
| 309 | w0 = sub 1.0f32 alpha |
| 310 | w1 = div alpha 6.0f32 |
| 311 | for site ulong 1296 |
| 312 | for mu ulong 4 |
| 313 | qLoad srcSlot site mu u |
| 314 | staple6 srcSlot site mu st |
| 315 | for c ulong 4 |
| 316 | put u c add mul w0 get u c mul w1 get st c |
| 317 | end |
| 318 | qNorm u |
| 319 | qStore dstSlot site mu u |
| 320 | end |
| 321 | end |
| 322 | end |
| 323 | |
| 324 | fn applyGaugeTransform srcSlot ulong dstSlot ulong to void |
| 325 | gx = new f32 4 0.0f32 |
| 326 | gy = new f32 4 0.0f32 |
| 327 | u = new f32 4 0.0f32 |
| 328 | t = new f32 4 0.0f32 |
| 329 | for site ulong 1296 |
| 330 | qRand gx |
| 331 | b = mul site 4 |
| 332 | for c ulong 4 |
| 333 | put osG add b c get gx c |
| 334 | end |
| 335 | end |
| 336 | for site ulong 1296 |
| 337 | b = mul site 4 |
| 338 | for c ulong 4 |
| 339 | put gx c get osG add b c |
| 340 | end |
| 341 | for mu ulong 4 |
| 342 | bn = mul nb6 site mu 1 4 |
| 343 | for c ulong 4 |
| 344 | put gy c get osG add bn c |
| 345 | end |
| 346 | qConj gy |
| 347 | qLoad srcSlot site mu u |
| 348 | qMul gx u t |
| 349 | qMul t gy u |
| 350 | qStore dstSlot site mu u |
| 351 | end |
| 352 | end |
| 353 | end |
| 354 | |
| 355 | fn plaq1x1 slot ulong site ulong mu ulong nu ulong to f64 |
| 356 | a = new f32 4 0.0f32 |
| 357 | b = new f32 4 0.0f32 |
| 358 | p = new f32 4 0.0f32 |
| 359 | q = new f32 4 0.0f32 |
| 360 | qLoad slot site mu a |
| 361 | qLoad slot nb6 site mu 1 nu b |
| 362 | qMul a b p |
| 363 | qLoad slot nb6 site nu 1 mu a |
| 364 | qConj a |
| 365 | qMul p a q |
| 366 | qLoad slot site nu b |
| 367 | qConj b |
| 368 | qMul q b p |
| 369 | ret f64 get p 0 |
| 370 | end |
| 371 | |
| 372 | fn rect1x2 slot ulong site ulong mu ulong nu ulong to f64 |
| 373 | a = new f32 4 0.0f32 |
| 374 | b = new f32 4 0.0f32 |
| 375 | p = new f32 4 0.0f32 |
| 376 | q = new f32 4 0.0f32 |
| 377 | s1 = nb6 site mu 1 |
| 378 | qLoad slot site mu a |
| 379 | qLoad slot s1 mu b |
| 380 | qMul a b p |
| 381 | qLoad slot nb6 s1 mu 1 nu a |
| 382 | qMul p a q |
| 383 | qLoad slot nb6 s1 nu 1 mu a |
| 384 | qConj a |
| 385 | qMul q a p |
| 386 | qLoad slot nb6 site nu 1 mu a |
| 387 | qConj a |
| 388 | qMul p a q |
| 389 | qLoad slot site nu b |
| 390 | qConj b |
| 391 | qMul q b p |
| 392 | ret f64 get p 0 |
| 393 | end |
| 394 | |
| 395 | fn rect2x2 slot ulong site ulong mu ulong nu ulong to f64 |
| 396 | a = new f32 4 0.0f32 |
| 397 | p = new f32 4 0.0f32 |
| 398 | q = new f32 4 0.0f32 |
| 399 | s = site |
| 400 | qLoad slot s mu p |
| 401 | s = nb6 s mu 1 |
| 402 | qLoad slot s mu a |
| 403 | qMul p a q |
| 404 | s = nb6 s mu 1 |
| 405 | qLoad slot s nu a |
| 406 | qMul q a p |
| 407 | s = nb6 s nu 1 |
| 408 | qLoad slot s nu a |
| 409 | qMul p a q |
| 410 | s = nb6 s nu 1 |
| 411 | s = nb6 s mu 5 |
| 412 | qLoad slot s mu a |
| 413 | qConj a |
| 414 | qMul q a p |
| 415 | s = nb6 s mu 5 |
| 416 | qLoad slot s mu a |
| 417 | qConj a |
| 418 | qMul p a q |
| 419 | s = nb6 s nu 5 |
| 420 | qLoad slot s nu a |
| 421 | qConj a |
| 422 | qMul q a p |
| 423 | s = nb6 s nu 5 |
| 424 | qLoad slot s nu a |
| 425 | qConj a |
| 426 | qMul p a q |
| 427 | ret f64 get q 0 |
| 428 | end |
| 429 | |
| 430 | fn chair6 slot ulong site ulong mu ulong nu ulong rh ulong to f64 |
| 431 | a = new f32 4 0.0f32 |
| 432 | p = new f32 4 0.0f32 |
| 433 | q = new f32 4 0.0f32 |
| 434 | s = site |
| 435 | qLoad slot s mu p |
| 436 | s = nb6 s mu 1 |
| 437 | qLoad slot s nu a |
| 438 | qMul p a q |
| 439 | s = nb6 s nu 1 |
| 440 | qLoad slot s rh a |
| 441 | qMul q a p |
| 442 | s = nb6 s rh 1 |
| 443 | s = nb6 s mu 5 |
| 444 | qLoad slot s mu a |
| 445 | qConj a |
| 446 | qMul p a q |
| 447 | s = nb6 s rh 5 |
| 448 | qLoad slot s rh a |
| 449 | qConj a |
| 450 | qMul q a p |
| 451 | s = nb6 s nu 5 |
| 452 | qLoad slot s nu a |
| 453 | qConj a |
| 454 | qMul p a q |
| 455 | ret f64 get q 0 |
| 456 | end |
| 457 | |
| 458 | fn evalSitePlane srcSlot ulong site ulong mu ulong nu ulong to void |
| 459 | v0 = plaq1x1 srcSlot site mu nu |
| 460 | put osAcc 0 add get osAcc 0 v0 |
| 461 | put osAcc 8 add get osAcc 8 sub mul 4.0f64 mul v0 v0 1.0f64 |
| 462 | put osAcc 1 add get osAcc 1 plaq1x1 2 site mu nu |
| 463 | v2 = plaq1x1 3 site mu nu |
| 464 | put osAcc 2 add get osAcc 2 v2 |
| 465 | put osAcc 9 add get osAcc 9 sub mul 4.0f64 mul v2 v2 1.0f64 |
| 466 | put osAcc 3 add get osAcc 3 plaq1x1 4 site mu nu |
| 467 | put osAcc 4 add get osAcc 4 rect1x2 srcSlot site mu nu |
| 468 | vr2 = rect1x2 3 site mu nu |
| 469 | put osAcc 5 add get osAcc 5 vr2 |
| 470 | put osAcc 10 add get osAcc 10 sub mul 4.0f64 mul vr2 vr2 1.0f64 |
| 471 | put osAcc 6 add get osAcc 6 rect2x2 3 site mu nu |
| 472 | put osAcc 11 add get osAcc 11 plaq1x1 srcSlot site nu mu |
| 473 | end |
| 474 | |
| 475 | fn putPrim isG ulong p ulong cfgIdx ulong v f64 to void |
| 476 | put osPrim add mul isG 120 add mul p 8 cfgIdx v |
| 477 | end |
| 478 | |
| 479 | fn getPrim isG ulong p ulong cfgIdx ulong to f64 |
| 480 | ret get osPrim add mul isG 120 add mul p 8 cfgIdx |
| 481 | end |
| 482 | |
| 483 | fn evalPrims srcSlot ulong cfgIdx ulong isG ulong to void |
| 484 | apeStep srcSlot 2 0.5f32 |
| 485 | apeStep 2 3 0.5f32 |
| 486 | apeStep 3 4 0.5f32 |
| 487 | |
| 488 | ctr = ulong 518 |
| 489 | putPrim isG 0 cfgIdx f64 get osBuf qOff srcSlot ctr 0 |
| 490 | lsum = f64 0.0f64 |
| 491 | for mu ulong 4 |
| 492 | lsum = add lsum f64 get osBuf qOff srcSlot ctr mu |
| 493 | end |
| 494 | putPrim isG 1 cfgIdx div lsum 4.0f64 |
| 495 | |
| 496 | for k ulong 16 |
| 497 | put osAcc k 0.0f64 |
| 498 | end |
| 499 | for site ulong 1296 |
| 500 | if isInt6 site |
| 501 | for mu ulong 4 |
| 502 | for nu ulong 4 |
| 503 | if lt mu nu |
| 504 | evalSitePlane srcSlot site mu nu |
| 505 | end |
| 506 | end |
| 507 | end |
| 508 | put osAcc 7 add get osAcc 7 chair6 3 site 0 1 2 |
| 509 | end |
| 510 | end |
| 511 | putPrim isG 2 cfgIdx div get osAcc 0 96.0f64 |
| 512 | putPrim isG 3 cfgIdx div get osAcc 1 96.0f64 |
| 513 | putPrim isG 4 cfgIdx div get osAcc 2 96.0f64 |
| 514 | putPrim isG 5 cfgIdx div get osAcc 3 96.0f64 |
| 515 | putPrim isG 6 cfgIdx div get osAcc 4 96.0f64 |
| 516 | putPrim isG 7 cfgIdx div get osAcc 5 96.0f64 |
| 517 | putPrim isG 8 cfgIdx div get osAcc 6 96.0f64 |
| 518 | putPrim isG 9 cfgIdx div get osAcc 7 16.0f64 |
| 519 | putPrim isG 10 cfgIdx div get osAcc 8 96.0f64 |
| 520 | putPrim isG 11 cfgIdx div get osAcc 9 96.0f64 |
| 521 | putPrim isG 12 cfgIdx div get osAcc 10 96.0f64 |
| 522 | putPrim isG 13 cfgIdx mul 0.5f64 add sub 1.0f64 div get osAcc 2 96.0f64 sub 1.0f64 div get osAcc 5 96.0f64 |
| 523 | putPrim isG 14 cfgIdx div get osAcc 11 96.0f64 |
| 524 | end |
| 525 | |
| 526 | fn buildConfig cfgIdx ulong to void |
| 527 | uRngSeed add 0x123456789abcdef0 mul cfgIdx 9973 |
| 528 | q = new f32 4 0.0f32 |
| 529 | beta = f64 2.4f64 |
| 530 | if ge cfgIdx 4 |
| 531 | beta = f64 3.0f64 |
| 532 | end |
| 533 | isTwist = eq and shr cfgIdx 1 1 1 |
| 534 | for site ulong 1296 |
| 535 | c0 = div site 216 |
| 536 | c1 = rem div site 36 6 |
| 537 | for mu ulong 4 |
| 538 | if isBdry6 site |
| 539 | if isTwist |
| 540 | put q 0 1.0f32 |
| 541 | put q 1 0.0f32 |
| 542 | put q 2 0.0f32 |
| 543 | put q 3 0.0f32 |
| 544 | if and eq mu 0 and ge c1 3 eq c0 0 |
| 545 | put q 0 neg 1.0f32 |
| 546 | end |
| 547 | if eq rem cfgIdx 2 1 |
| 548 | put q 1 mul 0.4f32 f32 uRngNorm64 |
| 549 | put q 2 mul 0.4f32 f32 uRngNorm64 |
| 550 | put q 3 mul 0.4f32 f32 uRngNorm64 |
| 551 | qNorm q |
| 552 | end |
| 553 | else |
| 554 | put q 0 1.0f32 |
| 555 | put q 1 0.0f32 |
| 556 | put q 2 0.0f32 |
| 557 | put q 3 0.0f32 |
| 558 | end |
| 559 | else |
| 560 | put q 0 0.8f32 |
| 561 | put q 1 mul 0.3f32 f32 uRngNorm64 |
| 562 | put q 2 mul 0.3f32 f32 uRngNorm64 |
| 563 | put q 3 mul 0.3f32 f32 uRngNorm64 |
| 564 | qNorm q |
| 565 | end |
| 566 | qStore 0 site mu q |
| 567 | end |
| 568 | end |
| 569 | sweepSu2 beta 20 |
| 570 | end |
| 571 | |
| 572 | note ========================================================================= |
| 573 | note Quantized 8-lane Observational-Equivalence Hash + Gauge-Invariance Gate |
| 574 | note ========================================================================= |
| 575 | fn quantHashCand to ulong |
| 576 | h = ulong 0xcbf29ce484222325 |
| 577 | for i ulong 8 |
| 578 | x = get osCandV i |
| 579 | q = long 0 |
| 580 | if ge x 0.0f64 |
| 581 | q = long add mul x 512.0f64 0.5f64 |
| 582 | else |
| 583 | q = long sub mul x 512.0f64 0.5f64 |
| 584 | end |
| 585 | h = mul xor h bitcast ulong q 0x100000001b3 |
| 586 | end |
| 587 | if eq h 0 |
| 588 | h = ulong 1 |
| 589 | end |
| 590 | ret h |
| 591 | end |
| 592 | |
| 593 | fn vecCloseCand nid ulong to bool |
| 594 | base = mul nid 8 |
| 595 | for i ulong 8 |
| 596 | if gt uAbs64 sub get osVec add base i get osCandV i 0.002f64 |
| 597 | ret false |
| 598 | end |
| 599 | end |
| 600 | ret true |
| 601 | end |
| 602 | |
| 603 | fn admitStore slot ulong h ulong op uchar l ulong r ulong dep uchar to void |
| 604 | nNodes = get osSt 0 |
| 605 | put osHtH slot h |
| 606 | put osHtN slot nNodes |
| 607 | put osSt 1 add get osSt 1 1 |
| 608 | put osOp nNodes op |
| 609 | put osL nNodes l |
| 610 | put osR nNodes r |
| 611 | put osDep nNodes dep |
| 612 | base = mul nNodes 8 |
| 613 | for i ulong 8 |
| 614 | put osVec add base i get osCandV i |
| 615 | put osGVec add base i get osCandG i |
| 616 | end |
| 617 | put osSt 0 add nNodes 1 |
| 618 | end |
| 619 | |
| 620 | fn tryAdmit op uchar l ulong r ulong dep uchar to bool |
| 621 | for i ulong 8 |
| 622 | if gt uAbs64 sub get osCandV i get osCandG i 0.0001f64 |
| 623 | put osSt 2 add get osSt 2 1 |
| 624 | ret false |
| 625 | end |
| 626 | end |
| 627 | if ge get osSt 1 OS_HT_MAX_OCC |
| 628 | ret false |
| 629 | end |
| 630 | if ge get osSt 0 OS_MAX_NODES |
| 631 | ret false |
| 632 | end |
| 633 | h = quantHashCand |
| 634 | slot = and h OS_HT_MASK |
| 635 | for pr ulong OS_MAX_PROBES bound 32 |
| 636 | if gt add pr 1 get osSt 5 |
| 637 | put osSt 5 add pr 1 |
| 638 | end |
| 639 | cur = get osHtH slot |
| 640 | if eq cur 0 |
| 641 | admitStore slot h op l r dep |
| 642 | ret true |
| 643 | end |
| 644 | if eq cur h |
| 645 | if vecCloseCand get osHtN slot |
| 646 | put osSt 3 add get osSt 3 1 |
| 647 | ret false |
| 648 | end |
| 649 | end |
| 650 | slot = and add slot 1 OS_HT_MASK |
| 651 | end |
| 652 | ret false |
| 653 | end |
| 654 | |
| 655 | fn printPrimName p ulong to void |
| 656 | if eq p 0 |
| 657 | uPrint tP0 |
| 658 | end |
| 659 | if eq p 1 |
| 660 | uPrint tP1 |
| 661 | end |
| 662 | if eq p 2 |
| 663 | uPrint tP2 |
| 664 | end |
| 665 | if eq p 3 |
| 666 | uPrint tP3 |
| 667 | end |
| 668 | if eq p 4 |
| 669 | uPrint tP4 |
| 670 | end |
| 671 | if eq p 5 |
| 672 | uPrint tP5 |
| 673 | end |
| 674 | if eq p 6 |
| 675 | uPrint tP6 |
| 676 | end |
| 677 | if eq p 7 |
| 678 | uPrint tP7 |
| 679 | end |
| 680 | if eq p 8 |
| 681 | uPrint tP8 |
| 682 | end |
| 683 | if eq p 9 |
| 684 | uPrint tP9 |
| 685 | end |
| 686 | if eq p 10 |
| 687 | uPrint tP10 |
| 688 | end |
| 689 | if eq p 11 |
| 690 | uPrint tP11 |
| 691 | end |
| 692 | if eq p 12 |
| 693 | uPrint tP12 |
| 694 | end |
| 695 | if eq p 13 |
| 696 | uPrint tP13 |
| 697 | end |
| 698 | if eq p 14 |
| 699 | uPrint tP14 |
| 700 | end |
| 701 | end |
| 702 | |
| 703 | fn printExpr nid ulong to void |
| 704 | op = get osOp nid |
| 705 | if eq op 0 |
| 706 | printPrimName get osL nid |
| 707 | ret |
| 708 | end |
| 709 | if eq op 1 |
| 710 | uPrint tOpChi |
| 711 | printPrimName get osL get osL nid |
| 712 | uPrint tRp |
| 713 | ret |
| 714 | end |
| 715 | if eq op 2 |
| 716 | uPrint tOpSq |
| 717 | printPrimName get osL get osL nid |
| 718 | uPrint tRp |
| 719 | ret |
| 720 | end |
| 721 | if eq op 3 |
| 722 | uPrint tOpSub |
| 723 | end |
| 724 | if eq op 4 |
| 725 | uPrint tOpAdd |
| 726 | end |
| 727 | if eq op 5 |
| 728 | uPrint tOpMul |
| 729 | end |
| 730 | if eq op 6 |
| 731 | uPrint tOpDiv |
| 732 | end |
| 733 | printPrimName get osL get osL nid |
| 734 | uPrint tComma |
| 735 | printPrimName get osL get osR nid |
| 736 | uPrint tRp |
| 737 | end |
| 738 | |
| 739 | fn runBfsDepth0 to void |
| 740 | put osLvlS 0 0 |
| 741 | for p ulong 15 |
| 742 | for i ulong 8 |
| 743 | put osCandV i getPrim 0 p i |
| 744 | put osCandG i getPrim 1 p i |
| 745 | end |
| 746 | ok = tryAdmit 0 p 0 0 |
| 747 | end |
| 748 | put osLvlE 0 get osSt 0 |
| 749 | end |
| 750 | |
| 751 | fn runBfs1Unary a ulong to void |
| 752 | ba = mul a 8 |
| 753 | for i ulong 8 |
| 754 | xa = get osVec add ba i |
| 755 | xg = get osGVec add ba i |
| 756 | put osCandV i sub mul 4.0f64 mul xa xa 1.0f64 |
| 757 | put osCandG i sub mul 4.0f64 mul xg xg 1.0f64 |
| 758 | end |
| 759 | ok = tryAdmit 1 a 0 1 |
| 760 | for i ulong 8 |
| 761 | xa = get osVec add ba i |
| 762 | xg = get osGVec add ba i |
| 763 | put osCandV i mul xa xa |
| 764 | put osCandG i mul xg xg |
| 765 | end |
| 766 | ok = tryAdmit 2 a 0 1 |
| 767 | end |
| 768 | |
| 769 | fn runBfs1BinOne a ulong b ulong op uchar to void |
| 770 | ba = mul a 8 |
| 771 | bb = mul b 8 |
| 772 | if eq op 6 |
| 773 | for i ulong 8 |
| 774 | if lt uAbs64 get osVec add bb i 0.05f64 |
| 775 | put osSt 4 add get osSt 4 1 |
| 776 | ret |
| 777 | end |
| 778 | end |
| 779 | end |
| 780 | for i ulong 8 |
| 781 | va = get osVec add ba i |
| 782 | vb = get osVec add bb i |
| 783 | ga = get osGVec add ba i |
| 784 | gb = get osGVec add bb i |
| 785 | if eq op 3 |
| 786 | put osCandV i sub va vb |
| 787 | put osCandG i sub ga gb |
| 788 | end |
| 789 | if eq op 4 |
| 790 | put osCandV i add va vb |
| 791 | put osCandG i add ga gb |
| 792 | end |
| 793 | if eq op 5 |
| 794 | put osCandV i mul va vb |
| 795 | put osCandG i mul ga gb |
| 796 | end |
| 797 | if eq op 6 |
| 798 | put osCandV i div va vb |
| 799 | put osCandG i div ga gb |
| 800 | end |
| 801 | end |
| 802 | ok = tryAdmit op a b 1 |
| 803 | end |
| 804 | |
| 805 | fn runBfs1BinPair a ulong b ulong to void |
| 806 | runBfs1BinOne a b 3 |
| 807 | runBfs1BinOne a b 4 |
| 808 | runBfs1BinOne a b 5 |
| 809 | runBfs1BinOne a b 6 |
| 810 | end |
| 811 | |
| 812 | fn runBfsDepth1 to void |
| 813 | e0 = get osLvlE 0 |
| 814 | put osLvlS 1 e0 |
| 815 | for a ulong e0 bound 32 |
| 816 | runBfs1Unary a |
| 817 | end |
| 818 | for a ulong e0 bound 32 |
| 819 | for b ulong e0 bound 32 |
| 820 | runBfs1BinPair a b |
| 821 | end |
| 822 | end |
| 823 | put osLvlE 1 get osSt 0 |
| 824 | end |
| 825 | |
| 826 | fn nodeGaugeErr nid ulong to f64 |
| 827 | base = mul nid 8 |
| 828 | gerr = f64 0.0f64 |
| 829 | for i ulong 8 |
| 830 | e = uAbs64 sub get osVec add base i get osGVec add base i |
| 831 | if gt e gerr |
| 832 | gerr = e |
| 833 | end |
| 834 | end |
| 835 | ret gerr |
| 836 | end |
| 837 | |
| 838 | fn printOneNode nid ulong to void |
| 839 | base = mul nid 8 |
| 840 | c24 = mul 0.5f64 add get osVec base get osVec add base 1 |
| 841 | t24 = mul 0.5f64 add get osVec add base 2 get osVec add base 3 |
| 842 | c30 = mul 0.5f64 add get osVec add base 4 get osVec add base 5 |
| 843 | t30 = mul 0.5f64 add get osVec add base 6 get osVec add base 7 |
| 844 | dTw = add uAbs64 sub t24 c24 uAbs64 sub t30 c30 |
| 845 | bulkSig = uAbs64 sub c30 c24 |
| 846 | if or eq get osDep nid 0 and gt bulkSig 0.05f64 lt dTw mul 0.35f64 bulkSig |
| 847 | uPrintU nid |
| 848 | uPrint tOsTab |
| 849 | uPrintU ulong get osDep nid |
| 850 | uPrint tOsTab |
| 851 | printExpr nid |
| 852 | uPrint tOsTab |
| 853 | uPrintF64 nodeGaugeErr nid |
| 854 | uPrint tOsTab |
| 855 | uPrintF64 c24 |
| 856 | uPrint tOsTab |
| 857 | uPrintF64 t24 |
| 858 | uPrint tOsTab |
| 859 | uPrintF64 c30 |
| 860 | uPrint tOsTab |
| 861 | uPrintF64 t30 |
| 862 | uPrint tOsTab |
| 863 | uPrintF64 dTw |
| 864 | uPrint tOsTab |
| 865 | uPrintF64 bulkSig |
| 866 | uPrint tOsTab |
| 867 | uPrintF64 div bulkSig add dTw 0.0001f64 |
| 868 | uPrint tOsNl |
| 869 | end |
| 870 | end |
| 871 | |
| 872 | fn printTopResults to void |
| 873 | uPrint tOsCol |
| 874 | n = get osSt 0 |
| 875 | for nid ulong n bound 1024 |
| 876 | printOneNode nid |
| 877 | end |
| 878 | end |
| 879 | |
| 880 | fn main to int |
| 881 | uPrint tOsHdr |
| 882 | for c ulong 8 |
| 883 | buildConfig c |
| 884 | evalPrims 0 c 0 |
| 885 | applyGaugeTransform 0 1 |
| 886 | evalPrims 1 c 1 |
| 887 | end |
| 888 | runBfsDepth0 |
| 889 | runBfsDepth1 |
| 890 | uPrint tOsStat |
| 891 | uPrintU get osSt 0 |
| 892 | uPrint tOsGRej |
| 893 | uPrintU get osSt 2 |
| 894 | uPrint tOsEPrun |
| 895 | uPrintU get osSt 3 |
| 896 | uPrint tOsBrG |
| 897 | uPrintU get osSt 4 |
| 898 | uPrint tOsOcc |
| 899 | uPrintU get osSt 1 |
| 900 | uPrint tOsMPr |
| 901 | uPrintU get osSt 5 |
| 902 | uPrint tOsNl |
| 903 | printTopResults |
| 904 | if lt get osSt 2 2 |
| 905 | ret 1 |
| 906 | end |
| 907 | uPrint tOsPass |
| 908 | ret 0 |
| 909 | end |