| Crates.io | ternsig |
| lib.rs | ternsig |
| version | 0.4.0 |
| created_at | 2026-01-22 02:19:19.924562+00 |
| updated_at | 2026-01-22 02:42:13.775291+00 |
| description | TernarySignal foundation - TensorISA, adaptive mastery learning, thermogram integration |
| homepage | |
| repository | https://github.com/blackfall-labs/ternsig |
| max_upload_size | |
| id | 2060586 |
| size | 251,907 |
TernarySignal foundation for CPU-only neural networks.
w = s * m
s in {-1, 0, +1} polarity
m in {0..255} magnitude
Two bytes per weight. Integer arithmetic only. No floats. No GPU.
Traditional neural networks use 32-bit floats (4 bytes per weight). Ternsig uses TernarySignal (2 bytes per weight):
| Property | Float | TernarySignal |
|---|---|---|
| Size | 4 bytes | 2 bytes |
| Arithmetic | FP multiply-add | Integer multiply-add |
| Hardware | GPU preferred | CPU native |
| Training | Gradient descent | Mastery learning |
pub struct TernarySignal {
pub polarity: i8, // -1, 0, or +1
pub magnitude: u8, // 0-255
}
Effective weight = polarity * magnitude. Range: -255 to +255.
Hot-reloadable neural network definitions as .tisa.asm files:
.registers
H0: i32[12] ; input activations
H1: i32[32] ; hidden layer
C0: ternary[32, 12] key="chip.audio.w1"
.program
load_input H0
ternary_matmul H1, C0, H0
relu H1, H1
store_output H1
halt
Pure integer adaptive learning. 23ms to 90% accuracy.
use ternsig::{MasteryConfig, MasteryState, mastery_update};
let mut weights = init_random_structure(16, 42);
let mut state = MasteryState::new(16);
let config = MasteryConfig::default();
// Learning loop
for sample in samples {
let activations = forward(&weights, &sample.input);
let direction = if sample.target > output { 1 } else { -1 };
mastery_update(&mut weights, &mut state, &activations, direction, &config);
}
Key principles:
max_activation / 4 participate (not percentile-based)Persistent weight storage with temperature lifecycle:
[dependencies]
ternsig = "0.2"
use ternsig::{TernarySignal, assemble, TensorInterpreter};
// Load chip definition
let program = assemble(include_str!("classifier.tisa.asm"))?;
let mut interpreter = TensorInterpreter::from_program(&program);
// Forward pass
let input: Vec<TernarySignal> = /* your input */;
let output = interpreter.forward(&input)?;
MIT OR Apache-2.0