Does using h heads with head dimension d_model/h increase computational cost compared to a single head of size d_model?

Last updated 22 November 2026

  • No extra matmul FLOPs: projections cost 4·N·d² either way, and QKᵀ costs h·N²·(d/h) = N²·d, same as one head.

  • What grows is the h·N² score count: softmax, masking and dropout do h× more elementwise work, and stored attention weights use h× memory (avoided by FlashAttention).

  • Small heads mean many small matmuls with low hardware efficiency, so d_k is usually kept around 64 to 128.

  • https://inamdaraditya.medium.com/multi-head-attention-from-scratch-a-complete-guide-to-the-engine-that-powers-every-transformer-8e78c5511e11
  • https://apxml.com/courses/foundations-transformers-architecture/chapter-6-advanced-architectural-variants-analysis/self-attention-complexity
  • https://mbrenndoerfer.com/writing/multi-head-attention-transformers
All Transformers interview questions