File size: 1,441 Bytes
e69d4eb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Threshold Pruner

Multi-method pruning framework for threshold logic circuits.

## Methods

| Method | Flag | Description |
|--------|------|-------------|
| Magnitude Reduction | `mag` | Reduce weights by 1 toward zero |
| Batched Magnitude | `batched` | GPU-parallel magnitude reduction |
| Zero Pruning | `zero` | Set weights directly to 0 |
| Quantization | `quant` | Force weights to {-1, 0, 1} |
| Evolutionary | `evo` | Mutation + selection with parsimony |
| Simulated Annealing | `anneal` | Gradual cooling search |
| Pareto Search | `pareto` | Correctness vs size tradeoff |

## Usage

```bash
# List available circuits
python prune.py --list

# Prune a circuit with all methods
python prune.py threshold-hamming74decoder

# Specific methods only
python prune.py threshold-hamming74decoder --methods mag,zero,evo

# Batch process
python prune.py --all --max-inputs 8

# Save best result
python prune.py threshold-hamming74decoder --save
```

## Requirements

```
torch
safetensors
```

## Circuit Format

Each circuit needs:
```
threshold-{name}/
β”œβ”€β”€ model.safetensors   # Weights: {layer.weight: [...], layer.bias: [...]}
β”œβ”€β”€ model.py            # Forward function
β”œβ”€β”€ config.json         # {inputs, outputs, neurons, layers, parameters}
```

## Related

- [Threshold Logic Circuits Collection](https://huggingface.co/collections/phanerozoic/threshold-logic-circuits-6972546b096a4384dd9f34ad)

## License

MIT