CharlesCNorton commited on
Commit ·
947a44b
1
Parent(s): 7ed141b
neural_attractor: tighten the README section and module docstring to a plain technical description (energy form, gate gadgets, clamped-subset modes, exactness and NP-hardness of the search modes)
Browse files- README.md +32 -34
- src/attractor.py +16 -32
README.md
CHANGED
|
@@ -457,40 +457,38 @@ noise margins. The processor is no longer *described by* a neural network; it
|
|
| 457 |
|
| 458 |
---
|
| 459 |
|
| 460 |
-
## neural_attractor — computation as
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
threshold neuron
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
Each gate
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
-
|
| 483 |
-
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
| 488 |
-
|
| 489 |
-
The
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
state sits at energy 0 by construction rather than being approximated by an
|
| 493 |
-
analog annealer, is the interesting place to attack it.
|
| 494 |
|
| 495 |
```bash
|
| 496 |
python tools/build_attractor.py # compile a multiplier to variants/neural_attractor.safetensors
|
|
|
|
| 457 |
|
| 458 |
---
|
| 459 |
|
| 460 |
+
## neural_attractor — computation as energy relaxation
|
| 461 |
+
|
| 462 |
+
An energy-based threshold network with no program counter, clock, or instruction
|
| 463 |
+
stream. A Boolean circuit compiles to a quadratic energy
|
| 464 |
+
`E(s) = sum_i L[i] s_i + sum_{i<j} Q[i,j] s_i s_j` over binary wire variables such
|
| 465 |
+
that, with any chosen subset of wires clamped, the circuit's consistent
|
| 466 |
+
assignment is the global minimum. The coupling matrix `Q` and linear terms `L`
|
| 467 |
+
are the program; execution is relaxation toward the minimum. The relaxation step
|
| 468 |
+
is a threshold neuron over the same integer weights,
|
| 469 |
+
`s_i <- H(-(L[i] + sum_j Q[i,j] s_j))`.
|
| 470 |
+
|
| 471 |
+
Each gate adds a gadget that is non-negative and zero exactly on its truth table:
|
| 472 |
+
`AND` `3z + xy - 2xz - 2yz`, `OR` `x + y + z + xy - 2xz - 2yz`, `NOT`
|
| 473 |
+
`1 - x - z + 2xz`. These are functionally complete, so any circuit compiles and
|
| 474 |
+
its evaluation is the ground state by construction. The choice of clamped wires
|
| 475 |
+
selects the mode:
|
| 476 |
+
|
| 477 |
+
- **Forward evaluation.** Clamp the inputs; propagating the gate relations in
|
| 478 |
+
topological order reaches the energy-0 fixed point. Checked bit-exact against
|
| 479 |
+
integer references for ripple-carry adders and array multipliers.
|
| 480 |
+
- **Inversion.** Clamp the outputs and relax over the free wires. The shipped
|
| 481 |
+
`neural_attractor` compiles an 8x8 array multiplier to 913 wires; it multiplies
|
| 482 |
+
forward bit-exactly, and clamping the product recovers factors
|
| 483 |
+
(35 = 5 x 7, 143 = 11 x 13).
|
| 484 |
+
- **Satisfiability.** Clamp a CNF's output wire to 1; a ground state is a
|
| 485 |
+
satisfying assignment.
|
| 486 |
+
|
| 487 |
+
Forward evaluation is exact and linear in gate count. Inversion and
|
| 488 |
+
open-constraint solving are ground-state search over the free wires, annealed.
|
| 489 |
+
The target energy is 0 by construction, so a zero-energy state certifies a
|
| 490 |
+
correct assignment, but reaching it is NP-hard in general and not guaranteed
|
| 491 |
+
within a fixed annealing schedule.
|
|
|
|
|
|
|
| 492 |
|
| 493 |
```bash
|
| 494 |
python tools/build_attractor.py # compile a multiplier to variants/neural_attractor.safetensors
|
src/attractor.py
CHANGED
|
@@ -1,41 +1,25 @@
|
|
| 1 |
-
"""Attractor computer:
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
an energy function E(s) whose global minimum, with the known wires clamped, is
|
| 7 |
-
the unique consistent assignment of the whole circuit. The "program" is the
|
| 8 |
-
coupling matrix Q (with linear terms L); running is relaxation toward the
|
| 9 |
-
minimum. The relaxation update is itself a threshold neuron,
|
| 10 |
-
|
| 11 |
-
s_i <- H( -( L[i] + sum_j Q[i,j] s_j ) ),
|
| 12 |
-
|
| 13 |
-
so the machine is the same substrate as the rest of the repo, one weight matrix
|
| 14 |
-
iterated to a fixed point, with no controller.
|
| 15 |
-
|
| 16 |
-
Each gate contributes a gadget that is >= 0 and equals 0 exactly when the gate
|
| 17 |
-
relation holds (binary variables in {0,1}):
|
| 18 |
|
| 19 |
AND z=x&y : 3z + xy - 2xz - 2yz
|
| 20 |
OR z=x|y : x + y + z + xy - 2xz - 2yz
|
| 21 |
NOT z=~x : 1 - x - z + 2xz
|
| 22 |
|
| 23 |
-
AND/OR/NOT are
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
gate relations in topological order, which lands on the energy-0 fixed point.
|
| 36 |
-
Backward and open-constraint modes are genuine search, annealed over the free
|
| 37 |
-
wires; that hardness is the point (factoring is hard), and an exact integer
|
| 38 |
-
substrate with structured gadgets is the interesting place to attack it.
|
| 39 |
"""
|
| 40 |
from __future__ import annotations
|
| 41 |
import math
|
|
|
|
| 1 |
+
"""Attractor computer: an energy-based threshold network.
|
| 2 |
|
| 3 |
+
A Boolean circuit is compiled to a quadratic pseudo-Boolean energy
|
| 4 |
+
E(s) = sum_i L[i] s_i + sum_{i<j} Q[i,j] s_i s_j over binary wire variables, with
|
| 5 |
+
per-gate gadgets that are non-negative and zero exactly on the gate truth table:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
AND z=x&y : 3z + xy - 2xz - 2yz
|
| 8 |
OR z=x|y : x + y + z + xy - 2xz - 2yz
|
| 9 |
NOT z=~x : 1 - x - z + 2xz
|
| 10 |
|
| 11 |
+
AND/OR/NOT are functionally complete, so any circuit compiles and its consistent
|
| 12 |
+
assignment is the global minimum. There is no program counter or clock: the
|
| 13 |
+
coupling matrix Q (with linear terms L) is the program, and execution is
|
| 14 |
+
relaxation toward the minimum. The relaxation step is a threshold neuron over the
|
| 15 |
+
same integer weights, s_i <- H(-(L[i] + sum_j Q[i,j] s_j)).
|
| 16 |
+
|
| 17 |
+
The clamped wire subset selects the mode. Clamp inputs to evaluate forward (exact
|
| 18 |
+
via topological propagation to the energy-0 fixed point); clamp outputs to invert
|
| 19 |
+
(a multiplier run backward returns factors); clamp a CNF output to 1 to solve
|
| 20 |
+
SAT. Forward evaluation is exact and linear in gate count; inversion and
|
| 21 |
+
open-constraint solving are annealed ground-state search, NP-hard in general,
|
| 22 |
+
with a zero-energy state certifying a correct assignment.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
"""
|
| 24 |
from __future__ import annotations
|
| 25 |
import math
|