SPB Git

Repository Public MIT Research preview

CE01-F04-tetes-kv.tex 2.4 KB 42 lines latex

1% CE01-F04 — Attention multi-têtes et variantes de têtes clé-valeur : MHA, GQA, MQA.2% Question : qu'est-ce qui change, exactement, entre MHA, GQA et MQA, et qu'est-ce que cela fait au cache ?3% Idée : le nombre de têtes de REQUÊTE reste H ; seul le nombre de têtes CLÉ-VALEUR (H_kv) change, et le cache KV4% est proportionnel à H_kv. Dessin pour H = 8 : fractions exactes 8/8, 2/8, 1/8.5\begin{tikzpicture}[x=1mm, y=1mm]6  \foreach \p/\titre/\sous/\nkv/\taille/\part in {7      0/MHA/multi-têtes/8/1/100,8      1/GQA/requêtes groupées/2/4/25,9      2/MQA/multi-requêtes/1/8/{12,5}}{10    \begin{scope}[shift={(\p*49.5, 0)}]11      \node[atlas region, minimum width=43mm, minimum height=47mm, anchor=south west, inner sep=0pt] (cadre) at (0,0) {};12      \node[atlas tag=atlasFlow, anchor=west] at ([xshift=3mm]cadre.north west) {\titre};13            \node[atlas note, anchor=north west] at (2.5, 43.6) {\sous};14      % têtes de requête15      \node[atlas note, anchor=south west] at (2.5, 33.6) {H = 8 têtes de requête};16      \foreach \h in {0,...,7}{17        \node[ce tenseur=atlasFlow, minimum width=4mm, minimum height=4.6mm, inner sep=0pt, font=\AtlasSizeTiny\bfseries] (q\h) at (4.6 + \h*4.82, 31) {Q};18      }19      % têtes clé-valeur20      \pgfmathtruncatemacro{\dernier}{\nkv-1}21      \foreach \g in {0,...,\dernier}{22        \pgfmathsetmacro{\xc}{4.6 + (\g*\taille + (\taille-1)/2)*4.82}23        \ifnum\nkv=8\relax24          \node[ce tenseur=atlasValid, minimum width=4mm, minimum height=4.6mm, inner sep=0pt, font=\fontsize{6}{7}\selectfont\bfseries] (kv\g) at (\xc, 19.5) {KV};25        \else26          \node[ce tenseur=atlasValid, minimum width=8.2mm, minimum height=4.6mm, inner sep=0pt, font=\AtlasSizeTiny\bfseries] (kv\g) at (\xc, 19.5) {K, V};27        \fi28      }29      \foreach \h in {0,...,7}{30        \pgfmathtruncatemacro{\g}{\h/\taille}31        \draw[atlas link, draw=atlasMuted] (q\h.south) -- (q\h.south |- 0,25.2) -- (kv\g.north |- 0,25.2) -- (kv\g.north);32      }33      \node[atlas note, anchor=north west] at (2.5, 15.8) {$\CEHkv = \nkv$ tête\ifnum\nkv>1 s\fi\ clé-valeur};34      % jauge du cache35      \draw[atlas band, fill=none] (2.5, 3) rectangle (40.5, 6.6);36      \pgfmathsetmacro{\larg}{38*\nkv/8}37      \fill[atlasValid, fill opacity=.6] (2.5, 3) rectangle (2.5+\larg, 6.6);38      \node[atlas note, anchor=south west, text=atlasFg] at (2.5, 7.3) {cache KV : \textbf{\part\ \%} de celui de MHA};39    \end{scope}40  }41\end{tikzpicture}42
Files main
Menu

Theme