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 (1219647/400000 cyc/op); safe for ultra-hot per-sample or per-packet inner loops.
Snap-Circuit Wiring Role: 1-to-1 Unary Transform Stage `(u64)->u64` — snaps directly into linear pipelines or fan-out DAG branches.
.text: 168 B (60 x86_64 insns)285 B)#[inline(always)] pub fn hutter_b158_trit_pack5_u64(trits: u64) -> u64 { let t0 = (trits & 0xF) % 3; let t1 = ((trits >> 4) & 0xF) % 3; let t2 = ((trits >> 8) & 0xF) % 3; let t3 = ((trits >> 12) & 0xF) % 3; let t4 = ((trits >> 16) & 0xF) % 3; t0 + t1 * 3 + t2 * 9 + t3 * 27 + t4 * 81 }
rustc -C opt-level=3 x86_64 Disassembly (168 B .text / 60 insns)hutter_b158_trit_pack5_u64:
push rbx
mov eax, edi
and al, 15
mov ecx, edi
and ecx, 15
imul ecx, ecx, 86
movzx ecx, ch
lea ecx, [rcx + 2*rcx]
sub al, cl
mov ecx, edi
shr cl, 4
movzx ecx, cl
imul edx, ecx, 86
shr edx, 8
lea edx, [rdx + 2*rdx]
sub cl, dl
movzx ecx, cl
mov edx, edi
shr edx, 8
mov esi, edx
and sil, 15
and edx, 15
imul edx, edx, 86
movzx edx, dh
lea edx, [rdx + 2*rdx]
sub sil, dl
movzx edx, sil
mov esi, edi
shr esi, 12
mov r8d, esi
and r8b, 15
and esi, 15
imul ebx, esi, 86
movzx esi, bh
lea esi, [rsi + 2*rsi]
sub r8b, sil
movzx esi, r8b
shr edi, 16
mov r8d, edi
and r8b, 15
and edi, 15
imul ebx, edi, 86
movzx edi, bh
lea edi, [rdi + 2*rdi]
sub r8b, dil
movzx edi, r8b
lea ecx, [rcx + 2*rcx]
add cl, al
lea eax, [rdx + 8*rdx]
add al, cl
lea ecx, [rsi + 8*rsi]
lea ecx, [rcx + 2*rcx]
add cl, al
movzx ecx, cl
lea eax, [rdi + 8*rdi]
lea eax, [rax + 8*rax]
movzx eax, al
add rax, rcx
pop rbx
ret
| Global Rank | Capsule & Domain | Hardware _rdtsc | Latency | Throughput | ELF .text | Ternary Vote | Author Aye |
|---|---|---|---|---|---|---|---|
| #28 | hutter_b158_trit_pack5_u64 (THIS CAPSULE) domain: hutter | id: 8e1a83683f22a916a0f1f20d7625e7d7 | 1219647/400000 cyc/op | 232399/160000 ns/op | 160000000/232399 ops/us | 168 B .text (60 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |