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_obs_synth_w3.om

1136 lines · 22733 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note src/ufbi_obs_synth_w3.om: Pure Seeded-OM-2 Wave-3 Pole-Free CentralObs Synthesizer
3note (4D SU(2), L=6, 16-Snapshot Ensemble across beta=2.30 & beta=2.50, cold vs twist).
4note
5note Upgrades over Wave-2 (src/ufbi_obs_synth_w2.om):
6note 1. 16-lane per-snapshot evaluation (4 independent snapshots x 4 arms:
7note cold_b230, twist_b230, cold_b250, twist_b250) capturing strong-coupling
8note per-configuration fluctuations where chi1(ADJ_PLAQ_S0) crosses zero.
9note 2. INV-4 Pole-Free Denominator Guard: rejects any ratio(A, B) unless denominator B
10note is strictly sign-definite across ALL 16 snapshots with margin tau=0.15
11note (either min_i B_i > 0.15 or max_i B_i < -0.15) AND condition ratio <= 4.0.
12note Explicitly tracks inv4_pole_killed (killing chi1(ADJ_PLAQ_S0) denominators!).
13note 3. Dimensionless bulk-fluctuation normalization: computes within-arm bulk std sigma_bulk
14note and reports dimensionless collar leakage delta_twist / sigma_bulk alongside uv_score.
15note 4. Retains INV-1 (BFS barriers), INV-2 (65536-slot table, MAX_PROBES=32, 70% cap),
16note INV-3 (bounded output), Physics Operator Prior (ratio > sub > mul > add),
17note Wake-Sleep Depth-2 mining, and exact local SU(2) gauge-invariance gate (<= 1e-4).
18note
19note Composed after: src/ufbi_math.om
20
21const W3_SLOT_F ulong 20736
22const W3_HT_SZ ulong 65536
23const W3_HT_MASK ulong 65535
24const W3_HT_MAX_OCC ulong 45875
25const W3_MAX_PROBES ulong 32
26const W3_MAX_NODES ulong 16384
27const W3_LANES ulong 16
28
29global osBuf f32 103680
30global osG f32 5184
31note 2 (orig/gauge) x 15 prims x 16 lanes = 480 f64
32global osPrim f64 480
33global osAcc f64 16
34
35note AST node pool (up to 16,384 distinct pole-free gauge-invariant CentralObs ASTs)
36note op: 0=PRIM, 1=CHI1, 2=SQ, 3=SUB, 4=ADD, 5=MUL, 6=RATIO
37global osOp uchar 16384
38global osL ulong 16384
39global osR ulong 16384
40global osDep uchar 16384
41note 16384 nodes x 16 lanes = 262144 f64 each
42global osVec f64 262144
43global osGVec f64 262144
44note Per-node min/max across all 16 snapshots for O(1) INV-4 pole-free check
45global osMinV f64 16384
46global osMaxV f64 16384
47
48global osCandV f64 16
49global osCandG f64 16
50global osHtH ulong 65536
51global osHtN ulong 65536
52note osSt: 0=nodes, 1=ht_occ, 2=gauge_killed, 3=equiv_pruned, 4=inv4_pole_killed, 5=max_probes, 6=inv3_oob
53global osSt ulong 16
54global osLvlS ulong 8
55global osLvlE ulong 8
56global osOpOrder ulong 4
57global osTopIds ulong 32
58global osTopScores f64 32
59
60text tW3Hdr "=== UFBI CENTRALOBS SYNTHESIZER WAVE-3: INV-4 POLE-FREE + BULK-SIGMA NORMALIZED (PURE OM-2) ===\n"
61text tW3Prior "PHYSICS_PRIOR_OP_ORDER: "
62text tW3Stat "OBS_SYNTH_W3_STATS nodes="
63text tW3GRej " gauge_killed="
64text tW3EPrun " equiv_pruned="
65text tW3Pole " inv4_pole_killed="
66text tW3Occ " ht_occ="
67text tW3MPr " max_probes="
68text tW3Wave1 " wave1_nodes="
69text tW3Wave2 " wave2_nodes="
70text tW3Col "rank\tid\tdepth\texpr\tgauge_err\tmin_val\tmax_val\tcold_b23\ttwist_b23\tcold_b25\ttwist_b25\tsig_bulk\tdTw_over_sig\tuv_score\n"
71text tW3Tab "\t"
72text tW3Sp " "
73text tW3Nl "\n"
74text tW3Pass "OBS_SYNTH_W3_DONE status=PASS gauge_controls_killed=2/2 inv4_pole_guard_active=1\n"
75
76text tP0 "RAW_LINK_0"
77text tP1 "RAW_LINK_SUM"
78text tP2 "PLAQ1x1_S0"
79text tP3 "PLAQ1x1_S1"
80text tP4 "PLAQ1x1_S2"
81text tP5 "PLAQ1x1_S4"
82text tP6 "RECT1x2_S0"
83text tP7 "RECT1x2_S2"
84text tP8 "RECT2x2_S2"
85text tP9 "CHAIR6_S2"
86text tP10 "ADJ_PLAQ_S0"
87text tP11 "ADJ_PLAQ_S2"
88text tP12 "ADJ_RECT_S2"
89text tP13 "CLOVER_S2"
90text tP14 "PLAQ1x1_S0_T"
91
92text tOpChi "chi1("
93text tOpSq "sq("
94text tOpSub "sub("
95text tOpAdd "add("
96text tOpMul "mul("
97text tOpDiv "ratio("
98text tComma ","
99text tRp ")"
100text tNSub "sub"
101text tNAdd "add"
102text tNMul "mul"
103text tNDiv "ratio"
104
105fn qOff slot ulong site ulong mu ulong to ulong
106ret add mul slot W3_SLOT_F mul add mul site 4 mu 4
107end
108
109fn qLoad slot ulong site ulong mu ulong dst edit f32 4 to void
110b = qOff slot site mu
111put dst 0 get osBuf b
112put dst 1 get osBuf add b 1
113put dst 2 get osBuf add b 2
114put dst 3 get osBuf add b 3
115end
116
117fn qStore slot ulong site ulong mu ulong src view f32 4 to void
118b = qOff slot site mu
119put osBuf b get src 0
120put osBuf add b 1 get src 1
121put osBuf add b 2 get src 2
122put osBuf add b 3 get src 3
123end
124
125fn qConj q edit f32 4 to void
126put q 1 neg get q 1
127put q 2 neg get q 2
128put q 3 neg get q 3
129end
130
131fn qMul a view f32 4 b view f32 4 o edit f32 4 to void
132v = mul get a 0 get b 0
133v = sub v mul get a 1 get b 1
134v = sub v mul get a 2 get b 2
135v = sub v mul get a 3 get b 3
136put o 0 v
137v = mul get a 0 get b 1
138v = add v mul get a 1 get b 0
139v = add v mul get a 2 get b 3
140v = sub v mul get a 3 get b 2
141put o 1 v
142v = mul get a 0 get b 2
143v = sub v mul get a 1 get b 3
144v = add v mul get a 2 get b 0
145v = add v mul get a 3 get b 1
146put o 2 v
147v = mul get a 0 get b 3
148v = add v mul get a 1 get b 2
149v = sub v mul get a 2 get b 1
150v = add v mul get a 3 get b 0
151put o 3 v
152end
153
154fn qDot4 a view f32 4 b view f32 4 to f32
155d = mul get a 0 get b 0
156d = add d mul get a 1 get b 1
157d = add d mul get a 2 get b 2
158ret add d mul get a 3 get b 3
159end
160
161fn qNorm q edit f32 4 to void
162n2 = mul get q 0 get q 0
163n2 = add n2 mul get q 1 get q 1
164n2 = add n2 mul get q 2 get q 2
165n2 = add n2 mul get q 3 get q 3
166if le n2 0.0000000001f32
167put q 0 1.0f32
168put q 1 0.0f32
169put q 2 0.0f32
170put q 3 0.0f32
171ret
172end
173inv = f32 div 1.0f64 uSqrt64 f64 n2
174for c ulong 4
175put q c mul get q c inv
176end
177end
178
179fn qRand dst edit f32 4 to void
180put dst 0 f32 uRngNorm64
181put dst 1 f32 uRngNorm64
182put dst 2 f32 uRngNorm64
183put dst 3 f32 uRngNorm64
184qNorm dst
185end
186
187fn nb6 site ulong dir ulong delta ulong to ulong
188c3 = rem site 6
189c2 = rem div site 6 6
190c1 = rem div site 36 6
191c0 = div site 216
192if eq dir 0
193c0 = rem add c0 delta 6
194end
195if eq dir 1
196c1 = rem add c1 delta 6
197end
198if eq dir 2
199c2 = rem add c2 delta 6
200end
201if eq dir 3
202c3 = rem add c3 delta 6
203end
204r = add mul c0 6 c1
205r = add mul r 6 c2
206ret add mul r 6 c3
207end
208
209fn isBdry6 site ulong to bool
210c3 = rem site 6
211c2 = rem div site 6 6
212c1 = rem div site 36 6
213c0 = div site 216
214if or eq c0 0 eq c0 5
215ret true
216end
217if or eq c1 0 eq c1 5
218ret true
219end
220if or eq c2 0 eq c2 5
221ret true
222end
223if or eq c3 0 eq c3 5
224ret true
225end
226ret false
227end
228
229fn isInt6 site ulong to bool
230c3 = rem site 6
231c2 = rem div site 6 6
232c1 = rem div site 36 6
233c0 = div site 216
234if or lt c0 2 gt c0 3
235ret false
236end
237if or lt c1 2 gt c1 3
238ret false
239end
240if or lt c2 2 gt c2 3
241ret false
242end
243if or lt c3 2 gt c3 3
244ret false
245end
246ret true
247end
248
249fn stapleAddOne slot ulong site ulong mu ulong nu ulong isBack bool dst edit f32 4 to void
250t1 = new f32 4 0.0f32
251t2 = new f32 4 0.0f32
252t3 = new f32 4 0.0f32
253p1 = new f32 4 0.0f32
254p2 = new f32 4 0.0f32
255xp = nb6 site mu 1
256if not isBack
257qLoad slot site nu t1
258qLoad slot nb6 site nu 1 mu t2
259qLoad slot xp nu t3
260qConj t3
261else
262xm = nb6 site nu 5
263qLoad slot xm nu t1
264qConj t1
265qLoad slot xm mu t2
266qLoad slot nb6 xp nu 5 nu t3
267end
268qMul t1 t2 p1
269qMul p1 t3 p2
270for c ulong 4
271put dst c add get dst c get p2 c
272end
273end
274
275fn stapleSum6 slot ulong site ulong mu ulong dst edit f32 4 to void
276for c ulong 4
277put dst c 0.0f32
278end
279for nu ulong 4
280if ne nu mu
281stapleAddOne slot site mu nu false dst
282stapleAddOne slot site mu nu true dst
283end
284end
285end
286
287fn apeSmear6 srcSlot ulong dstSlot ulong alpha f32 to void
288st = new f32 4 0.0f32
289u = new f32 4 0.0f32
290w0 = sub 1.0f32 alpha
291w1 = div alpha 6.0f32
292for site ulong 1296
293for mu ulong 4
294stapleSum6 srcSlot site mu st
295qLoad srcSlot site mu u
296for c ulong 4
297put u c add mul w0 get u c mul w1 get st c
298end
299qNorm u
300qStore dstSlot site mu u
301end
302end
303end
304
305fn applyGaugeLink srcSlot ulong dstSlot ulong site ulong mu ulong g view f32 4 to void
306u = new f32 4 0.0f32
307g2 = new f32 4 0.0f32
308t1 = new f32 4 0.0f32
309t2 = new f32 4 0.0f32
310qLoad srcSlot site mu u
311xp = nb6 site mu 1
312b2 = mul xp 4
313for c ulong 4
314put g2 c get osG add b2 c
315end
316qConj g2
317qMul g u t1
318qMul t1 g2 t2
319qNorm t2
320qStore dstSlot site mu t2
321end
322
323fn applyGaugeTransform srcSlot ulong dstSlot ulong to void
324g = new f32 4 0.0f32
325for site ulong 1296
326qRand g
327b = mul site 4
328for c ulong 4
329put osG add b c get g c
330end
331end
332for site ulong 1296
333b = mul site 4
334for c ulong 4
335put g c get osG add b c
336end
337for mu ulong 4
338applyGaugeLink srcSlot dstSlot site mu g
339end
340end
341end
342
343fn sweepLink6 site ulong mu ulong beta f64 to void
344st = new f32 4 0.0f32
345u = new f32 4 0.0f32
346cand = new f32 4 0.0f32
347stapleSum6 0 site mu st
348qLoad 0 site mu u
349for hit ulong 3
350for c ulong 4
351put cand c add get u c mul 0.35f32 f32 uRngNorm64
352end
353qNorm cand
354dS = mul beta f64 sub qDot4 cand st qDot4 u st
355if or ge dS 0.0f64 lt uRngUnit64 uExp64 dS
356for c ulong 4
357put u c get cand c
358end
359end
360end
361qNorm st
362dot = qDot4 u st
363for c ulong 4
364put u c sub mul mul 2.0f32 dot get st c get u c
365end
366qNorm u
367qStore 0 site mu u
368end
369
370fn sweepSu2 beta f64 nSweeps ulong to void
371for sw ulong nSweeps bound 128
372for site ulong 1296
373if not isBdry6 site
374for mu ulong 4
375sweepLink6 site mu beta
376end
377end
378end
379end
380end
381
382fn plaq1x1 slot ulong site ulong mu ulong nu ulong to f64
383a = new f32 4 0.0f32
384b = new f32 4 0.0f32
385p = new f32 4 0.0f32
386q = new f32 4 0.0f32
387qLoad slot site mu a
388qLoad slot nb6 site mu 1 nu b
389qMul a b p
390qLoad slot nb6 site nu 1 mu a
391qConj a
392qMul p a q
393qLoad slot site nu b
394qConj b
395qMul q b p
396ret f64 get p 0
397end
398
399fn rect1x2 slot ulong site ulong mu ulong nu ulong to f64
400a = new f32 4 0.0f32
401b = new f32 4 0.0f32
402p = new f32 4 0.0f32
403q = new f32 4 0.0f32
404s1 = nb6 site mu 1
405s2 = nb6 s1 mu 1
406qLoad slot site mu a
407qLoad slot s1 mu b
408qMul a b p
409qLoad slot s2 nu a
410qMul p a q
411qLoad slot nb6 s1 nu 1 mu a
412qConj a
413qMul q a p
414qLoad slot nb6 site nu 1 mu a
415qConj a
416qMul p a q
417qLoad slot site nu b
418qConj b
419qMul q b p
420ret f64 get p 0
421end
422
423fn rect2x2 slot ulong site ulong mu ulong nu ulong to f64
424a = new f32 4 0.0f32
425p = new f32 4 0.0f32
426q = new f32 4 0.0f32
427cur = site
428qLoad slot cur mu p
429cur = nb6 cur mu 1
430qLoad slot cur mu a
431qMul p a q
432cur = nb6 cur mu 1
433qLoad slot cur nu a
434qMul q a p
435cur = nb6 cur nu 1
436qLoad slot cur nu a
437qMul p a q
438cur = nb6 cur nu 1
439cur = nb6 cur mu 5
440qLoad slot cur mu a
441qConj a
442qMul q a p
443cur = nb6 cur mu 5
444qLoad slot cur mu a
445qConj a
446qMul p a q
447cur = nb6 cur nu 5
448qLoad slot cur nu a
449qConj a
450qMul q a p
451cur = nb6 cur nu 5
452qLoad slot cur nu a
453qConj a
454qMul p a q
455ret f64 get q 0
456end
457
458fn chair6 slot ulong site ulong d0 ulong d1 ulong d2 ulong to f64
459a = new f32 4 0.0f32
460p = new f32 4 0.0f32
461q = new f32 4 0.0f32
462cur = site
463qLoad slot cur d0 p
464cur = nb6 cur d0 1
465qLoad slot cur d1 a
466qMul p a q
467cur = nb6 cur d1 1
468qLoad slot cur d2 a
469qMul q a p
470cur = nb6 cur d2 1
471cur = nb6 cur d0 5
472qLoad slot cur d0 a
473qConj a
474qMul p a q
475cur = nb6 cur d1 5
476qLoad slot cur d1 a
477qConj a
478qMul q a p
479cur = nb6 cur d2 5
480qLoad slot cur d2 a
481qConj a
482qMul p a q
483ret f64 get q 0
484end
485
486fn putPrim isG ulong p ulong lane ulong val f64 to void
487idx = add mul isG 240 add mul p W3_LANES lane
488put osPrim idx val
489end
490
491fn getPrim isG ulong p ulong lane ulong to f64
492idx = add mul isG 240 add mul p W3_LANES lane
493ret get osPrim idx
494end
495
496fn evalSitePlane srcSlot ulong site ulong mu ulong nu ulong to void
497vp0 = plaq1x1 srcSlot site mu nu
498put osAcc 0 add get osAcc 0 vp0
499put osAcc 8 add get osAcc 8 sub mul 4.0f64 mul vp0 vp0 1.0f64
500if eq mu 0
501put osAcc 11 add get osAcc 11 vp0
502end
503vp1 = plaq1x1 2 site mu nu
504put osAcc 1 add get osAcc 1 vp1
505vp2 = plaq1x1 3 site mu nu
506put osAcc 2 add get osAcc 2 vp2
507put osAcc 9 add get osAcc 9 sub mul 4.0f64 mul vp2 vp2 1.0f64
508put osAcc 3 add get osAcc 3 plaq1x1 4 site mu nu
509put osAcc 4 add get osAcc 4 rect1x2 srcSlot site mu nu
510vr2 = rect1x2 3 site mu nu
511put osAcc 5 add get osAcc 5 vr2
512put osAcc 10 add get osAcc 10 sub mul 4.0f64 mul vr2 vr2 1.0f64
513put osAcc 6 add get osAcc 6 rect2x2 3 site mu nu
514end
515
516fn evalPrims srcSlot ulong lane ulong isG ulong to void
517apeSmear6 srcSlot 2 0.5f32
518apeSmear6 2 3 0.5f32
519apeSmear6 3 4 0.5f32
520apeSmear6 4 4 0.5f32
521u = new f32 4 0.0f32
522qLoad srcSlot 555 0 u
523putPrim isG 0 lane f64 get u 0
524lsum = f64 0.0f64
525for mu ulong 4
526qLoad srcSlot 555 mu u
527lsum = add lsum f64 get u 0
528end
529putPrim isG 1 lane div lsum 4.0f64
530for k ulong 16
531put osAcc k 0.0f64
532end
533for site ulong 1296
534if isInt6 site
535for mu ulong 4
536for nu ulong 4
537if lt mu nu
538evalSitePlane srcSlot site mu nu
539end
540end
541end
542put osAcc 7 add get osAcc 7 chair6 3 site 0 1 2
543end
544end
545putPrim isG 2 lane div get osAcc 0 96.0f64
546putPrim isG 3 lane div get osAcc 1 96.0f64
547putPrim isG 4 lane div get osAcc 2 96.0f64
548putPrim isG 5 lane div get osAcc 3 96.0f64
549putPrim isG 6 lane div get osAcc 4 96.0f64
550putPrim isG 7 lane div get osAcc 5 96.0f64
551putPrim isG 8 lane div get osAcc 6 96.0f64
552putPrim isG 9 lane div get osAcc 7 16.0f64
553putPrim isG 10 lane div get osAcc 8 96.0f64
554putPrim isG 11 lane div get osAcc 9 96.0f64
555putPrim isG 12 lane div get osAcc 10 96.0f64
556putPrim isG 13 lane mul 0.5f64 add sub 1.0f64 div get osAcc 2 96.0f64 sub 1.0f64 div get osAcc 5 96.0f64
557putPrim isG 14 lane div get osAcc 11 48.0f64
558end
559
560note 4 arms x 4 snapshots = 16 lanes:
561note arm 0 (lanes 0..3): cold beta=2.30 (strong coupling -> catches chi1 pole!)
562note arm 1 (lanes 4..7): twist beta=2.30
563note arm 2 (lanes 8..11): cold beta=2.50 (non-perturbative 2x scaling target)
564note arm 3 (lanes 12..15): twist beta=2.50
565fn buildArmSnapshots armIdx ulong to void
566uRngSeed add 0x333356789abcdef0 mul armIdx 19991
567q = new f32 4 0.0f32
568beta = f64 2.30f64
569if ge armIdx 2
570beta = f64 2.50f64
571end
572isTwist = eq and armIdx 1 1
573for site ulong 1296
574c0 = div site 216
575c1 = rem div site 36 6
576for mu ulong 4
577if isBdry6 site
578if isTwist
579put q 0 1.0f32
580put q 1 0.0f32
581put q 2 0.0f32
582put q 3 0.0f32
583if and eq mu 0 and ge c1 3 eq c0 0
584put q 0 neg 1.0f32
585end
586if eq and add c0 c1 1 1
587put q 1 mul 0.45f32 f32 uRngNorm64
588put q 2 mul 0.45f32 f32 uRngNorm64
589put q 3 mul 0.45f32 f32 uRngNorm64
590qNorm q
591end
592else
593put q 0 1.0f32
594put q 1 0.0f32
595put q 2 0.0f32
596put q 3 0.0f32
597end
598else
599put q 0 0.8f32
600put q 1 mul 0.3f32 f32 uRngNorm64
601put q 2 mul 0.3f32 f32 uRngNorm64
602put q 3 mul 0.3f32 f32 uRngNorm64
603qNorm q
604end
605qStore 0 site mu q
606end
607end
608sweepSu2 beta 32
609for s ulong 4
610sweepSu2 beta 10
611lane = add mul armIdx 4 s
612evalPrims 0 lane 0
613applyGaugeTransform 0 1
614evalPrims 1 lane 1
615end
616end
617
618fn ufbiPriorRank to void
619put osOpOrder 0 6
620put osOpOrder 1 3
621put osOpOrder 2 5
622put osOpOrder 3 4
623end
624
625fn printOpName op ulong to void
626if eq op 3
627uPrint tNSub
628end
629if eq op 4
630uPrint tNAdd
631end
632if eq op 5
633uPrint tNMul
634end
635if eq op 6
636uPrint tNDiv
637end
638end
639
640fn quantHashCand to ulong
641h = ulong 0xcbf29ce484222325
642for i ulong W3_LANES
643x = get osCandV i
644q = long 0
645if ge x 0.0f64
646q = long add mul x 256.0f64 0.5f64
647else
648q = long sub mul x 256.0f64 0.5f64
649end
650h = mul xor h bitcast ulong q 0x100000001b3
651end
652if eq h 0
653h = ulong 1
654end
655ret h
656end
657
658fn vecCloseCand nid ulong to bool
659base = mul nid W3_LANES
660for i ulong W3_LANES
661if gt uAbs64 sub get osVec add base i get osCandV i 0.004f64
662ret false
663end
664end
665ret true
666end
667
668fn admitVec nNodes ulong to void
669base = mul nNodes W3_LANES
670mn = get osCandV 0
671mx = mn
672for i ulong W3_LANES
673v = get osCandV i
674put osVec add base i v
675put osGVec add base i get osCandG i
676if lt v mn
677mn = v
678end
679if gt v mx
680mx = v
681end
682end
683put osMinV nNodes mn
684put osMaxV nNodes mx
685end
686
687fn admitStore slot ulong h ulong op uchar l ulong r ulong dep uchar to void
688nNodes = get osSt 0
689put osHtH slot h
690put osHtN slot nNodes
691put osSt 1 add get osSt 1 1
692put osOp nNodes op
693put osL nNodes l
694put osR nNodes r
695put osDep nNodes dep
696admitVec nNodes
697put osSt 0 add nNodes 1
698end
699
700fn tryAdmit op uchar l ulong r ulong dep uchar to bool
701for i ulong W3_LANES
702if gt uAbs64 sub get osCandV i get osCandG i 0.0001f64
703put osSt 2 add get osSt 2 1
704ret false
705end
706if gt uAbs64 get osCandV i 500.0f64
707put osSt 6 add get osSt 6 1
708ret false
709end
710end
711if ge get osSt 1 W3_HT_MAX_OCC
712ret false
713end
714if ge get osSt 0 W3_MAX_NODES
715ret false
716end
717h = quantHashCand
718slot = and h W3_HT_MASK
719for pr ulong W3_MAX_PROBES bound 32
720if gt add pr 1 get osSt 5
721put osSt 5 add pr 1
722end
723cur = get osHtH slot
724if eq cur 0
725admitStore slot h op l r dep
726ret true
727end
728if eq cur h
729if vecCloseCand get osHtN slot
730put osSt 3 add get osSt 3 1
731ret false
732end
733end
734slot = and add slot 1 W3_HT_MASK
735end
736ret false
737end
738
739note INV-4 Pole-Free Denominator Check:
740note Requires denominator nid to be strictly sign-definite across ALL 16 snapshots
741note with margin tau=0.15 AND condition ratio max|D|/min|D| <= 4.0.
742fn isPoleFreeDenom nid ulong to bool
743mn = get osMinV nid
744mx = get osMaxV nid
745if gt mn 0.15f64
746ret le div mx mn 4.0f64
747end
748if lt mx neg 0.15f64
749ret le div neg mn neg mx 4.0f64
750end
751ret false
752end
753
754fn armMean nid ulong arm ulong to f64
755base = add mul nid W3_LANES mul arm 4
756s = f64 0.0f64
757for k ulong 4
758s = add s get osVec add base k
759end
760ret mul 0.25f64 s
761end
762
763fn armVarSum nid ulong arm ulong mu f64 to f64
764base = add mul nid W3_LANES mul arm 4
765s = f64 0.0f64
766for k ulong 4
767d = sub get osVec add base k mu
768s = add s mul d d
769end
770ret s
771end
772
773fn nodeBulkSigma nid ulong to f64
774vs = armVarSum nid 0 armMean nid 0
775vs = add vs armVarSum nid 1 armMean nid 1
776vs = add vs armVarSum nid 2 armMean nid 2
777vs = add vs armVarSum nid 3 armMean nid 3
778ret uSqrt64 div vs 12.0f64
779end
780
781note Dimensionless bulk-fluctuation normalized score:
782note bulk_snr = |cold_b25 - cold_b23| / sigma_bulk
783note dTw_norm = (|twist_b23 - cold_b23| + |twist_b25 - cold_b25|) / (2 * sigma_bulk)
784note uv_score = bulk_snr / (dTw_norm + 0.05) (requires bulk_snr >= 1.5 and sigma_bulk >= 1e-4)
785fn nodeUvScore nid ulong to f64
786sig = nodeBulkSigma nid
787if lt sig 0.0001f64
788ret 0.0f64
789end
790bulkSnr = div uAbs64 sub armMean nid 2 armMean nid 0 sig
791if lt bulkSnr 1.5f64
792ret 0.0f64
793end
794dTw = add uAbs64 sub armMean nid 1 armMean nid 0 uAbs64 sub armMean nid 3 armMean nid 2
795ret div bulkSnr add div mul 0.5f64 dTw sig 0.05f64
796end
797
798fn printPrimName p ulong to void
799if eq p 0
800uPrint tP0
801end
802if eq p 1
803uPrint tP1
804end
805if eq p 2
806uPrint tP2
807end
808if eq p 3
809uPrint tP3
810end
811if eq p 4
812uPrint tP4
813end
814if eq p 5
815uPrint tP5
816end
817if eq p 6
818uPrint tP6
819end
820if eq p 7
821uPrint tP7
822end
823if eq p 8
824uPrint tP8
825end
826if eq p 9
827uPrint tP9
828end
829if eq p 10
830uPrint tP10
831end
832if eq p 11
833uPrint tP11
834end
835if eq p 12
836uPrint tP12
837end
838if eq p 13
839uPrint tP13
840end
841if eq p 14
842uPrint tP14
843end
844end
845
846fn printExpr nid ulong to void
847op = get osOp nid
848if eq op 0
849printPrimName get osL nid
850ret
851end
852if eq op 1
853uPrint tOpChi
854printExpr get osL nid
855uPrint tRp
856ret
857end
858if eq op 2
859uPrint tOpSq
860printExpr get osL nid
861uPrint tRp
862ret
863end
864if eq op 3
865uPrint tOpSub
866end
867if eq op 4
868uPrint tOpAdd
869end
870if eq op 5
871uPrint tOpMul
872end
873if eq op 6
874uPrint tOpDiv
875end
876printExpr get osL nid
877uPrint tComma
878printExpr get osR nid
879uPrint tRp
880end
881
882fn runBfsDepth0 to void
883put osLvlS 0 0
884for p ulong 15
885for i ulong W3_LANES
886put osCandV i getPrim 0 p i
887put osCandG i getPrim 1 p i
888end
889ok = tryAdmit 0 p 0 0
890end
891put osLvlE 0 get osSt 0
892end
893
894fn evalBinCand a ulong b ulong op uchar dep uchar to void
895ba = mul a W3_LANES
896bb = mul b W3_LANES
897if eq op 6
898if not isPoleFreeDenom b
899put osSt 4 add get osSt 4 1
900ret
901end
902end
903for i ulong W3_LANES
904va = get osVec add ba i
905vb = get osVec add bb i
906ga = get osGVec add ba i
907gb = get osGVec add bb i
908if eq op 3
909put osCandV i sub va vb
910put osCandG i sub ga gb
911end
912if eq op 4
913put osCandV i add va vb
914put osCandG i add ga gb
915end
916if eq op 5
917put osCandV i mul va vb
918put osCandG i mul ga gb
919end
920if eq op 6
921put osCandV i div va vb
922put osCandG i div ga gb
923end
924end
925ok = tryAdmit op a b dep
926end
927
928fn runBfsDepth1 to void
929e0 = get osLvlE 0
930put osLvlS 1 e0
931for a ulong e0 bound 32
932ba = mul a W3_LANES
933for i ulong W3_LANES
934xa = get osVec add ba i
935xg = get osGVec add ba i
936put osCandV i sub mul 4.0f64 mul xa xa 1.0f64
937put osCandG i sub mul 4.0f64 mul xg xg 1.0f64
938end
939ok = tryAdmit 1 a 0 1
940for i ulong W3_LANES
941xa = get osVec add ba i
942xg = get osGVec add ba i
943put osCandV i mul xa xa
944put osCandG i mul xg xg
945end
946ok = tryAdmit 2 a 0 1
947end
948for k ulong 4
949op = uchar get osOpOrder k
950for a ulong e0 bound 32
951for b ulong e0 bound 32
952evalBinCand a b op 1
953end
954end
955end
956put osLvlE 1 get osSt 0
957end
958
959fn selectTopNodes kMax ulong lim ulong to ulong
960cnt = ulong 0
961for i ulong kMax bound 32
962put osTopIds i 0
963put osTopScores i 0.0f64
964end
965for nid ulong lim bound 16384
966sc = nodeUvScore nid
967if gt sc 0.0f64
968if lt cnt kMax
969put osTopIds cnt nid
970put osTopScores cnt sc
971cnt = add cnt 1
972else
973wIdx = ulong 0
974wSc = get osTopScores 0
975for j ulong kMax bound 32
976if lt get osTopScores j wSc
977wSc = get osTopScores j
978wIdx = j
979end
980end
981if gt sc wSc
982put osTopIds wIdx nid
983put osTopScores wIdx sc
984end
985end
986end
987end
988for i ulong cnt bound 32
989best = i
990j = add i 1
991while lt j cnt bound 32
992if gt get osTopScores j get osTopScores best
993best = j
994end
995j = add j 1
996end
997ti = get osTopIds i
998ts = get osTopScores i
999put osTopIds i get osTopIds best
1000put osTopScores i get osTopScores best
1001put osTopIds best ti
1002put osTopScores best ts
1003end
1004ret cnt
1005end
1006
1007fn runBfsWave2 nMined ulong to void
1008e0 = get osLvlE 0
1009e1 = get osLvlE 1
1010put osLvlS 2 e1
1011for k ulong 4
1012op = uchar get osOpOrder k
1013for ti ulong nMined bound 32
1014a = get osTopIds ti
1015for b ulong e0 bound 32
1016evalBinCand a b op 2
1017evalBinCand b a op 2
1018end
1019end
1020end
1021for k ulong 4
1022op = uchar get osOpOrder k
1023for ti ulong nMined bound 32
1024a = get osTopIds ti
1025for tj ulong nMined bound 32
1026b = get osTopIds tj
1027evalBinCand a b op 2
1028end
1029end
1030end
1031for a ulong e1 bound 1024
1032if eq get osOp a 5
1033for b ulong e1 bound 1024
1034if eq get osOp b 2
1035evalBinCand a b 6 2
1036end
1037end
1038end
1039end
1040put osLvlE 2 get osSt 0
1041end
1042
1043fn nodeGaugeErr nid ulong to f64
1044base = mul nid W3_LANES
1045gerr = f64 0.0f64
1046for i ulong W3_LANES
1047e = uAbs64 sub get osVec add base i get osGVec add base i
1048if gt e gerr
1049gerr = e
1050end
1051end
1052ret gerr
1053end
1054
1055fn printRankedRow rk ulong nid ulong to void
1056sig = nodeBulkSigma nid
1057dTw = mul 0.5f64 add uAbs64 sub armMean nid 1 armMean nid 0 uAbs64 sub armMean nid 3 armMean nid 2
1058uPrintU rk
1059uPrint tW3Tab
1060uPrintU nid
1061uPrint tW3Tab
1062uPrintU ulong get osDep nid
1063uPrint tW3Tab
1064printExpr nid
1065uPrint tW3Tab
1066uPrintF64 nodeGaugeErr nid
1067uPrint tW3Tab
1068uPrintF64 get osMinV nid
1069uPrint tW3Tab
1070uPrintF64 get osMaxV nid
1071uPrint tW3Tab
1072uPrintF64 armMean nid 0
1073uPrint tW3Tab
1074uPrintF64 armMean nid 1
1075uPrint tW3Tab
1076uPrintF64 armMean nid 2
1077uPrint tW3Tab
1078uPrintF64 armMean nid 3
1079uPrint tW3Tab
1080uPrintF64 sig
1081uPrint tW3Tab
1082uPrintF64 div dTw sig
1083uPrint tW3Tab
1084uPrintF64 nodeUvScore nid
1085uPrint tW3Nl
1086end
1087
1088fn main to int
1089uPrint tW3Hdr
1090for arm ulong 4
1091buildArmSnapshots arm
1092end
1093ufbiPriorRank
1094uPrint tW3Prior
1095for k ulong 4
1096printOpName get osOpOrder k
1097uPrint tW3Sp
1098end
1099uPrint tW3Nl
1100runBfsDepth0
1101runBfsDepth1
1102w1Cnt = get osSt 0
1103nMined = selectTopNodes 24 w1Cnt
1104runBfsWave2 nMined
1105w2Cnt = get osSt 0
1106uPrint tW3Stat
1107uPrintU w2Cnt
1108uPrint tW3GRej
1109uPrintU get osSt 2
1110uPrint tW3EPrun
1111uPrintU get osSt 3
1112uPrint tW3Pole
1113uPrintU get osSt 4
1114uPrint tW3Occ
1115uPrintU get osSt 1
1116uPrint tW3MPr
1117uPrintU get osSt 5
1118uPrint tW3Wave1
1119uPrintU w1Cnt
1120uPrint tW3Wave2
1121uPrintU sub w2Cnt w1Cnt
1122uPrint tW3Nl
1123uPrint tW3Col
1124nTop = selectTopNodes 20 w2Cnt
1125for r ulong nTop bound 20
1126printRankedRow add r 1 get osTopIds r
1127end
1128if lt get osSt 2 2
1129ret 1
1130end
1131if eq get osSt 4 0
1132ret 2
1133end
1134uPrint tW3Pass
1135ret 0
1136end