atomic-neural-transistors

Crates.ioatomic-neural-transistors
lib.rsatomic-neural-transistors
version0.4.1
created_at2026-01-07 02:47:07.40654+00
updated_at2026-01-22 03:05:16.524367+00
descriptionUltra-small (<5K param) composable ternary neural primitives for CPU-only AI
homepage
repositoryhttps://github.com/blackfall-labs/atomic-neural-transistors
max_upload_size
id2027352
size4,705,906
Magnus Trent (magnus-trent)

documentation

README

Atomic Neural Transistors (ANTs)

Ultra-small (<5K param) composable neural primitives for real-time AI

License Rust


What are ANTs?

ANTs are the transistors of neural computing - atomic units that perform single operations with high precision and compose into larger systems.

Just as silicon transistors:

  • Do one thing (switch on/off)
  • Compose into gates, then circuits, then CPUs
  • Are fast and predictable

ANTs:

  • Do one thing (compare, classify, diff, etc.)
  • Compose into meshes, then bridges, then cognitive systems
  • Run in microseconds with deterministic behavior

Pretrained Models

ANT Accuracy Size Purpose
are_equal 99.5% 812 KB Compare two embeddings
is_empty 100% 209 KB Detect zero embeddings
contains ~97% 1.8 MB Query in sequence
has_duplicate 100% 1.8 MB Duplicate detection

Quick Start

use atomic_neural_transistors::{AtomicNeuralTransistor, AtomicConfig};
use candle_core::{Device, DType};
use candle_nn::{VarBuilder, VarMap};

// Create a tiny ANT
let device = Device::Cpu;
let varmap = VarMap::new();
let vb = VarBuilder::from_varmap(&varmap, DType::F32, &device);

let ant = AtomicNeuralTransistor::new(&AtomicConfig::tiny(32, 1), vb)?;
println!("Parameters: {}", ant.param_count()); // ~1.5K

Composition Algebra

Complex operations compose from primitives without additional training:

use atomic_neural_transistors::composition::{contains, has_duplicate, PerfectEquality};

let checker = PerfectEquality;

// contains = OR(AreEqual(query, seq[i]) for all i)
assert!(contains(&checker, 5, &[1, 2, 3, 5, 7]));

// has_duplicate = OR(AreEqual(seq[i], seq[j]) for all i < j)
assert!(has_duplicate(&checker, &[1, 2, 3, 2, 5]));

Architecture

atomic-neural-transistors/
├── src/
│   ├── config/          # AtomicConfig
│   ├── core/            # AtomicNeuralTransistor (the fundamental ANT)
│   ├── ants/            # Specialized ANTs
│   │   ├── compare.rs   # CompareANT
│   │   ├── diff.rs      # DiffANT
│   │   ├── merge.rs     # MergeANT
│   │   ├── gate.rs      # GateANT
│   │   └── classifier.rs# ClassifierANT
│   ├── composition/     # Composition algebra
│   │   ├── sequence.rs  # contains, has_duplicate, etc.
│   │   └── grid.rs      # Grid operations
│   └── pretrained/      # Model loading
└── models/              # Pretrained weights

Specialized ANTs

ANT Purpose Params
CompareANT Binary similarity ~1.5K
DiffANT Difference embedding ~3K
MergeANT Combine signals ~3K
GateANT Attention routing ~2K
ClassifierANT Multi-class ~5-10K

Examples

# Basic ANT usage
cargo run --example basic_usage

# Composition algebra
cargo run --example composition

# Sudoku validation
cargo run --example sudoku_check

Why ANTs?

1. Specialization Beats Generalization

A 117M param model allocates capacity across all tasks. ANTs dedicate 100% of their capacity to one operation.

2. Composition Preserves Accuracy

Unlike end-to-end training where errors compound, ANT composition maintains component accuracy. If AreEqual achieves 99.5%, composed operations inherit this precision.

3. Edge Deployment

ANTs run on:

  • Embedded systems
  • Mobile devices
  • Browsers (via WASM)
  • Microcontrollers

License

MIT OR Apache-2.0

Citation

@software{ant2024,
  title={Atomic Neural Transistors},
  author={Blackfall Labs},
  year={2024},
  url={https://github.com/blackfall-labs/atomic-neural-transistors}
}
Commit count: 7

cargo fmt