EasyDeepLearn

How do you pick the head dimension dheadd_{\mathrm{head}}?

hard

Answer

  • Common choice: dhead  =  d  /  nheadsd_{\mathrm{head}}\; = \;d\; / \;n_{\mathrm{heads}} (so total FLOPs match a single-head version with hidden dim d). dheadd_{\mathrm{head}} too small (< 32) → heads can't represent complex relationships; too large (> 128) → wastes parameters on redundancy.
  • Typical: dhead  =  64128d_{\mathrm{head}}\; = \;64 - 128.
  • Grouped-query attention (GQA, MQA) share K/V across groups of heads to reduce KV cache without hurting quality much.
Check yourself — multiple choice
  • dheadd_{\mathrm{head}} is fixed at 1
  • dhead  =  d/nheadsd_{\mathrm{head}}\; = \;d / n_{\mathrm{heads}} typically; too small underfits, too big wastes params; GQA/MQA share K/V to save KV cache
  • dheadd_{\mathrm{head}} can only be 512
  • Doesn't matter

dheadd_{\mathrm{head}} ≈ 64-128 typical; GQA/MQA share K/V to cut inference memory.

#attention#transformers

Practise Deep Learning

214 interview questions in this topic.

Related questions