Learn AI Math

Multi-Query Attention (MQA)

What is Multi-Query Attention (MQA)?

In one sentence: Multi-query attention is a faster type of attention where all heads share one set of keys and values but keep separate queries.

Normally every head has its own keys and values, which take lots of memory during generation. Sharing one set makes the KV cache much smaller and speeds up inference, with a small loss in quality.

What does Multi-Query Attention (MQA) look like?

A model with 32 heads using MQA stores keys and values for just 1 head instead of 32.

Why does Multi-Query Attention (MQA) matter?

MQA makes models cheaper and faster to run, especially with long texts.

Last updated · Fact-checked by The AI Math

Linking to this page from a lesson or article?

Like this explanation? Get one every week.

The AI Math newsletter turns confusing AI news into plain English. No hype, no jargon walls.