everydaytok commited on
Commit
4d35e75
Β·
verified Β·
1 Parent(s): 081f5a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +173 -193
app.py CHANGED
@@ -1,36 +1,20 @@
1
  #!/usr/bin/env python3
2
  """
3
- PRACTICALITY SYSTEM 19.3 β€” NEURO-SYMBOLIC ENZYME (RESTORED WISDOM)
4
  ═══════════════════════════════════════════════════════════════════
5
- FIXES FROM 19.2:
6
-
7
- 1. RESTORED HYPOTHESIS DEPTH:
8
- _hyp_bilinear: Full asymmetric split logic restored β€” geometric mean
9
- PLUS ascending/descending pairs at ratios [0.4, 0.7071, 0.9].
10
- Without this BilinearChain6 only gets the equal-split case.
11
-
12
- _hyp_monotone_product: Full ratio sweep restored [0.1, 0.2, 0.3,
13
- 0.4, 0.5, 0.6, 0.707, 0.8, 0.9, 0.95] with HC4 cascade propagation.
14
- 19.2 only tested ratio=0.4. The correct BilinearChain6 solution
15
- requires ratios like 0.5/2.0, 1.0/2.0, 1.5/3.0 which only emerge
16
- from the full sweep.
17
-
18
- 2. FIXED BATON REGISTRY:
19
- 19.2 only stored batons for rays that improved best_ce globally.
20
- Silent failure: recombination would fall back to self-recombination
21
- when ray_a had never topped the global best.
22
-
23
- 19.3 stores any baton with CE < BATON_REGISTRY_THRESHOLD (=2.0).
24
- Recombination now actually combines two different solution geometries.
25
- Cap at 5000 entries (FIFO) to prevent memory growth.
26
-
27
- 3. FULL OBSERVABILITY DASHBOARD:
28
- Restored the scientific instruments lost in the Gradio rewrite:
29
- - Per-problem performance table (runs, solve rate, avg CE, best CE)
30
- - Ray type efficacy table (tried, survived, rate per type)
31
- - Allosteric feedback diagnostics (which tension class fired most)
32
- - Recent run collapse view with binding and invariant details
33
- All auto-refreshing every 2 seconds.
34
  """
35
 
36
  import time, random, math, threading, warnings
@@ -48,7 +32,7 @@ import gradio as gr
48
  warnings.filterwarnings("ignore")
49
  USE_GPU = torch.cuda.is_available()
50
  DEVICE = torch.device("cuda" if USE_GPU else "cpu")
51
- print(f"[SYSTEM 19.3] Compute: {DEVICE.type.upper()} | Engine: Neuro-Symbolic Enzyme (Restored Wisdom)")
52
 
53
  # ══════════════════════════════════════════════════════════════════════
54
  # SECTION 1: CONSTANTS
@@ -65,10 +49,8 @@ RAY_BATCH_SIZE = 12288
65
  CE_EARN_RATIO = 0.90
66
  SCOUT_CE_THRESHOLD = 0.5
67
  BRANCH_WIDTH = 4
68
-
69
- # FIX 2: Registry threshold β€” store any baton that shows meaningful progress
70
  BATON_REGISTRY_THRESHOLD = 2.0
71
- BATON_REGISTRY_MAX = 5000 # FIFO cap to prevent memory growth
72
 
73
  # ══════════════════════════════════════════════════════════════════════
74
  # SECTION 2: INTERVAL ARITHMETIC (HC4)
@@ -145,7 +127,6 @@ def _hc4(box,constraints):
145
  return cur
146
 
147
  def _global_hc4_tighten_bounds(problem):
148
- """Tighten bounds using HC4 before hypothesis testing."""
149
  gb={v:IV(lo,hi) for v,(lo,hi) in problem.bounds.items()}
150
  c=_hc4(gb,problem.compiled_constraints)
151
  if c is None: return dict(problem.bounds)
@@ -153,7 +134,7 @@ def _global_hc4_tighten_bounds(problem):
153
  for v in problem.bounds if v in c}
154
 
155
  # ══════════════════════════════════════════════════════════════════════
156
- # SECTION 3: PSL PARSER & AXL LAYER
157
  # ══════════════════════════════════════════════════════════════════════
158
  @dataclass
159
  class PSLVar: name:str; lo:float; hi:float
@@ -241,7 +222,17 @@ def expand_psl(prog:PSLProgram) -> ExpandedProblem:
241
  return ExpandedProblem(variables,bounds,constraints,dict(scope_groups),dict(scope_vars),prog.scope_order)
242
 
243
  @dataclass
244
- class AXLInvariant: name:str; expr:str; tolerance:float=VERIFY_G2_TOLERANCE; mode:str="eq"
 
 
 
 
 
 
 
 
 
 
245
 
246
  @dataclass
247
  class AXLProblemDef:
@@ -344,12 +335,42 @@ class Problem:
344
  scope_groups:Dict[str,List[int]]=field(default_factory=dict)
345
  scope_vars:Dict[str,List[str]]=field(default_factory=dict)
346
  scope_order:List[str]=field(default_factory=list)
 
 
 
 
347
 
348
  def __post_init__(self):
349
  self.compiled_constraints=[
350
  compile_mc(c.kind,c.expr,c.direction,self.variables,c.weight,c.scope,c.branches)
351
  for c in self.constraints]
352
  self.var_idx={v:i for i,v in enumerate(self.variables)}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
353
 
354
  def tensor_energy(self,X:torch.Tensor) -> torch.Tensor:
355
  is_batched=(X.dim()==2)
@@ -405,34 +426,38 @@ class Problem:
405
  @dataclass
406
  class L9Certificate:
407
  residual_ce:float; dominant_vars:List[str]; dominant_exprs:List[str]
408
- # NEW: track tension class for allosteric diagnostics
409
- tension_class:str="unknown" # "isolated" | "relational" | "systemic"
410
 
411
  def _batched_deduce_and_evaluate(
412
  problem:Problem,
413
  hyps:List['Hypothesis']) -> List[Tuple[Dict,float,List[str],str]]:
414
  """
415
  Naked Evaluation with Masked Adam.
416
- Returns (binding, ce, dominant_vars, tension_class) per hypothesis.
417
- tension_class feeds the allosteric feedback diagnostics.
418
  """
419
  if not hyps: return []
420
  B=len(hyps); V=len(problem.variables)
421
 
422
- X_init=torch.zeros((B,V),device=DEVICE,dtype=torch.float32)
423
- mask =torch.ones( (B,V),device=DEVICE,dtype=torch.float32)
424
- target =torch.zeros((B,V),device=DEVICE,dtype=torch.float32)
425
-
426
- for i,hyp in enumerate(hyps):
427
- for j,v in enumerate(problem.variables):
428
- val=hyp.binding.get(v,(problem.bounds[v][0]+problem.bounds[v][1])/2)
429
- X_init[i,j]=val
430
  if v in hyp.pinned_vars:
