sovereign-reduction-algebra / docs /ARCHITECTURE.md
SNAPKITTYWEST's picture
October 2026 main drop: mirror from GitHub
018091e verified
|
Raw History Blame Contribute Delete
4.49 kB

Architecture

Sovereign Reduction Algebra is an array reduction algebra for an experimental SUBLEQ attention / bi-encoder. Production numeric work runs in J 9.7 and R 4.5 with gmp bigz. Python launches those processes and compares the integers they print. It does not multiply, reduce modulo the Goldilocks prime, or hash.

This is not a trained softmax transformer. Tower weights are a fixed permutation. The late interaction is subtract β†’ compare β†’ predicate β†’ select β†’ route β†’ reduce. The unmasked head must equal exact matrix multiplication. The routed tensor is a separate sparse approximation and is not required to match that product.

Components

Layer Path Role
J arithmetic j/biencoder.ijs Extended-integer matmul (+/ .*), SUBLEQ routing, field residues
J seal j/sha512.ijs FIPS 180-4 SHA-512; 64-bit words as two uint32 halves
J benches j/bench.ijs 6!:2 timings written through the Python recorder
R arithmetic r/biencoder.R gmp bigz matmul; never double, never base %*% on numeric
R seal r/sha512.R SHA-512 with uint16 limbs (high-bit uint32 is NA_integer_ in R)
R benches r/bench.R system.time timings
Launcher scripts/run_biencoder.py Starts J and R; compares printed decimals and hex seals
Bench recorder scripts/run_benchmarks.py Records timer output only; does not invent seconds
Results results/*.json Measured artifacts
TinyAPL tinyapl/, vendor/tinyapl Legacy demo. Complex Double cannot hold Goldilocks p.
Astra astra/*.apl GNU-APL style agent registry, routing, and mixture sources (included, not claimed executed here)
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Python process launcher β”‚
                    β”‚  compare printed ints    β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β–Ό                                     β–Ό
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚  J 9.7         β”‚                    β”‚  R 4.5 + gmp   β”‚
     β”‚  +/ .*         β”‚                    β”‚  bigz %*%      β”‚
     β”‚  SHA-512 DAG   β”‚                    β”‚  SHA-512 DAG   β”‚
     β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚                                     β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β–Ό
              exact_head Β· predicted Β· weights Β· prime
                            β”‚
                            β–Ό
                   parent SHA-512 seal

See also docs/images/architecture.svg.

Field

Goldilocks prime p = 18446744069414584321 = 2^64 βˆ’ 2^32 + 1 is held as an extended integer in both engines. Seeded small products agree with the field product when they do not wrap. A fixed large residue case is reduced in both languages and must agree.

Pipeline

ARRAY β†’ SUBTRACT β†’ COMPARE β†’ PREDICATE β†’ SELECT β†’ ROUTE β†’ REDUCE β†’ STATE

Two towers apply one fixed permutation (Wq +/ .* |: Wk = I in J; the same product in R). One integer training step does not move Wq or Wk. It adds the routed residual to an integer projection, then adds that projection elementwise to the routed prediction. The unmasked head must still equal A times B.

Verification rules

  1. Unmasked head equals exact A Γ— B in both engines.
  2. J and R agree on the seeded 4Γ—4 case (shapes, tensors, seals).
  3. SHA-512 DAG seals agree; verify passes; a one-entry mutation fails verify.
  4. Routed max absolute error is reported and does not gate exit status.
  5. Benchmark seconds come only from J 6!:2 or R system.time.

Legacy

TinyAPL remains for the earlier reduction-algebra demos. Its scalars are Complex Double; ulp at 2^64 is 4096, so p is not an exact distinct scalar. The older Python Goldilocks reference and SHA-256 JSON stub are not the production bi-encoder seal.