atlas

Research map / Large language models / Reasoning and chain of thought

NoMAD-Attention: Efficient LLM Inference on CPUs Through Multiply-add-free Attention

NeurIPS 2024 · Large language models › Reasoning and chain of thought · approach: Efficient LLM serving · 3 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes NoMAD-Attention, which replaces query-key multiply-add attention scores with product-quantized 4-bit key codes and SIMD in-register lookups, giving up to 2x decoding speedup for CodeLlama-7B on CPU at 16k context without finetuning.

Problem

LLM inference on CPUs is bottlenecked by the quadratic multiply-add operations in attention score computation, especially at long context lengths.

Approach

Product-quantize keys into 4-bit codes, compute per-query dot-product lookup tables quantized to 8 bits, and keep each sub-quantizer's table in 128-bit SIMD registers so attention scores are computed via batched shuffle lookups instead of MAD operations; works on pre-trained models without finetuning.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Replace dot-product attention with NoMAD-AttentionCodeLlama-7B with 4-bit weights · 16k contextspeedup: $2\times$ speedupHelped
Replace MAD-based attention with NoMAD-Attention lookups (ablation)Single-head attention · 16k queries at 16k contextattention score computation speedup: $8.3\times$ speedupHelped
Use PQ-Attention with 8-bit codes instead of NoMAD-Attention with 4-bit codes (ablation)Single-head attention · 16k queries at 16k contextattention score computation latencyHurt
Use PQ-Attention with 8-bit codes rather than NoMAD-Attention with 4-bit codes (ablation)Single-head attention key caching · 16k queries at 16k contextkey caching time: $2\times$ moreHurt
Set d_sub=2 instead of d_sub=1 (ablation)NoMAD-Attention on CodeLlama-7B with 4-bit weights · 16k contexttokens per second: $4$ -> $4.2$Helped
Use NoMAD-Attention at 8x key cache compression (d_sub=1)Attention-based LLMs · WikiText-2 test and PTB testperplexity: consistently less than a 4\% increaseHurt
Apply PCA dimensionality reduction to attentionAttention-based LLMs · WikiText-2 test and PTB testperplexityHurt

Surprising findings

Limitations

Experimental setup

Datasets: WikiText-2 Penn Treebank (PTB) stack-overflow-questions

Benchmarks: WikiText-2 Penn Treebank (PTB)

Metrics: perplexity prompt processing time decoding latency per token tokens per second attention latency per query

Baselines: dot-product attention (llama.cpp) PCA-Attention PQ-Attention

Builds on: product quantization PCA-Attention llama.cpp FAISS

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy