threshold-greaterthan

8-bit greater-than comparator. Returns 1 if a > b, 0 otherwise.

Circuit

b0 a0    b1 a1    b2 a2    b3 a3    b4 a4    b5 a5    b6 a6    b7 a7
 β”‚ β”‚ 0    β”‚ β”‚      β”‚ β”‚      β”‚ β”‚      β”‚ β”‚      β”‚ β”‚      β”‚ β”‚      β”‚ β”‚
 β””β”¬β”˜β”‚     β””β”¬β”˜      β””β”¬β”˜      β””β”¬β”˜      β””β”¬β”˜      β””β”¬β”˜      β””β”¬β”˜      β””β”¬β”˜
  β–Ό β”‚      β–Ό        β–Ό        β–Ό        β–Ό        β–Ό        β–Ό        β–Ό
β”Œβ”€β”€β”€β”β”‚  β”Œβ”€β”€β”€β”    β”Œβ”€β”€β”€β”    β”Œβ”€β”€β”€β”    β”Œβ”€β”€β”€β”    β”Œβ”€β”€β”€β”    β”Œβ”€β”€β”€β”    β”Œβ”€β”€β”€β”
β”‚FS0│┴──│FS1│────│FS2│────│FS3│────│FS4│────│FS5│────│FS6│────│FS7│──►(a>b)
β””β”€β”€β”€β”˜   β””β”€β”€β”€β”˜    β””β”€β”€β”€β”˜    β””β”€β”€β”€β”˜    β””β”€β”€β”€β”˜    β””β”€β”€β”€β”˜    β””β”€β”€β”€β”˜    β””β”€β”€β”€β”˜

Note: inputs are swapped compared to LessThan. Computes b - a.

Mechanism

The circuit computes b - a using subtraction:

  • If b β‰₯ a: no borrow propagates β†’ a ≀ b β†’ output 0
  • If b < a: borrow propagates out β†’ a > b β†’ output 1

This is equivalent to LessThan(b, a).

Truth Table (sample)

a b a > b
0 0 0
1 0 1
0 1 0
128 127 1
0 255 0
255 0 1
100 100 0
100 99 1

Full Subtractor Structure

        b       a           (note: b first, a second)
        β”‚       β”‚
        β””β”€β”€β”€β”¬β”€β”€β”€β”˜
            β–Ό
       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚   HS1   β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚       β”‚
       d1       b1
        β”‚        \
        β”‚   bin   \
        β””β”€β”€β”¬β”€β”€β”˜    \
           β–Ό        \
      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”    \
      β”‚   HS2   β”‚     β”‚
      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
       β”‚       β”‚      β”‚
       d       b2     β”‚
               β”‚      β”‚
               β””β”€β”€β”¬β”€β”€β”€β”˜
                  β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”
              β”‚  OR  β”‚
              β””β”€β”€β”€β”€β”€β”€β”˜
                  β”‚
                  β–Ό
                bout

Architecture

Component Per FS Total (8 FSs)
Neurons 9 72
Parameters 27 216

Layers: 32 (8 FSs Γ— 4 layers each)

Comparison Family

Circuit Condition Implementation
LessThan a < b borrow_out of (a - b)
Equal a = b NOR of all XOR bits
GreaterThan a > b borrow_out of (b - a)

Usage

from safetensors.torch import load_file

w = load_file('model.safetensors')

def greater_than(a, b):
    """a, b: 8-bit lists [a0..a7] (LSB first)
    Returns: 1 if a > b, 0 otherwise"""
    # See model.py for full implementation
    pass

# Example: 100 > 99?
a = [(100 >> i) & 1 for i in range(8)]
b = [(99 >> i) & 1 for i in range(8)]
result = greater_than(a, b)  # Returns 1

Files

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

License

MIT

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

Collection including phanerozoic/threshold-greaterthan