Files
myWiki/concepts/multi-query-attention.md

862 B
Raw Permalink Blame History

title, created, updated, type, tags, sources
title created updated type tags sources
Multi-Query Attention (MQA) 2025-04-15 2026-05-01 concept

Multi-Query Attention (MQA)

多查询注意力,由 Shazeer 2019 年提出,所有 Q 头共享单个 KV 头。

定义

MQA 是 multi-head-attention 的最激进简化:保留多个 Q 头以维持表达能力,但所有头共享同一对 K 和 V。KV 缓存缩减为 MHA 的 1/h。

质量权衡

  • 优势: KV 缓存极低,推理内存大幅减少
  • 劣势: 表达能力受损,训练不稳定,需要额外优化
  • 应用: PaLM 采用 MQA但后续模型多转向 grouped-query-attention

相关概念