Repository Public MIT Research preview
1% CE01-F06 — Préremplissage et décodage : deux régimes de calcul, deux métriques (TTFT, ITL).2% Question : pourquoi le premier jeton se fait-il attendre, alors que les suivants s'enchaînent vite ?3% DONNÉES : CE01-F06-donnees.tex (multiplications du modèle jouet à T = 128, formes closes vérifiées par les tests).4% Idée : le préremplissage calcule tout le triangle d'attention d'un coup ; le décodage n'ajoute qu'une ligne et relit le cache.5\input{CE01-F06-donnees.tex}%6\begin{tikzpicture}[x=1mm, y=1mm]7 % ---- schéma du préremplissage : tout le triangle ----8 \foreach \i in {0,...,7}{\foreach \j in {0,...,\i}{9 \fill[atlasFlow, fill opacity=.75] (2+\j*1.7, 48-\i*1.7) rectangle ++(1.45, -1.45);}}10 \node[atlas heading, anchor=north west] at (18.5, 49.6) {Préremplissage};11 \node[atlas note, anchor=north west, align=left] at (18.5, 44.6) {les T jetons d'entrée, en une passe ;\\tout le triangle d'attention est calculé ;\\le cache KV est écrit.};12 % ---- schéma du décodage : une seule ligne ----13 \begin{scope}[shift={(66,0)}]14 \foreach \i in {0,...,7}{\foreach \j in {0,...,\i}{15 \draw[atlasValid, line width=.5pt] (2+\j*1.7, 48-\i*1.7) rectangle ++(1.45, -1.45);}}16 \foreach \j in {0,...,8}{\fill[atlasFlow, fill opacity=.75] (2+\j*1.7, 48-8*1.7) rectangle ++(1.45, -1.45);}17 \node[atlas heading, anchor=north west] at (20.2, 49.6) {Décodage};18 \node[atlas note, anchor=north west, align=left] at (20.2, 44.6) {un jeton à la fois ; une seule ligne\\nouvelle, qui relit le cache KV\\(contours : déjà calculé).};19 \end{scope}20 % ---- frise temporelle ----21 \draw[atlas link, -{Stealth[length=5pt]}] (0, 14) -- (140, 14) node[atlas note, anchor=north east] at (140, 13.4) {temps};22 \node[ce phase=atlasFlow, minimum width=58mm, anchor=south west] at (0, 15.2) {préremplissage : \CEFsixPrefill\ multiplications};23 \foreach \k in {0,...,4}{24 \node[ce phase=atlasValid, minimum width=11mm, anchor=south west] (d\k) at (60.5+\k*12.6, 15.2) {};25 }26 \node[atlas note, anchor=west] at (124.5, 18.7) {…};27 \node[atlas note, anchor=south west, text=atlasFg] at (60.5, 23.6) {étapes de décodage : \CEFsixEtape\ multiplications chacune, soit \CEFsixRapport\ fois moins};28 \foreach \x/\n in {59.2/1, 71.8/2, 84.4/3, 97/4, 109.6/5, 122.2/6}{29 \draw[atlasUncertain, line width=1.1pt] (\x, 13) -- (\x, 22.6);30 }31 \node[atlas note, anchor=north, text=atlasUncertain] at (59.2, 12.6) {\textbf{1\textsuperscript{er} jeton}};32 \draw[ce cote, decoration={mirror}] (0, 9.4) -- node[atlas note, below=2.6mm, text=atlasFg] {\textbf{TTFT} : délai avant le premier jeton} (58.4, 9.4);33 \draw[ce cote, decoration={mirror}] (71.8, 12.4) -- node[atlas note, below=2.6mm, text=atlasFg] {\textbf{ITL}} (84.4, 12.4);34 \node[atlas note, anchor=north west, align=left] at (90, 9.2) {latence totale = TTFT + (n − 1) × ITL\\débit ≈ 1 / ITL quand n est grand};35 \node[ce nature, anchor=north east] at (140, 51) {modèle jouet, T = 128};36\end{tikzpicture}37