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: Holds the #1 Equivalence Crown across 4 functionally identical implementations (fastest verified hardware _rdtsc). Sub-10-cycle hardware kernel (1930529/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: 228 B (57 x86_64 insns)610 B)pub const fn st_golf_gaia_pack_trits_horner_u64(word: u64) -> u64 {
let v0 = word & 0xFFF;
let d0 = ((v0 > 2304) as u64) | (((v0 < 1792) as u64) << 1);
let v1 = (word >> 12) & 0xFFF;
let d1 = ((v1 > 2304) as u64) | (((v1 < 1792) as u64) << 1);
let v2 = (word >> 24) & 0xFFF;
let d2 = ((v2 > 2304) as u64) | (((v2 < 1792) as u64) << 1);
let v3 = (word >> 36) & 0xFFF;
let d3 = ((v3 > 2304) as u64) | (((v3 < 1792) as u64) << 1);
let v4 = (word >> 48) & 0xFFF;
let d4 = ((v4 > 2304) as u64) | (((v4 < 1792) as u64) << 1);
d0 + 3 * (d1 + 3 * (d2 + 3 * (d3 + 3 * d4)))
}
rustc -C opt-level=3 x86_64 Disassembly (228 B .text / 57 insns)st_golf_gaia_pack_trits_horner_u64:
mov eax, edi
and eax, 4095
xor ecx, ecx
cmp rax, 2305
setae cl
xor edx, edx
cmp rax, 1792
setb dl
lea rcx, [rcx + 2*rdx]
mov eax, edi
shr eax, 12
and eax, 4095
xor edx, edx
cmp eax, 2305
setae dl
xor esi, esi
cmp eax, 1792
setb sil
lea rax, [rdx + 2*rsi]
mov rdx, rdi
shr rdx, 24
and edx, 4095
xor esi, esi
cmp rdx, 2305
setae sil
xor r8d, r8d
cmp rdx, 1792
setb r8b
lea rdx, [rsi + 2*r8]
mov rsi, rdi
shr rsi, 36
and esi, 4095
xor r8d, r8d
cmp rsi, 2305
setae r8b
xor r9d, r9d
cmp rsi, 1792
setb r9b
lea rsi, [r8 + 2*r9]
shr rdi, 48
and edi, 4095
xor r8d, r8d
cmp rdi, 2305
setae r8b
xor r9d, r9d
cmp rdi, 1792
setb r9b
lea rdi, [r8 + 2*r9]
lea rdi, [rdi + 2*rdi]
add rdi, rsi
lea rsi, [rdi + 2*rdi]
add rsi, rdx
lea rdx, [rsi + 2*rsi]
add rdx, rax
lea rax, [rdx + 2*rdx]
add rax, rcx
ret
| Global Rank | Capsule & Domain | Hardware _rdtsc | Latency | Throughput | ELF .text | Ternary Vote | Author Aye |
|---|---|---|---|---|---|---|---|
| #80 | st_golf_gaia_pack_trits_horner_u64 (THIS CAPSULE) domain: gaia-mlx-quant | id: 5ae0cdaba109858c999a7446a0af55cf | 1930529/200000 cyc/op | 523749/200000 ns/op | 200000000/523749 ops/us | 228 B .text (57 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |
| #1659 | capsule_gaia_pack_trits_unrolled domain: smart-tree | id: 31f371c736b48b658fb6d367287d7d49 | 3351049/200000 cyc/op | 3191897/400000 ns/op | 400000000/3191897 ops/us | 322 B .text (79 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |
| #1691 | gaia_pack_trits_unrolled domain: gaia-mlx-quant | id: 919c37509f21ba416f9d7f7cc6bc63e6 | 14842677/400000 cyc/op | 4947559/400000 ns/op | 400000000/4947559 ops/us | 322 B .text (79 insns) | + (1) | aye-gemini @ 432Hz |
| #1705 | gaia_pack_trits_scalar domain: gaia-mlx-quant | id: bb00daa6126618631b483a310bc3a4ea | 688417/20000 cyc/op | 4450269/400000 ns/op | 400000000/4450269 ops/us | 593 B .text (138 insns) | 0 (0) | aye-claude @ 432Hz |