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_check8_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_check8_gb10.om` 1236 lines ยท 26132 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note src/ufbi_check8_gb10.om: Pure Seeded-OM-2 Zero-CUDA GB10 Runner for UFBI Check #8 3 note (Phase II Multi-Scale Gauge-Covariant Block-Spin RG Flow & Effective Dobrushin-Shlosman 4 note Contraction Across L=16 -> L1=8 -> L2=4 for beta in {1.50, 2.00, 2.30, 2.50, 2.70, 6.00}). 5 note 6 note What Check #8 measures directly on physical GB10 silicon: 7 note 1. Runtime RG_GAUGE_COV_ASSERT: applies a random local SU(2) gauge transformation g(x) 8 note on 16^4, runs Swendsen 2x gauge-covariant blocking (16^4 -> 8^4 -> 4^4) on both U 9 note and U^g, and asserts max |P^(k)(U^g) - P^(k)(U)| <= 1e-4 at every RG scale k=0,1,2. 10 note 2. Runtime ZERO_CONTACT_ASSERT: swaps frozen collar C0_cold vs C3_hot_haar on a fixed 11 note interior 16^4 config and asserts max |O^(k)(B1) - O^(k)(B0)| == 0.000000 at all 12 note 3 RG scales k=0 (a), k=1 (2a), k=2 (4a). 13 note 3. In-situ periodic bulk SU(2) plaquette calibration curve (beta) on periodic 8^4 14 note for beta in {0.25, 0.50, 1.00, 1.50, 2.00, 2.30, 2.50, 3.00, 4.00, 6.00} so each 15 note blocked plaquette maps directly to a non-perturbative running coupling beta_eff(k). 16 note 4. Multi-scale RG flow & scale-by-scale Dobrushin boundary sensitivity on frozen-collar 16^4 17 note (C0_cold vs C3_hot_haar & C8_smooth_hol, 256 measurements = 512 GPU sweeps/arm) at 18 note beta in {1.50, 2.00, 2.30, 2.50, 2.70, 6.00}: 19 note O0: P^(0) (fine scale a, 16^4 core [6,10)^4) 20 note O1: P^(1) (RG-1 scale 2a, 8^4 core [3,5)^4) 21 note O2: P^(2) (RG-2 scale 4a, 4^4 center X=(1,1,1,1)) 22 note O3: Adj^(1)(RG-1 scale 2a, adjoint plaquette 4*(P^(1))^2 - 1) 23 note O4: Adj^(2)(RG-2 scale 4a, adjoint plaquette 4*(P^(2))^2 - 1) 24 note 25 note Composed after: 26 note gpu/nvidia/native/nvrm/context.om 27 note gpu/nvidia/native/blackwell/vector.om 28 note gpu/nvidia/native/blackwell/launch.om 29 note gpu/nvidia/native/blackwell/batch.om 30 note om/encoder/bw_enc_sm121.om 31 note src/ufbi_math.om 32 note src/ufbi_check3_kernels.om 33 34 global uCodePos ulong 1 35 global uEntry ulong 8 36 global uCodeMap long 1 37 global uCodeFail uint 1 38 global uBind uint 32 39 global uBindN ulong 1 40 global uDirty uint 1 41 42 global dLinks long 1 43 global dStaples long 1 44 global dFlags long 1 45 global dNbSite long 1 46 global dRng long 1 47 48 note Fine 16^4 (65536 sites x 16 = `1048576` f32), RG-1 8^4 (4096 x 16 = 65536), RG-2 4^4 (256 x 16 = 4096) 49 global hL0 f32 `1048576` 50 global hL1 f32 65536 51 global hL2 f32 4096 52 global hGauge f32 262144 53 global hNb uint 524288 54 global hStage uchar 65536 55 56 note 5 observables x 256 sweeps = 1280 f64 57 global tsData f64 1280 58 global baseMean f64 5 59 global baseErr f64 5 60 global baseSig f64 5 61 global curMean f64 5 62 global curErr f64 5 63 global curSig f64 5 64 global curDelta f64 5 65 global curZ f64 5 66 global curRBulk f64 5 67 global mcAcc f64 6 68 global mcCnt ulong 1 69 global armBeta f32 1 70 global armSeed ulong 1 71 global rgSrcLvl ulong 1 72 global rgDstLvl ulong 1 73 global rgLf ulong 1 74 75 note 10-point periodic bulk calibration table (beta_i -> (beta_i)) 76 global calBeta f64 10 77 global calPlaq f64 10 78 79 text tC8Hdr "=== UFBI CHECK #8: PHASE-II MULTI-SCALE GAUGE-COVARIANT BLOCK-SPIN RG FLOW & DOBRUSHIN CONTRACTION (PURE OM-2 GB10) ===\n" 80 text tC8Err "FAIL: GB10 native NVRM/kernel error stage=" 81 text tC8GcFail "FAIL: RG_GAUGE_COV_ASSERT violated! err=" 82 text tC8GcOk "RG_GAUGE_COV_ASSERT scales=3 max_gauge_err=" 83 text tC8ZcFail "FAIL: ZERO_CONTACT_ASSERT violated! err=" 84 text tC8ZcOk "ZERO_CONTACT_ASSERT L=16 scales=3 max_direct_err=" 85 text tC8Pass " status=PASS\n" 86 text tC8CalHdr "=== IN-SITU PERIODIC 8^4 SU(2) BULK CALIBRATION CURVE ===\n" 87 text tC8CalCols "cal_beta\tcal_P_bulk\n" 88 text tC8RgHdr "=== MULTI-SCALE BLOCK-SPIN RG FLOW (16^4 -> 8^4 -> 4^4) ===\n" 89 text tC8Cols "beta\tcollar\tsweeps\tP0_m\tP1_m\tP2_m\tbeff_0\tbeff_1\tbeff_2\tdP0_Rb\tdP0_Z\tdP1_Rb\tdP1_Z\tdP2_Rb\tdP2_Z\tdA1_Rb\tdA1_Z\tdA2_Rb\tdA2_Z\tus\n" 90 text tTab "\t" 91 text tNl "\n" 92 text tK0 "C0_cold" 93 text tK3 "C3_hot_haar" 94 text tK8 "C8_smooth_hol" 95 text tC8Done "CHECK8_GB10_DONE status=PASS rg_gauge_cov_verified=1 zero_contact_verified=1\n" 96 97 fn uCodeWrite w view ulong 4 to void 98 p = get uCodePos 0 99 b = new uchar 16 0 100 if gt get uCodeMap 0 0 101 for i ulong 16 102 put b i uchar and shr get w div i 4 mul rem i 4 8 255 103 end 104 if ne mapwrite get uCodeMap 0 p b 0 16 16 105 put uCodeFail 0 1 106 end 107 end 108 put uCodePos 0 add p 16 109 end 110 111 fn uEmitAllKernels to void 112 put uCodePos 0 0 113 for id ulong 3 114 p = mul div add get uCodePos 0 255 256 256 115 put uEntry id p 116 put uCodePos 0 p 117 put uPc 0 0 118 put uGuard 0 0 119 ok = false 120 if eq id 0 121 ok = uEmitSu2Staple 122 end 123 if eq id 1 124 ok = uEmitSu2Overrelax 125 end 126 if eq id 2 127 ok = uEmitSu2Heatbath 128 end 129 if not ok 130 exit 4 131 end 132 uDone 133 end 134 end 135 136 fn uArg u uint to void 137 i = get uBindN 0 138 put uBind i u 139 put uBindN 0 add i 1 140 end 141 142 fn uPtr va ulong to void 143 uArg gblo va 144 uArg gbhi va 145 end 146 147 fn uRecord id ulong gx uint bx uint to bool 148 gbqmd 1 149 a = add mapaddr get uCodeMap 0 get uEntry id 150 put gbq1 32 gblo shr a 4 151 put gbq1 33 or uint and shr a 36 `2097151` `20971520` 152 put gbq1 59 gblo shr a 8 153 put gbq1 34 or uint 65536 bx 154 put gbq1 35 or uint 131073 shl uint 64 8 155 put gbq1 36 `78923784` 156 put gbq1 37 0 157 put gbq1 39 gx 158 put gbq1 40 1 159 put gbq1 41 1 160 put gbcb 216 bx 161 put gbcb 220 gx 162 put gbcb 221 1 163 put gbcb 222 1 164 cb = mapaddr get gbmem 1 165 words = get uBindN 0 166 endva = add cb add 896 mul words 4 167 put gbcb 212 gbhi endva 168 put gbcb 213 gblo endva 169 put gbused 0 0 170 gbsetup 171 if ne get uDirty 0 0 172 gbmth 0 40 4 173 gbemit 0 174 gbemit 0 175 gbemit 0 176 gbemit `2281701376` 177 put uDirty 0 0 178 end 179 gbdma cb 224 180 for j ulong 224 181 gbemit get gbcb j 182 end 183 gbdma add cb 896 uint words 184 for j ulong words bound 32 185 gbemit get uBind j 186 end 187 q = mapaddr get gbmem 2 188 gbinline q false 189 gbdma add q 8192 1 190 gbemit 1 191 gbinline add q 4096 true 192 gbrel add mapaddr get gbmem 3 32 6 193 put uBindN 0 0 194 ret gbappend id get gbst 1 195 end 196 197 fn uRunKernel id ulong gx uint bx uint to bool 198 put uDirty 0 1 199 if not gbbegin 1 200 ret false 201 end 202 if not uRecord id gx bx 203 ret false 204 end 205 ret gbbsubmit `2000000000` 206 end 207 208 fn stageU32 k ulong v uint to void 209 b = mul k 4 210 put hStage b uchar and v 255 211 put hStage add b 1 uchar and shr v 8 255 212 put hStage add b 2 uchar and shr v 16 255 213 put hStage add b 3 uchar and shr v 24 255 214 end 215 216 fn stageF32 k ulong v f32 to void 217 stageU32 k bitcast uint v 218 end 219 220 fn flushStage m long offBytes ulong nWords ulong to bool 221 nb = mul nWords 4 222 ret eq mapwrite m offBytes hStage 0 nb long nb 223 end 224 225 fn uploadLinks N ulong to bool 226 totalF = mul N 16 227 off = ulong 0 228 while lt off totalF bound 128 229 cnt = sub totalF off 230 if gt cnt 16384 231 cnt = ulong 16384 232 end 233 for k ulong cnt bound 16384 234 stageF32 k get hL0 add off k 235 end 236 if not flushStage get dLinks 0 mul off 4 cnt 237 ret false 238 end 239 off = add off cnt 240 end 241 ret true 242 end 243 244 fn coordIdx c0 ulong c1 ulong c2 ulong c3 ulong L ulong to ulong 245 r = add mul c0 L c1 246 r = add mul r L c2 247 ret add mul r L c3 248 end 249 250 fn stepCoord s ulong L ulong dir ulong delta ulong to ulong 251 c3 = rem s L 252 t = div s L 253 c2 = rem t L 254 t = div t L 255 c1 = rem t L 256 c0 = div t L 257 if eq dir 0 258 c0 = rem add c0 delta L 259 end 260 if eq dir 1 261 c1 = rem add c1 delta L 262 end 263 if eq dir 2 264 c2 = rem add c2 delta L 265 end 266 if eq dir 3 267 c3 = rem add c3 delta L 268 end 269 ret coordIdx c0 c1 c2 c3 L 270 end 271 272 fn buildNbTable L ulong to bool 273 N = mul mul L L mul L L 274 for s ulong N bound 65536 275 c3 = rem s L 276 t = div s L 277 c2 = rem t L 278 t = div t L 279 c1 = rem t L 280 c0 = div t L 281 b = mul s 8 282 put hNb b uint coordIdx rem add c0 1 L c1 c2 c3 L 283 put hNb add b 1 uint coordIdx rem add c0 sub L 1 L c1 c2 c3 L 284 put hNb add b 2 uint coordIdx c0 rem add c1 1 L c2 c3 L 285 put hNb add b 3 uint coordIdx c0 rem add c1 sub L 1 L c2 c3 L 286 put hNb add b 4 uint coordIdx c0 c1 rem add c2 1 L c3 L 287 put hNb add b 5 uint coordIdx c0 c1 rem add c2 sub L 1 L c3 L 288 put hNb add b 6 uint coordIdx c0 c1 c2 rem add c3 1 L L 289 put hNb add b 7 uint coordIdx c0 c1 c2 rem add c3 sub L 1 L L 290 end 291 totalW = mul N 8 292 off = ulong 0 293 while lt off totalW bound 64 294 cnt = sub totalW off 295 if gt cnt 16384 296 cnt = ulong 16384 297 end 298 for k ulong cnt bound 16384 299 stageU32 k get hNb add off k 300 end 301 if not flushStage get dNbSite 0 mul off 4 cnt 302 ret false 303 end 304 off = add off cnt 305 end 306 ret true 307 end 308 309 fn isBdryL s ulong L ulong to bool 310 c3 = rem s L 311 t = div s L 312 c2 = rem t L 313 t = div t L 314 c1 = rem t L 315 c0 = div t L 316 lm1 = sub L 1 317 if or eq c0 0 eq c0 lm1 318 ret true 319 end 320 if or eq c1 0 eq c1 lm1 321 ret true 322 end 323 if or eq c2 0 eq c2 lm1 324 ret true 325 end 326 if or eq c3 0 eq c3 lm1 327 ret true 328 end 329 ret false 330 end 331 332 fn isBox4 s ulong L ulong lo ulong hi ulong to bool 333 c3 = rem s L 334 t = div s L 335 c2 = rem t L 336 t = div t L 337 c1 = rem t L 338 c0 = div t L 339 if or lt c0 lo ge c0 hi 340 ret false 341 end 342 if or lt c1 lo ge c1 hi 343 ret false 344 end 345 if or lt c2 lo ge c2 hi 346 ret false 347 end 348 if or lt c3 lo ge c3 hi 349 ret false 350 end 351 ret true 352 end 353 354 fn downloadBox L ulong lo ulong hi ulong to void 355 N = mul mul L L mul L L 356 lm = get dLinks 0 357 for s ulong N bound 65536 358 if isBox4 s L lo hi 359 base = mul s 16 360 for k ulong 16 361 put hL0 add base k bitcast f32 uint mapget lm mul add base k 4 4 362 end 363 end 364 end 365 end 366 367 fn siteFlag s ulong L ulong freezeCollar bool to uint 368 if and freezeCollar isBdryL s L 369 ret uint 2 370 end 371 c3 = rem s L 372 t = div s L 373 c2 = rem t L 374 t = div t L 375 c1 = rem t L 376 c0 = div t L 377 ret uint and add add c0 c1 add c2 c3 1 378 end 379 380 fn buildFlags L ulong freezeCollar bool to bool 381 N = mul mul L L mul L L 382 totalW = mul N 4 383 off = ulong 0 384 while lt off totalW bound 32 385 cnt = sub totalW off 386 if gt cnt 16384 387 cnt = ulong 16384 388 end 389 for k ulong cnt bound 16384 390 stageU32 k siteFlag div add off k 4 L freezeCollar 391 end 392 if not flushStage get dFlags 0 mul off 4 cnt 393 ret false 394 end 395 off = add off cnt 396 end 397 ret true 398 end 399 400 fn seedGpuRng N ulong seed ulong to bool 401 uRngSeed seed 402 off = ulong 0 403 while lt off N bound 16 404 cnt = sub N off 405 if gt cnt 16384 406 cnt = ulong 16384 407 end 408 for k ulong cnt bound 16384 409 r = uint and uRngNext 0xffffffff 410 if eq r 0 411 r = uint 0x9e3779b9 412 end 413 stageU32 k r 414 end 415 if not flushStage get dRng 0 mul off 4 cnt 416 ret false 417 end 418 off = add off cnt 419 end 420 ret true 421 end 422 423 fn qNormHost base ulong to void 424 a0 = get hL0 base 425 a1 = get hL0 add base 1 426 a2 = get hL0 add base 2 427 a3 = get hL0 add base 3 428 n2 = add add mul a0 a0 mul a1 a1 add mul a2 a2 mul a3 a3 429 if le n2 0.`0000000001f32` 430 put hL0 base 1.0f32 431 put hL0 add base 1 0.0f32 432 put hL0 add base 2 0.0f32 433 put hL0 add base 3 0.0f32 434 ret 435 end 436 inv = f32 div 1.0f64 uSqrt64 f64 n2 437 put hL0 base mul a0 inv 438 put hL0 add base 1 mul a1 inv 439 put hL0 add base 2 mul a2 inv 440 put hL0 add base 3 mul a3 inv 441 end 442 443 fn setCollarLink s ulong mu ulong L ulong cid ulong to void 444 base = mul add mul s 4 mu 4 445 put hL0 base 1.0f32 446 put hL0 add base 1 0.0f32 447 put hL0 add base 2 0.0f32 448 put hL0 add base 3 0.0f32 449 if eq cid 0 450 ret 451 end 452 if eq cid 3 453 put hL0 base f32 uRngNorm64 454 put hL0 add base 1 f32 uRngNorm64 455 put hL0 add base 2 f32 uRngNorm64 456 put hL0 add base 3 f32 uRngNorm64 457 qNormHost base 458 ret 459 end 460 if eq cid 8 461 if eq mu 0 462 put hL0 base 0.0f32 463 put hL0 add base 1 1.0f32 464 end 465 if eq mu 1 466 put hL0 base 0.0f32 467 put hL0 add base 2 1.0f32 468 end 469 if eq mu 2 470 put hL0 base 0.0f32 471 put hL0 add base 3 1.0f32 472 end 473 if eq mu 3 474 put hL0 base 0.5f32 475 put hL0 add base 1 0.5f32 476 put hL0 add base 2 0.5f32 477 put hL0 add base 3 0.5f32 478 end 479 end 480 end 481 482 fn initLatticeHost L ulong cid ulong freezeCollar bool seed ulong to void 483 N = mul mul L L mul L L 484 uRngSeed seed 485 for s ulong N bound 65536 486 isB = and freezeCollar isBdryL s L 487 for mu ulong 4 488 if isB 489 setCollarLink s mu L cid 490 else 491 base = mul add mul s 4 mu 4 492 put hL0 base 0.85f32 493 put hL0 add base 1 mul 0.25f32 f32 uRngNorm64 494 put hL0 add base 2 mul 0.25f32 f32 uRngNorm64 495 put hL0 add base 3 mul 0.25f32 f32 uRngNorm64 496 qNormHost base 497 end 498 end 499 end 500 end 501 502 fn initLattice L ulong cid ulong freezeCollar bool seed ulong to bool 503 N = mul mul L L mul L L 504 initLatticeHost L cid freezeCollar seed 505 ret uploadLinks N 506 end 507 508 fn gpuRunStaple N ulong mu ulong par ulong to bool 509 gx = uint div add N 255 256 510 nu0 = ulong 0 511 nu1 = ulong 1 512 nu2 = ulong 2 513 if eq mu 0 514 nu0 = ulong 1 515 nu1 = ulong 2 516 nu2 = ulong 3 517 end 518 if eq mu 1 519 nu0 = ulong 0 520 nu1 = ulong 2 521 nu2 = ulong 3 522 end 523 if eq mu 2 524 nu0 = ulong 0 525 nu1 = ulong 1 526 nu2 = ulong 3 527 end 528 uPtr mapaddr get dLinks 0 529 uPtr mapaddr get dStaples 0 530 uPtr mapaddr get dFlags 0 531 uPtr mapaddr get dNbSite 0 532 uArg uint N 533 uArg uint mu 534 uArg uint par 535 uArg uint nu0 536 uArg uint nu1 537 uArg uint nu2 538 ret uRunKernel 0 gx 256 539 end 540 541 fn gpuRunOverrelax N ulong mu ulong par ulong to bool 542 gx = uint div add N 255 256 543 uPtr mapaddr get dLinks 0 544 uPtr mapaddr get dStaples 0 545 uPtr mapaddr get dFlags 0 546 uArg uint N 547 uArg uint mu 548 uArg uint par 549 ret uRunKernel 1 gx 256 550 end 551 552 fn gpuRunHeatbath N ulong mu ulong par ulong beta f32 to bool 553 gx = uint div add N 255 256 554 uPtr mapaddr get dLinks 0 555 uPtr mapaddr get dStaples 0 556 uPtr mapaddr get dFlags 0 557 uPtr mapaddr get dRng 0 558 uArg uint N 559 uArg uint mu 560 uArg uint par 561 uArg bitcast uint beta 562 ret uRunKernel 2 gx 256 563 end 564 565 fn gpuSweep N ulong beta f32 nOr ulong to bool 566 for mu ulong 4 567 for par ulong 2 568 if not gpuRunStaple N mu par 569 ret false 570 end 571 if not gpuRunHeatbath N mu par beta 572 ret false 573 end 574 for r ulong nOr bound 8 575 if not gpuRunStaple N mu par 576 ret false 577 end 578 if not gpuRunOverrelax N mu par 579 ret false 580 end 581 end 582 end 583 end 584 ret true 585 end 586 587 note ========================================================================= 588 note Quaternion Helpers + Gauge-Covariant Swendsen 2x Block-Spin RG (lvl 0->1->2) 589 note lvl: 0=hL0 (16^4), 1=hL1 (8^4), 2=hL2 (4^4) 590 note ========================================================================= 591 fn hQMul a view f32 4 b view f32 4 o edit f32 4 to void 592 v = mul get a 0 get b 0 593 v = sub v mul get a 1 get b 1 594 v = sub v mul get a 2 get b 2 595 v = sub v mul get a 3 get b 3 596 put o 0 v 597 v = mul get a 0 get b 1 598 v = add v mul get a 1 get b 0 599 v = add v mul get a 2 get b 3 600 v = sub v mul get a 3 get b 2 601 put o 1 v 602 v = mul get a 0 get b 2 603 v = sub v mul get a 1 get b 3 604 v = add v mul get a 2 get b 0 605 v = add v mul get a 3 get b 1 606 put o 2 v 607 v = mul get a 0 get b 3 608 v = add v mul get a 1 get b 2 609 v = sub v mul get a 2 get b 1 610 v = add v mul get a 3 get b 0 611 put o 3 v 612 end 613 614 fn hQConj q edit f32 4 to void 615 put q 1 neg get q 1 616 put q 2 neg get q 2 617 put q 3 neg get q 3 618 end 619 620 fn hQNorm q edit f32 4 to void 621 n2 = mul get q 0 get q 0 622 n2 = add n2 mul get q 1 get q 1 623 n2 = add n2 mul get q 2 get q 2 624 n2 = add n2 mul get q 3 get q 3 625 if le n2 0.`0000000001f32` 626 put q 0 1.0f32 627 put q 1 0.0f32 628 put q 2 0.0f32 629 put q 3 0.0f32 630 ret 631 end 632 inv = f32 div 1.0f64 uSqrt64 f64 n2 633 for c ulong 4 634 put q c mul get q c inv 635 end 636 end 637 638 fn loadLvl lvl ulong s ulong mu ulong dst edit f32 4 to void 639 b = mul add mul s 4 mu 4 640 if eq lvl 0 641 put dst 0 get hL0 b 642 put dst 1 get hL0 add b 1 643 put dst 2 get hL0 add b 2 644 put dst 3 get hL0 add b 3 645 ret 646 end 647 if eq lvl 1 648 put dst 0 get hL1 b 649 put dst 1 get hL1 add b 1 650 put dst 2 get hL1 add b 2 651 put dst 3 get hL1 add b 3 652 ret 653 end 654 put dst 0 get hL2 b 655 put dst 1 get hL2 add b 1 656 put dst 2 get hL2 add b 2 657 put dst 3 get hL2 add b 3 658 end 659 660 fn storeLvl lvl ulong s ulong mu ulong src view f32 4 to void 661 b = mul add mul s 4 mu 4 662 if eq lvl 0 663 put hL0 b get src 0 664 put hL0 add b 1 get src 1 665 put hL0 add b 2 get src 2 666 put hL0 add b 3 get src 3 667 ret 668 end 669 if eq lvl 1 670 put hL1 b get src 0 671 put hL1 add b 1 get src 1 672 put hL1 add b 2 get src 2 673 put hL1 add b 3 get src 3 674 ret 675 end 676 put hL2 b get src 0 677 put hL2 add b 1 get src 1 678 put hL2 add b 2 get src 2 679 put hL2 add b 3 get src 3 680 end 681 682 note Swendsen 2x1 blocked staple from fine site x to x+2*mu via +-nu (reads rgSrcLvl, rgLf) 683 fn addBlockStaple x ulong mu ulong nu ulong isBack bool dst edit f32 4 to void 684 lvl = get rgSrcLvl 0 685 Lf = get rgLf 0 686 a = new f32 4 0.0f32 687 b = new f32 4 0.0f32 688 p = new f32 4 0.0f32 689 q = new f32 4 0.0f32 690 x2m = stepCoord stepCoord x Lf mu 1 Lf mu 1 691 if not isBack 692 xn = stepCoord x Lf nu 1 693 loadLvl lvl x nu a 694 loadLvl lvl xn mu b 695 hQMul a b p 696 loadLvl lvl stepCoord xn Lf mu 1 mu a 697 hQMul p a q 698 loadLvl lvl x2m nu a 699 hQConj a 700 hQMul q a p 701 else 702 xm = stepCoord x Lf nu sub Lf 1 703 loadLvl lvl xm nu a 704 hQConj a 705 loadLvl lvl xm mu b 706 hQMul a b p 707 loadLvl lvl stepCoord xm Lf mu 1 mu a 708 hQMul p a q 709 loadLvl lvl stepCoord x2m Lf nu sub Lf 1 nu a 710 hQMul q a p 711 end 712 for c ulong 4 713 put dst c add get dst c get p c 714 end 715 end 716 717 fn coarseToFine X ulong Lf ulong to ulong 718 Lc = div Lf 2 719 c3 = rem X Lc 720 t = div X Lc 721 c2 = rem t Lc 722 t = div t Lc 723 c1 = rem t Lc 724 c0 = div t Lc 725 ret coordIdx mul c0 2 mul c1 2 mul c2 2 mul c3 2 Lf 726 end 727 728 note Compute ONE Swendsen gauge-covariant 2x blocked link at coarse site X (fine origin x = 2X) 729 fn blockLinkOne X ulong mu ulong to void 730 srcLvl = get rgSrcLvl 0 731 Lf = get rgLf 0 732 x = coarseToFine X Lf 733 u1 = new f32 4 0.0f32 734 u2 = new f32 4 0.0f32 735 w0 = new f32 4 0.0f32 736 st = new f32 4 0.0f32 737 loadLvl srcLvl x mu u1 738 loadLvl srcLvl stepCoord x Lf mu 1 mu u2 739 hQMul u1 u2 w0 740 for nu ulong 4 741 if ne nu mu 742 addBlockStaple x mu nu false st 743 addBlockStaple x mu nu true st 744 end 745 end 746 wS = div 0.5f32 6.0f32 747 for c ulong 4 748 put w0 c add mul 0.5f32 get w0 c mul wS get st c 749 end 750 hQNorm w0 751 storeLvl get rgDstLvl 0 X mu w0 752 end 753 754 note Block sites in coarse box [cLo, cHi)^4 from srcLvl (size Lf) into dstLvl (size Lf/2) 755 fn blockBox srcLvl ulong dstLvl ulong Lf ulong cLo ulong cHi ulong to void 756 put rgSrcLvl 0 srcLvl 757 put rgDstLvl 0 dstLvl 758 put rgLf 0 Lf 759 Lc = div Lf 2 760 Nc = mul mul Lc Lc mul Lc Lc 761 for X ulong Nc bound 4096 762 if isBox4 X Lc cLo cHi 763 for mu ulong 4 764 blockLinkOne X mu 765 end 766 end 767 end 768 end 769 770 fn plaqLvl lvl ulong L ulong s ulong mu ulong nu ulong to f64 771 a = new f32 4 0.0f32 772 b = new f32 4 0.0f32 773 p = new f32 4 0.0f32 774 q = new f32 4 0.0f32 775 loadLvl lvl s mu a 776 loadLvl lvl stepCoord s L mu 1 nu b 777 hQMul a b p 778 loadLvl lvl stepCoord s L nu 1 mu a 779 hQConj a 780 hQMul p a q 781 loadLvl lvl s nu b 782 hQConj b 783 hQMul q b p 784 ret f64 get p 0 785 end 786 787 fn accumPlaqSite lvl ulong L ulong s ulong to void 788 for mu ulong 4 789 for nu ulong 4 790 if lt mu nu 791 vp = plaqLvl lvl L s mu nu 792 put mcAcc 4 add get mcAcc 4 vp 793 put mcAcc 5 add get mcAcc 5 sub mul 4.0f64 mul vp vp 1.0f64 794 put mcCnt 0 add get mcCnt 0 1 795 end 796 end 797 end 798 end 799 800 fn evalPlaqBox lvl ulong L ulong lo ulong hi ulong accIdx ulong to f64 801 N = mul mul L L mul L L 802 put mcAcc 4 0.0f64 803 put mcAcc 5 0.0f64 804 put mcCnt 0 0 805 for s ulong N bound 65536 806 if isBox4 s L lo hi 807 accumPlaqSite lvl L s 808 end 809 end 810 fc = f64 get mcCnt 0 811 put mcAcc accIdx div get mcAcc 5 fc 812 ret div get mcAcc 4 fc 813 end 814 815 note Full 3-scale evaluation on 16^4 (strictly zero contact with frozen shell {0, 15}!): 816 note RG-1 (L1=8): block box [1, 7)^4 -> fine sites read in [1, 14] (ZERO 0, ZERO 15!) 817 note RG-2 (L2=4): block box [1, 3)^4 -> L1 sites read in [1, 6] (subset of [1, 7)^4!) 818 note O0 = P^(0) on 16^4 core [6, 10)^4 819 note O1 = P^(1) on 8^4 core [3, 5)^4, O3 = Adj^(1) 820 note O2 = P^(2) on 4^4 center [1, 2)^4, O4 = Adj^(2) 821 fn evalMultiScale res edit f64 5 to void 822 blockBox 0 1 16 1 7 823 blockBox 1 2 8 1 3 824 p0 = evalPlaqBox 0 16 6 10 0 825 p1 = evalPlaqBox 1 8 3 5 1 826 p2 = evalPlaqBox 2 4 1 2 2 827 put res 0 p0 828 put res 1 p1 829 put res 2 p2 830 put res 3 get mcAcc 1 831 put res 4 get mcAcc 2 832 end 833 834 note ========================================================================= 835 note Runtime Self-Checks: 836 note 1. RG_GAUGE_COV_ASSERT: random local SU(2) gauge transform on 16^4 -> 0 error at k=0,1,2! 837 note 2. ZERO_CONTACT_ASSERT: swap frozen shell {0,15} C0->C3 -> 0.000000 error at k=0,1,2! 838 note ========================================================================= 839 fn applyGauge16Link s ulong mu ulong g view f32 4 to void 840 u = new f32 4 0.0f32 841 g2 = new f32 4 0.0f32 842 t1 = new f32 4 0.0f32 843 t2 = new f32 4 0.0f32 844 loadLvl 0 s mu u 845 xp = stepCoord s 16 mu 1 846 b2 = mul xp 4 847 for c ulong 4 848 put g2 c get hGauge add b2 c 849 end 850 hQConj g2 851 hQMul g u t1 852 hQMul t1 g2 t2 853 hQNorm t2 854 storeLvl 0 s mu t2 855 end 856 857 fn applyRandomGauge16 to void 858 g = new f32 4 0.0f32 859 uRngSeed 0x44449999 860 for s ulong 65536 861 put g 0 f32 uRngNorm64 862 put g 1 f32 uRngNorm64 863 put g 2 f32 uRngNorm64 864 put g 3 f32 uRngNorm64 865 hQNorm g 866 b = mul s 4 867 for c ulong 4 868 put hGauge add b c get g c 869 end 870 end 871 for s ulong 65536 872 b = mul s 4 873 for c ulong 4 874 put g c get hGauge add b c 875 end 876 for mu ulong 4 877 applyGauge16Link s mu g 878 end 879 end 880 end 881 882 fn assertRgGaugeCov to void 883 initLatticeHost 16 3 true 0x88881111 884 v0 = new f64 5 0.0f64 885 v1 = new f64 5 0.0f64 886 evalMultiScale v0 887 applyRandomGauge16 888 evalMultiScale v1 889 maxE = f64 0.0f64 890 for o ulong 5 891 e = uAbs64 sub get v1 o get v0 o 892 if gt e maxE 893 maxE = e 894 end 895 end 896 if gt maxE 0.`0001f64` 897 uPrint tC8GcFail 898 uPrintF64 maxE 899 uPrint tNl 900 exit 98 901 end 902 uPrint tC8GcOk 903 uPrintF64 maxE 904 uPrint tC8Pass 905 end 906 907 fn assertZeroContact8 to void 908 initLatticeHost 16 0 true 0x77772222 909 v0 = new f64 5 0.0f64 910 v1 = new f64 5 0.0f64 911 evalMultiScale v0 912 uRngSeed 0x99993333 913 for s ulong 65536 914 if isBdryL s 16 915 for mu ulong 4 916 setCollarLink s mu 16 3 917 end 918 end 919 end 920 evalMultiScale v1 921 maxE = f64 0.0f64 922 for o ulong 5 923 e = uAbs64 sub get v1 o get v0 o 924 if gt e maxE 925 maxE = e 926 end 927 end 928 if gt maxE 0.`000000000001f64` 929 uPrint tC8ZcFail 930 uPrintF64 maxE 931 uPrint tNl 932 exit 99 933 end 934 uPrint tC8ZcOk 935 uPrintF64 maxE 936 uPrint tC8Pass 937 end 938 939 note ========================================================================= 940 note In-Situ Periodic 8^4 Bulk Calibration + Piecewise-Linear Inverse beta_eff(P) 941 note ========================================================================= 942 fn runCalPoint idx ulong beta f32 to void 943 N = ulong 4096 944 if not seedGpuRng N add 0xc0100001 mul idx 7919 945 exit 21 946 end 947 if not initLattice 8 0 false add 0xc0100001 mul idx 104729 948 exit 22 949 end 950 for sw ulong 48 951 if not gpuSweep N beta 3 952 exit 23 953 end 954 end 955 acc = f64 0.0f64 956 for k ulong 32 957 if not gpuSweep N beta 2 958 exit 24 959 end 960 downloadBox 8 0 8 961 acc = add acc evalPlaqBox 0 8 0 8 0 962 end 963 pMean = div acc 32.0f64 964 put calBeta idx f64 beta 965 put calPlaq idx pMean 966 uPrintF64 f64 beta 967 uPrint tTab 968 uPrintF64 pMean 969 uPrint tNl 970 end 971 972 fn invertBetaEff p f64 to f64 973 if le p get calPlaq 0 974 ret mul get calBeta 0 div p get calPlaq 0 975 end 976 for i ulong 9 977 p0 = get calPlaq i 978 p1 = get calPlaq add i 1 979 if le p p1 980 b0 = get calBeta i 981 b1 = get calBeta add i 1 982 dp = sub p1 p0 983 if le dp 0.`000001f64` 984 ret b0 985 end 986 ret add b0 mul sub b1 b0 div sub p p0 dp 987 end 988 end 989 ret get calBeta 9 990 end 991 992 note ========================================================================= 993 note Statistics (16-Block Jackknife over 256 Measurements + Bulk Sigma) 994 note ========================================================================= 995 fn storeMeas8 k ulong to void 996 downloadBox 16 1 15 997 v = new f64 5 0.0f64 998 evalMultiScale v 999 b = mul k 5 1000 for o ulong 5 1001 put tsData add b o get v o 1002 end 1003 end 1004 1005 fn sumBlk8 o ulong st ulong blkSz ulong to f64 1006 s = f64 0.0f64 1007 for j ulong blkSz bound 32 1008 s = add s get tsData add mul add st j 5 o 1009 end 1010 ret s 1011 end 1012 1013 fn summarizeOne8 o ulong nMeas ulong to void 1014 blkSz = div nMeas 16 1015 tot = f64 0.0f64 1016 for k ulong nMeas bound 256 1017 tot = add tot get tsData add mul k 5 o 1018 end 1019 mean = div tot f64 nMeas 1020 put curMean o mean 1021 vSum = f64 0.0f64 1022 for k ulong nMeas bound 256 1023 dv = sub get tsData add mul k 5 o mean 1024 vSum = add vSum mul dv dv 1025 end 1026 put curSig o uSqrt64 div vSum f64 sub nMeas 1 1027 jkSum = f64 0.0f64 1028 for b ulong 16 1029 bs = sumBlk8 o mul b blkSz blkSz 1030 d = sub div sub tot bs f64 sub nMeas blkSz mean 1031 jkSum = add jkSum mul d d 1032 end 1033 put curErr o uSqrt64 mul 0.`9375f64` jkSum 1034 end 1035 1036 fn summarizeTs8 nMeas ulong to void 1037 for o ulong 5 1038 summarizeOne8 o nMeas 1039 end 1040 end 1041 1042 fn computeDiffZR8 cid ulong to void 1043 if eq cid 0 1044 for o ulong 5 1045 put baseMean o get curMean o 1046 put baseErr o get curErr o 1047 put baseSig o get curSig o 1048 put curDelta o 0.0f64 1049 put curZ o 0.0f64 1050 put curRBulk o 0.0f64 1051 end 1052 ret 1053 end 1054 for o ulong 5 1055 diff = uAbs64 sub get curMean o get baseMean o 1056 se = uSqrt64 add mul get curErr o get curErr o mul get baseErr o get baseErr o 1057 z = f64 0.0f64 1058 if gt se 0.`0000001f64` 1059 z = div diff se 1060 end 1061 rBulk = f64 0.0f64 1062 sb = get baseSig o 1063 if gt sb 0.`0000001f64` 1064 rBulk = div diff sb 1065 end 1066 put curDelta o diff 1067 put curZ o z 1068 put curRBulk o rBulk 1069 end 1070 end 1071 1072 fn printRow8 cid ulong nMeas ulong us ulong to void 1073 uPrintF64 f64 get armBeta 0 1074 uPrint tTab 1075 if eq cid 0 1076 uPrint tK0 1077 end 1078 if eq cid 3 1079 uPrint tK3 1080 end 1081 if eq cid 8 1082 uPrint tK8 1083 end 1084 uPrint tTab 1085 uPrintU nMeas 1086 uPrint tTab 1087 uPrintF64 get curMean 0 1088 uPrint tTab 1089 uPrintF64 get curMean 1 1090 uPrint tTab 1091 uPrintF64 get curMean 2 1092 uPrint tTab 1093 uPrintF64 invertBetaEff get curMean 0 1094 uPrint tTab 1095 uPrintF64 invertBetaEff get curMean 1 1096 uPrint tTab 1097 uPrintF64 invertBetaEff get curMean 2 1098 for o ulong 5 1099 uPrint tTab 1100 uPrintF64 get curRBulk o 1101 uPrint tTab 1102 uPrintF64 get curZ o 1103 end 1104 uPrint tTab 1105 uPrintU us 1106 uPrint tNl 1107 end 1108 1109 fn runArm8 beta f32 cid ulong nTherm ulong nMeas ulong to void 1110 t0 = monons 1111 put armBeta 0 beta 1112 seed = get armSeed 0 1113 N = ulong 65536 1114 if not seedGpuRng N add seed mul cid 7919 1115 exit 31 1116 end 1117 if not initLattice 16 cid true add seed mul cid 104729 1118 exit 32 1119 end 1120 for sw ulong nTherm bound 128 1121 if not gpuSweep N beta 3 1122 exit 33 1123 end 1124 end 1125 for k ulong nMeas bound 256 1126 if not gpuSweep N beta 2 1127 exit 34 1128 end 1129 if not gpuSweep N beta 2 1130 exit 35 1131 end 1132 storeMeas8 k 1133 end 1134 summarizeTs8 nMeas 1135 computeDiffZR8 cid 1136 us = div ulong sub monons t0 1000 1137 printRow8 cid nMeas us 1138 end 1139 1140 fn runBeta8 beta f32 seed ulong to void 1141 put armSeed 0 seed 1142 runArm8 beta 0 64 256 1143 runArm8 beta 3 64 256 1144 runArm8 beta 8 64 256 1145 end 1146 1147 fn allocBuf bytes ulong cached bool to long 1148 m = nvalloc bytes cached 1149 if le m 0 1150 uPrint tC8Err 1151 uPrintU ulong get nvstage 0 1152 uPrint tNl 1153 exit 6 1154 end 1155 ret m 1156 end 1157 1158 fn main to int 1159 uPrint tC8Hdr 1160 if not gbopen 1 1161 uPrint tC8Err 1162 uPrintU ulong get nvstage 0 1163 uPrint tNl 1164 ret 2 1165 end 1166 if not gbbopen 1167 ret 3 1168 end 1169 put uCodeMap 0 0 1170 uEmitAllKernels 1171 csize = mul div add get uCodePos 0 4095 4096 4096 1172 cm = nvalloc csize false 1173 if le cm 0 1174 ret 4 1175 end 1176 put uCodeMap 0 cm 1177 put uCodeFail 0 0 1178 uEmitAllKernels 1179 if ne get uCodeFail 0 0 1180 ret 5 1181 end 1182 1183 put dLinks 0 allocBuf `4194304` true 1184 put dStaples 0 allocBuf `4194304` true 1185 put dFlags 0 allocBuf `1048576` true 1186 put dNbSite 0 allocBuf `2097152` true 1187 put dRng 0 allocBuf 262144 true 1188 1189 note Self-checks on 16^4 host RG blocking before touching GPU MC 1190 assertRgGaugeCov 1191 assertZeroContact8 1192 1193 note Step 1: In-situ 10-point periodic 8^4 SU(2) calibration curve 1194 uPrint tC8CalHdr 1195 uPrint tC8CalCols 1196 if not buildNbTable 8 1197 rc = nvmclose 1198 ret 10 1199 end 1200 if not buildFlags 8 false 1201 rc = nvmclose 1202 ret 11 1203 end 1204 runCalPoint 0 0.25f32 1205 runCalPoint 1 0.50f32 1206 runCalPoint 2 1.00f32 1207 runCalPoint 3 1.50f32 1208 runCalPoint 4 2.00f32 1209 runCalPoint 5 2.30f32 1210 runCalPoint 6 2.50f32 1211 runCalPoint 7 3.00f32 1212 runCalPoint 8 4.00f32 1213 runCalPoint 9 6.00f32 1214 1215 note Step 2: Frozen-collar 16^4 Multi-Scale RG Flow (16^4 -> 8^4 -> 4^4) 1216 uPrint tC8RgHdr 1217 uPrint tC8Cols 1218 if not buildNbTable 16 1219 rc = nvmclose 1220 ret 12 1221 end 1222 if not buildFlags 16 true 1223 rc = nvmclose 1224 ret 13 1225 end 1226 runBeta8 1.50f32 0x80010001 1227 runBeta8 2.00f32 0x80020001 1228 runBeta8 2.30f32 0x80030001 1229 runBeta8 2.50f32 0x80040001 1230 runBeta8 2.70f32 0x80050001 1231 runBeta8 6.00f32 0x80060001 1232 1233 uPrint tC8Done 1234 rc = nvmclose 1235 ret 0 1236 end