Embedl's FlashHead Makes Small AI Models Run 1.75x Faster Without Retraining
A training-free drop-in replacement turns the language model output layer from a dominant cost into a negligible one, delivering up to 1.75x speedups.
ProTakeaways
- FlashHead is a training-free drop-in replacement for the dense classification head in language models, from Embedl.
- The paper reports up to 1.75x end-to-end speedup on Llama-3.2-1B with no accuracy loss.
- It reframes next-token prediction as an inverted-file retrieval problem over clustered token embeddings.
- Four innovations: equal-sized clusters, multi-probing at scale, probabilistic sampling, and selective int4 quantization.
- Validated across Llama-3.2, Llama-3.1-8B, Qwen-3, and Gemma-3, from 270M to 8B parameters.
- Limitation: no closed-form full-vocabulary distribution, requiring Monte Carlo estimation for likelihood-based evals.
The output layer of a small language model has quietly become one of its biggest expenses. As vocabularies balloon past 100,000 tokens while model bodies shrink for phones and laptops, the final matrix multiplication that maps hidden states to token probabilities has swelled into a runtime hog. A new paper from researchers at Embedl introduces FlashHead, a drop-in replacement that treats this layer as a retrieval problem instead of a dense classification, and reports meaningful end-to-end speedups without any retraining.
Why the last layer got so expensive
In state-of-the-art small language models such as Llama-3.2, Gemma 3, and Qwen 3, the classification head alone accounts for between 20% and 60% of total model parameters and dominates inference cost. The reason is arithmetic: the head performs a single matrix multiplication between the hidden state and an embedding matrix with one row per vocabulary token. When the vocabulary is 128,256 tokens (Llama-3.2) but the transformer body has been trimmed to a billion parameters, that one multiplication swallows a huge share of the compute budget.
Existing fixes have tradeoffs. Hierarchical softmax organizes the vocabulary into a tree to reduce complexity, but suffers from tree construction bias and limited flexibility, while adaptive softmax groups tokens by frequency and learns cluster heads jointly with the model. Both require retraining. Vocabulary trimming keeps only frequent tokens but hurts robustness on rare or multilingual inputs. And quantization techniques were developed to compress weights and activations while maintaining model accuracy, yet these methods explicitly avoid quantizing the classification head, since low-bit heads tend to degrade output quality.
Retrieval instead of classification
FlashHead reframes next-token prediction as a two-stage nearest-neighbor lookup inspired by inverted-file indexes from information retrieval. Offline, token embeddings are grouped into clusters using spherical k-means. At inference, the hidden state is first compared against cluster centroids, then only the tokens inside the most promising clusters are scored in full precision.

Four design choices make this practical:
- Equal-sized clusters. A modified k-means step forces every cluster to hold the same number of tokens. Enforcing equal cluster sizes allows the cluster-to-token mapping to be stored as a dense tensor, so token indices can be computed with simple modular arithmetic. Without equal cluster sizes, it becomes ragged and requires per-cluster length tracking and masked gathers, which significantly increase memory access cost on accelerators.
- Aggressive multi-probing. Instead of picking one cluster, FlashHead scores hundreds to thousands of them in parallel. The default configuration uses 8,016 clusters with 512 probes per token, far beyond what prior retrieval-based heads have attempted.
- Probabilistic probe sampling. For open-ended generation, probes are sampled without replacement from a softmax over centroid scores. This unifies top-k retrieval and multinomial sampling in one mechanism, so temperature-based decoding still works.
- Selective int4 quantization. Because the first stage only needs coarse cluster rankings that get refined later, it tolerates low-bit compute that would wreck a dense head.
What the numbers look like
The team benchmarked on an NVIDIA RTX 3500 Ada GPU at batch size 1, the realistic setting for on-device use. Head-only latency dropped dramatically, and those savings carried through to full-model time-per-output-token.
| Model | Head speedup | Full-model speedup (INT4) |
|---|---|---|
| Llama-3.2-1B | 4.9x | 1.75x |
| Llama-3.2-3B | 3.1x | 1.3x |
| Llama-3.1-8B | 2.2x | 1.1x |
| Qwen-3-1.7B | 3.6x | 1.3x |
| Gemma-3-270M | 2.7x | 1.4x |
Accuracy held up across the board. On MMLU-Pro, HellaSwag, IFEval, BoolQ, BBH, TruthfulQA, and GSM8K with Llama-3.2-1B-Instruct, FlashHead is the only method to consistently match the baseline on all aggregate metrics. On top-1 containment (the fraction of tokens matching the dense head's argmax), FlashHead scored 1.00 on Alpaca and MATH-Hard and 0.97 on the multilingual XNLI benchmark, while vocabulary trimming collapsed to 0.51 on XNLI.
The catch
FlashHead does not produce a closed-form probability distribution over the entire vocabulary. That is fine for generation but awkward for research evaluations that need log-likelihoods over every token, like HellaSwag or BoolQ scoring. The authors work around this with a Monte Carlo estimator that averages roughly 10,000 sampled probe sets, but it adds evaluation overhead. Clustering also has a one-time cost: clustering the 128,256-token vocabulary of Llama-3.2 into 8,016 clusters takes 4 hours on a single A40 GPU.
Perhaps the most interesting practical takeaway is what this enables together with quantization. FlashHead unlocks safe int4 execution of the head, which existing inference frameworks avoid. That combination is where the biggest end-to-end gains appear, and it removes one of the last dense fp16 layers standing in the way of fully quantized on-device models. The team says code integrated into Llama 3.2, Gemma 3, and Qwen 3 will be released, though the public repository URL was redacted in the arXiv preprint for blind review.