TL;DR
Vision Transformers (ViTs) are great at seeing the world, but way too heavy to fit on tiny, $10 microcontrollers. By squashing *every single weight* and normalization parameter—even the notoriously fragile first and last layers—down to just three values (${-1, 0, +1}$), FTerViT shrinks an 88 MB model down to under 6 MB while barely losing accuracy. For the first time, a strong, standard-architecture ViT can run directly on a tiny edge chip with just 8 MB of RAM.
What Problem Does This Paper Address?
Imagine trying to pack an elephant into a suitcase. That is essentially the challenge of deploying a standard Vision Transformer—like the 88.3 MB DeiT-Small—onto a microcontroller unit (MCU) that only has a few megabytes of memory.
A popular way to shrink neural networks is ternary quantization: forcing 32-bit floating-point (FP32) weights into just three numbers: $-1, 0,$ or $+1$ (stored in 2 bits). However, previous "ternary" ViTs had a secret: they only ternarized the middle transformer blocks. Whenever researchers tried to quantize the input patch embedding, the LayerNorm parameters, or the final classifier head, accuracy fell off a cliff (dropping over 22 percentage points in prior work).
Leaving those delicate layers in full precision sounds harmless—they make up less than 4% of the parameters in a compact model like DeiT-Tiny. Yet, because everything else is compressed 16$\times$, that tiny 4% suddenly balloons to consume 38% of the total storage! On a memory-starved microcontroller, those leftover FP32 bytes are a dealbreaker.
Methods
To eliminate the memory bottleneck without lobotomizing the network, the authors introduce FTerViT, combining a full suite of ternary operators with a clever two-step training recipe. (Note: while weights are ternary, activations remain 8-bit during training).
- New Ternary Primitives: Alongside standard
TernaryBitLinearlayers (from BitNet b1.58, using mean-absolute-value scaling), the authors introduce two novel modules: TernaryBitConv2d: Handles the fragile first-layer patch embedding using per-channel scaling to accommodate wildly varying filter magnitudes.TernaryLayerNorm: Ternarizes the learnable scale ($\gamma$) and shift ($\beta$) parameters while keeping tiny per-token statistics and biases in FP32.- Pure-KL Knowledge Distillation: Instead of training with standard ground-truth labels (cross-entropy loss), which creates conflicting gradients in ultra-low-bit networks, the ternary "student" learns exclusively by mimicking the output probabilities of a frozen FP32 "teacher" of the exact same architecture (forward-KL divergence).
- Two-Phase Training: Phase 1 trains the model for 250 epochs until validation accuracy plateaus. Then comes Phase 2: a brief, 10-epoch "recovery" restart with a 10$\times$ smaller learning rate ($1\text{e-}5$), allowing the quantized scales to gently settle into place.
Datasets
The authors train and evaluate FTerViT on three standard, widely used image classification benchmarks (no new datasets were introduced):
- ImageNet-1K (at $224\times224$ and $384\times384$ resolutions)
- CIFAR-10 and CIFAR-100 (to test generalization on smaller tasks)
Key Insights and Ideas
- Tiny parameter count $\neq$ tiny importance: Using Taylor and Hessian sensitivity analyses, the authors prove why prior methods failed. In DeiT-Small, LayerNorms hold less than 0.2% of the parameters yet account for up to 34% of total model importance, and the patch embedding is the single most sensitive individual layer in the entire network.
- Work smarter, not longer: Prolonging Phase 1 training from 250 to 400 epochs barely helps. Instead, stopping at epoch 250 and running the 10-epoch low-learning-rate Phase 2 recovery vaults accuracy up by 3–4 percentage points—beating the 400-epoch model in a fraction of the compute time.
- Free sparsity & curious scales: Across the network, roughly 37.3% of the ternary weights become exact zeros, giving hardware free opportunities to skip math. Curiously,
TernaryLayerNormscale parameters ($\gamma$) never use the $-1$ bin—only $0$ and $+1$—acting as an essential learned amplifier across layers.
Key Results
- State-of-the-Art Ternary Accuracy: On ImageNet-1K, FTerViT (DeiT-S) hits 77.47% top-1 accuracy at 5.81 MB (15.2$\times$ compression), beating the prior partial-ternary TerViT by +3.27 percentage points while being smaller.
- Closing the FP32 Gap: Using a stronger DeiT-III-S backbone at $384\times384$, FTerViT reaches 82.43% at 6.09 MB—just 2.42 percentage points shy of its 88.9 MB FP32 teacher. On CIFAR-10, DeiT-Tiny hits 97.43% at 1.53 MB (virtually tied with FP32's 97.52%).
- Real Microcontroller Deployment: Using a custom dependency-free C engine (packing 4 weights per byte), they deploy FTerViT-Small (5.81 MB, 79.64% ImageNet accuracy) onto a $10 ESP32-S3-EYE** board (240 MHz dual-core MCU, 8 MB PSRAM). It beats prior MCU-tailored ViTs like MCUFormer by +6.02 percentage points, while kernel-level benchmarks show packed ternary execution is **1.71$\times$ faster and uses 55% less active energy than FP32.
Limitations and Future Work
- Not for real-time video (yet): On the tiny 240 MHz MCU, a full forward pass takes 21.06 seconds, and the C engine uses basic, unoptimized bit-unpacking (keeping activations in FP32 on-device). Right now, this is built for duty-cycled sensing—like snapping one photo an hour to check crop health or monitor remote gauges—not autonomous drones.
- Model scale & training pipeline: Because larger ViTs exceed the 8 MB MCU budget, scaling laws for massive ternary ViTs weren't tested here. Finally, the authors suggest their two-phase training recipe could potentially be unified into a single continuous schedule in future work.
Summary updated