% Compile with pdflatex. Replace the demonstration content before delivery.
\documentclass[aspectratio=169,11pt]{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb,graphicx,booktabs}

\definecolor{AcademicBlue}{RGB}{26,57,86}
\definecolor{AcademicTeal}{RGB}{0,105,112}
\setbeamercolor{structure}{fg=AcademicBlue}
\setbeamercolor{frametitle}{fg=AcademicBlue,bg=white}
\setbeamercolor{title}{fg=AcademicBlue}
\setbeamercolor{alerted text}{fg=AcademicTeal}
\setbeamercolor{block title}{fg=white,bg=AcademicBlue}
\setbeamercolor{block body}{fg=black,bg=AcademicBlue!5}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{itemize items}[circle]
\setbeamertemplate{footline}{%
  \hfill\usebeamerfont{page number in head/foot}%
  \insertframenumber\,/\,\inserttotalframenumber\hspace{4mm}\vspace{3mm}}
\setbeamersize{text margin left=8mm,text margin right=8mm}
\setbeamerfont{frametitle}{size=\Large,series=\bfseries}
\setbeamerfont{title}{size=\LARGE,series=\bfseries}
\newcommand{\papersource}[1]{\par\smallskip{\scriptsize\color{gray}#1\par}}

\usepackage{lmodern}

\title[EG-MLA]{EG-MLA: Embedding-Gated\\Multi-head Latent Attention}
\subtitle{For Scalable and Efficient LLMs\\A critical reading of arXiv:2509.16686v1}
\author{Paper authors: Zhengge Cai and Haowen Hou\\[2mm]\small Independent research-group presentation}
\date{Paper: 20 September 2025 \quad Reading: 14 September 2026}
\begin{document}
\begin{frame}
\titlepage
\end{frame}

\begin{frame}{Extra token-specific capacity enables a smaller cache}
\begin{block}{Core idea}
Modulate reconstructed K/V features using a per-layer token embedding, then apply LayerNorm.
\end{block}
\begin{center}
\begin{tabular}{lrr}
\toprule
Base models, 50B tokens & MLA-kv256 & EG-MLA-kv64\\
\midrule
Mean accuracy across 12 tasks & 43.84\% & 44.33\%\\
KV elements/token, all layers & 3,840 & 1,536\\
Total parameters & 120M & 274M\\
\bottomrule
\end{tabular}
\end{center}
\alert{60.0\% less KV state; 154M extra embedding parameters.}
\papersource{Paper, Tables 1 and 10, PDF pp.5,13. Cache counts recomputed from dimensions.}
\note{Use about one minute. Introduce the distinction between static weights and sequence-dependent state before discussing the headline percentages.}
\end{frame}

\begin{frame}{KV memory grows with both context and concurrency}
\[
M_{\rm KV}=BT\,s\,(2n_hd_hl)\qquad\text{for MHA}
\]
\begin{itemize}
\item $B$: batch size; $T$: cached tokens per sequence.
\item $n_h$: heads; $d_h$: head width; $l$: layers; $s$: bytes/element.
\item MQA/GQA share K/V across heads; MLA stores a shared latent vector plus a positional key.
\item EG-MLA asks whether token identity can compensate for an even smaller latent vector.
\end{itemize}
\begin{block}{Accounting point}
At fixed model size, KV memory is linear in $T$. A full attention-score matrix is a different object.
\end{block}
\papersource{Derived from Table 5, PDF p.7; Appendix B, p.10. The introduction's quadratic-cache wording is inaccurate.}
\end{frame}

\begin{frame}{Context and token identity meet at the gate}
\begin{columns}[c]
\column{0.53\textwidth}
\centering
\includegraphics[width=\linewidth,height=0.75\textheight,keepaspectratio]{figures/fig-02-architecture.pdf}
\column{0.45\textwidth}
\begin{itemize}
\item Hidden state $\mathbf x_t$: context-dependent content.
\item Token ID $i_t$: a per-layer embedding lookup.
\item Project both branches; multiply; normalize.
\item Same token ID gives the same gate within a layer, across contexts.
\end{itemize}
\end{columns}
\papersource{Author's Fig.2, PDF p.3. Offloading and prefetching are inference implementation choices.}
\end{frame}

\begin{frame}{The multiplication follows KV up-projection}
\[
\begin{aligned}
\mathbf c_t^{KV}&=W^{DKV}\mathbf x_t,
&\mathbf{kv}_t^C&=W^{UKV}\mathbf c_t^{KV},\\
\mathbf e_t&=\operatorname{Emb}(i_t),
&\mathbf g_t&=W^{UE}\mathbf e_t,\\
\widetilde{\mathbf{kv}}_t^C
&=\operatorname{LN}(\mathbf{kv}_t^C\odot\mathbf g_t).
\end{aligned}
\]
\begin{itemize}
\item $\mathbf c_t^{KV}\in\mathbb R^{d_c}$ is the compact content state.
\item Both multiplied vectors have width $D_{KV}=n_h(d_h+d_v)$.
\item The gate is not sigmoid-bounded; it can change signs.
\item LayerNorm acts after the product, before splitting K and V.
\end{itemize}
\papersource{Paper, main Eqs.(1)--(5), PDF p.3; Appendix E, pp.12--13. $D_{KV}$ is presentation notation.}
\end{frame}

\begin{frame}{The model retains causal softmax attention}
\[
\begin{aligned}
\mathbf q_{t,h}&=[\mathbf q^C_{t,h};\mathbf q^R_{t,h}],
&\mathbf k_{j,h}&=[\mathbf k^C_{j,h};\mathbf k^R_j],\\
\mathbf u_{t,h}&=\sum_{j\le t}\operatorname{Softmax}_{j}
\!\left(\frac{\mathbf q_{t,h}^{T}\mathbf k_{j,h}}{\sqrt{d_h+d_h^R}}\right)\mathbf v^C_{j,h}.
\end{aligned}
\]
\begin{itemize}
\item $h$ indexes heads; $d_h^R$ is the RoPE branch width.
\item RoPE applies to Q/K positional branches; V is unrotated.
\item Pseudocode adds RMSNorm before KV up-projection, distinct from the LayerNorm after gating.
\item Listed models use direct Q projection when \texttt{q\_lora\_rank=0}.
\end{itemize}
\papersource{Appendix C, Eqs.(6)--(14), PDF p.11; Appendix E, pp.12--13. The prose about RoPE on V conflicts with the formulas/code.}
\end{frame}

\begin{frame}{Multiplication creates structured second-order interactions}
\[
(w_1^Tx_1)(w_2^Tx_2)
=\sum_{a,b}w_1^{(a)}w_2^{(b)}x_1^{(a)}x_2^{(b)}
=x_1^T(w_1w_2^T)x_2.
\]
\begin{block}{Authors' rationale}
Cross-features couple contextual content with token identity without explicitly materializing an outer-product feature vector.
\end{block}
\begin{block}{Reading interpretation}
Each channel has a rank-at-most-one bilinear coefficient matrix. This is a useful mechanism explanation, not a proof of lossless compression or zero extra computation.
\end{block}
\papersource{Paper, main Eqs.(6)--(8), PDF p.4. Rank observation is this reading's derivation.}
\end{frame}

\begin{frame}{A fixed positional branch limits cache compression}
\begin{center}
\begin{tabular}{lrr}
\toprule
Base configuration & Formula, all 12 layers & Elements/token\\
\midrule
MHA & $2\cdot12\cdot64\cdot12$ & 18,432\\
MLA-kv256 & $(256+64)\cdot12$ & 3,840\\
EG-kv128 & $(128+64)\cdot12$ & 2,304\\
EG-kv64 & $(64+64)\cdot12$ & 1,536\\
EG-kv16 & $(16+64)\cdot12$ & 960\\
\bottomrule
\end{tabular}
\end{center}
\begin{itemize}
\item kv64: 91.67\% less state than MHA; 60.0\% less than MLA.
\item Paper: 91.6\% and 59.9\%, using rounded K-element counts.
\item The 64-dimensional RoPE key remains at every layer.
\end{itemize}
\papersource{Tables 5 and 10, PDF pp.7,13. Exact counts derived from the reported architecture; bytes depend on dtype.}
\end{frame}

\begin{frame}{A small activated model can have a large embedding table}
\begin{center}
\begin{tabular}{lrrr}
\toprule
Model & Activated & Gate embeddings & Total\\
\midrule
MLA-Base & 120M & 0 & 120M\\
EG-MLA-Base-kv64 & 120M & 154M & 274M\\
MLA-1.2B & 1188M & 0 & 1188M\\
EG-MLA-1.2B & 1182M & 618M & 1800M\\
\bottomrule
\end{tabular}
\end{center}
\begin{itemize}
\item Near-matched activated parameters do not match total capacity.
\item Training must store and update additional parameters.
\item Inference offloading trades GPU residency for host memory and transfer requirements.
\end{itemize}
\papersource{Tables 4, 7 and 10, PDF pp.7,10,13. ``Activated'' follows the paper's separate embedding accounting.}
\end{frame}

\begin{frame}{The main evaluation uses 50B training tokens}
\begin{itemize}
\item ClimbMix: 400B-token data pool; 50B tokens per main run.
\item Decoder-only language modeling; Base: 12 layers, width 768.
\item 12 downstream tasks: 0-shot, except MMLU at 5-shot.
\item Data mixture tuned using PIQA, ARC-E and HellaSwag validation sets; corresponding test sets used for evaluation.
\item Three PPL datasets: ClimbMix-val, WikiText103, LAMBADA.
\item The gating ablation uses \alert{10B tokens}, not the main budget.
\end{itemize}
\begin{block}{Comparison limits}
No reported multi-seed uncertainty; incomplete task/scorer configuration. Low-rank MLA baselines are not fully swept alongside EG-MLA.
\end{block}
\papersource{Experimental Settings, PDF p.4; Tables 3 and 7, pp.6,10.}
\end{frame}

\begin{frame}{Base accuracy survives aggressive latent compression}
\begin{center}
\begin{tabular}{lrrr}
\toprule
Model & KV elements/token & Mean accuracy & Change vs MLA\\
\midrule
MLA-kv256 & 3,840 & 43.84\% & ---\\
EG-kv256 & 3,840 & 44.46\% & +0.62 pp\\
EG-kv128 & 2,304 & 44.14\% & +0.30 pp\\
EG-kv64 & 1,536 & 44.33\% & +0.49 pp\\
EG-kv16 & 960 & 44.10\% & +0.26 pp\\
\bottomrule
\end{tabular}
\end{center}
\begin{itemize}
\item Fixed embedding width 256; all trained on 50B tokens.
\item kv64 improves PIQA/ARC-C but lowers WinoGrande/BoolQ.
\item Mean improvements are small; no significance estimates.
\end{itemize}
\papersource{Table 1, PDF p.5; cache counts from Table 10, p.13. pp = percentage points.}
\end{frame}

\begin{frame}{Larger embeddings offer diminishing returns}
\begin{center}
\begin{tabular}{rrrr}
\toprule
Embedding width & Embedding params & Mean accuracy & Mean PPL\\
\midrule
128 & 77M & 44.33\% & 25.06\\
256 & 154M & 44.33\% & 22.95\\
512 & 309M & 44.91\% & 20.51\\
1024 & 618M & 45.06\% & 21.01\\
2048 & 1236M & 45.17\% & 20.56\\
\bottomrule
\end{tabular}
\end{center}
\begin{itemize}
\item Fixed latent width 64; 50B training tokens.
\item 512 $\to$ 2048 adds 927M embedding parameters for +0.26 pp.
\item PPL is lower-is-better and does not improve beyond 512 here.
\end{itemize}
\papersource{Tables 2 and 8, PDF pp.6,11. PPL is a three-dataset arithmetic mean. No fitted scaling-law exponent is reported.}
\end{frame}

\begin{frame}{LayerNorm is essential in the reported ablation}
\begin{center}
\begin{tabular}{lrr}
\toprule
10B-token experiment, kv256 & Validation loss $\downarrow$ & vs full EG\\
\midrule
MLA & 3.2156 & +0.0547\\
EG: multiplication + LayerNorm & 3.1609 & ---\\
Remove LayerNorm & 3.2573 & +0.0964\\
Replace multiplication with addition & 3.1901 & +0.0292\\
\bottomrule
\end{tabular}
\end{center}
\begin{itemize}
\item Removing LayerNorm makes EG worse than MLA.
\item Multiplication beats addition, but addition also beats MLA.
\item The result supports the combined design; it does not isolate every contribution of extra capacity and normalization.
\end{itemize}
\papersource{Table 3, PDF p.6. Differences calculated from reported losses.}
\end{frame}

\begin{frame}{At 1.2B activated parameters, the mean is competitive}
\begin{center}
\begin{tabular}{lrr}
\toprule
50B-token experiment & MLA-1.2B & EG-MLA-1.2B\\
\midrule
Mean accuracy & 49.61\% & 49.95\%\\
BoolQ & 53.15\% & 59.45\%\\
LAMBADA & 38.02\% & 40.25\%\\
MMLU & 28.42\% & 26.92\%\\
TruthfulQA & 33.76\% & 31.27\%\\
\bottomrule
\end{tabular}
\end{center}
\alert{+0.34 pp in the mean; 4 task wins, 7 losses, 1 tie.}
\begin{itemize}
\item EG uses 1800M total parameters, including 618M embeddings.
\item The paper's 40.1\% cache ratio conflicts with listed dimensions; see backup calculation.
\end{itemize}
\papersource{Table 4, PDF p.7; Tables 7 and 11, pp.10,14; cache-ratio claim, p.5.}
\end{frame}

\begin{frame}{The medium-scale results qualify the scaling claim}
\begin{center}
\begin{tabular}{lrrr}
\toprule
Large models, context 2048 & Total params & Accuracy $\uparrow$ & Mean PPL $\downarrow$\\
\midrule
MLA-kv512 & 645M & 49.53\% & 12.09\\
EG-kv128-emb512 & 951M & 48.66\% & 12.18\\
EG-kv256-emb512 & 961M & 48.71\% & 11.56\\
\bottomrule
\end{tabular}
\end{center}
\begin{itemize}
\item kv128: accuracy falls by 0.87 pp; mean PPL also worsens.
\item kv256: mean PPL improves, but accuracy falls by 0.82 pp.
\item Billion-scale training is demonstrated; uniform quality gains across scales are not.
\end{itemize}
\papersource{Appendix G, Tables 11--12, PDF p.14. All models trained on 50B tokens.}
\end{frame}

\begin{frame}{Precomputation makes the gate a runtime lookup}
\[
G[i]=W^{UE}\operatorname{Emb}(i)
\qquad\Longrightarrow\qquad
\mathbf g_t=G[i_t].
\]
\begin{itemize}
\item EG-MLA-A precomputes during loading, then looks up and prefetches projected embeddings.
\item Projected tables can be wider than the original embeddings; storage and transfer still matter.
\item Token-specific gating and LayerNorm complicate MLA's fixed-matrix absorption.
\end{itemize}
\begin{block}{Implementation gap}
The appendix supplies a full-sequence forward pass, without an incremental compressed-cache decoding kernel.
\end{block}
\papersource{Efficiency Evaluation, PDF pp.5--7; Fig.2, p.3; Appendix E, pp.12--13. Absorption/storage implications are reading analysis.}
\end{frame}

\begin{frame}{The measured speed trade-off depends on the variant}
\begin{center}
\begin{tabular}{lrrr}
\toprule
Prompt 1024, batch 32 & MLA & EG-MLA & EG-MLA-A\\
\midrule
Prefill (ms) $\downarrow$ & 532 & 542 & 530\\
Decode (ms) $\downarrow$ & 26.1 & 27.7 & 27.1\\
Reported tokens/s $\uparrow$ & 38.4 & 36.1 & 36.9\\
\bottomrule
\end{tabular}
\end{center}
\begin{itemize}
\item Single A800 80GB; 120M MLA vs 274M EG models.
\item Ordinary EG has slower prefill in all 15 plotted settings, conflicting with the prose's average-speedup claim.
\item EG-A improves prefill in some settings; decode is usually slower. At batch 32, its mean gap is about 1 ms.
\end{itemize}
\papersource{Values transcribed from Fig.4, PDF p.7; prose, pp.5--6. tokens/s aggregation is unspecified and numerically resembles 1000/decode(ms).}
\end{frame}

\begin{frame}{Embedding sharding reduces reported training costs}
\begin{center}
\begin{tabular}{llrrr}
\toprule
Nodes & Method & Peak MB & Tokens/s & Step ms\\
\midrule
2 & Vanilla & 13,950 & 42,528 & 385.25\\
2 & Dimension-wise & 12,233 & 86,743 & 188.88\\
4 & Vanilla & 13,950 & 80,114 & 409.02\\
4 & Dimension-wise & 11,759 & 175,031 & 187.21\\
\bottomrule
\end{tabular}
\end{center}
\begin{itemize}
\item At 2 nodes: 12.3\% lower peak memory; 104.0\% higher throughput.
\item Reported communication: 16.25 ms / 24.38 ms at 2 / 4 nodes.
\item Exact input/output shard layout is underspecified; concatenation needs compatible output partitioning.
\end{itemize}
\papersource{Table 6, PDF p.7; Fig.3 and Embedding Parallelism, p.6. These are training measurements, separate from inference latency.}
\end{frame}

\begin{frame}{Sharing nearby layers introduces a measurable quality cost}
\begin{center}
\begin{tabular}{lrrr}
\toprule
Layer group size & Mean accuracy & Change & Mean PPL $\downarrow$\\
\midrule
No sharing & 48.71\% & --- & 11.56\\
2 & 48.53\% & $-0.18$ pp & 11.90\\
4 & 48.15\% & $-0.56$ pp & 12.54\\
6 & 47.80\% & $-0.91$ pp & 13.52\\
\bottomrule
\end{tabular}
\end{center}
\begin{itemize}
\item Reuses parts of KV projections and intermediate activations.
\item Small groups limit degradation; larger groups worsen PPL.
\item Main text recommends size 2; Appendix H recommends 3, but no size-3 result is tabulated.
\end{itemize}
\papersource{Appendix H, Tables 13--14, PDF p.15; main text, p.7. Large-ctx2048-kv256-emb512. Changes here are percentage points.}
\end{frame}

\begin{frame}{Four boundaries govern the interpretation}
\begin{enumerate}
\item \textbf{Capacity:} near-equal activated counts hide substantial extra stored parameters.
\item \textbf{Causality:} missing low-rank MLA sweeps and uncertainty estimates limit attribution of small gains.
\item \textbf{Systems:} compact state needs a documented decoding path, offloading policy and total-memory accounting.
\item \textbf{Consistency:} cache ratios, some hyperparameter rows, a PPL average and latency prose need clarification.
\end{enumerate}
\papersource{Evidence: Tables 1,4,7--12 and Fig.4; Appendix E. The notes document exact locators and arithmetic. No training replication was performed.}
\end{frame}

\begin{frame}{Take away the capacity trade-off and its conditions}
\begin{block}{What the paper establishes}
Token-identity gating with LayerNorm can preserve Base-model quality with much smaller KV state, and is trainable at billion-scale activated capacity.
\end{block}
\begin{block}{What determines deployment value}
Total static storage, context/concurrency, gate reconstruction, and prefetch bandwidth must be evaluated together with task quality.
\end{block}
\begin{block}{Most useful next experiment}
Match total capacity or training FLOPs, sweep MLA's latent width, and benchmark a complete compressed-cache decoder with total peak memory.
\end{block}
\papersource{Synthesis of Tables 1,3,4,10--12 and Fig.4. Next experiment is a proposal from this reading.}
\end{frame}

\begin{frame}{Source and reading scope}
\textbf{Zhengge Cai and Haowen Hou (2025).}\\[2mm]
\emph{EG-MLA: Embedding-Gated Multi-head Latent Attention for Scalable and Efficient LLMs.}\\[3mm]
\href{https://arxiv.org/abs/2509.16686v1}{arXiv:2509.16686v1}, submitted 20 September 2025.
\begin{itemize}
\item Same-version PDF and author TeX source acquired 14 September 2026.
\item Read: all main sections, Appendices A--H and the supplied pseudocode.
\item Page references use 1-based PDF page order (16 pages).
\item Original figures are reused with attribution; numerical tables are retypeset from the paper.
\item This is an independent reading, not an author presentation or an experimental reproduction.
\end{itemize}
\papersource{Companion: reading-notes.zh.md. Main discussion: approximately 25 minutes; following pages are backup material.}
\end{frame}

\appendix
\begin{frame}{Backup: language-modeling gains survive compression}
\begin{center}
\begin{tabular}{lrrrr}
\toprule
Model & ClimbMix PPL & Wiki PPL & LAMBADA PPL & Mean\\
\midrule
MLA-kv256 & 15.45 & 15.63 & 49.88 & 26.99\\
EG-kv256 & 14.32 & 14.26 & 37.12 & 21.90\\
EG-kv128 & 14.49 & 14.34 & 35.73 & 21.52\\
EG-kv64 & 15.32 & 14.58 & 38.94 & 22.95\\
EG-kv16 & 15.13 & 15.08 & 43.76 & 24.66\\
\bottomrule
\end{tabular}
\end{center}
\begin{itemize}
\item All entries are lower-is-better; 50B tokens, embedding width 256.
\item More compression can worsen PPL within EG-MLA.
\item Mean of corpus PPLs is not the perplexity of their concatenation.
\end{itemize}
\papersource{Appendix D, Table 9, PDF p.11. The original caption says 12 tasks, but the table contains three PPL datasets.}
\end{frame}

\begin{frame}{Backup: the 1.2B cache ratio does not reconcile}
\begin{center}
\begin{tabular}{lrr}
\toprule
Listed XLarge configuration & MLA & EG-MLA\\
\midrule
Layers & 24 & 24\\
KV latent dimension & 512 & 128\\
RoPE key dimension & 64 & 64\\
\bottomrule
\end{tabular}
\end{center}
\[
\frac{\text{EG cache}}{\text{MLA cache}}
=\frac{(128+64)\cdot24}{(512+64)\cdot24}=33.3\%.
\]
\begin{itemize}
\item Main text says 40.1\%; these listed dimensions imply 33.3\%.
\item An unreported accounting difference or a textual error could explain it; the paper does not resolve which.
\end{itemize}
\papersource{Claim: PDF p.5. Formula: Table 5, p.7. Dimensions: Tables 7 and 11, pp.10,14. Calculation is this reading's audit.}
\end{frame}

\begin{frame}{Backup: a simple static-memory break-even calculation}
\begin{itemize}
\item Compare Base MLA-kv256 with EG-kv64.
\item Assume equal precision and all 154M extra embeddings on GPU.
\item Ignore workspaces, activations, table expansion and offloading.
\end{itemize}
\[
\text{saved elements/token}=3840-1536=2304
\]
\[
\text{aggregate cached tokens for break-even}
\approx\frac{154\times10^6}{2304}\approx66{,}840.
\]
\begin{block}{Teaching illustration, not a measured threshold}
Aggregate cached tokens scale approximately as $BT$. Offloading changes GPU residency while adding host storage and transfer costs.
\end{block}
\papersource{Derived from Table 10, PDF p.13. The shared dtype cancels in this deliberately simplified accounting.}
\end{frame}

\begin{frame}{Backup: validation loss stays lower in the plotted 1.2B run}
\begin{columns}[c]
\column{0.64\textwidth}
\centering
\includegraphics[width=\linewidth,height=0.70\textheight,keepaspectratio]{figures/fig-07-loss-difference.png}
\column{0.34\textwidth}
\begin{itemize}
\item Horizontal: training tokens, billions.
\item Vertical: EG loss minus MLA loss.
\item Negative values favor EG.
\item This trajectory is not a downstream accuracy curve or a multi-seed uncertainty estimate.
\end{itemize}
\end{columns}
\papersource{Author's Fig.7, Appendix G, PDF p.14.}
\end{frame}
\end{document}
