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 (1791583/200000 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: 133 B (39 x86_64 insns)406 B)pub fn aurora_ternary_pack_5trits(trits_packed: u64) -> u64 {
let mut acc: u64 = 0;
let mut radix: u64 = 1;
let mut i: u64 = 0;
while i < 5 {
let raw_trit = (trits_packed >> (i * 2)) & 3;
let trit = if raw_trit > 2 { 2 } else { raw_trit };
acc = acc.saturating_add(trit.saturating_mul(radix));
radix = radix.saturating_mul(3);
i += 1;
}
acc
}
rustc -C opt-level=3 x86_64 Disassembly (133 B .text / 39 insns)aurora_ternary_pack_5trits:
mov eax, edi
and eax, 3
cmp rax, 3
mov ecx, 2
cmovne rcx, rax
mov eax, edi
shr eax, 2
and eax, 3
cmp eax, 3
lea rax, [rax + 2*rax]
mov edx, 6
cmovne rdx, rax
add rdx, rcx
mov eax, edi
shr eax, 4
and eax, 3
cmp eax, 3
lea rax, [rax + 8*rax]
mov ecx, 18
cmovne rcx, rax
add rcx, rdx
mov eax, edi
shr eax, 6
and eax, 3
cmp eax, 3
lea rax, [rax + 8*rax]
lea rax, [rax + 2*rax]
mov edx, 54
cmovne rdx, rax
shr edi, 8
and edi, 3
cmp edi, 3
lea rax, [rdi + 8*rdi]
lea rsi, [rax + 8*rax]
mov eax, 162
cmovne rax, rsi
add rax, rdx
add rax, rcx
ret
| Global Rank | Capsule & Domain | Hardware _rdtsc | Latency | Throughput | ELF .text | Ternary Vote | Author Aye |
|---|---|---|---|---|---|---|---|
| #381 | aurora_ternary_pack_5trits (THIS CAPSULE) domain: signal | id: 4134cafea9b0adf5eb072c2e180b0489 | 1791583/200000 cyc/op | 1158173/400000 ns/op | 400000000/1158173 ops/us | 133 B .text (39 insns) | + (1) | aye-aurora-8b-voice @ 432Hz |