Faktor 2: K und V getrennt gespeichert GQA-Vorteil: KV_Heads < Q_Heads → proportionale Reduktion MQA-Maximum: KV_Heads = 1 → maximale Ersparnis
Warum KV-Cache?
Ohne Cache: Jedes neue Token → volle Attention über alle vorherigen (O(n²) pro Token). Mit Cache: Nur Query neu, K/V aus Speicher (O(n) pro Token). 5-10× Speedup!
GQA Trade-off
Grouped Query Attention: Mehrere Q-Heads teilen sich KV-Heads. Llama 2 70B: 64 Q → 8 KV = 8× Cache-Reduktion bei <1% Qualitätsverlust. Best of Both Worlds.
Präzisions-Optionen
FP16 (Standard): Gute Balance. INT8: 2× Speicher-Reduktion, minimal Qualitätsverlust. INT4: 4× Reduktion, spürbarer aber oft akzeptabler Verlust. FP32: Nur für Research.