>_faiz.palwala

The ALU Inversion: Why 1.58-Bit Models Break Classical Rooflines

November 16, 2026[Tech]

The Classical Expectation

For the last three years of generative AI, every inference engineer has operated under the same physical assumption: single-batch autoregressive decode (M = 1) is purely memory-bandwidth bound. Compute FLOPs do not matter. In standard FP16 or BF16 execution, you read 2 bytes of weight data to perform 2 floating-point operations. The arithmetic intensity is strictly:

Arithmetic Intensity = (2 FLOPs) / (2 Bytes) = 1.0 FLOP/Byte

The memory bus is completely choked feeding the execution units, while the compute ALUs spend the majority of their clock cycles idling, waiting for weights to arrive from DRAM.

Ternary representation completely inverts that dynamic. By packing 5 trits into a single 8-bit byte (3^5 = 243 <= 256), model weights compress by nearly 8x. But for every byte streamed from RAM, the hardware now has to unpack and calculate across 5 distinct weights. The arithmetic intensity jumps to:

Arithmetic Intensity ≈ 8.0 FLOP/Byte

Suddenly, the memory controllers are resting. The bottleneck flips entirely into instruction issue throughput, unpacking math, and dependency stalls.

On our testbed, reading the 22.28 MB Gate/Up projection matrix for Ternary-Bonsai-2-27B at theoretical line-rate should take roughly 87.6 µs. Yet our initial naive kernel took 773.7 µs, streaming at just 28.8 GB/s. The memory bus was barely at 38.7% utilization. The GPU wasn’t memory-bound at all; it was choked on ALU instruction issue bottlenecks.


What They Don’t Teach You in School

Like any sane engineer, instead of just vibing it, I turned to the literature. If someone has already invented the wheel, why reinvent it? But when we attempted to solve this ALU bottleneck using standard techniques from recent systems papers, we ran directly into hardware ceilings.

1. Why Microsoft T-MAC (ASPLOS 2024) Fails in Base-3

Microsoft’s T-MAC introduced an elegant concept: do not unpack compressed weights at runtime. Instead, precompute all possible linear combinations of activations into a lookup table so matrix multiplication becomes simple table indexing.

T-MAC assumes power-of-2 bit groupings (2-bit or 4-bit integers). In Base-3 packing, 5 trits are packed per byte. Constructing an activation table for 5-element activation groups across an input dimension of K = 5120 requires:

1024 groups × 243 combinations × 2 bytes (FP16) = 497.6 KB

On-chip threadgroup SRAM is hard-capped at 32 KB.

A Base-3 activation table overflows fast local memory by 15.5x, forcing spills into slower caches and DRAM. That memory spilling destroys throughput, making T-MAC slower than direct arithmetic unpacking.

The table has to sit on the weights side: a static 243-entry weight lookup table requires only 2.43 KB, which fits comfortably inside on-core caches.

2. Why BitNet.cpp’s Bit-Plane Popcount Loses to Dual-Issue FP16

On x86 and ARM CPUs, BitNet partitions weights into Sign and Non-Zero bit-planes, computing dot products using SIMD popcount instructions without floating-point math.

Modern GPU execution units feature dedicated dual-issue FP16 FMA pipelines capable of retiring two FP16 multiply-accumulates per cycle. Integer shift, mask, and bitwise popcount instructions share a secondary integer unit with lower issue throughput.

Issuing single-cycle fma(x, w, acc) instructions with unpacked FP16 weights executes nearly 2x faster than integer bit-plane logic.


The v0.6.0 Production Core: Fused SOTA and Warp Cooperativity

To overcome these physical bottlenecks, we engineered the v0.6.0 production core around bare-metal measurements:

Rendering Graph...
  1. Horizon 32-Byte Block Interleaving: Packed weights, FP16 scales, and biases are stored in contiguous 32-byte blocks matching 128-byte cachelines with zero stride penalties.
  2. Shape-Aware Dispatch:
    • Wide MLP Projections (N > 1024): 1D SRAM activation caching (threadgroup half shared_act[128]) streams weights at 95.1 GB/s sustained, cutting MLP latency to 234.3 µs.
    • Narrow Attention KV Projections (N <= 1024): 32-lane cooperative SIMD warp reductions with zero threadgroup barriers, eliminating idle core starvation.
  3. Fused Operator Graph:
    • TernarySwiGLU: Fuses Gate, Up, and SiLU multiplication into a single kernel dispatch.
    • TernaryFusedQKV: Evaluates Query, Key, and Value projections in a single memory sweep.
  4. AMX JIT Prefill Engine (M > 1): Dispatches prompt evaluation directly into hardware AMX matrix coprocessors, delivering 116.34 tok/s prefill throughput (1.15x faster than official baseline).

Announcing mlx-ternary v0.6.0: Open Source on GitHub

Today, we are officially flipping mlx-ternary public on GitHub:

What is Shipped in v0.6.0:

  • 6.37 GB Unified Memory Baseline: Slashes 27.2B model memory from 54.4 GB (FP16) down to 6.37 GB flat (0.78 GB lighter than official baseline, 0.00 GB memory leaks).
  • 116.3 tok/s Prefill / 15.2 - 16.5 tok/s Decode: Outperforming official baseline prefill by 15% on an everyday laptop.
  • 100% Bit-Exact Parity: Bit-for-bit identical outputs matching reference models.
  • Zero-Build JIT Runtime: Pure Python and Metal Shading Language dynamically compiled via mlx.core.fast.metal_kernel.
  • Quarantined Speculative Research Track: Full Prompt Lookup Decoding (PLD) and 16-layer self-speculative draft proposal engines accessible via --speculative-experimental.

Quickstart:

pip install mlx-ternary

# Audit your GPU:
mlx-ternary bench

# Run interactive generation on 27.2B Bonsai:
mlx-ternary generate prism-ml/Ternary-Bonsai-2-27B-mlx-2bit --prompt "def quicksort(arr):"

The Roadmap: What Comes Next

We are not stopping at 95 GB/s.

  • v0.7.0 (Christmas 2026): Pure-ALU Shift-and-Mask LUT Inversion (ADR-003)
    Replaces constant-memory lookup tables with pure ALU bit-shifts and masking arithmetic to eliminate register pressure and push bus utilization toward the 140+ GB/s physical ceiling.
  • v0.8.0 (Q1 2027): Continuous Batching & Multi-Model Serving
    Paged KV cache management and concurrent multi-model hosting in unified memory.

If you are an engineer optimizing on-device inference, building custom Metal shaders, or pushing low-bit LLM boundaries, clone the repository, run the benchmarks on your hardware, and let’s push edge silicon to its absolute physical limits.