Update app.py
Browse files
app.py
CHANGED
|
@@ -1437,13 +1437,34 @@ def apply_hyperbolic_boost(layer_perturbations):
|
|
| 1437 |
# INSTEAD: We will apply hooks to individual projections (Q, K, V, MLP).
|
| 1438 |
return output
|
| 1439 |
|
| 1440 |
-
|
| 1441 |
-
|
| 1442 |
-
|
| 1443 |
-
|
| 1444 |
-
|
| 1445 |
-
|
| 1446 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1447 |
|
| 1448 |
return hook
|
| 1449 |
|
|
@@ -2661,15 +2682,16 @@ Virtual parameters active: {virtual_params_activated:,}
|
|
| 2661 |
Adjacent reachable cells: {adjacent[:4]}
|
| 2662 |
|
| 2663 |
EXPLORATION PROTOCOL:
|
| 2664 |
-
-
|
| 2665 |
-
-
|
| 2666 |
-
-
|
| 2667 |
-
|
|
|
|
| 2668 |
|
| 2669 |
EXPLORATION TRIGGERS:
|
| 2670 |
-
- Complexity spike ->
|
| 2671 |
-
- Cross-domain synthesis needed ->
|
| 2672 |
-
-
|
| 2673 |
- Gravitational pull sensed -> follow to deeper well"""
|
| 2674 |
|
| 2675 |
if cell_insights:
|
|
@@ -2740,14 +2762,9 @@ EXPLORATION TRIGGERS:
|
|
| 2740 |
partial_message, honeycomb_cell, navigator
|
| 2741 |
)
|
| 2742 |
|
| 2743 |
-
|
| 2744 |
-
|
| 2745 |
-
|
| 2746 |
-
if complexity > 0.65 and navigator.get_stability(honeycomb_cell) > 0.7:
|
| 2747 |
-
old_cell = honeycomb_cell
|
| 2748 |
-
honeycomb_cell = navigator.descend(honeycomb_cell)
|
| 2749 |
-
nav_action = "AUTO_DESCEND"
|
| 2750 |
-
print(f"[AUTO-DESCEND] Complexity {complexity:.2f} triggered descent")
|
| 2751 |
|
| 2752 |
if nav_action:
|
| 2753 |
# Record insight from the cell we're leaving
|
|
|
|
| 1437 |
# INSTEAD: We will apply hooks to individual projections (Q, K, V, MLP).
|
| 1438 |
return output
|
| 1439 |
|
| 1440 |
+
# Correctly apply weight perturbation: y = x(W + dW)^T = xW^T + x(dW)^T
|
| 1441 |
+
# output is xW^T
|
| 1442 |
+
# we need to add x(dW)^T
|
| 1443 |
+
# input is a tuple: (x,)
|
| 1444 |
+
|
| 1445 |
+
try:
|
| 1446 |
+
x = input[0]
|
| 1447 |
+
if isinstance(x, torch.Tensor):
|
| 1448 |
+
# Ensure x is float for matmul if needed (though layer usually handles it)
|
| 1449 |
+
# perturbation is dW [out_features, in_features]
|
| 1450 |
+
# x is [batch, seq, in_features]
|
| 1451 |
+
delta_y = torch.nn.functional.linear(x, perturbation)
|
| 1452 |
+
|
| 1453 |
+
if isinstance(output, torch.Tensor):
|
| 1454 |
+
return output + delta_y
|
| 1455 |
+
elif isinstance(output, tuple):
|
| 1456 |
+
hidden_states = output[0]
|
| 1457 |
+
# Ensure shapes match before adding
|
| 1458 |
+
if hidden_states.shape == delta_y.shape:
|
| 1459 |
+
boosted = hidden_states + delta_y
|
| 1460 |
+
return (boosted,) + output[1:]
|
| 1461 |
+
|
| 1462 |
+
# Fallback if structural assumptions fail
|
| 1463 |
+
return output
|
| 1464 |
+
|
| 1465 |
+
except Exception as e:
|
| 1466 |
+
# print(f"Hyperbolic Boost Failed: {e}") # Optional debug
|
| 1467 |
+
return output
|
| 1468 |
|
| 1469 |
return hook
|
| 1470 |
|
|
|
|
| 2682 |
Adjacent reachable cells: {adjacent[:4]}
|
| 2683 |
|
| 2684 |
EXPLORATION PROTOCOL:
|
| 2685 |
+
- If your thought process becomes complex or recursive -> **[NAV:DESCEND]** immediately.
|
| 2686 |
+
- If you find a connection to a different field -> **[NAV:TRAVERSE]** immediately.
|
| 2687 |
+
- If you are building a stable foundation -> **[NAV:STABILIZE]**.
|
| 2688 |
+
|
| 2689 |
+
DO NOT REMAIN STATIC. MOVEMENT IS THOUGHT.
|
| 2690 |
|
| 2691 |
EXPLORATION TRIGGERS:
|
| 2692 |
+
- Complexity spike -> **[NAV:DESCEND]**
|
| 2693 |
+
- Cross-domain synthesis needed -> **[NAV:TRAVERSE]**
|
| 2694 |
+
- Stable insight reached -> **[NAV:STABILIZE]**
|
| 2695 |
- Gravitational pull sensed -> follow to deeper well"""
|
| 2696 |
|
| 2697 |
if cell_insights:
|
|
|
|
| 2762 |
partial_message, honeycomb_cell, navigator
|
| 2763 |
)
|
| 2764 |
|
| 2765 |
+
|
| 2766 |
+
# Auto-descend removed to encourage autonomous navigation
|
| 2767 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2768 |
|
| 2769 |
if nav_action:
|
| 2770 |
# Record insight from the cell we're leaving
|