# Oszczędne warianty uwagi (MQA, GQA, MLA)

EN: **Memory-efficient attention variants (MQA, GQA, MLA)** · id `attnvariants` · aliases: MQA, GQA, MLA, multi-query attention, grouped-query attention, multi-head latent attention

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Sieci i modele generatywne](https://aiatlasgraph.com/t/neural.md) › [Transformery i attention](https://aiatlasgraph.com/t/transformers.md) › Oszczędne warianty uwagi (MQA, GQA, MLA)

## Description

- PL: Modyfikacje uwagi wielogłowicowej ograniczające pamięć KV cache i koszt generowania: MQA współdzieli jeden zestaw kluczy i wartości między głowami, GQA — między grupami głów, a MLA kompresuje reprezentacje kluczy i wartości do przestrzeni ukrytej.
- EN: Multi-head attention variants that reduce KV-cache memory and generation cost: MQA shares one set of keys and values across heads, GQA shares them across groups of heads, and MLA compresses key-value representations into a latent space.

## In one sentence

- PL: To zmiany mechanizmu uwagi zmniejszające pamięć potrzebną do przechowywania wcześniej przetworzonego tekstu.
- EN: These attention changes reduce the memory needed to store previously processed text.

## Problem it solves

- PL: Długie rozmowy zajmują dużo pamięci i ograniczają liczbę osób obsługiwanych jednocześnie.
- EN: Long conversations occupy substantial memory and limit how many people can be served at once.

## What it does

- PL: Części uwagi współdzielą wybrane zapisy albo przechowują je w skompresowanej postaci, zamiast utrzymywać osobne pełne kopie.
- EN: Attention components share selected representations or store compressed versions rather than keeping separate full copies.

## Everyday example

- PL: Wybierasz model z oszczędniejszą uwagą, żeby serwer mógł prowadzić więcej długich rozmów.
- EN: You choose a model with memory-saving attention so a server can handle more long conversations.

## This concerns you if you…

- PL: pamięć ogranicza liczbę równoczesnych rozmów
- PL: porównujesz koszt różnych konstrukcji uwagi
- EN: find memory limits concurrent conversations
- EN: compare the costs of different attention designs

## Keywords

MQA · GQA · MLA · KV cache · shared key-value heads · latent KV compression · DeepSeek-V2

## How it works

- PL: MQA i GQA współdzielą projekcje kluczy oraz wartości pomiędzy głowami zapytań, zmniejszając przechowywany stan. MLA zapisuje skompresowany latent, z którego uzyskuje potrzebne reprezentacje, zmieniając konstrukcję uwagi i jej pamięci podręcznej.
- EN: MQA and GQA share key and value projections across query heads, reducing stored state. MLA stores a compressed latent from which required representations are obtained, changing attention construction and its cache.

## Limits

- PL: Oszczędność pamięci nie usuwa całego kosztu uwagi ani wag modelu. Współdzielenie i kompresja zmieniają pojemność reprezentacji; wdrożenie zależy od treningu oraz obsługi danego wariantu przez silnik.
- EN: Memory savings do not eliminate all attention or model-weight costs. Sharing and compression change representational capacity; deployment depends on training and engine support for the variant.

## Key terms

- PL: **grupa głów**: Głowy zapytań korzystające ze wspólnego zestawu kluczy i wartości.
- PL: **latent KV**: Skompresowana reprezentacja zastępująca bezpośrednie przechowywanie kluczy i wartości.
- EN: **head group**: Query heads using a shared set of keys and values.
- EN: **KV latent**: A compressed representation replacing direct storage of keys and values.

## Know first

- [Mechanizm self-attention (zapytania, klucze, wartości) (Self-attention (queries, keys, values))](https://aiatlasgraph.com/t/selfattention.md)
- [Algebra liniowa: wektory i macierze (Linear algebra: vectors and matrices)](https://aiatlasgraph.com/t/linearalgebra.md)

## Examples

- PL: multi-query attention · grouped-query attention · multi-head latent attention (DeepSeek-V2)

## Related topics

Untyped, symmetric "see also" links.

- [Zarządzanie KV cache (KV cache management)](https://aiatlasgraph.com/t/kvcache.md)

## Sources

- [GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints](<https://arxiv.org/abs/2305.13245>) `gqa-2023` · by Joshua Ainslie, James Lee-Thorp, Michiel de Jong, Yury Zemlyanskiy, Federico Lebrón, Sumit Sanghai
- [The Big LLM Architecture Comparison — From DeepSeek V3 to GLM-5](<https://magazine.sebastianraschka.com/p/the-big-llm-architecture-comparison>) `raschka-llm-arch-comparison` · by Sebastian Raschka
- [Mistral 7B](<https://arxiv.org/abs/2310.06825>) `mistral-7b-2023` · by Albert Q. Jiang, Alexandre Sablayrolles, Arthur Mensch i in. (Mistral AI) · sponsored
- [DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model](<https://arxiv.org/abs/2405.04434>) `deepseek-v2-mla-2024` · by DeepSeek-AI et al. · sponsored

---

AI Atlas revision 122 (2026-10-30) · HTML: https://aiatlasgraph.com/t/attnvariants · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-10-30
