interplane.Get Omega
Read in your language

yang

This project has not described itself yet.

Brought by drakestapleton

branch main Branches Tags History

yang / src / ufbi_check10_gb10.om

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