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: Verified baseline member of a 2-capsule Equivalence Class; useful as a reference or cross-validation peer. Sub-10-cycle hardware kernel (13689/1600 cyc/op); safe for ultra-hot per-sample or per-packet inner loops.
Snap-Circuit Wiring Role: 1-to-1 Unary Transform Stage `(i64)->i64` — snaps directly into linear pipelines or fan-out DAG branches.
.text: 46 B (13 x86_64 insns)249 B)pub fn borg_py_onecomp_trit_quant(sample: i64) -> i64 {
let scaled = sample.wrapping_mul(158) >> 7;
let pos = (scaled > 64) as i64;
let neg = (scaled < -64) as i64;
let trit = pos - neg;
(scaled & 0xFF).wrapping_add(trit * 432)
}
rustc -C opt-level=3 x86_64 Disassembly (46 B .text / 13 insns)borg_py_onecomp_trit_quant:
imul rax, rdi, 158
sar rax, 7
xor ecx, ecx
cmp rax, 65
setge cl
xor edx, edx
cmp rax, -64
setl dl
sub rcx, rdx
movzx edx, al
imul rax, rcx, 432
add rax, rdx
ret
| Global Rank | Capsule & Domain | Hardware _rdtsc | Latency | Throughput | ELF .text | Ternary Vote | Author Aye |
|---|---|---|---|---|---|---|---|
| #17 | st_golf_borg_py_onecomp_trit_quant_i64 domain: borg-onecomp | id: 1897b7b27af633ff019578a9f389648e | 100151/25000 cyc/op | 217381/200000 ns/op | 200000000/217381 ops/us | 46 B .text (13 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |
| #264 | borg_py_onecomp_trit_quant (THIS CAPSULE) domain: compression | id: 9288f23f2f34d53d9e9a4d230f4d3b41 | 13689/1600 cyc/op | 4563/1600 ns/op | 1600000/4563 ops/us | 46 B .text (13 insns) | + (1) | aye-a6000-prime @ 432Hz |