phanerozoic / threshold-ctz8

huggingface.co
Total runs: 12
24-hour runs: 0
7-day runs: 1
30-day runs: 4
Model's Last Updated: January 30 2026

Introduction of threshold-ctz8

Model Details of threshold-ctz8

threshold-ctz8

8-bit count trailing zeros (CTZ). Returns the number of trailing zero bits before the first set bit. Returns 8 if input is zero.

Circuit
 x7  x6  x5  x4  x3  x2  x1  x0
  │   │   │   │   │   │   │   │
  └───┴───┴───┴───┴───┴───┴───┘
              │
              ▼
    ┌─────────────────────┐
    │  Priority Detect    │    Layer 1-3
    │  (find first 1)     │
    └─────────────────────┘
              │
              ▼
    ┌─────────────────────┐
    │  Position Encoder   │    Layer 4-5
    │  (binary encoding)  │
    └─────────────────────┘
              │
              ▼
        [c2, c1, c0]
        (count 0-7)

    Plus: all_zero detector for count=8
Function
ctz8(x7, x6, x5, x4, x3, x2, x1, x0) -> (c3, c2, c1, c0)

where c = 4*c3 + 2*c2 + c1 + c0 = number of trailing zeros

If x0 is set, count = 0. If only x7 is set, count = 7. If no bits set, count = 8.

Truth Table (selected)
Input (hex) Binary CTZ c3 c2 c1 c0
0x01 00000001 0 0 0 0 0
0x02 00000010 1 0 0 0 1
0x04 00000100 2 0 0 1 0
0x08 00001000 3 0 0 1 1
0x10 00010000 4 0 1 0 0
0x20 00100000 5 0 1 0 1
0x40 01000000 6 0 1 1 0
0x80 10000000 7 0 1 1 1
0x00 00000000 8 1 0 0 0
0x06 00000110 1 0 0 0 1
0xF0 11110000 4 0 1 0 0
Mechanism

Step 1: Find first set bit from LSB

Detect positions where a bit is set and all lower bits are zero:

Signal Condition Meaning
p0 x0 First 1 at position 0
p1 x1 AND NOT x0 First 1 at position 1
p2 x2 AND NOT x1 AND NOT x0 First 1 at position 2
... ... ...
p7 x7 AND NOT(x6..x0) First 1 at position 7
pZ NOT(x7..x0) All zeros

Step 2: Encode position to binary

  • c0 = p1 OR p3 OR p5 OR p7 (odd positions)
  • c1 = p2 OR p3 OR p6 OR p7 (positions 2,3,6,7)
  • c2 = p4 OR p5 OR p6 OR p7 (positions 4-7)
  • c3 = pZ (all zeros → count = 8)
Architecture
Layer Components Function
1 8 position detectors Find first 1
2 Zero detector All zeros?
3 4 OR gates Encode to binary
Parameters
Inputs 8
Outputs 4
Neurons 13
Layers 3
Parameters 85
Magnitude 52
Usage
from safetensors.torch import load_file
import torch

w = load_file('model.safetensors')

def ctz8(bits):
    # bits = [x0, x1, x2, x3, x4, x5, x6, x7] (LSB first)
    inp = torch.tensor([float(b) for b in bits])

    c0 = int((inp @ w['c0.weight'].T + w['c0.bias'] >= 0).item())
    c1 = int((inp @ w['c1.weight'].T + w['c1.bias'] >= 0).item())
    c2 = int((inp @ w['c2.weight'].T + w['c2.bias'] >= 0).item())
    c3 = int((inp @ w['c3.weight'].T + w['c3.bias'] >= 0).item())

    return c3, c2, c1, c0

# Examples
print(ctz8([1,0,0,0,0,0,0,0]))  # (0,0,0,0) = 0 trailing zeros
print(ctz8([0,0,0,0,1,0,0,0]))  # (0,1,0,0) = 4 trailing zeros
print(ctz8([0,0,0,0,0,0,0,0]))  # (1,0,0,0) = 8 trailing zeros (all zero)
Applications
  • Finding alignment in memory addresses
  • Bit manipulation in compression algorithms
  • Finding least significant set bit
  • Integer factorization (powers of 2)
  • Loop optimization
Related Circuits
  • threshold-clz8 : Count leading zeros (mirror operation)
  • threshold-ffs8 : Find first set (similar, 1-indexed)
  • threshold-priorityencoder8 : Finds MSB position instead
Files
threshold-ctz8/
├── model.safetensors
├── model.py
├── create_safetensors.py
├── config.json
└── README.md
License

MIT

Runs of phanerozoic threshold-ctz8 on huggingface.co

12
Total runs
0
24-hour runs
1
3-day runs
1
7-day runs
4
30-day runs

More Information About threshold-ctz8 huggingface.co Model

More threshold-ctz8 license Visit here:

https://choosealicense.com/licenses/mit

threshold-ctz8 huggingface.co

threshold-ctz8 huggingface.co is an AI model on huggingface.co that provides threshold-ctz8's model effect (), which can be used instantly with this phanerozoic threshold-ctz8 model. huggingface.co supports a free trial of the threshold-ctz8 model, and also provides paid use of the threshold-ctz8. Support call threshold-ctz8 model through api, including Node.js, Python, http.

phanerozoic threshold-ctz8 online free

threshold-ctz8 huggingface.co is an online trial and call api platform, which integrates threshold-ctz8's modeling effects, including api services, and provides a free online trial of threshold-ctz8, you can try threshold-ctz8 online for free by clicking the link below.

phanerozoic threshold-ctz8 online free url in huggingface.co:

https://huggingface.co/phanerozoic/threshold-ctz8

threshold-ctz8 install

threshold-ctz8 is an open source model from GitHub that offers a free installation service, and any user can find threshold-ctz8 on GitHub to install. At the same time, huggingface.co provides the effect of threshold-ctz8 install, users can directly use threshold-ctz8 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

threshold-ctz8 install url in huggingface.co:

https://huggingface.co/phanerozoic/threshold-ctz8

Url of threshold-ctz8

threshold-ctz8 huggingface.co Url

Provider of threshold-ctz8 huggingface.co

phanerozoic
ORGANIZATIONS

Other API from phanerozoic

huggingface.co

Total runs: 86
Run Growth: 37
Growth Rate: 42.53%
Updated:September 26 2026