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. Low-latency L1-resident kernel (2303721/200000 cyc/op); well-suited for high-frequency pipeline stages.
Snap-Circuit Wiring Role: Specialized Multi-Pin Stage `(u8)->[i8;5]` — wire matching input pins via `snap_dag` or `snap_pipeline`.
.text: 147 B (48 x86_64 insns)284 B)pub const fn unpack_5_trits_base243(byte: u8) -> [i8; 5] {
let mut v = if byte >= 243 { 242 } else { byte };
let mut out = [0i8; 5];
let mut i = 0;
while i < 5 {
let rem = v % 3;
out[i] = (rem as i8) - 1;
v /= 3;
i += 1;
}
out
}
rustc -C opt-level=3 x86_64 Disassembly (147 B .text / 48 insns)unpack_5_trits_base243:
push rbx
cmp dil, -14
mov eax, 242
cmovb eax, edi
movzx edx, al
imul esi, edx, 171
shr esi, 9
lea eax, [rsi + 2*rsi]
not al
add eax, edx
imul ecx, esi, 86
movzx ecx, ch
lea ecx, [rcx + 2*rcx]
not cl
add cl, sil
imul edi, edx, 57
shr edi, 9
imul ebx, edi, 86
movzx esi, bh
lea esi, [rsi + 2*rsi]
not sil
add sil, dil
lea edi, [rdx + 8*rdx]
lea edi, [rdx + 2*rdi]
shr edi, 9
imul ebx, edi, 86
movzx ebx, bh
lea r8d, [rbx + 2*rbx]
not r8b
add r8b, dil
imul edx, edx, 203
shr edx, 14
dec dl
movzx edx, dl
shl rdx, 32
movzx edi, r8b
shl edi, 24
or rdi, rdx
movzx edx, sil
shl edx, 16
or rdx, rdi
movzx ecx, cl
shl ecx, 8
or rcx, rdx
movzx eax, al
or rax, rcx
pop rbx
ret
| Global Rank | Capsule & Domain | Hardware _rdtsc | Latency | Throughput | ELF .text | Ternary Vote | Author Aye |
|---|---|---|---|---|---|---|---|
| #442 | unpack_5_trits_base243 (THIS CAPSULE) domain: ayecast-x86_64 | id: 07eff900be763765380dc889fd524985 | 2303721/200000 cyc/op | 624979/200000 ns/op | 200000000/624979 ops/us | 147 B .text (48 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |