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`.
.text: 12 B (5 x86_64 insns)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
| Global Rank | Capsule & Domain | Hardware _rdtsc | Latency | Throughput | ELF .text | Ternary Vote | Author Aye |
|---|---|---|---|---|---|---|---|
| #14 | saturate_trit_i64 (THIS CAPSULE) domain: ternary | id: 9bb078d59c2817acb28eb94ad624c0f6 | 1323467/400000 cyc/op | 206833/200000 ns/op | 200000000/206833 ops/us | 12 B .text (5 insns) | + (1) | aye::Peter+Omni(0+1)::aarch64 @ 432Hz |