% 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}}


\title[KVM]{Key-Value Means}
\subtitle{Transformers with Expandable Block-Recurrent Compressed Memory}
\author{A paper discussion\\[2mm]\small Paper authors: Daniel Goldstein, Navneel Singhal, Eugene Cheah}
\date{arXiv:2605.09877v5 (3 August 2026)\\Reading: 22 September 2026}
\begin{document}
\begin{frame}
\titlepage
\centering\small Exact recent tokens + compressed, optionally growing memory.
\end{frame}
\begin{frame}{Memory capacity should be a design choice}

\begin{columns}[T]
\begin{column}{.48\textwidth}
\begin{block}{Full attention}
Keep every historical KV pair.
\end{block}
\begin{itemize}
\item State grows as $O(N)$.
\item Each new query scans growing history.
\end{itemize}
\end{column}
\begin{column}{.48\textwidth}
\begin{block}{Fixed-state recurrence}
Compress everything into a fixed state.
\end{block}
\begin{itemize}
\item Constant state and amortized work.
\item Novel information competes for capacity.
\end{itemize}
\end{column}
\end{columns}
\bigskip
\alert{KVM asks: can state grow more slowly than the context?}

\papersource{Sec. 1, PDF pp. 1--2; Table 1. N = sequence length.}
\end{frame}

\begin{frame}{One softmax reads recent tokens and old memory}

\centering
\includegraphics[width=.84\linewidth,height=.65\textheight,keepaspectratio]{figures/fig02-attention.pdf}
\par\small Blue: causal local window. Orange: compressed historical state.

\papersource{Original Fig. 2, PDF p. 4. Illustration: C = 3, L = 6; experiments: C = 256, L = 512.}
\end{frame}

\begin{frame}{Block boundaries separate reading from compression}

\begin{enumerate}
\item Form Q, K and V using the GPTAlpha-2 backbone.
\item Read the current state and causal BSWA window.
\item At the boundary, remove the oldest window block.
\item Append selected tokens; merge the rest into memory.
\item Reuse the updated state for the next query block.
\end{enumerate}
\begin{block}{Initialization matters}
The first chunk creates $C$ state rows. Do not merge it a second time.\par
The first $S=1$ row is a protected, readable sink.
\end{block}

\papersource{Sec. 3.2, PDF pp. 4--6; Appendix B, pp. 17--18 (equivalent shifted update order).}
\end{frame}

\begin{frame}{Readout uses one competition over both regions}

\[
 K^A=\begin{bmatrix}\tau_{\mathrm{state}}\hat s^K\\\tau_{\mathrm{bswa}}k_{b:e}\end{bmatrix},
 \qquad V^A=\begin{bmatrix}\hat s^V\\v_{b:e}\end{bmatrix}
\]
\[
 y_u=\operatorname{softmax}\!\left(\frac{q_u(K^A)^\top}{\sqrt{d_h}}+M_u\right)V^A
\]
\begin{itemize}
\item $\hat s^K,\hat s^V$: normalized memory readouts.
\item $\tau$: learned per-head inverse temperatures for each region.
\item $M_u$: all old state visible; future local tokens masked.
\end{itemize}

\papersource{Sec. 3.2 Readout, PDF pp. 5--6 (unnumbered equations). $b=e-L$; $d_h$ = head dimension.}
\end{frame}

\begin{frame}{Append the tokens least represented by old memory}

\[
 s_j=\max_i\bar k_j\hat s_i^{K\top},\qquad
 A_e=\text{indices of the }n_{\mathrm{append}}\text{ smallest }s_j
\]
\begin{itemize}
\item A preset budget determines \emph{how many} rows to add.
\item Similarity determines \emph{which} overflow tokens get new rows.
\item Copy $\bar k_j$, $v_j$, and the initial value radius $\|v_j\|_2$.
\item Then merge the remaining tokens into the expanded state.
\end{itemize}
\begin{block}{Content selection is adaptive; capacity scheduling is preset}
No learned, content-dependent growth budget is evaluated here.
\end{block}

\papersource{Sec. 3.2 Append, PDF p. 6; Appendix G, p. 22. Overflow token index: j.}
\end{frame}

\begin{frame}{Merge uses hard routing and a learned write weight}

