Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,27 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
-
PRACTICALITY SYSTEM 27.
|
| 4 |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 5 |
-
REGRESSIONS FIXED FROM 27.
|
| 6 |
|
| 7 |
-
1. THE
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
|
| 13 |
-
2.
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
HERITAGE MAINTAINED:
|
| 19 |
All 17 domain templates. Original-Space Adam. Depth-0 Ray Expansion.
|
| 20 |
-
|
| 21 |
"""
|
| 22 |
|
| 23 |
import os, time, random, math, threading, warnings, json, textwrap, itertools, copy
|
|
@@ -48,7 +52,7 @@ GEMINI_MODEL = "gemini-3.5-flash"
|
|
| 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 27.
|
| 52 |
|
| 53 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 54 |
# SECTION 1: CONSTANTS & SAFE HELPERS
|
|
@@ -83,11 +87,11 @@ def safe_round(val, ndigits=8):
|
|
| 83 |
return round(val, ndigits)
|
| 84 |
except: return val
|
| 85 |
|
| 86 |
-
def
|
| 87 |
-
"""Clamps floats to
|
| 88 |
try:
|
| 89 |
-
if not math.isfinite(v): return
|
| 90 |
-
return max(-
|
| 91 |
except: return 0.0
|
| 92 |
|
| 93 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -404,9 +408,10 @@ def compile_mc(kind,expr_str,direction,variables,weight=1.0,scope="root",branche
|
|
| 404 |
if not isinstance(val, torch.Tensor):
|
| 405 |
val = torch.tensor(float(val), device=DEVICE, dtype=torch.float32)
|
| 406 |
except Exception:
|
| 407 |
-
# Shield: Catch
|
| 408 |
-
val = torch.tensor(
|
| 409 |
-
|
|
|
|
| 410 |
|
| 411 |
mc.torch_func=_t_wrapper
|
| 412 |
if kind=="equality":
|
|
@@ -527,7 +532,7 @@ class Problem:
|
|
| 527 |
elif mc.direction=="geq": total+=(torch.relu(-val)**2)*eff_weight
|
| 528 |
else: total+=(torch.relu(val)**2)*eff_weight
|
| 529 |
for i,v in enumerate(self.variables):
|
| 530 |
-
lo,hi=
|
| 531 |
col=X[:,i] if is_batched else X[i]
|
| 532 |
margin=(hi-lo)*0.1*(1.0-step_ratio)
|
| 533 |
out_of_bounds=torch.relu(lo-margin-col)+torch.relu(col-(hi+margin))
|
|
@@ -535,7 +540,7 @@ class Problem:
|
|
| 535 |
|
| 536 |
if is_optimizing and self.minimize_var and self.minimize_var in self.var_idx:
|
| 537 |
midx = self.var_idx[self.minimize_var]
|
| 538 |
-
lo,hi =
|
| 539 |
rng = max(hi-lo, 1e-8)
|
| 540 |
col = X[:,midx] if is_batched else X[midx]
|
| 541 |
normalized = (col - lo) / rng
|
|
@@ -544,7 +549,7 @@ class Problem:
|
|
| 544 |
return total.view(batch_size,-1).sum(dim=1)
|
| 545 |
|
| 546 |
def scalar_energy(self, b: Dict[str,float]) -> float:
|
| 547 |
-
x_arr=[b.get(v,(
|
| 548 |
X_t=torch.tensor(x_arr,device=DEVICE,dtype=torch.float32).unsqueeze(0)
|
| 549 |
with torch.no_grad():
|
| 550 |
return float(self.tensor_energy(X_t, step_ratio=1.0, is_optimizing=False).item())
|
|
@@ -1672,12 +1677,12 @@ def _batched_deduce_and_evaluate(problem, hyps: List['Hypothesis']) -> List[Tupl
|
|
| 1672 |
xr, mr, tr = [], [], []
|
| 1673 |
active_vars=problem.get_markov_blanket(set(hyp.pinned_vars.keys()), depth=2)
|
| 1674 |
for j,v in enumerate(problem.variables):
|
| 1675 |
-
lo,hi=
|
| 1676 |
if v in hyp.pinned_vars:
|
| 1677 |
-
val=
|
| 1678 |
xr.append(val); mr.append(0.0); tr.append(val)
|
| 1679 |
else:
|
| 1680 |
-
val=
|
| 1681 |
is_active=(v in active_vars) or (len(hyp.pinned_vars)==0)
|
| 1682 |
xr.append(val); mr.append(1.0 if is_active else 0.0); tr.append(0.0)
|
| 1683 |
x_data.append(xr); mask_data.append(mr); target_data.append(tr)
|
|
@@ -1703,7 +1708,7 @@ def _batched_deduce_and_evaluate(problem, hyps: List['Hypothesis']) -> List[Tupl
|
|
| 1703 |
optimizer.step()
|
| 1704 |
X.data = torch.where(mask == 0.0, target, X.data)
|
| 1705 |
for j, v in enumerate(problem.variables):
|
| 1706 |
-
lo, hi =
|
| 1707 |
margin = (hi - lo) * 0.1 * (1.0 - step_ratio)
|
| 1708 |
X.data[:, j] = torch.clamp(X.data[:, j], lo - margin, hi + margin)
|
| 1709 |
|
|
@@ -1729,8 +1734,8 @@ def _batched_deduce_and_evaluate(problem, hyps: List['Hypothesis']) -> List[Tupl
|
|
| 1729 |
|
| 1730 |
def _mprt_sample(problem, work_box, N):
|
| 1731 |
var_list=problem.variables; V=len(var_list)
|
| 1732 |
-
lo_t=torch.tensor([
|
| 1733 |
-
hi_t=torch.tensor([
|
| 1734 |
for i in range(V):
|
| 1735 |
if lo_t[i]>=hi_t[i]: m=(lo_t[i]+hi_t[i])/2; lo_t[i]=m-1e-6; hi_t[i]=m+1e-6
|
| 1736 |
X=lo_t.unsqueeze(0)+(hi_t-lo_t).unsqueeze(0)*torch.rand((N,V), device=DEVICE)
|
|
@@ -2135,6 +2140,7 @@ class SequenceRayTracer:
|
|
| 2135 |
model=StructuralModel(best_binding,best_ce); total_fired=0; solved=False
|
| 2136 |
seed_baton=Baton(binding=best_binding,ce=best_ce,ray_id="SEED",
|
| 2137 |
l9=L9Certificate(best_ce,base_problem.variables[:3],[],"systemic"))
|
|
|
|
| 2138 |
|
| 2139 |
while total_fired<MAX_RAYS_PER_ATTEMPT and GLOBAL_SOLVE_STATE["is_running"]:
|
| 2140 |
if not queues["core"]:
|
|
@@ -2162,19 +2168,28 @@ class SequenceRayTracer:
|
|
| 2162 |
g1_pass,g2_pass,inv_results,_=_verify(final_b,base_problem,axl_def.anchors)
|
| 2163 |
improved=final_ce<best_ce; passed_pruning=final_ce<parent_ce*CE_EARN_RATIO
|
| 2164 |
|
| 2165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2166 |
with STATE_LOCK:
|
|
|
|
| 2167 |
GLOBAL_SOLVE_STATE["recent_traces"].append(HypothesisTrace(
|
| 2168 |
-
hid=ray.ray_id,round_idx=total_fired,ray_name=
|
| 2169 |
-
ray_type=ray.ray_type,
|
|
|
|
| 2170 |
survived=(g1_pass and g2_pass),elapsed_ms=0.0,
|
| 2171 |
g1_pass=g1_pass,g2_pass=g2_pass,binding=final_b,
|
| 2172 |
invariant_results=inv_results,tension_class=tension_class,depth=ray.depth))
|
|
|
|
| 2173 |
|
| 2174 |
out_baton=Baton(binding=final_b,ce=final_ce,ray_id=ray.ray_id,
|
| 2175 |
l9=L9Certificate(final_ce,dom_vars,[],tension_class))
|
| 2176 |
|
| 2177 |
-
|
|
|
|
|
|
|
| 2178 |
if final_ce < dynamic_baton_thresh:
|
| 2179 |
baton_registry[ray.ray_id] = out_baton
|
| 2180 |
if len(baton_registry) > BATON_REGISTRY_MAX:
|
|
@@ -2245,7 +2260,7 @@ OUTPUT SCHEMA (JSON only, no markdown):
|
|
| 2245 |
RULES: USE ** FOR EXPONENTS. NEVER USE ^. No =, >=, <= inside expressions.
|
| 2246 |
EQ/GEQ/LEQ are expression's relation to zero. Output ONLY the JSON object."""
|
| 2247 |
|
| 2248 |
-
COLLAPSER_SYSTEM_PROMPT = """You are the Grounded Hypothesis Engine for Practicality 27.
|
| 2249 |
|
| 2250 |
Check infeasibility_report first. If non-empty: the system proved infeasibility via
|
| 2251 |
algebraic propagation before firing any rays. Output:
|
|
@@ -2651,10 +2666,10 @@ def _reset_ans_cache(a_cache):
|
|
| 2651 |
return a_cache
|
| 2652 |
|
| 2653 |
# ββ Gradio App ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 2654 |
-
with gr.Blocks(css=CSS, title="Practicality 27.
|
| 2655 |
gr.Markdown(
|
| 2656 |
-
"## β Practicality 27.
|
| 2657 |
-
"`[Direct Parser / LLM] -> [INT Grid] -> [
|
| 2658 |
)
|
| 2659 |
|
| 2660 |
dash_cache = gr.State({"html": ""})
|
|
@@ -2701,13 +2716,16 @@ with gr.Blocks(css=CSS, title="Practicality 27.4") as demo:
|
|
| 2701 |
value=(f"Compute: {DEVICE.type.upper()}\n"
|
| 2702 |
f"Axioms: {len(ALL_AXIOMS)}\n"
|
| 2703 |
f"Templates: {len(STRUCTURAL_HYPOTHESIS_TEMPLATES)}\n"
|
| 2704 |
-
f"\n27.
|
| 2705 |
-
f" β
|
| 2706 |
-
f"
|
| 2707 |
-
f"
|
| 2708 |
-
f" β
|
| 2709 |
-
f"
|
| 2710 |
-
f"
|
|
|
|
|
|
|
|
|
|
| 2711 |
f" ray.depth < 1 unconditional branching.\n"
|
| 2712 |
f" MINIMIZE Soft Objectives (isolated)\n"
|
| 2713 |
f" Range-normalized Adam reverted to orig space.\n"
|
|
@@ -2739,15 +2757,15 @@ with gr.Blocks(css=CSS, title="Practicality 27.4") as demo:
|
|
| 2739 |
outputs=[live_html,dash_cache,ans_cache],
|
| 2740 |
js="""
|
| 2741 |
function() {
|
| 2742 |
-
if (!window.
|
| 2743 |
-
window.
|
| 2744 |
const el = document.getElementById('dash_poll_btn');
|
| 2745 |
if (!el) return;
|
| 2746 |
(el.tagName === 'BUTTON' ? el : el.querySelector('button'))?.click();
|
| 2747 |
}, 1000);
|
| 2748 |
}
|
| 2749 |
-
if (!window.
|
| 2750 |
-
window.
|
| 2751 |
const el = document.getElementById('ans_poll_btn');
|
| 2752 |
if (!el) return;
|
| 2753 |
(el.tagName === 'BUTTON' ? el : el.querySelector('button'))?.click();
|
|
@@ -2785,11 +2803,11 @@ with gr.Blocks(css=CSS, title="Practicality 27.4") as demo:
|
|
| 2785 |
outputs=[ans_cache])
|
| 2786 |
|
| 2787 |
gr.Markdown(
|
| 2788 |
-
f"Practicality 27.
|
| 2789 |
elem_classes=["status-bar"])
|
| 2790 |
|
| 2791 |
if __name__ == "__main__":
|
| 2792 |
-
print(f"[SYSTEM 27.
|
| 2793 |
-
print(f"[SYSTEM 27.
|
| 2794 |
-
print(f"[SYSTEM 27.
|
| 2795 |
demo.launch(server_name="0.0.0.0", server_port=7860, share=False)
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
"""
|
| 3 |
+
PRACTICALITY SYSTEM 27.5 β THE GRADIENT-PRESERVING CORE
|
| 4 |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 5 |
+
REGRESSIONS FIXED FROM 27.4:
|
| 6 |
|
| 7 |
+
1. THE FLOAT32 ERASURE TRAP (1e15 -> 1e5)
|
| 8 |
+
Clamping errors to 1e15 resulted in L2 losses of 1e30. In float32,
|
| 9 |
+
adding a gradient of 1e4 to 1e30 results in 1e30 (the gradient is
|
| 10 |
+
erased by floating point limits). Clamping is now 1e5, yielding
|
| 11 |
+
a max penalty of 1e10, strictly preserving Adam's gradients.
|
| 12 |
|
| 13 |
+
2. BATON REGISTRY DEATH LOOP
|
| 14 |
+
A high initial CE resulted in a massive dynamic registry threshold,
|
| 15 |
+
causing every garbage ray to be saved and infinitely re-seeded.
|
| 16 |
+
The registry is now strictly hard-capped to never accept CE > 100,000.
|
| 17 |
+
|
| 18 |
+
3. UI RAY TRANSPARENCY
|
| 19 |
+
If the solver is trapped on a plateau, the UI will now force-display
|
| 20 |
+
a [SCOUT] ray every 2,000 iterations to prove the axioms are firing.
|
| 21 |
|
| 22 |
HERITAGE MAINTAINED:
|
| 23 |
All 17 domain templates. Original-Space Adam. Depth-0 Ray Expansion.
|
| 24 |
+
Decoupled MINIMIZE. Proxy Decomposition. Fail-Fast execution.
|
| 25 |
"""
|
| 26 |
|
| 27 |
import os, time, random, math, threading, warnings, json, textwrap, itertools, copy
|
|
|
|
| 52 |
warnings.filterwarnings("ignore")
|
| 53 |
USE_GPU = torch.cuda.is_available()
|
| 54 |
DEVICE = torch.device("cuda" if USE_GPU else "cpu")
|
| 55 |
+
print(f"[SYSTEM 27.5] Compute: {DEVICE.type.upper()} | Gradient-Preserving Core")
|
| 56 |
|
| 57 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 58 |
# SECTION 1: CONSTANTS & SAFE HELPERS
|
|
|
|
| 87 |
return round(val, ndigits)
|
| 88 |
except: return val
|
| 89 |
|
| 90 |
+
def _c5(v):
|
| 91 |
+
"""Clamps floats to 1e5 so PyTorch MSE (1e10) doesn't erase float32 gradients."""
|
| 92 |
try:
|
| 93 |
+
if not math.isfinite(v): return 1e5 if v > 0 else -1e5
|
| 94 |
+
return max(-1e5, min(1e5, float(v)))
|
| 95 |
except: return 0.0
|
| 96 |
|
| 97 |
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 408 |
if not isinstance(val, torch.Tensor):
|
| 409 |
val = torch.tensor(float(val), device=DEVICE, dtype=torch.float32)
|
| 410 |
except Exception:
|
| 411 |
+
# Shield: Catch mathematically invalid domains (e.g. log(-1)) and clamp to 1e5
|
| 412 |
+
val = torch.tensor(1e5, device=DEVICE, dtype=torch.float32)
|
| 413 |
+
# Replace NaNs with 1e5 so (1e5)^2 = 1e10 maintains gradients without overflowing
|
| 414 |
+
return torch.nan_to_num(val, posinf=1e5, neginf=-1e5, nan=1e5)
|
| 415 |
|
| 416 |
mc.torch_func=_t_wrapper
|
| 417 |
if kind=="equality":
|
|
|
|
| 532 |
elif mc.direction=="geq": total+=(torch.relu(-val)**2)*eff_weight
|
| 533 |
else: total+=(torch.relu(val)**2)*eff_weight
|
| 534 |
for i,v in enumerate(self.variables):
|
| 535 |
+
lo,hi=_c5(self.bounds[v][0]),_c5(self.bounds[v][1])
|
| 536 |
col=X[:,i] if is_batched else X[i]
|
| 537 |
margin=(hi-lo)*0.1*(1.0-step_ratio)
|
| 538 |
out_of_bounds=torch.relu(lo-margin-col)+torch.relu(col-(hi+margin))
|
|
|
|
| 540 |
|
| 541 |
if is_optimizing and self.minimize_var and self.minimize_var in self.var_idx:
|
| 542 |
midx = self.var_idx[self.minimize_var]
|
| 543 |
+
lo,hi = _c5(self.bounds[self.minimize_var][0]), _c5(self.bounds[self.minimize_var][1])
|
| 544 |
rng = max(hi-lo, 1e-8)
|
| 545 |
col = X[:,midx] if is_batched else X[midx]
|
| 546 |
normalized = (col - lo) / rng
|
|
|
|
| 549 |
return total.view(batch_size,-1).sum(dim=1)
|
| 550 |
|
| 551 |
def scalar_energy(self, b: Dict[str,float]) -> float:
|
| 552 |
+
x_arr=[b.get(v,(_c5(self.bounds.get(v,(-1,1))[0])+_c5(self.bounds.get(v,(-1,1))[1]))/2) for v in self.variables]
|
| 553 |
X_t=torch.tensor(x_arr,device=DEVICE,dtype=torch.float32).unsqueeze(0)
|
| 554 |
with torch.no_grad():
|
| 555 |
return float(self.tensor_energy(X_t, step_ratio=1.0, is_optimizing=False).item())
|
|
|
|
| 1677 |
xr, mr, tr = [], [], []
|
| 1678 |
active_vars=problem.get_markov_blanket(set(hyp.pinned_vars.keys()), depth=2)
|
| 1679 |
for j,v in enumerate(problem.variables):
|
| 1680 |
+
lo,hi=_c5(problem.bounds[v][0]),_c5(problem.bounds[v][1])
|
| 1681 |
if v in hyp.pinned_vars:
|
| 1682 |
+
val=_c5(hyp.pinned_vars[v])
|
| 1683 |
xr.append(val); mr.append(0.0); tr.append(val)
|
| 1684 |
else:
|
| 1685 |
+
val=_c5(hyp.binding.get(v,(lo+hi)/2))
|
| 1686 |
is_active=(v in active_vars) or (len(hyp.pinned_vars)==0)
|
| 1687 |
xr.append(val); mr.append(1.0 if is_active else 0.0); tr.append(0.0)
|
| 1688 |
x_data.append(xr); mask_data.append(mr); target_data.append(tr)
|
|
|
|
| 1708 |
optimizer.step()
|
| 1709 |
X.data = torch.where(mask == 0.0, target, X.data)
|
| 1710 |
for j, v in enumerate(problem.variables):
|
| 1711 |
+
lo, hi = _c5(problem.bounds[v][0]), _c5(problem.bounds[v][1])
|
| 1712 |
margin = (hi - lo) * 0.1 * (1.0 - step_ratio)
|
| 1713 |
X.data[:, j] = torch.clamp(X.data[:, j], lo - margin, hi + margin)
|
| 1714 |
|
|
|
|
| 1734 |
|
| 1735 |
def _mprt_sample(problem, work_box, N):
|
| 1736 |
var_list=problem.variables; V=len(var_list)
|
| 1737 |
+
lo_t=torch.tensor([_c5(max(problem.bounds.get(v,(-10.0,10.0))[0], work_box[v].lo if v in work_box else problem.bounds.get(v,(-10,10))[0])) for v in var_list], device=DEVICE, dtype=torch.float32)
|
| 1738 |
+
hi_t=torch.tensor([_c5(min(problem.bounds.get(v,(-10.0,10.0))[1], work_box[v].hi if v in work_box else problem.bounds.get(v,(-10,10))[1])) for v in var_list], device=DEVICE, dtype=torch.float32)
|
| 1739 |
for i in range(V):
|
| 1740 |
if lo_t[i]>=hi_t[i]: m=(lo_t[i]+hi_t[i])/2; lo_t[i]=m-1e-6; hi_t[i]=m+1e-6
|
| 1741 |
X=lo_t.unsqueeze(0)+(hi_t-lo_t).unsqueeze(0)*torch.rand((N,V), device=DEVICE)
|
|
|
|
| 2140 |
model=StructuralModel(best_binding,best_ce); total_fired=0; solved=False
|
| 2141 |
seed_baton=Baton(binding=best_binding,ce=best_ce,ray_id="SEED",
|
| 2142 |
l9=L9Certificate(best_ce,base_problem.variables[:3],[],"systemic"))
|
| 2143 |
+
last_ui_update_fired = 0
|
| 2144 |
|
| 2145 |
while total_fired<MAX_RAYS_PER_ATTEMPT and GLOBAL_SOLVE_STATE["is_running"]:
|
| 2146 |
if not queues["core"]:
|
|
|
|
| 2168 |
g1_pass,g2_pass,inv_results,_=_verify(final_b,base_problem,axl_def.anchors)
|
| 2169 |
improved=final_ce<best_ce; passed_pruning=final_ce<parent_ce*CE_EARN_RATIO
|
| 2170 |
|
| 2171 |
+
# UI Trace Visibility: Show improvements, passing states, or force a scout ray every 2k shots
|
| 2172 |
+
# so the user knows the engine hasn't frozen on a flatland plateau.
|
| 2173 |
+
force_ui_scout = not improved and not passed_pruning and (total_fired - last_ui_update_fired > 2000)
|
| 2174 |
+
|
| 2175 |
+
if improved or (g1_pass and g2_pass) or passed_pruning or force_ui_scout:
|
| 2176 |
with STATE_LOCK:
|
| 2177 |
+
display_name = f"[SCOUT] {ray.name}" if force_ui_scout else ray.name
|
| 2178 |
GLOBAL_SOLVE_STATE["recent_traces"].append(HypothesisTrace(
|
| 2179 |
+
hid=ray.ray_id,round_idx=total_fired,ray_name=display_name,
|
| 2180 |
+
ray_type="scout" if force_ui_scout else ray.ray_type,
|
| 2181 |
+
ce_before=parent_ce,ce_after=final_ce,
|
| 2182 |
survived=(g1_pass and g2_pass),elapsed_ms=0.0,
|
| 2183 |
g1_pass=g1_pass,g2_pass=g2_pass,binding=final_b,
|
| 2184 |
invariant_results=inv_results,tension_class=tension_class,depth=ray.depth))
|
| 2185 |
+
if force_ui_scout: last_ui_update_fired = total_fired
|
| 2186 |
|
| 2187 |
out_baton=Baton(binding=final_b,ce=final_ce,ray_id=ray.ray_id,
|
| 2188 |
l9=L9Certificate(final_ce,dom_vars,[],tension_class))
|
| 2189 |
|
| 2190 |
+
# DYNAMIC BATON REGISTRY: Cap the threshold to 100,000 so flatland garbage
|
| 2191 |
+
# doesn't flood the registry and cause endless re-seeding loops.
|
| 2192 |
+
dynamic_baton_thresh = min(100000.0, max(BATON_REGISTRY_THRESHOLD, best_ce * 1.5, init_ce * 0.1))
|
| 2193 |
if final_ce < dynamic_baton_thresh:
|
| 2194 |
baton_registry[ray.ray_id] = out_baton
|
| 2195 |
if len(baton_registry) > BATON_REGISTRY_MAX:
|
|
|
|
| 2260 |
RULES: USE ** FOR EXPONENTS. NEVER USE ^. No =, >=, <= inside expressions.
|
| 2261 |
EQ/GEQ/LEQ are expression's relation to zero. Output ONLY the JSON object."""
|
| 2262 |
|
| 2263 |
+
COLLAPSER_SYSTEM_PROMPT = """You are the Grounded Hypothesis Engine for Practicality 27.5.
|
| 2264 |
|
| 2265 |
Check infeasibility_report first. If non-empty: the system proved infeasibility via
|
| 2266 |
algebraic propagation before firing any rays. Output:
|
|
|
|
| 2666 |
return a_cache
|
| 2667 |
|
| 2668 |
# ββ Gradio App ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 2669 |
+
with gr.Blocks(css=CSS, title="Practicality 27.5") as demo:
|
| 2670 |
gr.Markdown(
|
| 2671 |
+
"## β Practicality 27.5 β The Gradient-Preserving Core\n"
|
| 2672 |
+
"`[Direct Parser / LLM] -> [INT Grid] -> [1e5 Shield Adam] -> [No Death Loops]`"
|
| 2673 |
)
|
| 2674 |
|
| 2675 |
dash_cache = gr.State({"html": ""})
|
|
|
|
| 2716 |
value=(f"Compute: {DEVICE.type.upper()}\n"
|
| 2717 |
f"Axioms: {len(ALL_AXIOMS)}\n"
|
| 2718 |
f"Templates: {len(STRUCTURAL_HYPOTHESIS_TEMPLATES)}\n"
|
| 2719 |
+
f"\n27.5 UPDATES (Gradient-Preserving):\n"
|
| 2720 |
+
f" β 1e5 SHIELD: Fixed the 2e31 Flatland Bug.\n"
|
| 2721 |
+
f" PyTorch now preserves gradients without \n"
|
| 2722 |
+
f" erasing them via float32 limits.\n"
|
| 2723 |
+
f" β BATON CAP: High-CE garbage is no longer\n"
|
| 2724 |
+
f" saved, killing the re-seed loop.\n"
|
| 2725 |
+
f" β SCOUT RAYS: UI forces a trace update\n"
|
| 2726 |
+
f" every 2,000 rays to prove execution.\n"
|
| 2727 |
+
f"\n27.4 FEATURES RETAINED:\n"
|
| 2728 |
+
f" Fail-Fast execution (No retries)\n"
|
| 2729 |
f" ray.depth < 1 unconditional branching.\n"
|
| 2730 |
f" MINIMIZE Soft Objectives (isolated)\n"
|
| 2731 |
f" Range-normalized Adam reverted to orig space.\n"
|
|
|
|
| 2757 |
outputs=[live_html,dash_cache,ans_cache],
|
| 2758 |
js="""
|
| 2759 |
function() {
|
| 2760 |
+
if (!window._p275_dash) {
|
| 2761 |
+
window._p275_dash = setInterval(() => {
|
| 2762 |
const el = document.getElementById('dash_poll_btn');
|
| 2763 |
if (!el) return;
|
| 2764 |
(el.tagName === 'BUTTON' ? el : el.querySelector('button'))?.click();
|
| 2765 |
}, 1000);
|
| 2766 |
}
|
| 2767 |
+
if (!window._p275_ans) {
|
| 2768 |
+
window._p275_ans = setInterval(() => {
|
| 2769 |
const el = document.getElementById('ans_poll_btn');
|
| 2770 |
if (!el) return;
|
| 2771 |
(el.tagName === 'BUTTON' ? el : el.querySelector('button'))?.click();
|
|
|
|
| 2803 |
outputs=[ans_cache])
|
| 2804 |
|
| 2805 |
gr.Markdown(
|
| 2806 |
+
f"Practicality 27.5 Β· Gradient-Preserving Core Β· Float32 Erasure Fixed",
|
| 2807 |
elem_classes=["status-bar"])
|
| 2808 |
|
| 2809 |
if __name__ == "__main__":
|
| 2810 |
+
print(f"[SYSTEM 27.5] Compute: {DEVICE.type.upper()} | Quantum={HAS_QUANTUM}")
|
| 2811 |
+
print(f"[SYSTEM 27.5] Templates: {len(STRUCTURAL_HYPOTHESIS_TEMPLATES)}")
|
| 2812 |
+
print(f"[SYSTEM 27.5] Fixes: 1e5 shield preserves float32 gradients. Registry hard-capped.")
|
| 2813 |
demo.launch(server_name="0.0.0.0", server_port=7860, share=False)
|