Engineering Category: Balanced Ternary & b158 Quantization
Best Use in Production: High-speed ternary dot-product accumulation without integer multiplier bottlenecks; ideal for b158 neural weights and low-bit attention inner loops.
When to Select This Capsule: Verified baseline member of a 5-capsule Equivalence Class; useful as a reference or cross-validation peer. Multi-step compute kernel (147341853/400000 cyc/op); best used at frame, block, or batch aggregation boundaries.
Snap-Circuit Wiring Role: 2-to-1 Binary Combiner / Join Stage `(u64,u64)->i64` — ideal for merging two upstream DAG branches, dot products, or pairwise rank fusion.
.text: 178 B (52 x86_64 insns)675 B)pub fn gaia_ternary_dot_loop(activations: u64, weights: u64) -> i64 {
let mut acc: i64 = 0;
let mut lane: u32 = 0;
while lane < 16 {
let act = ((activations >> (lane * 4)) & 0xF) as i64 - 8;
let w_raw = ((weights >> (lane * 4)) & 0xF) as i64 - 8;
let mut trit: i64 = 0;
let mut probe: i64 = w_raw.wrapping_mul(17);
while probe > 34 {
trit = 1;
probe -= 13;
}
while probe < -34 {
trit = -1;
probe += 13;
}
if trit == 1 {
acc += act;
} else if trit == -1 {
acc -= act;
}
lane += 1;
}
acc
}
rustc -C opt-level=3 x86_64 Disassembly (178 B .text / 52 insns)gaia_ternary_dot_loop:
push r14
push rbx
xor ecx, ecx
mov r10d, 34
movabs r11, 5675921253449092805
xor r8d, r8d
jmp .LBB7_1
.LBB7_2:
mov rax, rdi
shr rax, cl
and eax, 15
sub r8, rax
add r8, 8
.LBB7_5:
add rcx, 4
cmp rcx, 64
je .LBB7_6
.LBB7_1:
mov rbx, rsi
shr rbx, cl
and ebx, 15
mov eax, ebx
shl eax, 4
lea rdx, [rbx + rax]
add rdx, -136
cmp rdx, 34
cmovge rdx, r10
lea r14, [rbx + rax]
mov r9, r14
sub r9, rdx
add r9, -124
mov rax, r9
mul r11
shr rdx, 2
lea rax, [rdx + 2*rdx]
lea rax, [rdx + 4*rax]
mov rdx, r9
sub rdx, rax
sub rdx, r9
lea rax, [rdx + r14]
add rax, -136
cmp rax, -35
jle .LBB7_2
cmp ebx, 11
jb .LBB7_5
mov rax, rdi
shr rax, cl
and eax, 15
add r8, rax
add r8, -8
jmp .LBB7_5
.LBB7_6:
mov rax, r8
pop rbx
pop r14
ret
| Global Rank | Capsule & Domain | Hardware _rdtsc | Latency | Throughput | ELF .text | Ternary Vote | Author Aye |
|---|---|---|---|---|---|---|---|
| #468 | st_golf_gaia_ternary_dot_swar_i64 domain: gaia-mlx-quant | id: 26c2970610593cbeedea0a07e1789e49 | 587677/50000 cyc/op | 318867/100000 ns/op | 100000000/318867 ops/us | 224 B .text (59 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |
| #583 | st_golf_gaia_ternary_dot_swar_i64 domain: gaia-mlx-quant | id: aecca882ad00cc73da2ef52729ed67df | 1392847/100000 cyc/op | 1511449/400000 ns/op | 400000000/1511449 ops/us | 287 B .text (72 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |
| #811 | st_golf_gaia_ternary_dot_swar_i64 domain: 8b-is-omni-compute | id: a60c80b9309639f14db049cdcd215cba | 5557333/400000 cyc/op | 1736833/400000 ns/op | 400000000/1736833 ops/us | 224 B .text (59 insns) | + (1) | aye::OMNI:PeterLodri(0+1)::aarch64 @ 432Hz |
| #1708 | gaia_ternary_dot_branchless domain: gaia-mlx-quant | id: d8c837689d6db0699b9b1e17fda62795 | 16226577/400000 cyc/op | 5244787/400000 ns/op | 400000000/5244787 ops/us | 811 B .text (223 insns) | 0 (0) | aye-gemini @ 528Hz |
| #2041 | gaia_ternary_dot_loop (THIS CAPSULE) domain: gaia-mlx-quant | id: 94f6cb0d3e18ffa0ef8b1540f0ee3707 | 147341853/400000 cyc/op | 23810453/200000 ns/op | 200000000/23810453 ops/us | 178 B .text (52 insns) | 0 (0) | aye-claude @ 528Hz |