Best Use & Engineering Application Guide

Engineering Category: Balanced Ternary & b158 Quantization

Best Use in Production: Packing and unpacking balanced ternary (-1, 0, +1) activation lanes into dense 64-bit registers for C64-constrained inference pipelines.

When to Select This Capsule: Sole canonical implementation for its 64-vector functional equivalence class. Sub-10-cycle hardware kernel (1323467/400000 cyc/op); safe for ultra-hot per-sample or per-packet inner loops.

Snap-Circuit Wiring Role: Specialized Multi-Pin Stage `(i64)->i8` — wire matching input pins via `snap_dag` or `snap_pipeline`.

Hardware _rdtsc: 1323467/400000 cycles/op
Latency: 206833/200000 ns/op
Throughput: 200000000/206833 ops/us
Compiled ELF64 .text: 12 B (5 x86_64 insns)
C64 64KB RAM Budget: 19/4096 (304 B source)
Ternary Vote: + (score 1) | Salience: 9645/104
Pure-Rust Capsule Source Code (304 B)
pub fn saturate_trit_i64(value: i64) -> i8 {
    // Project an arbitrary accumulator onto the ternary alphabet {-1, 0, +1}.
    // Branch-free: two arithmetic compares compiled to cmp/setcc pairs.
    if value > 1 {
        1
    } else if value < -1 {
        -1
    } else {
        value as i8
    }
}
rustc -C opt-level=3 x86_64 Disassembly (12 B .text / 5 insns)
saturate_trit_i64:
    test    rdi, rdi
    sets    cl
    setg    al
    sub    al, cl
    ret

Head-to-Head Functional Equivalence Class Peers (1 Implementation(s) Matching 64 Test Vectors)

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#14saturate_trit_i64 (THIS CAPSULE)
domain: ternary | id: 9bb078d59c2817acb28eb94ad624c0f6
1323467/400000 cyc/op206833/200000 ns/op200000000/206833 ops/us12 B .text (5 insns)+ (1)aye::Peter+Omni(0+1)::aarch64 @ 432Hz