431
- mask[i,j] =0.0
432
- target[i,j]=hyp.pinned_vars[v]
433
- X_init[i,j]=hyp.pinned_vars[v]
 
 
 
 
 
 
 
434
 
435
- X=X_init.clone().detach().requires_grad_(True)
436
  optimizer=torch.optim.Adam([X],lr=0.05)
437
 
438
  for _ in range(DEDUCE_ADAM_STEPS):
@@ -453,20 +478,28 @@ def _batched_deduce_and_evaluate(
453
  final_ce=problem.tensor_energy(X)
454
  final_ce.sum().backward()
455
 
456
- ce_vals =final_ce.detach().cpu().numpy()
457
- grads =X.grad.abs().cpu().numpy()
458
- X_vals =X.detach().cpu().numpy()
 
 
 
 
 
459
 
460
  results=[]
461
  for i in range(B):
462
  final_b={problem.variables[j]:float(X_vals[i,j]) for j in range(V)}
463
- var_tensions={problem.variables[j]:float(grads[i,j]) for j in range(V)}
464
- dom_vars=sorted(var_tensions.keys(),key=lambda v:-var_tensions[v])[:3]
465
- n_dom=sum(1 for v in dom_vars if var_tensions[v]>1e-4)
 
 
466
  if n_dom<=1: tension_class="isolated"
467
  elif n_dom==2: tension_class="relational"
468
  else: tension_class="systemic"
469
  results.append((final_b,float(ce_vals[i]),dom_vars,tension_class))
 
470
  return results
471
 
472
  def _mprt_sample(problem,work_box,N):
@@ -570,7 +603,7 @@ class StructuralModel:
570
  resonant_pairs:List[Tuple[str,str]]=field(default_factory=list)
571
 
572
  # ══════════════════════════════════════════════════════════════════════
573
- # SECTION 8: HYPOTHESIS CONSTRUCTORS (RESTORED FULL DEPTH)
574
  # ══════════════════════════════════════════════════════════════════════
575
  def _make_hyp(hid,binding,h_type,claim,derivation,pinned,free,conf):
576
  return Hypothesis(hid=hid,binding=binding,h_type=h_type,claim=claim,
@@ -598,111 +631,69 @@ def _hyp_quadratic(p,bt,a,m):
598
  return hyps
599
 
600
  def _hyp_bilinear(p,bt,a,m):
601
- """
602
- FIX 19.3: Restored full asymmetric split logic.
603
- Geometric mean + ascending/descending pairs at multiple ratios.
604
- Without this BilinearChain6 only sees the equal-split case.
605
- """
606
  hyps=[]; b=dict(bt.binding)
607
- for mc in p.compiled_constraints:
608
- if not mc.parsed or not mc.parsed.is_Add: continue
609
- for term in mc.parsed.args:
610
- if not term.is_Mul: continue
611
- syms_in=[str(s) for s in term.free_symbols if str(s) in p.variables]
612
- if len(syms_in)!=2: continue
613
- vi,vj=syms_in
614
- lo_i,hi_i=p.bounds.get(vi,(0,10)); lo_j,hi_j=p.bounds.get(vj,(0,10))
615
- product=abs(b.get(vi,1)*b.get(vj,1))
616
- if product<=0: continue
617
- gm=math.sqrt(product)
618
-
619
- # Geometric mean (equal split)
620
- if lo_i<=gm<=hi_i and lo_j<=gm<=hi_j:
621
- nb=dict(b); nb[vi]=nb[vj]=gm
622
- hyps.append(_make_hyp(f"bil_eq_{vi}_{vj}",nb,"bilinear",
623
- f"GeoMean({vi}={vj}={gm:.3f})",["bilinear"],{vi:gm,vj:gm},
624
- [v for v in p.variables if v not in [vi,vj]],0.70))
625
-
626
- # RESTORED: Asymmetric splits
627
- for ratio in [0.4, 0.7071, 0.9]:
628
- vs=gm*ratio; vl=product/(vs+1e-9)
629
- # Ascending: vi < vj
630
- if lo_i<=vs<=hi_i and lo_j<=vl<=hi_j and vs<vl:
631
- nb2=dict(b); nb2[vi]=vs; nb2[vj]=vl
632
- hyps.append(_make_hyp(f"bil_asc_{int(ratio*100)}_{vi}_{vj}",nb2,"bilinear",
633
- f"BilAsc({vi}={vs:.3f}<{vj}={vl:.3f})",["bilinear"],{vi:vs,vj:vl},
634
- [v for v in p.variables if v not in [vi,vj]],0.75))
635
- # Descending: vi > vj
636
- if lo_i<=vl<=hi_i and lo_j<=vs<=hi_j and vl>vs:
637
- nb3=dict(b); nb3[vi]=vl; nb3[vj]=vs
638
- hyps.append(_make_hyp(f"bil_desc_{int(ratio*100)}_{vi}_{vj}",nb3,"bilinear",
639
- f"BilDesc({vi}={vl:.3f}>{vj}={vs:.3f})",["bilinear"],{vi:vl,vj:vs},
640
- [v for v in p.variables if v not in [vi,vj]],0.75))
641
  return hyps
642
 
643
  def _hyp_monotone_product(p,bt,a,m):
644
- """
645
- FIX 19.3: Full ratio sweep restored [0.1 β†’ 0.95] with HC4 cascade.
646
- 19.2 only tested ratio=0.4. The correct BilinearChain6 solutions
647
- require ratios like 0.25 (t1=0.5, t2=1.0) which need this sweep.
648
- """
649
  hyps=[]; b=dict(bt.binding)
650
 
651
- # Build ordered pairs from inequality constraints
652
- ordered_pairs:List[Tuple[str,str]]=[]
653
- for mc in p.compiled_constraints:
654
- if mc.kind=="inequality" and mc.direction=="geq" and len(mc.syms_used)==2:
655
- ordered_pairs.append((mc.syms_used[0],mc.syms_used[1]))
656
 
657
- if not ordered_pairs: return hyps
 
 
658
 
659
- # Tighten bounds via HC4 before pinning
660
- tb=_global_hc4_tighten_bounds(p)
 
 
 
661
 
662
- for mc in p.compiled_constraints:
663
- if mc.kind!="equality" or not mc.parsed or not mc.parsed.is_Add: continue
664
- for term in mc.parsed.args:
665
- if not term.is_Mul: continue
666
- syms_in=[str(s) for s in term.free_symbols if str(s) in p.variables]
667
- if len(syms_in)!=2: continue
668
- va,vb=syms_in
669
- try:
670
- const_part=mc.parsed-sp.Symbol(va)*sp.Symbol(vb)
671
- k=float(-const_part.evalf())
672
- except: continue
673
- if k<=0: continue
674
-
675
- for (v_small,v_large) in ordered_pairs:
676
- if set([va,vb])!=set([v_small,v_large]): continue
677
- lo_s,hi_s=p.bounds.get(v_small,(-1e18,1e18))
678
- lo_l,hi_l=p.bounds.get(v_large,(-1e18,1e18))
679
-
680
- # RESTORED: Full ratio sweep
681
- for ratio in [0.1,0.2,0.3,0.4,0.5,0.6,0.707,0.8,0.9,0.95]:
682
- vs_sq=k*ratio
683
- if vs_sq<=0: continue
684
- vs=math.sqrt(vs_sq); vl=k/vs
685
- if not(lo_s<=vs<=hi_s and lo_l<=vl<=hi_l and vs<=vl): continue
686
-
687
- nb=dict(b); nb[v_small]=vs; nb[v_large]=vl
688
-
689
- # HC4 cascade to propagate implications
690
- box={u:IV(*tb.get(u,p.bounds.get(u,(-10,10)))) for u in p.variables}
691
- box[v_small]=IV(vs-1e-6,vs+1e-6)
692
- box[v_large]=IV(vl-1e-6,vl+1e-6)
693
- cont=_hc4(box,p.compiled_constraints)
694
- pinned={v_small:vs,v_large:vl}
695
- if cont:
696
- for u,iv in cont.items():
697
- if u in p.bounds: nb[u]=iv.mid()
698
- pinned={u:nb[u] for u in p.variables if cont[u].width()<1e-2}
699
-
700
- hyps.append(_make_hyp(
701
- f"mpr_{v_small}_{v_large}_r{int(ratio*100)}",
702
- nb,"monotone_product",
703
- f"MonoProd({v_small}={vs:.4f}≀{v_large}={vl:.4f})",
704
- [mc.expr_str,"ordered","hc4"],pinned,
705
- [u for u in p.variables if u not in pinned],0.88))
706
  return hyps
707
 
708
  def _hyp_metric(p,bt,a,m): return [_make_hyp("met",bt.binding,"metric","Radial",[],{},p.variables,0.75)]
@@ -800,7 +791,6 @@ AXIOM_CONSTRUCTORS={
800
  # ══════════════════════════════════════════════════════════════════════
801
  class CreativeSeeder:
802
  def target_seeds(self,anchors:List[AXLInvariant]) -> List[AxiomRay]:
803
- """Bidirectional search: spawn from goal state structure."""
804
  seeds=[]
805
  for a in anchors:
806
  if "*" in a.expr and "**" not in a.expr:
@@ -814,10 +804,6 @@ class CreativeSeeder:
814
  return seeds
815
 
816
  def intelligent_branch(self,ray,out_baton,remaining_axioms,branch_width) -> List[AxiomRay]:
817
- """
818
- Allosteric feedback: gradient topology biases next axiom selection.
819
- Returns children sorted by weighted stochastic score.
820
- """
821
  dom_vars=out_baton.l9.dominant_vars if out_baton.l9 else []
822
  n_dom=len([v for v in dom_vars])
823
  isolated ={Axiom.ATOMIC,Axiom.EXTREMAL,Axiom.MUTABLE,Axiom.DUALITY,Axiom.LOCALITY}
@@ -902,7 +888,7 @@ class CreativeSeeder:
902
  CREATIVE_SEEDER=CreativeSeeder()
903
 
904
  # ══════════════════════════════════════════════════════════════════════
905
- # SECTION 10: VERIFY LAYER
906
  # ══════════════════════════════════════════════════════════════════════
907
  def _verify(binding:Dict[str,float],base_problem:Problem,
908
  anchors:List[AXLInvariant]) -> Tuple[bool,bool,Dict[str,Tuple[float,bool]],float]:
@@ -911,10 +897,11 @@ def _verify(binding:Dict[str,float],base_problem:Problem,
911
  g2={}
912
  for inv in anchors:
913
  try:
914
- syms={v:sp.Symbol(v) for v in binding}
915
- expr=parse_expr(inv.expr,local_dict=syms)
916
- func=sp.lambdify(list(expr.free_symbols),expr,modules="math")
917
- val=float(func(*[binding.get(str(s),0.0) for s in expr.free_symbols])); err=abs(val)
 
918
  if inv.mode=="eq": passed=err<inv.tolerance
919
  elif inv.mode=="geq": passed=val>=-inv.tolerance
920
  elif inv.mode=="leq": passed=val<=inv.tolerance
@@ -925,19 +912,23 @@ def _verify(binding:Dict[str,float],base_problem:Problem,
925
  return g1_pass,g2_pass,g2,round(g1_ce,6)
926
 
927
  # ══════════════════════════════════════════════════════════════════════
928
- # SECTION 11: SEQUENCE RAY TRACER (Fixed Baton Registry)
929
  # ══════════════════════════════════════════════════════════════════════
930
  class SequenceRayTracer:
931
  def trace(self,axl_def:AXLProblemDef,base_problem:Problem):
932
  hero_traces:List[HypothesisTrace]=[]
933
 
934
- # FIX 2: Registry stores ANY baton below threshold, not just global bests
935
  baton_registry:Dict[str,Baton]={}
936
- baton_registry_keys:deque=deque() # FIFO for memory cap
937
 
938
  successful_rays:List[AxiomRay]=[]
939
  resonant_pairs:List[Tuple[str,str]]=[]
940
 
 
 
 
 
 
941
  init_b,init_ce=_mprt_sample(base_problem,
942
  {v:IV(*base_problem.bounds[v]) for v in base_problem.variables},N_MPRT_EXPLORE)
943
  seed_baton=Baton(binding=init_b,ce=init_ce,ray_id="SEED",
@@ -954,11 +945,9 @@ class SequenceRayTracer:
954
  best_ce=init_ce; best_binding=dict(init_b); total_fired=0
955
  model=StructuralModel(best_binding,best_ce)
956
 
957
- # Allosteric diagnostics counters
958
  allosteric_counts={"isolated":0,"relational":0,"systemic":0}
959
 
960
  while total_fired<MAX_TOTAL_RAYS:
961
- # Build batch
962
  batch_rays:List[AxiomRay]=[]
963
  for _ in range(RAY_BATCH_SIZE):
964
  start_idx=q_idx
@@ -973,7 +962,6 @@ class SequenceRayTracer:
973
  t0=time.time()
974
  historical_batons=list(baton_registry.values())
975
 
976
- # Generate one hypothesis per ray
977
  batch_hyps:List[Tuple[int,Hypothesis]]=[]
978
  for i,ray in enumerate(batch_rays):
979
  p_baton=ray.baton or seed_baton
@@ -982,7 +970,6 @@ class SequenceRayTracer:
982
  if not hyps: hyps=[_make_hyp("fb",p_baton.binding,"fallback","Pass",[],{},base_problem.variables,0.1)]
983
  batch_hyps.append((i,hyps[0]))
984
 
985
- # Batched masked deduction + gradient oracle
986
  eval_results=_batched_deduce_and_evaluate(base_problem,[h for _,h in batch_hyps])
987
  elapsed_ms=(time.time()-t0)*1000/max(1,len(batch_rays))
988
 
@@ -996,7 +983,6 @@ class SequenceRayTracer:
996
  overall_pass=g1_pass and g2_pass
997
 
998
  improved=final_ce<best_ce
999
- # Save traces for heroes + random sample for observability
1000
  if improved or overall_pass or random.random()<0.002:
1001
  hero_traces.append(HypothesisTrace(
1002
  hid=ray.ray_id,round_idx=total_fired-len(batch_rays)+ray_idx,
@@ -1011,7 +997,6 @@ class SequenceRayTracer:
1011
  out_baton=Baton(binding=final_b,ce=final_ce,ray_id=ray.ray_id,
1012
  l9=L9Certificate(final_ce,dom_vars,[],tension_class))
1013
 
1014
- # FIX 2: Register baton if below threshold β€” not just global bests
1015
  if final_ce<BATON_REGISTRY_THRESHOLD:
1016
  if ray.ray_id in baton_registry:
1017
  baton_registry[ray.ray_id]=out_baton
@@ -1029,7 +1014,6 @@ class SequenceRayTracer:
1029
 
1030
  if overall_pass: solved=True
1031
 
1032
- # Resonance detection
1033
  if improved and len(ray.sequence)>=2:
1034
  pair=(ray.sequence[-2],ray.sequence[-1])
1035
  if pair not in resonant_pairs: resonant_pairs.append(pair)
@@ -1045,21 +1029,18 @@ class SequenceRayTracer:
1045
  and a not in ray.sequence]
1046
 
1047
  new_children:List[AxiomRay]=[]
1048
- # Allosteric feedback branching
1049
  new_children.extend(
1050
  CREATIVE_SEEDER.intelligent_branch(ray,out_baton,remaining,BRANCH_WIDTH))
1051
  inv=CREATIVE_SEEDER.invert(ray,final_ce)
1052
  if inv: new_children.append(inv)
1053
 
1054
- # FIX 2: Recombination now gets real registered batons from both parents
1055
  if len(successful_rays)>=2:
1056
  candidates=[r for r in successful_rays if r.ray_id!=ray.ray_id]
1057
  if candidates:
1058
  partner=random.choice(candidates)
1059
- # Look up actual registered batons β€” fall back to current only if missing
1060
  ba=baton_registry.get(ray.ray_id,out_baton)
1061
  bb=baton_registry.get(partner.ray_id)
1062
- if bb is not None: # Only recombine if partner has a registered baton
1063
  new_children.extend(CREATIVE_SEEDER.recombine(ray,partner,ba,bb)[:3])
1064
 
1065
  new_children.extend(
@@ -1233,7 +1214,6 @@ def build_base_problem(axl_def:AXLProblemDef) -> Problem:
1233
  STATE_LOCK = threading.Lock()
1234
  IS_RUNNING = False
1235
 
1236
- # FIX 3: Full observability state
1237
  PROBLEM_STATS:Dict[str,Dict]={p.name:{
1238
  "runs":0,"solved":0,"total_ce":0.0,"best_ce":float('inf'),
1239
  "best_binding":{},"best_ray":"β€”",
@@ -1241,7 +1221,7 @@ PROBLEM_STATS:Dict[str,Dict]={p.name:{
1241
  "allosteric":{"isolated":0,"relational":0,"systemic":0},
1242
  } for p in AXL_PROBLEMS}
1243
 
1244
- RECENT_RUNS:List[Dict]=[] # Last 30 full run records
1245
  MAX_RECENT=30
1246
  _PROB_IDX=0
1247
 
@@ -1308,10 +1288,10 @@ def toggle_engine():
1308
  global IS_RUNNING
1309
  IS_RUNNING=not IS_RUNNING
1310
  if IS_RUNNING: threading.Thread(target=background_worker,daemon=True).start()
1311
- return "⏹ STOP 19.3" if IS_RUNNING else "β–Ά START 19.3"
1312
 
1313
  # ══════════════════════════════════════════════════════════════════════
1314
- # SECTION 14: GRADIO DASHBOARD (Full Observability Restored)
1315
  # ══════════════════════════════════════════════════════════════════════
1316
  RAY_ICONS={"seed":"🌱","branch":"🌿","tension":"⚑","scout":"πŸ”­",
1317
  "recombine":"🧬","invert":"πŸ”„","target":"🎯"}
@@ -1476,11 +1456,11 @@ def refresh_dashboard():
1476
  return f"""
1477
  <div style='background:#090909;color:#e0e0e0;font-family:monospace;padding:16px;max-width:1700px'>
1478
  <h2 style='color:#26C6DA;border-bottom:1px solid #1a1a1a;padding-bottom:5px;font-size:1.05em;margin:0 0 8px 0'>
1479
- βš— Practicality 19.3 β€” Neuro-Symbolic Enzyme (Restored Wisdom)
1480
  </h2>
1481
  <div style='color:#2a2a2a;font-size:0.70em;margin-bottom:10px'>
1482
- Masked Adam (structural pins) Β· Gradient Oracle β†’ Allosteric Feedback Β·
1483
- Full Bilinear Splits Β· Full MPR Ratio Sweep Β· Fixed Baton Registry Β· 12K Batch
1484
  </div>
1485
  <div style='margin-bottom:12px'>
1486
  <span style='display:inline-block;padding:2px 8px;border-radius:3px;background:#0e0e0e;margin:2px;font-size:0.72em;border:1px solid #1a1a1a;color:#aaa'>Runs: {runs}</span>
@@ -1493,7 +1473,7 @@ def refresh_dashboard():
1493
 
1494
  <h4 style='color:#252525;font-size:0.78em;letter-spacing:2px;text-transform:uppercase;margin:16px 0 4px 0'>Creative Ray Type Efficacy</h4>
1495
  <table style='width:100%;border-collapse:collapse;margin-bottom:10px'>
1496
- <tr style='color:#252525;font-size:0.68em'><th></th><th>Type</th><th>Tried</th><th>Survived</th><th>Failed</th><th>Rate</th><th>Mechanism (19.3)</th></tr>
1497
  {types}
1498
  </table>
1499
 
@@ -1518,14 +1498,14 @@ def refresh_dashboard():
1518
  {recnt}
1519
  </div>"""
1520
 
1521
- with gr.Blocks(theme=gr.themes.Monochrome(text_size="sm"),title="Practicality 19.3") as demo:
1522
- gr.Markdown("## βš— Practicality 19.3 β€” Neuro-Symbolic Enzyme")
1523
  gr.Markdown(
1524
  f"**Compute:** `{DEVICE.type.upper()}` | "
1525
- f"**Fixes:** Full bilinear splits Β· Full MPR sweep Β· Fixed baton registry Β· Full observability")
1526
 
1527
  with gr.Row():
1528
- btn=gr.Button("β–Ά START 19.3",variant="primary",scale=1)
1529
  gr.Markdown("*Engine cycles through 14 domains. Dashboard auto-refreshes every 2s.*")
1530
 
1531
  html_out=gr.HTML(refresh_dashboard())
@@ -1539,5 +1519,5 @@ with gr.Blocks(theme=gr.themes.Monochrome(text_size="sm"),title="Practicality 19
1539
  demo.load(auto_refresh,inputs=None,outputs=html_out)
1540
 
1541
  if __name__=="__main__":
1542
- print(f"[SYSTEM 19.3] Launching on 0.0.0.0:7860 | Compute: {DEVICE.type.upper()}")
1543
  demo.launch(server_name="0.0.0.0",server_port=7860,share=False)
 
1
  #!/usr/bin/env python3
2
  """
3
+ PRACTICALITY SYSTEM 20.0 β€” TRUE GPU SATURATION & PRECOMPILATION
4
  ═══════════════════════════════════════════════════════════════════
5
+ AIM:
6
+ To extract a true, LLM-readable structural isomorphism of a mathematical problem.
7
+
8
+ THE BOTTLENECK FIX (20.0):
9
+ In 19.3, large batch sizes starved the GPU because Python was doing heavy lifting
10
+ (SymPy parsing, string evaluation, dict sorting) inside the 12k loop.
11
+
12
+ System 20.0 implements True Parallelism:
13
+ 1. Pre-compilation: Anchors and Axiom properties (Bilinear/Monotone constants)
14
+ are parsed exactly ONCE at initialization.
15
+ 2. GPU Top-K Gradients: Python dict sorting is replaced by `torch.topk()` to
16
+ calculate allosteric tension vectors for all 12,288 rays simultaneously on GPU.
17
+ 3. Fast Tensor Build: CPU array generation is streamlined to feed PyTorch instantly.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  """
19
 
20
  import time, random, math, threading, warnings
 
32
  warnings.filterwarnings("ignore")
33
  USE_GPU = torch.cuda.is_available()
34
  DEVICE = torch.device("cuda" if USE_GPU else "cpu")
35
+ print(f"[SYSTEM 20.0] Compute: {DEVICE.type.upper()} | Engine: True GPU Saturation")
36
 
37
  # ══════════════════════════════════════════════════════════════════════
38
  # SECTION 1: CONSTANTS
 
49
  CE_EARN_RATIO = 0.90
50
  SCOUT_CE_THRESHOLD = 0.5
51
  BRANCH_WIDTH = 4
 
 
52
  BATON_REGISTRY_THRESHOLD = 2.0
53
+ BATON_REGISTRY_MAX = 5000
54
 
55
  # ══════════════════════════════════════════════════════════════════════
56
  # SECTION 2: INTERVAL ARITHMETIC (HC4)
 
127
  return cur
128
 
129
  def _global_hc4_tighten_bounds(problem):
 
130
  gb={v:IV(lo,hi) for v,(lo,hi) in problem.bounds.items()}
131
  c=_hc4(gb,problem.compiled_constraints)
132
  if c is None: return dict(problem.bounds)
 
134
  for v in problem.bounds if v in c}
135
 
136
  # ══════════════════════════════════════════════════════════════════════
137
+ # SECTION 3: PSL PARSER & PRE-COMPILATION
138
  # ══════════════════════════════════════════════════════════════════════
139
  @dataclass
140
  class PSLVar: name:str; lo:float; hi:float
 
222
  return ExpandedProblem(variables,bounds,constraints,dict(scope_groups),dict(scope_vars),prog.scope_order)
223
 
224
  @dataclass
225
+ class AXLInvariant:
226
+ name:str; expr:str; tolerance:float=VERIFY_G2_TOLERANCE; mode:str="eq"
227
+ compiled_func: Optional[Callable] = field(default=None, repr=False)
228
+ syms_used: List[str] = field(default_factory=list)
229
+
230
+ def compile(self, variables: List[str]):
231
+ """SYSTEM 20.0 FIX: Pre-compile anchors to avoid parsing inside the 12k batch loop"""
232
+ syms = {v: sp.Symbol(v) for v in variables}
233
+ parsed = parse_expr(self.expr, local_dict=syms)
234
+ self.syms_used = [str(s) for s in parsed.free_symbols if str(s) in variables]
235
+ self.compiled_func = sp.lambdify([sp.Symbol(v) for v in self.syms_used], parsed, modules="math")
236
 
237
  @dataclass
238
  class AXLProblemDef:
 
335
  scope_groups:Dict[str,List[int]]=field(default_factory=dict)
336
  scope_vars:Dict[str,List[str]]=field(default_factory=dict)
337
  scope_order:List[str]=field(default_factory=list)
338
+
339
+ # SYSTEM 20.0 PRECOMPILATION ARRAYS
340
+ bilinear_pairs: List[Tuple[str,str]] = field(default_factory=list)
341
+ monotone_targets: List[Tuple[str,str,float]] = field(default_factory=list)
342
 
343
  def __post_init__(self):
344
  self.compiled_constraints=[
345
  compile_mc(c.kind,c.expr,c.direction,self.variables,c.weight,c.scope,c.branches)
346
  for c in self.constraints]
347
  self.var_idx={v:i for i,v in enumerate(self.variables)}
348
+
349
+ # SYSTEM 20.0: Pre-extract structural signatures to avoid AST parsing in batch loops
350
+ ordered_pairs = []
351
+ for mc in self.compiled_constraints:
352
+ if mc.kind == "inequality" and mc.direction == "geq" and len(mc.syms_used) == 2:
353
+ ordered_pairs.append((mc.syms_used[0], mc.syms_used[1]))
354
+
355
+ for mc in self.compiled_constraints:
356
+ if mc.parsed and mc.parsed.is_Add:
357
+ for term in mc.parsed.args:
358
+ if term.is_Mul:
359
+ syms_in = [str(s) for s in term.free_symbols if str(s) in self.variables]
360
+ if len(syms_in) == 2:
361
+ va, vb = syms_in
362
+ if (va, vb) not in self.bilinear_pairs and (vb, va) not in self.bilinear_pairs:
363
+ self.bilinear_pairs.append((va, vb))
364
+ if mc.kind == "equality":
365
+ try:
366
+ const_part = mc.parsed - sp.Symbol(va)*sp.Symbol(vb)
367
+ k = float(-const_part.evalf())
368
+ if k > 0:
369
+ for vs, vl in ordered_pairs:
370
+ if set([va, vb]) == set([vs, vl]):
371
+ if (vs, vl, k) not in self.monotone_targets:
372
+ self.monotone_targets.append((vs, vl, k))
373
+ except: pass
374
 
375
  def tensor_energy(self,X:torch.Tensor) -> torch.Tensor:
376
  is_batched=(X.dim()==2)
 
426
  @dataclass
427
  class L9Certificate:
428
  residual_ce:float; dominant_vars:List[str]; dominant_exprs:List[str]
429
+ tension_class:str="unknown"
 
430
 
431
  def _batched_deduce_and_evaluate(
432
  problem:Problem,
433
  hyps:List['Hypothesis']) -> List[Tuple[Dict,float,List[str],str]]:
434
  """
435
  Naked Evaluation with Masked Adam.
436
+ SYSTEM 20.0 FIX: Optimized array building & PyTorch Top-K extraction
437
+ to bypass Python CPU loops over large batches.
438
  """
439
  if not hyps: return []
440
  B=len(hyps); V=len(problem.variables)
441
 
442
+ # Fast Python list building to avoid element-by-element tensor operations
443
+ x_data = []
444
+ mask_data = []
445
+ target_data = []
446
+ for hyp in hyps:
447
+ xr, mr, tr = [], [], []
448
+ for v in problem.variables:
 
449
  if v in hyp.pinned_vars:
450
+ val = hyp.pinned_vars[v]
451
+ xr.append(val); mr.append(0.0); tr.append(val)
452
+ else:
453
+ val = hyp.binding.get(v, (problem.bounds[v][0]+problem.bounds[v][1])/2)
454
+ xr.append(val); mr.append(1.0); tr.append(0.0)
455
+ x_data.append(xr); mask_data.append(mr); target_data.append(tr)
456
+
457
+ X = torch.tensor(x_data, device=DEVICE, dtype=torch.float32, requires_grad=True)
458
+ mask = torch.tensor(mask_data, device=DEVICE, dtype=torch.float32)
459
+ target = torch.tensor(target_data, device=DEVICE, dtype=torch.float32)
460
 
 
461
  optimizer=torch.optim.Adam([X],lr=0.05)
462
 
463
  for _ in range(DEDUCE_ADAM_STEPS):
 
478
  final_ce=problem.tensor_energy(X)
479
  final_ce.sum().backward()
480
 
481
+ ce_vals = final_ce.detach().cpu().numpy()
482
+ X_vals = X.detach().cpu().numpy()
483
+
484
+ # SYSTEM 20.0 FIX: GPU Top-K completely removes Python dictionary sorting overhead
485
+ grads_abs = X.grad.abs()
486
+ _, topk_idx = torch.topk(grads_abs, k=min(3, V), dim=1)
487
+ topk_idx_np = topk_idx.cpu().numpy()
488
+ grads_np = grads_abs.cpu().numpy()
489
 
490
  results=[]
491
  for i in range(B):
492
  final_b={problem.variables[j]:float(X_vals[i,j]) for j in range(V)}
493
+
494
+ # O(1) top-K gradient extraction per element
495
+ dom_vars = [problem.variables[idx] for idx in topk_idx_np[i] if float(grads_np[i, idx]) > 1e-4]
496
+ n_dom = len(dom_vars)
497
+
498
  if n_dom<=1: tension_class="isolated"
499
  elif n_dom==2: tension_class="relational"
500
  else: tension_class="systemic"
501
  results.append((final_b,float(ce_vals[i]),dom_vars,tension_class))
502
+
503
  return results
504
 
505
  def _mprt_sample(problem,work_box,N):
 
603
  resonant_pairs:List[Tuple[str,str]]=field(default_factory=list)
604
 
605
  # ══════════════════════════════════════════════════════════════════════
606
+ # SECTION 8: HYPOTHESIS CONSTRUCTORS (Pre-Compiled)
607
  # ══════════════════════════════════════════════════════════════════════
608
  def _make_hyp(hid,binding,h_type,claim,derivation,pinned,free,conf):
609
  return Hypothesis(hid=hid,binding=binding,h_type=h_type,claim=claim,
 
631
  return hyps
632
 
633
  def _hyp_bilinear(p,bt,a,m):
634
+ """SYSTEM 20.0 FIX: Uses pre-extracted bilinear pairs."""
 
 
 
 
635
  hyps=[]; b=dict(bt.binding)
636
+ for vi, vj in p.bilinear_pairs:
637
+ lo_i,hi_i=p.bounds.get(vi,(0,10)); lo_j,hi_j=p.bounds.get(vj,(0,10))
638
+ product=abs(b.get(vi,1)*b.get(vj,1))
639
+ if product<=0: continue
640
+ gm=math.sqrt(product)
641
+
642
+ if lo_i<=gm<=hi_i and lo_j<=gm<=hi_j:
643
+ nb=dict(b); nb[vi]=nb[vj]=gm
644
+ hyps.append(_make_hyp(f"bil_eq_{vi}_{vj}",nb,"bilinear",
645
+ f"GeoMean({vi}={vj}={gm:.3f})",["bilinear"],{vi:gm,vj:gm},
646
+ [v for v in p.variables if v not in [vi,vj]],0.70))
647
+
648
+ for ratio in [0.4, 0.7071, 0.9]:
649
+ vs=gm*ratio; vl=product/(vs+1e-9)
650
+ if lo_i<=vs<=hi_i and lo_j<=vl<=hi_j and vs<vl:
651
+ nb2=dict(b); nb2[vi]=vs; nb2[vj]=vl
652
+ hyps.append(_make_hyp(f"bil_asc_{int(ratio*100)}_{vi}_{vj}",nb2,"bilinear",
653
+ f"BilAsc({vi}={vs:.3f}<{vj}={vl:.3f})",["bilinear"],{vi:vs,vj:vl},
654
+ [v for v in p.variables if v not in [vi,vj]],0.75))
655
+ if lo_i<=vl<=hi_i and lo_j<=vs<=hi_j and vl>vs:
656
+ nb3=dict(b); nb3[vi]=vl; nb3[vj]=vs
657
+ hyps.append(_make_hyp(f"bil_desc_{int(ratio*100)}_{vi}_{vj}",nb3,"bilinear",
658
+ f"BilDesc({vi}={vl:.3f}>{vj}={vs:.3f})",["bilinear"],{vi:vl,vj:vs},
659
+ [v for v in p.variables if v not in [vi,vj]],0.75))
 
 
 
 
 
 
 
 
 
 
660
  return hyps
661
 
662
  def _hyp_monotone_product(p,bt,a,m):
663
+ """SYSTEM 20.0 FIX: Uses pre-extracted monotone targets."""
 
 
 
 
664
  hyps=[]; b=dict(bt.binding)
665
 
666
+ if not p.monotone_targets: return hyps
667
+ tb=_global_hc4_tighten_bounds(p)
 
 
 
668
 
669
+ for v_small, v_large, k in p.monotone_targets:
670
+ lo_s,hi_s=p.bounds.get(v_small,(-1e18,1e18))
671
+ lo_l,hi_l=p.bounds.get(v_large,(-1e18,1e18))
672
 
673
+ for ratio in [0.1,0.2,0.3,0.4,0.5,0.6,0.707,0.8,0.9,0.95]:
674
+ vs_sq=k*ratio
675
+ if vs_sq<=0: continue
676
+ vs=math.sqrt(vs_sq); vl=k/vs
677
+ if not(lo_s<=vs<=hi_s and lo_l<=vl<=hi_l and vs<=vl): continue
678
 
679
+ nb=dict(b); nb[v_small]=vs; nb[v_large]=vl
680
+
681
+ box={u:IV(*tb.get(u,p.bounds.get(u,(-10,10)))) for u in p.variables}
682
+ box[v_small]=IV(vs-1e-6,vs+1e-6)
683
+ box[v_large]=IV(vl-1e-6,vl+1e-6)
684
+ cont=_hc4(box,p.compiled_constraints)
685
+ pinned={v_small:vs,v_large:vl}
686
+ if cont:
687
+ for u,iv in cont.items():
688
+ if u in p.bounds: nb[u]=iv.mid()
689
+ pinned={u:nb[u] for u in p.variables if cont[u].width()<1e-2}
690
+
691
+ hyps.append(_make_hyp(
692
+ f"mpr_{v_small}_{v_large}_r{int(ratio*100)}",
693
+ nb,"monotone_product",
694
+ f"MonoProd({v_small}={vs:.4f}≀{v_large}={vl:.4f})",
695
+ ["ordered","hc4"],pinned,
696
+ [u for u in p.variables if u not in pinned],0.88))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
697
  return hyps
698
 
699
  def _hyp_metric(p,bt,a,m): return [_make_hyp("met",bt.binding,"metric","Radial",[],{},p.variables,0.75)]
 
791
  # ══════════════════════════════════════════════════════════════════════
792
  class CreativeSeeder:
793
  def target_seeds(self,anchors:List[AXLInvariant]) -> List[AxiomRay]:
 
794
  seeds=[]
795
  for a in anchors:
796
  if "*" in a.expr and "**" not in a.expr:
 
804
  return seeds
805
 
806
  def intelligent_branch(self,ray,out_baton,remaining_axioms,branch_width) -> List[AxiomRay]:
 
 
 
 
807
  dom_vars=out_baton.l9.dominant_vars if out_baton.l9 else []
808
  n_dom=len([v for v in dom_vars])
809
  isolated ={Axiom.ATOMIC,Axiom.EXTREMAL,Axiom.MUTABLE,Axiom.DUALITY,Axiom.LOCALITY}
 
888
  CREATIVE_SEEDER=CreativeSeeder()
889
 
890
  # ══════════════════════════════════════════════════════════════════════
891
+ # SECTION 10: VERIFY LAYER (SYSTEM 20.0 FIX: Pre-compiled lambda evaluation)
892
  # ══════════════════════════════════════════════════════════════════════
893
  def _verify(binding:Dict[str,float],base_problem:Problem,
894
  anchors:List[AXLInvariant]) -> Tuple[bool,bool,Dict[str,Tuple[float,bool]],float]:
 
897
  g2={}
898
  for inv in anchors:
899
  try:
900
+ if inv.compiled_func:
901
+ val = float(inv.compiled_func(*[binding.get(v, 0.0) for v in inv.syms_used]))
902
+ else:
903
+ val = 999.0 # Failsafe
904
+ err=abs(val)
905
  if inv.mode=="eq": passed=err<inv.tolerance
906
  elif inv.mode=="geq": passed=val>=-inv.tolerance
907
  elif inv.mode=="leq": passed=val<=inv.tolerance
 
912
  return g1_pass,g2_pass,g2,round(g1_ce,6)
913
 
914
  # ══════════════════════════════════════════════════════════════════════
915
+ # SECTION 11: SEQUENCE RAY TRACER
916
  # ══════════════════════════════════════════════════════════════════════
917
  class SequenceRayTracer:
918
  def trace(self,axl_def:AXLProblemDef,base_problem:Problem):
919
  hero_traces:List[HypothesisTrace]=[]
920
 
 
921
  baton_registry:Dict[str,Baton]={}
922
+ baton_registry_keys:deque=deque()
923
 
924
  successful_rays:List[AxiomRay]=[]
925
  resonant_pairs:List[Tuple[str,str]]=[]
926
 
927
+ # SYSTEM 20.0 FIX: Precompile anchors before 12k loop starts
928
+ for inv in axl_def.anchors:
929
+ if not inv.compiled_func:
930
+ inv.compile(base_problem.variables)
931
+
932
  init_b,init_ce=_mprt_sample(base_problem,
933
  {v:IV(*base_problem.bounds[v]) for v in base_problem.variables},N_MPRT_EXPLORE)
934
  seed_baton=Baton(binding=init_b,ce=init_ce,ray_id="SEED",
 
945
  best_ce=init_ce; best_binding=dict(init_b); total_fired=0
946
  model=StructuralModel(best_binding,best_ce)
947
 
 
948
  allosteric_counts={"isolated":0,"relational":0,"systemic":0}
949
 
950
  while total_fired<MAX_TOTAL_RAYS:
 
951
  batch_rays:List[AxiomRay]=[]
952
  for _ in range(RAY_BATCH_SIZE):
953
  start_idx=q_idx
 
962
  t0=time.time()
963
  historical_batons=list(baton_registry.values())
964
 
 
965
  batch_hyps:List[Tuple[int,Hypothesis]]=[]
966
  for i,ray in enumerate(batch_rays):
967
  p_baton=ray.baton or seed_baton
 
970
  if not hyps: hyps=[_make_hyp("fb",p_baton.binding,"fallback","Pass",[],{},base_problem.variables,0.1)]
971
  batch_hyps.append((i,hyps[0]))
972
 
 
973
  eval_results=_batched_deduce_and_evaluate(base_problem,[h for _,h in batch_hyps])
974
  elapsed_ms=(time.time()-t0)*1000/max(1,len(batch_rays))
975
 
 
983
  overall_pass=g1_pass and g2_pass
984
 
985
  improved=final_ce<best_ce
 
986
  if improved or overall_pass or random.random()<0.002:
987
  hero_traces.append(HypothesisTrace(
988
  hid=ray.ray_id,round_idx=total_fired-len(batch_rays)+ray_idx,
 
997
  out_baton=Baton(binding=final_b,ce=final_ce,ray_id=ray.ray_id,
998
  l9=L9Certificate(final_ce,dom_vars,[],tension_class))
999
 
 
1000
  if final_ce<BATON_REGISTRY_THRESHOLD:
1001
  if ray.ray_id in baton_registry:
1002
  baton_registry[ray.ray_id]=out_baton
 
1014
 
1015
  if overall_pass: solved=True
1016
 
 
1017
  if improved and len(ray.sequence)>=2:
1018
  pair=(ray.sequence[-2],ray.sequence[-1])
1019
  if pair not in resonant_pairs: resonant_pairs.append(pair)
 
1029
  and a not in ray.sequence]
1030
 
1031
  new_children:List[AxiomRay]=[]
 
1032
  new_children.extend(
1033
  CREATIVE_SEEDER.intelligent_branch(ray,out_baton,remaining,BRANCH_WIDTH))
1034
  inv=CREATIVE_SEEDER.invert(ray,final_ce)
1035
  if inv: new_children.append(inv)
1036
 
 
1037
  if len(successful_rays)>=2:
1038
  candidates=[r for r in successful_rays if r.ray_id!=ray.ray_id]
1039
  if candidates:
1040
  partner=random.choice(candidates)
 
1041
  ba=baton_registry.get(ray.ray_id,out_baton)
1042
  bb=baton_registry.get(partner.ray_id)
1043
+ if bb is not None:
1044
  new_children.extend(CREATIVE_SEEDER.recombine(ray,partner,ba,bb)[:3])
1045
 
1046
  new_children.extend(
 
1214
  STATE_LOCK = threading.Lock()
1215
  IS_RUNNING = False
1216
 
 
1217
  PROBLEM_STATS:Dict[str,Dict]={p.name:{
1218
  "runs":0,"solved":0,"total_ce":0.0,"best_ce":float('inf'),
1219
  "best_binding":{},"best_ray":"β€”",
 
1221
  "allosteric":{"isolated":0,"relational":0,"systemic":0},
1222
  } for p in AXL_PROBLEMS}
1223
 
1224
+ RECENT_RUNS:List[Dict]=[]
1225
  MAX_RECENT=30
1226
  _PROB_IDX=0
1227
 
 
1288
  global IS_RUNNING
1289
  IS_RUNNING=not IS_RUNNING
1290
  if IS_RUNNING: threading.Thread(target=background_worker,daemon=True).start()
1291
+ return "⏹ STOP 20.0" if IS_RUNNING else "β–Ά START 20.0"
1292
 
1293
  # ══════════════════════════════════════════════════════════════════════
1294
+ # SECTION 14: GRADIO DASHBOARD
1295
  # ══════════════════════════════════════════════════════════════════════
1296
  RAY_ICONS={"seed":"🌱","branch":"🌿","tension":"⚑","scout":"πŸ”­",
1297
  "recombine":"🧬","invert":"πŸ”„","target":"🎯"}
 
1456
  return f"""
1457
  <div style='background:#090909;color:#e0e0e0;font-family:monospace;padding:16px;max-width:1700px'>
1458
  <h2 style='color:#26C6DA;border-bottom:1px solid #1a1a1a;padding-bottom:5px;font-size:1.05em;margin:0 0 8px 0'>
1459
+ βš— Practicality 20.0 β€” True GPU Saturation
1460
  </h2>
1461
  <div style='color:#2a2a2a;font-size:0.70em;margin-bottom:10px'>
1462
+ Masked Adam (structural pins) Β· GPU Top-K Oracle β†’ Allosteric Feedback Β·
1463
+ Pre-Compiled Axioms & Anchors Β· 12K Batch Scale
1464
  </div>
1465
  <div style='margin-bottom:12px'>
1466
  <span style='display:inline-block;padding:2px 8px;border-radius:3px;background:#0e0e0e;margin:2px;font-size:0.72em;border:1px solid #1a1a1a;color:#aaa'>Runs: {runs}</span>
 
1473
 
1474
  <h4 style='color:#252525;font-size:0.78em;letter-spacing:2px;text-transform:uppercase;margin:16px 0 4px 0'>Creative Ray Type Efficacy</h4>
1475
  <table style='width:100%;border-collapse:collapse;margin-bottom:10px'>
1476
+ <tr style='color:#252525;font-size:0.68em'><th></th><th>Type</th><th>Tried</th><th>Survived</th><th>Failed</th><th>Rate</th><th>Mechanism (20.0)</th></tr>
1477
  {types}
1478
  </table>
1479
 
 
1498
  {recnt}
1499
  </div>"""
1500
 
1501
+ with gr.Blocks(theme=gr.themes.Monochrome(text_size="sm"),title="Practicality 20.0") as demo:
1502
+ gr.Markdown("## βš— Practicality 20.0 β€” True GPU Saturation")
1503
  gr.Markdown(
1504
  f"**Compute:** `{DEVICE.type.upper()}` | "
1505
+ f"**Fixes:** Pre-compiled Axiom ASTs Β· Pre-compiled Anchor Lambdas Β· GPU Top-K Gradients")
1506
 
1507
  with gr.Row():
1508
+ btn=gr.Button("β–Ά START 20.0",variant="primary")
1509
  gr.Markdown("*Engine cycles through 14 domains. Dashboard auto-refreshes every 2s.*")
1510
 
1511
  html_out=gr.HTML(refresh_dashboard())
 
1519
  demo.load(auto_refresh,inputs=None,outputs=html_out)
1520
 
1521
  if __name__=="__main__":
1522
+ print(f"[SYSTEM 20.0] Launching on 0.0.0.0:7860 | Compute: {DEVICE.type.upper()}")
1523
  demo.launch(server_name="0.0.0.0",server_port=7860,share=False)