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
Files changed (2) hide show
  1. README.md +32 -34
  2. 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 relaxation, run in any direction
461
-
462
- `neural_matrix8` still runs a program forward. `neural_attractor` drops the
463
- last of the von Neumann structure: no program counter, no clock, no forward-only
464
- execution. A computation is compiled into an energy function `E(s)` whose global
465
- minimum, with the known wires clamped, is the unique consistent assignment of the
466
- whole circuit. The program is the coupling matrix `Q` (with linear terms `L`);
467
- running is relaxation toward the minimum, and the relaxation update is itself a
468
- threshold neuron, `s_i <- H(-(L[i] + sum_j Q[i,j] s_j))`, so the machine is the
469
- same substrate, one weight matrix with no controller.
470
-
471
- Each gate contributes a gadget that is non-negative and equals zero exactly when
472
- the gate relation holds (binary variables): `AND` is `3z + xy - 2xz - 2yz`, `OR`
473
- is `x + y + z + xy - 2xz - 2yz`, `NOT` is `1 - x - z + 2xz`. Those are universal,
474
- so any circuit compiles and universality is a theorem about the gadgets rather
475
- than a hope about the dynamics. Forward evaluation is exact: clamp the inputs and
476
- propagate through the gate relations in topological order, landing on the
477
- energy-0 fixed point; the canonical form anneals the whole network to the same
478
- minimum.
479
-
480
- What no program counter can do falls out of clamping a different subset of wires:
481
-
482
- - **Run circuits backward.** Clamp a multiplier's product and relax over the
483
- inputs, and the machine returns factors. The shipped `neural_attractor` is an
484
- 8x8 multiplier compiled to couplings (913 wires); it multiplies forward
485
- bit-exactly and, run in reverse, factors (35 = 5 x 7, 143 = 11 x 13).
486
- - **Solve.** Clamp a CNF formula's output to 1 and the minimum is a satisfying
487
- assignment, so the same object is a circuit evaluator and a SAT solver.
488
-
489
- The forward direction is exact and cheap; the backward and open-constraint modes
490
- are genuine annealed search, and that hardness is the point. Factoring is hard,
491
- and an exact integer-ternary substrate with structured gadgets, where the ground
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: computation as relaxation of a threshold network.
2
 
3
- Every other machine in this repository is a stored-program computer whose gates
4
- happen to be threshold neurons: it has a program counter, a fetch, and an
5
- instruction stream. This one has none of those. A computation is compiled into
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 universal, so any circuit compiles, and universality of the
24
- machine is a theorem about the gadgets rather than a hope about the dynamics.
25
-
26
- Two things a program counter cannot do fall out of this:
27
-
28
- * Evaluate in any direction. Clamp inputs and relax to read outputs; or clamp
29
- outputs and relax to recover inputs. Running a multiplier backward is
30
- integer factoring; running any predicate backward is search.
31
- * Solve. Clamp a formula's output to 1 and the minimum is a satisfying
32
- assignment, so the same object is a circuit evaluator and a SAT solver.
33
-
34
- Forward evaluation (inputs clamped) is exact and cheap: propagate through the
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