threshold-pruner / README.md
CharlesCNorton
Initial commit: threshold circuit pruning framework
e69d4eb
# 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