\[
 g_j=1+\operatorname{ELU}(x_jW_g),\qquad
 \pi(j)=\operatorname*{arg\,max}_{i\ge1}\bar k_j\operatorname{LN}_s(s_{+,i}^K)^\top
\]
\[
 s_{\mathrm{new},i}^K=s_{+,i}^K+\sum_{j:\pi(j)=i}g_j\bar k_j,
 \quad
 s_{\mathrm{new},i}^V=s_{+,i}^V+\sum_{j:\pi(j)=i}g_jv_j
\]
\begin{itemize}
\item Route into old rows or rows appended in this same step.
\item Exclude the protected sink from merge targets.
\item Positive $g_j$ controls update strength, not the target ranking.
\item Batch assignments precede accumulation; old state is not decayed.
\end{itemize}

\papersource{Sec. 3.2, PDF pp. 5--6. $s_+$ is the post-append state; $W_g$ is $d$ by 1 for each head.}
\end{frame}

\begin{frame}{Value radius preservation protects readout scale}

\[
 \hat s_i^K=\operatorname{LN}_s(s_i^K),\qquad
 \hat s_i^V=\rho_i\frac{s_i^V}{\max(\|s_i^V\|_2,\epsilon_{\mathrm{norm}})}
\]
\begin{itemize}
\item Persist weighted sums; normalize just before reading.
\item $\rho_i$ is set when a slot is created and never updated.
\item No per-slot token count is needed for this normalized readout.
\end{itemize}
\begin{block}{Reader's teaching example}
Averaging $(1,0)$ and $(0,1)$ shrinks the norm to $1/\sqrt2$.\par
Restoring norm preserves scale, but cannot recover both input vectors.
\end{block}

\papersource{Sec. 3.2, PDF pp. 5--7; Appendix G, p. 22. Normalization is not lossless compression.}
\end{frame}

\begin{frame}{Local position survives; old rotary content is removed}

\[
 \bar k_t=\operatorname{LN}_s\!\left(k_t
 \operatorname{diag}(\underbrace{0,\ldots,0}_{r},\underbrace{1,\ldots,1}_{d_h-r})\right)
\]
\begin{itemize}
\item Queries and local keys use partial RoPE (usually half the channels).
\item Overflow keys lose the original rotary-subspace content.
\item A single query/projection family can read both regions.
\item This sacrifices some key expressivity; it is not inverse rotation.
\end{itemize}
\small\alert{Formula-reading caveat:} affine LayerNorm follows zeroing; final channels need not remain zero. Strict position invariance is not proved.

\papersource{Eq. (1), PDF p. 5; Appendix G, pp. 22--23. Caveat is reader analysis.}
\end{frame}

\begin{frame}{State growth sets the asymptotic cost}

\centering
\begin{tabular}{lccc}
\toprule
Strategy & State & Prefill & Decode/token\\
\midrule
KVM fixed & $O(1)$ & $O(N)$ & $O(1)$\\
KVM sqrt & $O(\sqrt N)$ & $O(N^{1.5})$ & $O(\sqrt N)$\\
Full attention & $O(N)$ & $O(N^2)$ & $O(N)$\\
\bottomrule
\end{tabular}
\bigskip
\begin{itemize}
\item Fixed chunk/window sizes and head dimensions; amortized decode.
\item Reader derivation: $m(t)\propto t^\alpha$ gives $O(N^{1+\alpha})$ prefill.
\item Within-chunk parallelism does not remove state dependencies.
\item Runtime state size is not total training peak memory.
\end{itemize}

\papersource{Table 1, PDF p. 2; Appendix B, p. 18. General exponent and memory caveat: reader analysis.}
\end{frame}

\begin{frame}{The novelty lies in a combination of choices}

\begin{itemize}
\item \textbf{Versus OVQ:} joint local/state softmax, growable rows, gated sums and JIT normalization without counts.
\item \textbf{Versus fixed-state recurrence:} capacity can grow with context.
\item \textbf{Versus post-hoc KV merging:} train the model to use compressed memory; do not preserve full-attention outputs exactly.
\item \textbf{Implementation:} standard operations are sufficient; reported speed results use custom Triton kernels.
\end{itemize}

\papersource{Sec. 2, PDF pp. 2--3; Appendix A, pp. 16--17; Sec. 5, pp. 8--9.}
\end{frame}

\begin{frame}{Evaluation covers small trained models and length extrapolation}

\begin{tabular}{ll}
\toprule
Model / tokens & 120M / 3B; 350M / 7.8B\\
Data / training context & Prolong / 8K\\
KVM window & $C=256$; two chunks ($L=512$)\\
Memory schedules & Fixed 256; $16\sqrt N$; saturating hybrid\\
\bottomrule
\end{tabular}
\medskip
\begin{itemize}
\item GPTA-2 full attention, BSWA, RWKV-7 and OVQ/SWA baselines.
\item TextbookChapters loss and NIAH evaluated out to 32K.
\item Full RULER at \textbf{4K}; LongBench \textbf{few-shot subset}.
\item RWKV-7 uses its own backbone; comparisons are not all module-only.
\end{itemize}

\papersource{Sec. 4, PDF p. 7; Appendix D, p. 19. Hybrid state caps approach 1024; alternate SWA = 256.}
\end{frame}

\begin{frame}{Stable long-position loss does not guarantee retrieval}

\centering
\includegraphics[width=.87\linewidth,height=.65\textheight,keepaspectratio]{figures/fig04-loss.png}
\par\small Top: 120M. Bottom: 350M. Lower loss is better; each point averages 1024 tokens.
\par\small KVM remains competitive beyond 8K; GPTA HalfRoPE/SWA remains strong.

\papersource{Original Fig. 4, PDF p. 8. No exact point values or confidence intervals are reported.}
\end{frame}

\begin{frame}{Growing state rescues difficult retrieval at 16K}

\centering
\begin{tabular}{lrrrr}
\toprule
350M model & S1 32K & S2 16K & S3 16K & S3 32K\\
\midrule
RWKV-7 & 12.6 & 2.0 & 1.2 & 0.4\\
GPTA-2 & 22.4 & 45.2 & 37.6 & 5.8\\
KVM-256 & 98.8 & 3.6 & 3.0 & 2.4\\
KVM-sqrt & 98.4 & 71.0 & \textbf{77.6} & \textbf{36.6}\\
OVQ/SWA & 45.2 & 17.6 & 8.6 & 2.6\\
\bottomrule
\end{tabular}
\bigskip
\begin{itemize}
\item S3 16K: $3.0\to77.6$, a \textbf{74.6 percentage-point} increase.
\item S2/S3 use essay distractors; novelty is the authors' explanation.
\item Even growing memory degrades at 32K. Retrieval is not solved.
\end{itemize}

\papersource{Selected entries, Table 2, PDF p. 8. All scores higher is better; trained context is 8K.}
\end{frame}

\begin{frame}{Retrieval gains depend on task and model scale}

\begin{columns}[T]
\begin{column}{.48\textwidth}
\begin{block}{120M KVM-sqrt, 32K}
S1: 99.6\\
S2: 4.2\\
S3: 2.6
\end{block}
Growing state alone is insufficient for strong difficult retrieval.
\end{column}
\begin{column}{.48\textwidth}
\begin{block}{350M, S2 at 32K}
KVM-sqrt: 17.0\\
GPTA-2: 20.8\\
GPTA HalfRoPE/SWA: 23.6
\end{block}
The same ranking does not hold across tasks and lengths.
\end{column}
\end{columns}
\bigskip
\alert{Scale comparison changes both parameter count and training tokens.}

\papersource{Table 2, PDF p. 8; training setup, p. 7. Scores higher is better.}
\end{frame}

\begin{frame}{Competitive averages still leave a RULER gap}

\centering
\begin{tabular}{lrrr}
\toprule
350M model & Short avg. & LB subset & RULER-4K\\
\midrule
GPTA-2 & 47.2 & 25.1 & 47.2\\
KVM-256 & 47.3 & 23.7 & 33.2\\
KVM-sqrt & 47.7 & 25.0 & 38.6\\
KVM/SWA & 47.3 & 25.2 & 40.7\\
OVQ/SWA & 46.9 & 21.0 & 29.0\\
\bottomrule
\end{tabular}
\bigskip
\begin{itemize}
\item KVM-sqrt closely matches GPTA-2 on this LB subset average.
\item It trails GPTA-2 by \textbf{8.6 points} on full RULER at 4K.
\item Small short-task differences lack reported multi-seed uncertainty.
\end{itemize}

\papersource{Table 2, PDF p. 8; Table 4, p. 20. All columns higher is better; short avg. excludes perplexity.}
\end{frame}

\begin{frame}{Speed improves at long contexts within a defined kernel scope}

\centering
\includegraphics[width=.93\linewidth,height=.40\textheight,keepaspectratio]{figures/fig05-speed.png}
\par\medskip
\begin{tabular}{lrrr}
\toprule
32K speedup & Decode & Prefill & Backward\\
\midrule
KVM-256 & $29.77\times$ & $4.59\times$ & $7.99\times$\\
KVM-sqrt & $7.88\times$ & $1.76\times$ & $3.30\times$\\
\bottomrule
\end{tabular}
\par\medskip\small MI325X; one layer; 32 heads $\times$ 128 dims; batch 8; BF16 I/O.\par
\small Includes routing/state updates; excludes projections, position encoding and other layer work.

\papersource{Original Fig. 5 and Sec. 5, PDF pp. 8--9. Baseline: PyTorch Flash SDPA / ROCm AOTriton.}
\end{frame}

\begin{frame}{Value normalization matters far more for long retrieval}

\centering
\begin{tabular}{lrrr}
\toprule
120M KVM-256 & S1 32K & RULER-4K & Short avg.\\
\midrule
Baseline & 98.4 & 25.2 & 42.0\\
No sink & 79.6 & 19.1 & 41.9\\
No head temperatures & 98.8 & 25.5 & 42.2\\
No value-length norm & \textbf{3.6} & 13.4 & 42.6\\
No merge gate & 87.8 & 20.3 & 42.5\\
\bottomrule
\end{tabular}
\bigskip
\begin{itemize}
\item Removing value normalization costs 94.8 points on S1 32K.
\item Short benchmarks largely miss this failure.
\item Temperature gains are mixed; key JIT norm is not separately ablated.
\end{itemize}

\papersource{Table 3, PDF p. 9; Table 5, p. 20. Selected reported entries; all columns higher is better.}
\end{frame}

\begin{frame}{Length extrapolation has several distinct meanings}

\begin{columns}[c]
\begin{column}{.59\textwidth}
\includegraphics[width=\linewidth,height=.64\textheight,keepaspectratio]{figures/fig06-rope.png}
\end{column}
\begin{column}{.39\textwidth}
\begin{itemize}
\item HalfRoPE stabilizes position-wise loss.
\item NoPE can still win on specific retrieval tasks.
\item More NoPE training improves some scores but worsens long-position loss.
\end{itemize}
\small These tests use GPTA-2/SWA, not an isolated KVM position ablation.
\end{column}
\end{columns}

\papersource{Original Fig. 6, p. 21; Tables 6--7, pp. 20--21. Figure says 7Gtok; tables specify 7.8Gtok.}
\end{frame}

\begin{frame}{The evidence supports a trade-off, with open questions}

\begin{itemize}
\item \textbf{Scale:} 120M/350M language-model experiments, not large deployed models.
\item \textbf{Compression:} no lossless guarantee, error bound or capacity theorem.
\item \textbf{Systems:} no end-to-end throughput or full peak-memory study.
\item \textbf{Schedules:} fixed during training; adaptive capacity and train/test changes remain future work.
\item \textbf{Transfer:} GQA/MLA combinations and distillation are proposed, not demonstrated.
\end{itemize}

\papersource{Sec. 7, PDF pp. 9--10; evidence boundaries from Secs. 4--6 and Appendices D--G.}
\end{frame}

\begin{frame}{Take home: grow memory when fixed capacity becomes limiting}

\begin{enumerate}
\item \textbf{Mechanism:} one softmax over exact recent KV and compressed old KV; append novel content, merge similar content.
\item \textbf{Result:} growing state substantially improves difficult retrieval in some settings, while reducing long-context mixing cost.
\item \textbf{Boundary:} gains depend on task, scale and budget; full attention still wins some important comparisons.
\end{enumerate}
\begin{block}{Discussion}
Which workload is limited by memory capacity, and which by local modeling or compute overhead?
\end{block}

\papersource{Synthesis of Secs. 3--7. Suggested main presentation: about 25 minutes; backup follows references.}
\end{frame}

\begin{frame}{Paper and reproducibility entry points}

\textbf{Daniel Goldstein, Navneel Singhal, Eugene Cheah.}\par
\medskip
\emph{Key-Value Means: Transformers with Expandable Block-Recurrent Compressed Memory.}\par
\medskip
arXiv:2605.09877v5, revised 3 August 2026.\par
\href{https://arxiv.org/abs/2605.09877v5}{arxiv.org/abs/2605.09877v5}\par
\medskip
\href{https://github.com/featherless-ai/KVM-paper}{Code linked by the paper: featherless-ai/KVM-paper}\par
\href{https://huggingface.co/collections/featherless-ai/kvm-paper}{Models linked by the paper: featherless-ai/kvm-paper}\par
\bigskip
\small This discussion reads the version-matched PDF and author TeX, including Appendices A--G. Original figures are reused; selected tables are re-typeset. Experiments were not rerun.

\end{frame}

\begin{frame}{Backup: budget growth is monotone and supply-limited}
\[
 M^\star(e)=\max\{m,\min(\mathcal B(e),m+C)\},
 \quad n_{\mathrm{append}}=\min(M^\star(e)-m,|\Omega_e|)
\]
\begin{itemize}
\item Never delete state rows; add at most one overflow chunk.
\item Initialize with $C$ rows before applying growth updates.
\end{itemize}
\medskip
\centering
\begin{tabular}{lll}
\toprule
Choice & Budget behavior & Evaluated configuration\\
\midrule
Fixed & 256 slots & All KVM layers\\
Power law & $16\sqrt N$ & All KVM layers\\
Saturating & Approaches 1024 & KVM/SWA hybrid\\
\bottomrule
\end{tabular}
\papersource{Sec. 3.2, p. 6; schedules summarized from Fig. 3, p. 5 and Sec. 4, p. 7. m = current rows.}
\end{frame}

\begin{frame}{Backup: row counts are not measured memory bytes}

\begin{block}{Reader calculation at $N=32768$, with $L\le512$}
KVM-sqrt: $16\sqrt{32768}\approx2896$ state rows.\par
State plus window: $\approx3408$ rows, or $10.4\%$ of full KV rows.\par
\medskip
KVM-256: at most $256+512=768$ rows, or $2.34\%$.
\end{block}
\begin{itemize}
\item Excludes radius scalars, dtype differences and temporary tensors.
\item Training may retain intermediate states for backpropagation.
\item Budget rounding and block timing affect exact counts.
\end{itemize}

\papersource{Reader calculation from the schedules in Sec. 4, p. 7; not an empirical GPU-memory measurement.}
\end{frame}

\begin{frame}{Backup: backbone and training are part of the comparison}

\begin{itemize}
\item GPTAlpha-2: Q/K LayerNorm with bias; token shift; value residual from the first layer; partial RoPE; squared-ReLU channel mixer.
\item CompleteP ($\alpha=1$); AdamC with $\beta_1=.9$, $\beta_2=.95$, $\epsilon=10^{-8}$.
\item Base LR $2\times10^{-3}$ and weight decay $.2$, tuned at 120M/3B; longer-run scaling by $1/\sqrt{N_{\mathrm{steps}}}$.
\item Batch: 524,288 tokens. Warmup: 200 steps, then linear decay to zero. RoPE base: 10,000.
\item No weight decay on scalar/vector parameters; no reported quality multi-seed intervals.
\end{itemize}

\papersource{Appendices C--D, PDF pp. 18--19. The speed-benchmark head count is not the training-model specification.}
\end{frame}

\begin{frame}{Backup: reported speed crossovers differ by operation}

\centering
\begin{tabular}{lrrr}
\toprule
First faster tested length & Decode & Prefill & Backward\\
\midrule
KVM-256 & 1K & 8K & 4K\\
KVM-sqrt & 1K & 16K & 8K\\
\bottomrule
\end{tabular}
\bigskip
\begin{itemize}
\item Routing and state updates create overhead at shorter contexts.
\item Figure bands span min/max run medians, not confidence intervals.
\item The largest ratio belongs to fixed-state decode, not all operations.
\item Hardware, batch size and kernel implementation remain part of the result.
\end{itemize}

\papersource{Sec. 5 and Fig. 5, PDF pp. 8--9; single-layer sequence mixing on AMD MI325X.}
\end{frame}
\end{document}
