threshold-crc16-mag53

CRC-16 CCITT single-step function using magnitude-optimal XOR components.

Optimization

This circuit uses proven-optimal XOR decompositions instead of naive OR+NAND+AND:

Component Naive Approach Optimized Savings
XOR (2-input) OR+NAND+AND (mag 10) mag-7 symmetric 30%
XOR3 (3-input) ge1/ge2/ge3 (mag 19) mag-10 flat 47%

Total magnitude: 74 β†’ 53 (28% reduction)

XOR Component Choices

XOR (2-input) - Magnitude 7

From the 6 proven-optimal solutions, we use the symmetric opposites family:

h1: [-1, +1], bias=0   (fires when b > a)
h2: [+1, -1], bias=0   (fires when a > b)
out: [-1, -1], bias=1  (NOR of hidden)

Selected for:

  • Zero biases in hidden layer (simpler accumulator)
  • Symmetric structure (clearer mathematical reasoning)
  • Proven optimal via exhaustive search (no mag-6 solutions exist)

XOR3 (3-input) - Magnitude 10

From the 18 proven-optimal solutions, we use the selector + full pattern:

h1: [0, 0, -1], bias=0   (selector: fires when c=0)
h2: [-1, +1, -1], bias=0 (full: fires when b > a+c)
h3: [-1, -1, +1], bias=0 (full: fires when c > a+b)
out: [+1, -1, -1], bias=0

Selected for:

  • All biases are zero
  • Selector neuron isolates the "unique" input in CRC context
  • Proven optimal via exhaustive search (387M configs, no mag-9 solutions)

Polynomial

0x1021 = x^16 + x^12 + x^5 + 1 (CRC-16-CCITT)

Function

feedback = C[15] XOR D

C'[0]  = feedback           (tap at x^0)  ← XOR (mag 7)
C'[1]  = C[0]
C'[2]  = C[1]
C'[3]  = C[2]
C'[4]  = C[3]
C'[5]  = C[4] XOR feedback  (tap at x^5)  ← XOR3 (mag 10)
C'[6]  = C[5]
...
C'[11] = C[10]
C'[12] = C[11] XOR feedback (tap at x^12) ← XOR3 (mag 10)
C'[13] = C[12]
C'[14] = C[13]
C'[15] = C[14]

Architecture

Inputs 17 (C[0:15] + D)
Outputs 16 (C'[0:15])
Neurons 24
Layers 2
Parameters 389
Magnitude 53

Breakdown

Component Neurons Magnitude
13 pass-throughs 13 26
C'[0] XOR 3 7
C'[5] XOR3 4 10
C'[12] XOR3 4 10
Total 24 53

Verification

  • Exhaustively tested against all 2^17 = 131,072 input combinations
  • XOR optimality proven via exhaustive search (magnitude 7, 6 solutions)
  • XOR3 optimality proven via exhaustive search (magnitude 10, 18 solutions)

Comparison to Naive Implementation

Version Magnitude Reduction
threshold-crc16 (naive) 74 baseline
threshold-crc16-mag53 53 28%

Files

threshold-crc16-mag53/
β”œβ”€β”€ model.safetensors
β”œβ”€β”€ model.py
β”œβ”€β”€ create_safetensors.py
β”œβ”€β”€ config.json
└── README.md

Usage

from safetensors.torch import load_file
from model import forward

weights = load_file('model.safetensors')

# Single step: 16-bit CRC state + 1 data bit β†’ new 16-bit state
inputs = [c0, c1, ..., c15, d]  # 17 binary values
outputs = forward(inputs, weights)  # 16 binary values

License

MIT

Downloads last month
20
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Collection including phanerozoic/threshold-crc16-mag53