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 (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.

Hardware _rdtsc: 1219647/400000 cycles/op
Latency: 232399/160000 ns/op
Throughput: 160000000/232399 ops/us
Compiled ELF64 .text: 168 B (60 x86_64 insns)
C64 64KB RAM Budget: 285/65536 (285 B source)
Ternary Vote: + (score 1) | Salience: 2480/27
Pure-Rust Capsule Source Code (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

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

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#28hutter_b158_trit_pack5_u64 (THIS CAPSULE)
domain: hutter | id: 8e1a83683f22a916a0f1f20d7625e7d7
1219647/400000 cyc/op232399/160000 ns/op160000000/232399 ops/us168 B .text (60 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz