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/yang/blob/main/src/ufbi_check10_gb10.om # yang This project has not described itself yet. 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 `yang / src / ufbi_check10_gb10.om` 1290 lines ยท 25981 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note src/ufbi_check10_gb10.om: Pure Seeded-OM-2 Zero-CUDA GB10 Runner for UFBI Check #10 3 note (Phase II Exact S^3 Schwinger-Dyson 5-Operator Hamiltonian Coupling Extraction: 4 note F [1x1], A [Adj], R [1x2], W22 [2x2], Cr [3D 6-link Crown] + Multi-Loop Dobrushin Norm alpha_ML 5 note across 16^4 -> 8^4 -> 4^4 and 32^4 -> 16^4 -> 8^4 -> 4^4, ZERO calibration table needed!). 6 note 7 note Exact S^3 Lie-algebraic Schwinger-Dyson / Score-Matching equations: 8 note For left-invariant generators L_a (a=1,2,3) on SU(2) ~= S^3: 9 note L_a(W_0) = -W_a, Delta(W_0) = -3 W_0 10 note L_a(4 W_0^2 - 1) = -8 W_0 W_a, Delta(4 W_0^2 - 1) = -8 (4 W_0^2 - 1) 11 note Integration by parts under S^3 Haar measure yields the exact 5x5 symmetric PSD system: 12 note M_{beta, alpha} * c_alpha = b_beta 13 note where M_{beta,alpha} = < sum_{a=1}^3 (L_a Phi^(beta)_e)(L_a Phi^(alpha)_e) >, 14 note b_beta = -< Delta_e Phi^(beta)_e >. 15 note Built-in exact self-verification: at k=0 (bare Wilson lattice), M c = b MUST recover 16 note (beta_F, beta_A, beta_R, beta_22, beta_Cr) = (beta_bare, 0, 0, 0, 0)! 17 note Evaluates Lean-certified multi-loop Dobrushin norm directly on every blocked scale: 18 note alpha_ML = 9|beta_F| + 18 tanh(2|beta_A|) + 45|beta_R| + 42|beta_22| + 60|beta_Cr|. 19 note 20 note Composed after: 21 note gpu/nvidia/native/nvrm/context.om 22 note gpu/nvidia/native/blackwell/vector.om 23 note gpu/nvidia/native/blackwell/launch.om 24 note gpu/nvidia/native/blackwell/batch.om 25 note om/encoder/bw_enc_sm121.om 26 note src/ufbi_math.om 27 note src/ufbi_check3_kernels.om 28 29 global uCodePos ulong 1 30 global uEntry ulong 8 31 global uCodeMap long 1 32 global uCodeFail uint 1 33 global uBind uint 32 34 global uBindN ulong 1 35 global uDirty uint 1 36 37 global dLinks long 1 38 global dStaples long 1 39 global dFlags long 1 40 global dNbSite long 1 41 global dRng long 1 42 43 note Host link levels (max 16^4 = 1,048,576 f32; lvl 3 = direct GPU dLinks read for 32^4!) 44 global hL1 f32 `1048576` 45 global hL2 f32 65536 46 global hL3 f32 4096 47 global hStage uchar 65536 48 49 note Schwinger-Dyson 5-operator accumulators across 4 scales (k=0..3) 50 note sdM: 4 scales x 25 (5x5 matrix) = 100 f64; sdB: 4 scales x 5 = 20 f64; sdCnt: 4 ulong 51 global sdM f64 100 52 global sdB f64 20 53 global sdCnt ulong 4 54 note Per-link temporary gradient 5x3 = 15 f64 and laplacian 5 f64 55 global linkG f64 15 56 global linkL f64 5 57 note 5x5 linear solver scratch: aug 5x6 = 30 f64, sol 5 f64 58 global linA f64 30 59 global linX f64 5 60 61 global kernelWeight f32 1 62 global kernelTrial ulong 1 63 global kernelFallback ulong 1 64 global kernelMinNorm f32 1 65 text tKernelStats "projection_min_sq_and_fallbacks\t" 66 global rgSrcLvl ulong 1 67 global rgDstLvl ulong 1 68 global rgLf ulong 1 69 global walkCur ulong 1 70 global walkLvl ulong 1 71 global walkL ulong 1 72 global walkQ f32 4 73 74 text tC10Hdr "=== UFBI CHECK #10: EXACT S^3 SCHWINGER-DYSON 5-OPERATOR BLOCKED HAMILTONIAN TOMOGRAPHY (PURE OM-2 GB10) ===\n" 75 text tC10Err "FAIL: GB10 native NVRM/kernel error stage=" 76 text tC10H16 "=== 16^4 -> 8^4 -> 4^4 EXACT 5-OPERATOR SCHWINGER-DYSON RG FLOW (64 MEAS, ZERO CALIBRATION TABLE) ===\n" 77 text tC10H32 "=== 32^4 -> 16^4 -> 8^4 -> 4^4 DEEP k=3 SCHWINGER-DYSON RG FLOW (1,048,576 SITES, 16 MEAS) ===\n" 78 text tC10Cols "L_base\tbeta\tk\tbeta_SD1\tbeta_F\tbeta_A\tbeta_R\tbeta_22\tbeta_Cr\talpha_ML\tus\n" 79 text tTab "\t" 80 text tNl "\n" 81 text tC10Done "CHECK10_GB10_DONE status=PASS\n" 82 83 fn uCodeWrite w view ulong 4 to void 84 p = get uCodePos 0 85 b = new uchar 16 0 86 if gt get uCodeMap 0 0 87 for i ulong 16 88 put b i uchar and shr get w div i 4 mul rem i 4 8 255 89 end 90 if ne mapwrite get uCodeMap 0 p b 0 16 16 91 put uCodeFail 0 1 92 end 93 end 94 put uCodePos 0 add p 16 95 end 96 97 fn uEmitAllKernels to void 98 put uCodePos 0 0 99 for id ulong 3 100 p = mul div add get uCodePos 0 255 256 256 101 put uEntry id p 102 put uCodePos 0 p 103 put uPc 0 0 104 put uGuard 0 0 105 ok = false 106 if eq id 0 107 ok = uEmitSu2Staple 108 end 109 if eq id 1 110 ok = uEmitSu2Overrelax 111 end 112 if eq id 2 113 ok = uEmitSu2Heatbath 114 end 115 if not ok 116 exit 4 117 end 118 uDone 119 end 120 end 121 122 fn uArg u uint to void 123 i = get uBindN 0 124 put uBind i u 125 put uBindN 0 add i 1 126 end 127 128 fn uPtr va ulong to void 129 uArg gblo va 130 uArg gbhi va 131 end 132 133 fn uRecord id ulong gx uint bx uint to bool 134 gbqmd 1 135 a = add mapaddr get uCodeMap 0 get uEntry id 136 put gbq1 32 gblo shr a 4 137 put gbq1 33 or uint and shr a 36 `2097151` `20971520` 138 put gbq1 59 gblo shr a 8 139 put gbq1 34 or uint 65536 bx 140 put gbq1 35 or uint 131073 shl uint 64 8 141 put gbq1 36 `78923784` 142 put gbq1 37 0 143 put gbq1 39 gx 144 put gbq1 40 1 145 put gbq1 41 1 146 put gbcb 216 bx 147 put gbcb 220 gx 148 put gbcb 221 1 149 put gbcb 222 1 150 cb = mapaddr get gbmem 1 151 words = get uBindN 0 152 endva = add cb add 896 mul words 4 153 put gbcb 212 gbhi endva 154 put gbcb 213 gblo endva 155 put gbused 0 0 156 gbsetup 157 if ne get uDirty 0 0 158 gbmth 0 40 4 159 gbemit 0 160 gbemit 0 161 gbemit 0 162 gbemit `2281701376` 163 put uDirty 0 0 164 end 165 gbdma cb 224 166 for j ulong 224 167 gbemit get gbcb j 168 end 169 gbdma add cb 896 uint words 170 for j ulong words bound 32 171 gbemit get uBind j 172 end 173 q = mapaddr get gbmem 2 174 gbinline q false 175 gbdma add q 8192 1 176 gbemit 1 177 gbinline add q 4096 true 178 gbrel add mapaddr get gbmem 3 32 6 179 put uBindN 0 0 180 ret gbappend id get gbst 1 181 end 182 183 fn uRunKernel id ulong gx uint bx uint to bool 184 put uDirty 0 1 185 if not gbbegin 1 186 ret false 187 end 188 if not uRecord id gx bx 189 ret false 190 end 191 ret gbbsubmit `2000000000` 192 end 193 194 fn stageU32 k ulong v uint to void 195 b = mul k 4 196 put hStage b uchar and v 255 197 put hStage add b 1 uchar and shr v 8 255 198 put hStage add b 2 uchar and shr v 16 255 199 put hStage add b 3 uchar and shr v 24 255 200 end 201 202 fn stageF32 k ulong v f32 to void 203 stageU32 k bitcast uint v 204 end 205 206 fn flushStage m long offBytes ulong nWords ulong to bool 207 nb = mul nWords 4 208 ret eq mapwrite m offBytes hStage 0 nb long nb 209 end 210 211 fn coordIdx c0 ulong c1 ulong c2 ulong c3 ulong L ulong to ulong 212 r = add mul c0 L c1 213 r = add mul r L c2 214 ret add mul r L c3 215 end 216 217 fn stepCoord s ulong L ulong dir ulong delta ulong to ulong 218 c3 = rem s L 219 t = div s L 220 c2 = rem t L 221 t = div t L 222 c1 = rem t L 223 c0 = div t L 224 if eq dir 0 225 c0 = rem add c0 delta L 226 end 227 if eq dir 1 228 c1 = rem add c1 delta L 229 end 230 if eq dir 2 231 c2 = rem add c2 delta L 232 end 233 if eq dir 3 234 c3 = rem add c3 delta L 235 end 236 ret coordIdx c0 c1 c2 c3 L 237 end 238 239 fn isBox4 s ulong L ulong lo ulong hi ulong to bool 240 c3 = rem s L 241 t = div s L 242 c2 = rem t L 243 t = div t L 244 c1 = rem t L 245 c0 = div t L 246 if or lt c0 lo ge c0 hi 247 ret false 248 end 249 if or lt c1 lo ge c1 hi 250 ret false 251 end 252 if or lt c2 lo ge c2 hi 253 ret false 254 end 255 if or lt c3 lo ge c3 hi 256 ret false 257 end 258 ret true 259 end 260 261 fn stageSiteNb kSite ulong s ulong L ulong to void 262 c3 = rem s L 263 t = div s L 264 c2 = rem t L 265 t = div t L 266 c1 = rem t L 267 c0 = div t L 268 b = mul kSite 8 269 stageU32 b uint coordIdx rem add c0 1 L c1 c2 c3 L 270 stageU32 add b 1 uint coordIdx rem add c0 sub L 1 L c1 c2 c3 L 271 stageU32 add b 2 uint coordIdx c0 rem add c1 1 L c2 c3 L 272 stageU32 add b 3 uint coordIdx c0 rem add c1 sub L 1 L c2 c3 L 273 stageU32 add b 4 uint coordIdx c0 c1 rem add c2 1 L c3 L 274 stageU32 add b 5 uint coordIdx c0 c1 rem add c2 sub L 1 L c3 L 275 stageU32 add b 6 uint coordIdx c0 c1 c2 rem add c3 1 L L 276 stageU32 add b 7 uint coordIdx c0 c1 c2 rem add c3 sub L 1 L L 277 end 278 279 fn buildNbTableStream L ulong to bool 280 N = mul mul L L mul L L 281 off = ulong 0 282 while lt off N bound 512 283 cnt = sub N off 284 if gt cnt 2048 285 cnt = ulong 2048 286 end 287 for k ulong cnt bound 2048 288 stageSiteNb k add off k L 289 end 290 if not flushStage get dNbSite 0 mul off 32 mul cnt 8 291 ret false 292 end 293 off = add off cnt 294 end 295 ret true 296 end 297 298 fn siteParity s ulong L ulong to uint 299 c3 = rem s L 300 t = div s L 301 c2 = rem t L 302 t = div t L 303 c1 = rem t L 304 c0 = div t L 305 ret uint and add add c0 c1 add c2 c3 1 306 end 307 308 fn buildFlagsStream L ulong to bool 309 N = mul mul L L mul L L 310 totalW = mul N 4 311 off = ulong 0 312 while lt off totalW bound 256 313 cnt = sub totalW off 314 if gt cnt 16384 315 cnt = ulong 16384 316 end 317 for k ulong cnt bound 16384 318 stageU32 k siteParity div add off k 4 L 319 end 320 if not flushStage get dFlags 0 mul off 4 cnt 321 ret false 322 end 323 off = add off cnt 324 end 325 ret true 326 end 327 328 fn seedGpuRngStream N ulong seed ulong to bool 329 uRngSeed seed 330 off = ulong 0 331 while lt off N bound 64 332 cnt = sub N off 333 if gt cnt 16384 334 cnt = ulong 16384 335 end 336 for k ulong cnt bound 16384 337 r = uint and uRngNext 0xffffffff 338 if eq r 0 339 r = uint 0x9e3779b9 340 end 341 stageU32 k r 342 end 343 if not flushStage get dRng 0 mul off 4 cnt 344 ret false 345 end 346 off = add off cnt 347 end 348 ret true 349 end 350 351 fn stageRandLink kLink ulong to void 352 a0 = f32 0.85f32 353 a1 = mul 0.25f32 f32 uRngNorm64 354 a2 = mul 0.25f32 f32 uRngNorm64 355 a3 = mul 0.25f32 f32 uRngNorm64 356 n2 = add add mul a0 a0 mul a1 a1 add mul a2 a2 mul a3 a3 357 inv = f32 div 1.0f64 uSqrt64 f64 n2 358 b = mul kLink 4 359 stageF32 b mul a0 inv 360 stageF32 add b 1 mul a1 inv 361 stageF32 add b 2 mul a2 inv 362 stageF32 add b 3 mul a3 inv 363 end 364 365 fn initLatticeStream L ulong seed ulong to bool 366 N = mul mul L L mul L L 367 uRngSeed seed 368 totalLinks = mul N 4 369 off = ulong 0 370 while lt off totalLinks bound 1024 371 cnt = sub totalLinks off 372 if gt cnt 4096 373 cnt = ulong 4096 374 end 375 for k ulong cnt bound 4096 376 stageRandLink k 377 end 378 if not flushStage get dLinks 0 mul off 16 mul cnt 4 379 ret false 380 end 381 off = add off cnt 382 end 383 ret true 384 end 385 386 fn gpuRunStaple N ulong mu ulong par ulong to bool 387 gx = uint div add N 255 256 388 nu0 = ulong 0 389 nu1 = ulong 1 390 nu2 = ulong 2 391 if eq mu 0 392 nu0 = ulong 1 393 nu1 = ulong 2 394 nu2 = ulong 3 395 end 396 if eq mu 1 397 nu0 = ulong 0 398 nu1 = ulong 2 399 nu2 = ulong 3 400 end 401 if eq mu 2 402 nu0 = ulong 0 403 nu1 = ulong 1 404 nu2 = ulong 3 405 end 406 uPtr mapaddr get dLinks 0 407 uPtr mapaddr get dStaples 0 408 uPtr mapaddr get dFlags 0 409 uPtr mapaddr get dNbSite 0 410 uArg uint N 411 uArg uint mu 412 uArg uint par 413 uArg uint nu0 414 uArg uint nu1 415 uArg uint nu2 416 ret uRunKernel 0 gx 256 417 end 418 419 fn gpuRunOverrelax N ulong mu ulong par ulong to bool 420 gx = uint div add N 255 256 421 uPtr mapaddr get dLinks 0 422 uPtr mapaddr get dStaples 0 423 uPtr mapaddr get dFlags 0 424 uArg uint N 425 uArg uint mu 426 uArg uint par 427 ret uRunKernel 1 gx 256 428 end 429 430 fn gpuRunHeatbath N ulong mu ulong par ulong beta f32 to bool 431 gx = uint div add N 255 256 432 uPtr mapaddr get dLinks 0 433 uPtr mapaddr get dStaples 0 434 uPtr mapaddr get dFlags 0 435 uPtr mapaddr get dRng 0 436 uArg uint N 437 uArg uint mu 438 uArg uint par 439 uArg bitcast uint beta 440 ret uRunKernel 2 gx 256 441 end 442 443 fn gpuSweep N ulong beta f32 nOr ulong to bool 444 for mu ulong 4 445 for par ulong 2 446 if not gpuRunStaple N mu par 447 ret false 448 end 449 if not gpuRunHeatbath N mu par beta 450 ret false 451 end 452 for r ulong nOr bound 8 453 if not gpuRunStaple N mu par 454 ret false 455 end 456 if not gpuRunOverrelax N mu par 457 ret false 458 end 459 end 460 end 461 end 462 ret true 463 end 464 465 fn downloadAllToL1 N ulong to void 466 lm = get dLinks 0 467 nf = mul N 16 468 for i ulong nf bound `1048576` 469 put hL1 i bitcast f32 uint mapget lm mul i 4 4 470 end 471 end 472 473 note ========================================================================= 474 note Quaternion Algebra & Gauge-Covariant Swendsen 2x RG Blocking 475 note ========================================================================= 476 fn hQMul a view f32 4 b view f32 4 dst edit f32 4 to void 477 v = mul get a 0 get b 0 478 v = sub v mul get a 1 get b 1 479 v = sub v mul get a 2 get b 2 480 v = sub v mul get a 3 get b 3 481 put dst 0 v 482 v = mul get a 0 get b 1 483 v = add v mul get a 1 get b 0 484 v = add v mul get a 2 get b 3 485 v = sub v mul get a 3 get b 2 486 put dst 1 v 487 v = mul get a 0 get b 2 488 v = sub v mul get a 1 get b 3 489 v = add v mul get a 2 get b 0 490 v = add v mul get a 3 get b 1 491 put dst 2 v 492 v = mul get a 0 get b 3 493 v = add v mul get a 1 get b 2 494 v = sub v mul get a 2 get b 1 495 v = add v mul get a 3 get b 0 496 put dst 3 v 497 end 498 499 fn hQConj q edit f32 4 to void 500 put q 1 neg get q 1 501 put q 2 neg get q 2 502 put q 3 neg get q 3 503 end 504 505 fn hQNorm q edit f32 4 fallback view f32 4 to void 506 n2 = mul get q 0 get q 0 507 n2 = add n2 mul get q 1 get q 1 508 n2 = add n2 mul get q 2 get q 2 509 n2 = add n2 mul get q 3 get q 3 510 if lt n2 get kernelMinNorm 0 511 put kernelMinNorm 0 n2 512 end 513 if le n2 0.`0000000001f32` 514 put kernelFallback 0 add get kernelFallback 0 1 515 for c ulong 4 516 put q c get fallback c 517 end 518 ret 519 end 520 inv = f32 div 1.0f64 uSqrt64 f64 n2 521 for c ulong 4 522 put q c mul get q c inv 523 end 524 end 525 526 fn loadLvl lvl ulong s ulong mu ulong dst edit f32 4 to void 527 b = mul add mul s 4 mu 4 528 if eq lvl 0 529 put dst 0 get hL1 b 530 put dst 1 get hL1 add b 1 531 put dst 2 get hL1 add b 2 532 put dst 3 get hL1 add b 3 533 ret 534 end 535 if eq lvl 1 536 put dst 0 get hL2 b 537 put dst 1 get hL2 add b 1 538 put dst 2 get hL2 add b 2 539 put dst 3 get hL2 add b 3 540 ret 541 end 542 if eq lvl 2 543 put dst 0 get hL3 b 544 put dst 1 get hL3 add b 1 545 put dst 2 get hL3 add b 2 546 put dst 3 get hL3 add b 3 547 ret 548 end 549 lm = get dLinks 0 550 bo = mul b 4 551 put dst 0 bitcast f32 uint mapget lm bo 4 552 put dst 1 bitcast f32 uint mapget lm add bo 4 4 553 put dst 2 bitcast f32 uint mapget lm add bo 8 4 554 put dst 3 bitcast f32 uint mapget lm add bo 12 4 555 end 556 557 fn storeLvl lvl ulong s ulong mu ulong src view f32 4 to void 558 b = mul add mul s 4 mu 4 559 if eq lvl 0 560 put hL1 b get src 0 561 put hL1 add b 1 get src 1 562 put hL1 add b 2 get src 2 563 put hL1 add b 3 get src 3 564 ret 565 end 566 if eq lvl 1 567 put hL2 b get src 0 568 put hL2 add b 1 get src 1 569 put hL2 add b 2 get src 2 570 put hL2 add b 3 get src 3 571 ret 572 end 573 put hL3 b get src 0 574 put hL3 add b 1 get src 1 575 put hL3 add b 2 get src 2 576 put hL3 add b 3 get src 3 577 end 578 579 fn addBlockStaple x ulong mu ulong nu ulong isBack bool dst edit f32 4 to void 580 lvl = get rgSrcLvl 0 581 Lf = get rgLf 0 582 a = new f32 4 0.0f32 583 b = new f32 4 0.0f32 584 p = new f32 4 0.0f32 585 q = new f32 4 0.0f32 586 x2m = stepCoord stepCoord x Lf mu 1 Lf mu 1 587 if not isBack 588 xn = stepCoord x Lf nu 1 589 loadLvl lvl x nu a 590 loadLvl lvl xn mu b 591 hQMul a b p 592 loadLvl lvl stepCoord xn Lf mu 1 mu a 593 hQMul p a q 594 loadLvl lvl x2m nu a 595 hQConj a 596 hQMul q a p 597 else 598 xm = stepCoord x Lf nu sub Lf 1 599 loadLvl lvl xm nu a 600 hQConj a 601 loadLvl lvl xm mu b 602 hQMul a b p 603 loadLvl lvl stepCoord xm Lf mu 1 mu a 604 hQMul p a q 605 loadLvl lvl stepCoord x2m Lf nu sub Lf 1 nu a 606 hQMul q a p 607 end 608 for c ulong 4 609 put dst c add get dst c get p c 610 end 611 end 612 613 fn coarseToFine X ulong Lf ulong to ulong 614 Lc = div Lf 2 615 c3 = rem X Lc 616 t = div X Lc 617 c2 = rem t Lc 618 t = div t Lc 619 c1 = rem t Lc 620 c0 = div t Lc 621 ret coordIdx mul c0 2 mul c1 2 mul c2 2 mul c3 2 Lf 622 end 623 624 fn projectPaths w0 view f32 4 st view f32 4 mixed edit f32 4 to void 625 weight = get kernelWeight 0 626 wS = div weight 6.0f32 627 w0factor = sub 1.0f32 weight 628 for c ulong 4 629 straightTerm = mul w0factor get w0 c 630 stapleTerm = mul wS get st c 631 put mixed c add straightTerm stapleTerm 632 end 633 hQNorm mixed w0 634 end 635 636 fn blockLinkOne X ulong mu ulong to void 637 srcLvl = get rgSrcLvl 0 638 Lf = get rgLf 0 639 x = coarseToFine X Lf 640 u1 = new f32 4 0.0f32 641 u2 = new f32 4 0.0f32 642 w0 = new f32 4 0.0f32 643 st = new f32 4 0.0f32 644 loadLvl srcLvl x mu u1 645 loadLvl srcLvl stepCoord x Lf mu 1 mu u2 646 hQMul u1 u2 w0 647 for nu ulong 4 648 if ne nu mu 649 addBlockStaple x mu nu false st 650 addBlockStaple x mu nu true st 651 end 652 end 653 projectPaths w0 st u1 654 storeLvl get rgDstLvl 0 X mu u1 655 end 656 657 fn blockBox srcLvl ulong dstLvl ulong Lf ulong cLo ulong cHi ulong to void 658 put rgSrcLvl 0 srcLvl 659 put rgDstLvl 0 dstLvl 660 put rgLf 0 Lf 661 Lc = div Lf 2 662 Nc = mul mul Lc Lc mul Lc Lc 663 for X ulong Nc bound 65536 664 if isBox4 X Lc cLo cHi 665 for mu ulong 4 666 blockLinkOne X mu 667 end 668 end 669 end 670 end 671 672 note ========================================================================= 673 note Exact S^3 Path Walker & 5-Operator Lie-Algebraic Schwinger-Dyson Accumulator 674 note ========================================================================= 675 fn walkStart lvl ulong L ulong s ulong to void 676 put walkLvl 0 lvl 677 put walkL 0 L 678 put walkCur 0 s 679 put walkQ 0 1.0f32 680 put walkQ 1 0.0f32 681 put walkQ 2 0.0f32 682 put walkQ 3 0.0f32 683 end 684 685 fn walkStep dir ulong isNeg ulong to void 686 lvl = get walkLvl 0 687 L = get walkL 0 688 cur = get walkCur 0 689 u = new f32 4 0.0f32 690 curQ = new f32 4 0.0f32 691 resQ = new f32 4 0.0f32 692 for c ulong 4 693 put curQ c get walkQ c 694 end 695 if eq isNeg 0 696 loadLvl lvl cur dir u 697 hQMul curQ u resQ 698 put walkCur 0 stepCoord cur L dir 1 699 else 700 ncur = stepCoord cur L dir sub L 1 701 loadLvl lvl ncur dir u 702 hQConj u 703 hQMul curQ u resQ 704 put walkCur 0 ncur 705 end 706 for d ulong 4 707 put walkQ d get resQ d 708 end 709 end 710 711 fn recordFundLoop op ulong to void 712 w0 = f64 get walkQ 0 713 w1 = f64 get walkQ 1 714 w2 = f64 get walkQ 2 715 w3 = f64 get walkQ 3 716 base = mul op 3 717 put linkG base sub get linkG base w1 718 put linkG add base 1 sub get linkG add base 1 w2 719 put linkG add base 2 sub get linkG add base 2 w3 720 put linkL op add get linkL op mul 3.0f64 w0 721 end 722 723 fn recordPlaqAndAdj to void 724 w0 = f64 get walkQ 0 725 w1 = f64 get walkQ 1 726 w2 = f64 get walkQ 2 727 w3 = f64 get walkQ 3 728 note op 0 = fundamental 1x1 plaquette 729 put linkG 0 sub get linkG 0 w1 730 put linkG 1 sub get linkG 1 w2 731 put linkG 2 sub get linkG 2 w3 732 put linkL 0 add get linkL 0 mul 3.0f64 w0 733 note op 1 = adjoint 1x1 plaquette (4 W0^2 - 1): L_a = -8 W0 W_a, -Delta = +8 (4 W0^2 - 1) 734 c8 = mul 8.0f64 w0 735 put linkG 3 sub get linkG 3 mul c8 w1 736 put linkG 4 sub get linkG 4 mul c8 w2 737 put linkG 5 sub get linkG 5 mul c8 w3 738 chi1 = sub mul 4.0f64 mul w0 w0 1.0f64 739 put linkL 1 add get linkL 1 mul 8.0f64 chi1 740 end 741 742 fn accumPlaneOps lvl ulong L ulong s ulong mu ulong nu ulong to void 743 note 2 plaquettes (forward +nu, backward -nu) -> ops 0 & 1 744 walkStart lvl L s 745 walkStep mu 0 746 walkStep nu 0 747 walkStep mu 1 748 walkStep nu 1 749 recordPlaqAndAdj 750 751 walkStart lvl L s 752 walkStep mu 0 753 walkStep nu 1 754 walkStep mu 1 755 walkStep nu 0 756 recordPlaqAndAdj 757 758 note 6 planar 1x2 rectangles touching link (s, mu) in plane (mu, nu) -> op 2 759 note R1: +mu,+mu,+nu,-mu,-mu,-nu 760 walkStart lvl L s 761 walkStep mu 0 762 walkStep mu 0 763 walkStep nu 0 764 walkStep mu 1 765 walkStep mu 1 766 walkStep nu 1 767 recordFundLoop 2 768 note R2: +mu,+nu,-mu,-mu,-nu,+mu 769 walkStart lvl L s 770 walkStep mu 0 771 walkStep nu 0 772 walkStep mu 1 773 walkStep mu 1 774 walkStep nu 1 775 walkStep mu 0 776 recordFundLoop 2 777 note R3: +mu,+mu,-nu,-mu,-mu,+nu 778 walkStart lvl L s 779 walkStep mu 0 780 walkStep mu 0 781 walkStep nu 1 782 walkStep mu 1 783 walkStep mu 1 784 walkStep nu 0 785 recordFundLoop 2 786 note R4: +mu,-nu,-mu,-mu,+nu,+mu 787 walkStart lvl L s 788 walkStep mu 0 789 walkStep nu 1 790 walkStep mu 1 791 walkStep mu 1 792 walkStep nu 0 793 walkStep mu 0 794 recordFundLoop 2 795 note R5: +mu,+nu,+nu,-mu,-nu,-nu 796 walkStart lvl L s 797 walkStep mu 0 798 walkStep nu 0 799 walkStep nu 0 800 walkStep mu 1 801 walkStep nu 1 802 walkStep nu 1 803 recordFundLoop 2 804 note R6: +mu,-nu,-nu,-mu,+nu,+nu 805 walkStart lvl L s 806 walkStep mu 0 807 walkStep nu 1 808 walkStep nu 1 809 walkStep mu 1 810 walkStep nu 0 811 walkStep nu 0 812 recordFundLoop 2 813 814 note 4 planar 2x2 square loops touching link (s, mu) in plane (mu, nu) -> op 3 815 note Q1: +mu,+mu,+nu,+nu,-mu,-mu,-nu,-nu 816 walkStart lvl L s 817 walkStep mu 0 818 walkStep mu 0 819 walkStep nu 0 820 walkStep nu 0 821 walkStep mu 1 822 walkStep mu 1 823 walkStep nu 1 824 walkStep nu 1 825 recordFundLoop 3 826 note Q2: +mu,+nu,+nu,-mu,-mu,-nu,-nu,+mu 827 walkStart lvl L s 828 walkStep mu 0 829 walkStep nu 0 830 walkStep nu 0 831 walkStep mu 1 832 walkStep mu 1 833 walkStep nu 1 834 walkStep nu 1 835 walkStep mu 0 836 recordFundLoop 3 837 note Q3: +mu,+mu,-nu,-nu,-mu,-mu,+nu,+nu 838 walkStart lvl L s 839 walkStep mu 0 840 walkStep mu 0 841 walkStep nu 1 842 walkStep nu 1 843 walkStep mu 1 844 walkStep mu 1 845 walkStep nu 0 846 walkStep nu 0 847 recordFundLoop 3 848 note Q4: +mu,-nu,-nu,-mu,-mu,+nu,+nu,+mu 849 walkStart lvl L s 850 walkStep mu 0 851 walkStep nu 1 852 walkStep nu 1 853 walkStep mu 1 854 walkStep mu 1 855 walkStep nu 0 856 walkStep nu 0 857 walkStep mu 0 858 recordFundLoop 3 859 end 860 861 fn accumCrownPair lvl ulong L ulong s ulong mu ulong nu ulong rho ulong to void 862 for sn ulong 2 863 for sr ulong 2 864 walkStart lvl L s 865 walkStep mu 0 866 walkStep nu sn 867 walkStep rho sr 868 walkStep mu 1 869 walkStep nu sub 1 sn 870 walkStep rho sub 1 sr 871 recordFundLoop 4 872 end 873 end 874 end 875 876 fn accumSDMat kIdx ulong to void 877 mBase = mul kIdx 25 878 bBase = mul kIdx 5 879 for r ulong 5 880 bi = add bBase r 881 put sdB bi add get sdB bi get linkL r 882 gr = mul r 3 883 for c ulong 5 884 gc = mul c 3 885 dot = mul get linkG gr get linkG gc 886 dot = add dot mul get linkG add gr 1 get linkG add gc 1 887 dot = add dot mul get linkG add gr 2 get linkG add gc 2 888 mi = add mBase add mul r 5 c 889 put sdM mi add get sdM mi dot 890 end 891 end 892 put sdCnt kIdx add get sdCnt kIdx 1 893 end 894 895 fn accumSDLink lvl ulong L ulong s ulong mu ulong kIdx ulong to void 896 for i ulong 15 897 put linkG i 0.0f64 898 end 899 for j ulong 5 900 put linkL j 0.0f64 901 end 902 for nu ulong 4 903 if ne nu mu 904 accumPlaneOps lvl L s mu nu 905 for rho ulong 4 906 if ne rho mu 907 if ne rho nu 908 accumCrownPair lvl L s mu nu rho 909 end 910 end 911 end 912 end 913 end 914 accumSDMat kIdx 915 end 916 917 fn sampleSDBox lvl ulong L ulong lo ulong kIdx ulong to void 918 for c0 ulong 4 919 for c1 ulong 4 920 for c2 ulong 4 921 for c3 ulong 4 922 s = coordIdx add c0 lo add c1 lo add c2 lo add c3 lo L 923 for mu ulong 4 924 accumSDLink lvl L s mu kIdx 925 end 926 end 927 end 928 end 929 end 930 end 931 932 note ========================================================================= 933 note 5x5 Partial-Pivoting Gaussian Elimination & Lean Multi-Loop Dobrushin Norm 934 note ========================================================================= 935 fn solve5x5Load kIdx ulong to void 936 mBase = mul kIdx 25 937 bBase = mul kIdx 5 938 for r ulong 5 939 for c ulong 5 940 put linA add mul r 6 c get sdM add mBase add mul r 5 c 941 end 942 put linA add mul r 6 5 get sdB add bBase r 943 end 944 end 945 946 fn solve5x5Swap p ulong pivR ulong to void 947 for c ulong 6 948 i1 = add mul p 6 c 949 i2 = add mul pivR 6 c 950 tmp = get linA i1 951 put linA i1 get linA i2 952 put linA i2 tmp 953 end 954 end 955 956 fn solve5x5ElimRow p ulong r3 ulong fac f64 to void 957 for c3 ulong 6 958 if ge c3 p 959 idx3 = add mul r3 6 c3 960 idxP = add mul p 6 c3 961 nv = sub get linA idx3 mul fac get linA idxP 962 put linA idx3 nv 963 end 964 end 965 end 966 967 fn solve5x5ElimStep p ulong to void 968 pivR = p 969 pivV = uAbs64 get linA add mul p 6 p 970 for r2 ulong 5 971 if gt r2 p 972 av = uAbs64 get linA add mul r2 6 p 973 if gt av pivV 974 pivV = av 975 pivR = r2 976 end 977 end 978 end 979 if ne pivR p 980 solve5x5Swap p pivR 981 end 982 diag = get linA add mul p 6 p 983 if le uAbs64 diag 0.`000000000001f64` 984 if ne get kernelTrial 0 0 985 exit 67 986 end 987 ret 988 end 989 for r3 ulong 5 990 if gt r3 p 991 fac = div get linA add mul r3 6 p diag 992 solve5x5ElimRow p r3 fac 993 end 994 end 995 end 996 997 fn solve5x5Back to void 998 for step ulong 5 999 r4 = sub 4 step 1000 rhs = get linA add mul r4 6 5 1001 for c4 ulong 5 1002 if gt c4 r4 1003 rhs = sub rhs mul get linA add mul r4 6 c4 get linX c4 1004 end 1005 end 1006 d4 = get linA add mul r4 6 r4 1007 if le uAbs64 d4 0.`000000000001f64` 1008 if ne get kernelTrial 0 0 1009 exit 67 1010 end 1011 put linX r4 0.0f64 1012 else 1013 put linX r4 div rhs d4 1014 end 1015 end 1016 end 1017 1018 fn solve5x5 kIdx ulong to void 1019 solve5x5Load kIdx 1020 for p ulong 5 1021 solve5x5ElimStep p 1022 end 1023 solve5x5Back 1024 end 1025 1026 fn uTanh64 x f64 to f64 1027 if ge x 20.0f64 1028 ret 1.0f64 1029 end 1030 if le x neg 20.0f64 1031 ret neg 1.0f64 1032 end 1033 e2 = uExp64 mul 2.0f64 x 1034 ret div sub e2 1.0f64 add e2 1.0f64 1035 end 1036 1037 fn printSDRow Lbase ulong beta f64 k ulong us ulong to void 1038 m00 = get sdM mul k 25 1039 b0 = get sdB mul k 5 1040 bSD1 = f64 0.0f64 1041 if gt m00 0.`000000000001f64` 1042 bSD1 = div b0 m00 1043 end 1044 solve5x5 k 1045 cF = get linX 0 1046 cA = get linX 1 1047 cR = get linX 2 1048 c22 = get linX 3 1049 cCr = get linX 4 1050 aML = mul 9.0f64 uAbs64 cF 1051 aML = add aML mul 18.0f64 uTanh64 mul 2.0f64 uAbs64 cA 1052 aML = add aML mul 45.0f64 uAbs64 cR 1053 aML = add aML mul 42.0f64 uAbs64 c22 1054 aML = add aML mul 60.0f64 uAbs64 cCr 1055 uPrintU Lbase 1056 uPrint tTab 1057 uPrintF64 beta 1058 uPrint tTab 1059 uPrintU k 1060 uPrint tTab 1061 uPrintF64 bSD1 1062 uPrint tTab 1063 uPrintF64 cF 1064 uPrint tTab 1065 uPrintF64 cA 1066 uPrint tTab 1067 uPrintF64 cR 1068 uPrint tTab 1069 uPrintF64 c22 1070 uPrint tTab 1071 uPrintF64 cCr 1072 uPrint tTab 1073 uPrintF64 aML 1074 uPrint tTab 1075 uPrintU us 1076 uPrint tNl 1077 end 1078 1079 fn resetSD to void 1080 for i ulong 100 1081 put sdM i 0.0f64 1082 end 1083 for j ulong 20 1084 put sdB j 0.0f64 1085 end 1086 for k ulong 4 1087 put sdCnt k 0 1088 end 1089 end 1090 1091 note Run 5-Operator Schwinger-Dyson RG Tomography on 16^4 -> 8^4 -> 4^4 (64 measurements) 1092 fn runSD16 beta f32 seed ulong to void 1093 t0 = monons 1094 N = ulong 65536 1095 if not seedGpuRngStream N seed 1096 exit 31 1097 end 1098 if not initLatticeStream 16 add seed 104729 1099 exit 32 1100 end 1101 for sw ulong 64 1102 if not gpuSweep N beta 3 1103 exit 33 1104 end 1105 end 1106 resetSD 1107 for m ulong 64 1108 if not gpuSweep N beta 2 1109 exit 34 1110 end 1111 if not gpuSweep N beta 2 1112 exit 35 1113 end 1114 downloadAllToL1 N 1115 sampleSDBox 0 16 6 0 1116 blockBox 0 1 16 0 8 1117 sampleSDBox 1 8 2 1 1118 blockBox 1 2 8 0 4 1119 sampleSDBox 2 4 0 2 1120 end 1121 us = div ulong sub monons t0 1000 1122 printSDRow 16 f64 beta 0 us 1123 printSDRow 16 f64 beta 1 us 1124 printSDRow 16 f64 beta 2 us 1125 end 1126 1127 note Run Deep k=3 5-Operator Schwinger-Dyson RG on 32^4 (1,048,576 sites -> 16^4 -> 8^4 -> 4^4, 16 meas) 1128 fn runSD32 beta f32 seed ulong to void 1129 t0 = monons 1130 N = ulong `1048576` 1131 if not seedGpuRngStream N seed 1132 exit 41 1133 end 1134 if not initLatticeStream 32 add seed 104729 1135 exit 42 1136 end 1137 for sw ulong 32 1138 if not gpuSweep N beta 3 1139 exit 43 1140 end 1141 end 1142 resetSD 1143 for m ulong 16 1144 if not gpuSweep N beta 2 1145 exit 44 1146 end 1147 if not gpuSweep N beta 2 1148 exit 45 1149 end 1150 sampleSDBox 3 32 14 0 1151 blockBox 3 0 32 0 16 1152 sampleSDBox 0 16 6 1 1153 blockBox 0 1 16 0 8 1154 sampleSDBox 1 8 2 2 1155 blockBox 1 2 8 0 4 1156 sampleSDBox 2 4 0 3 1157 end 1158 us = div ulong sub monons t0 1000 1159 printSDRow 32 f64 beta 0 us 1160 printSDRow 32 f64 beta 1 us 1161 printSDRow 32 f64 beta 2 us 1162 printSDRow 32 f64 beta 3 us 1163 end 1164 1165 fn allocBuf bytes ulong cached bool to long 1166 m = nvalloc bytes cached 1167 if le m 0 1168 uPrint tC10Err 1169 uPrintU ulong get nvstage 0 1170 uPrint tNl 1171 exit 6 1172 end 1173 ret m 1174 end 1175 1176 fn kernelArg idx ulong to ulong 1177 b = new uchar 9 0 1178 n = argread idx b 0 9 1179 if le n 0 1180 exit 64 1181 end 1182 r = ulong 0 1183 for i ulong ulong n bound 9 1184 c = get b i 1185 if or lt c 48 gt c 57 1186 exit 64 1187 end 1188 r = add mul r 10 ulong sub c 48 1189 end 1190 ret r 1191 end 1192 1193 fn main to int 1194 put kernelWeight 0 0.5f32 1195 put kernelMinNorm 0 2.0f32 1196 seed = ulong 0 1197 if ne argcnt 1 1198 if ne argcnt 3 1199 ret 64 1200 end 1201 quarter = kernelArg 1 1202 seed = kernelArg 2 1203 if gt quarter 4 1204 ret 64 1205 end 1206 put kernelTrial 0 1 1207 put kernelWeight 0 div f32 quarter 4.0f32 1208 put uStrictRejection 0 1 1209 end 1210 uPrint tC10Hdr 1211 if not gbopen 1 1212 uPrint tC10Err 1213 uPrintU ulong get nvstage 0 1214 uPrint tNl 1215 ret 2 1216 end 1217 if not gbbopen 1218 ret 3 1219 end 1220 put uCodeMap 0 0 1221 uEmitAllKernels 1222 csize = mul div add get uCodePos 0 4095 4096 4096 1223 cm = nvalloc csize false 1224 if le cm 0 1225 ret 4 1226 end 1227 put uCodeMap 0 cm 1228 put uCodeFail 0 0 1229 uEmitAllKernels 1230 if ne get uCodeFail 0 0 1231 ret 5 1232 end 1233 1234 put dLinks 0 allocBuf `67108864` true 1235 put dStaples 0 allocBuf `67108864` true 1236 put dFlags 0 allocBuf `16777216` true 1237 put dNbSite 0 allocBuf `33554432` true 1238 put dRng 0 allocBuf `4194304` true 1239 1240 if ne get kernelTrial 0 0 1241 if not buildNbTableStream 32 1242 ret 14 1243 end 1244 if not buildFlagsStream 32 1245 ret 15 1246 end 1247 uPrint tC10Cols 1248 runSD32 2.30f32 add seed 0xac310000 1249 uPrint tKernelStats 1250 uPrintF64 f64 get kernelMinNorm 0 1251 uPrint tTab 1252 uPrintU get kernelFallback 0 1253 uPrint tNl 1254 uPrint tC10Done 1255 rc = nvmclose 1256 ret 0 1257 end 1258 uPrint tC10H16 1259 uPrint tC10Cols 1260 if not buildNbTableStream 16 1261 rc = nvmclose 1262 ret 12 1263 end 1264 if not buildFlagsStream 16 1265 rc = nvmclose 1266 ret 13 1267 end 1268 runSD16 1.50f32 0xa1010001 1269 runSD16 2.00f32 0xa1020001 1270 runSD16 2.30f32 0xa1030001 1271 runSD16 2.50f32 0xa1040001 1272 runSD16 6.00f32 0xa1060001 1273 1274 uPrint tC10H32 1275 uPrint tC10Cols 1276 if not buildNbTableStream 32 1277 rc = nvmclose 1278 ret 14 1279 end 1280 if not buildFlagsStream 32 1281 rc = nvmclose 1282 ret 15 1283 end 1284 runSD32 2.00f32 0xa3020001 1285 runSD32 2.30f32 0xa3030001 1286 1287 uPrint tC10Done 1288 rc = nvmclose 1289 ret 0 1290 end