% 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[TTT layers]{Learning to (Learn at Test Time)}
\subtitle{RNNs with Expressive Hidden States}
\author{Paper authors: Yu Sun et al.}
\date{arXiv:2407.04620v4 \quad | \quad Reading: 21 September 2026}
\begin{document}

\begin{frame}
\titlepage
\vspace{-5mm}
\begin{center}\large Learn a small model on the current sequence;\\use its weights as recurrent memory.\end{center}
\papersource{Research-group presentation, approximately 25 minutes plus backup.\\Source: v4, revised 31 August 2025. All paper experiments were completed in v1.}
\end{frame}

\begin{frame}{Fixed-size memory needs a better update rule}
\begin{columns}[T]
\begin{column}{.47\textwidth}
\begin{block}{Self-attention}
Keep a growing list of keys and values.\\[2mm]
Query the history at every step.
\end{block}
\begin{itemize}
\item Rich access to past context.
\item Total attention work: $O(T^2)$.
\end{itemize}
\end{column}
\begin{column}{.47\textwidth}
\begin{block}{Recurrent layers}
Compress history into a fixed-size state.\\[2mm]
Update that state at every step.
\end{block}
\begin{itemize}
\item Total sequence work: $O(T)$.
\item Compression can lose useful information.
\end{itemize}
\end{column}
\end{columns}
\medskip
\alert{TTT asks: can learning itself be the compression rule?}
\papersource{Paper, Secs. 1--2, PDF pp. 2--4. Complexity in context length, at fixed model width.}
\end{frame}

\begin{frame}{The hidden state becomes a trainable model}
\centering
\includegraphics[width=.93\linewidth,height=3.35cm,keepaspectratio]{figures/fig-01.pdf}
\[
W_t=W_{t-1}-\eta\nabla_W\ell(W_{t-1};x_t),\qquad z_t=f(x_t;W_t)
\]
\raggedright
\begin{itemize}
\item Each sequence has its own evolving fast weights $W_t$.
\item Training this inner model is part of the layer's forward pass.
\end{itemize}
\papersource{Paper, Fig. 1, p. 1; Sec. 2.1, Eqs. (1)--(3), p. 4. Naive online formulation.}
\end{frame}

\begin{frame}{The outer loop learns what to write and what to query}
\[
k_t=\theta_Kx_t,\qquad v_t=\theta_Vx_t,\qquad q_t=\theta_Qx_t
\]
\begin{block}{Inner learning problem}
\[
\ell(W;x_t)=\|f(k_t;W)-v_t\|^2,\qquad z_t=f(q_t;W_t)
\]
\end{block}
\begin{itemize}
\item $k_t$: training view; $v_t$: reconstruction target; $q_t$: test view.
\item For one head: $x_t\in\mathbb R^D$, $k_t,v_t,q_t\in\mathbb R^d$.
\item The projections are learned for next-token prediction.
\item Current-token reconstruction requires no future-token label.
\end{itemize}
\papersource{Paper, Sec. 2.3, Eqs. (4)--(5), PDF pp. 5--6. Simplified per-head dimensions.}
\end{frame}

\begin{frame}{Inner adaptation and outer training have different roles}
\centering
\begin{tabular}{lll}
\toprule
 & Inner loop & Outer loop \\
\midrule
Data unit & Token representation & Sequence \\
Training data & Current prefix & Dataset of sequences \\
Objective & Reconstruction & Next-token prediction \\
Updated variables & Fast weights $W$ & Shared parameters $\theta$ \\
At inference & Active & Frozen \\
\bottomrule
\end{tabular}
\medskip
\begin{itemize}
\item Outer training differentiates through inner gradient updates.
\item Learn $\theta_K,\theta_V,\theta_Q$, initialization, learning rate, and the rest of the network.
\item Reset each sequence to the shared initialization $W_0$.
\end{itemize}
\papersource{Paper, Sec. 2.2, p. 5; Sec. 2.7, pp. 11--12; Table 2, p. 18. Table adapted.}
\end{frame}

\begin{frame}{The practical learners need stable inner optimization}
\[
f(x)=x+\operatorname{LN}\!\left(f_{\mathrm{res}}(x)\right)
\]
\begin{columns}[T]
\begin{column}{.47\textwidth}
\begin{block}{TTT-Linear}
$f_{\mathrm{res}}(x)=Wx$\\[2mm]
Square linear core; LN and residual added.
\end{block}
\end{column}
\begin{column}{.47\textwidth}
\begin{block}{TTT-MLP}
Two-layer MLP with GELU.\\[2mm]
Hidden width is $4\times$ input width.
\end{block}
\end{column}
\end{columns}
\[
W_0=\theta_{\mathrm{init}},\qquad
\eta(x)=\eta_{\mathrm{base}}\sigma(\theta_{\mathrm{lr}}\cdot x)
\]
\begin{itemize}
\item Base learning rate: 1 for Linear, 0.1 for MLP.
\item Default backbone adds temporal convolutions and gating.
\end{itemize}
\papersource{Paper, Sec. 2.7, PDF pp. 11--12; Appendix C, pp. 29--30.}
\end{frame}

\begin{frame}{Mini-batches parallelize gradients without future leakage}
\begin{columns}[c]
\begin{column}{.53\textwidth}
\includegraphics[width=\linewidth,height=3.4cm,keepaspectratio]{figures/fig-06.pdf}
\end{column}
\begin{column}{.45\textwidth}
For a block starting after token $a$:
\[
G_t=\nabla_W\ell(W_a;x_t)
\]
\[
W_t=W_a-\eta\!\sum_{s=a+1}^{t}G_s
\]
Gradients share $W_a$; outputs use causal prefix sums.
\end{column}
\end{columns}
\medskip
\begin{itemize}
\item $b=1$: online GD; $b=T$: full-sequence batch GD.
\item Main experiments choose $b=16$; blocks remain sequential.
\end{itemize}
\papersource{Paper, Sec. 2.4 and Fig. 6, p. 7. Constant $\eta$ for exposition.\\For 1-based tokens, use $a=b\lfloor(t-1)/b\rfloor$ to make boundary indexing explicit.}
\end{frame}

\begin{frame}{Dual form avoids materializing every intermediate weight}
First block, bare linear model, identity views; $X=[x_1,\ldots,x_b]$.
\[
E=W_0X-X,\qquad W_b=W_0-2\eta EX^\top
\]
\begin{block}{Compute all causal outputs with matrix products}
\[
Z=W_0X-2\eta E\operatorname{triu}(X^\top X)
\]
\end{block}
\begin{itemize}
\item Columns are tokens: upper triangular means source $s\leq t$.
\item Same outputs as the primal form of the same mini-batch rule.
\item Per block: $O(bd^2+b^2d)$; more arithmetic, less costly I/O.
\item Reported $>5\times$ training speedup over primal in JAX/TPU.
\end{itemize}
\papersource{Paper, Sec. 2.5, PDF pp. 8--9. Speedup is not relative to Transformer or Mamba.}
\end{frame}

\begin{frame}{Batch size trades learning quality against hardware efficiency}
\centering
\includegraphics[width=.95\linewidth,height=4.45cm,keepaspectratio]{figures/fig-07.pdf}
\raggedright
Smaller $b$ improves perplexity here. Larger $b$ first reduces latency, then increases output-computation cost.
\papersource{Paper, Fig. 7, p. 8. Right: $T=2048$, a single TTT-Linear 1.3B layer in pure PyTorch.\\This is not the final fused-kernel whole-network benchmark. Main setting: $b=16$.}
\end{frame}

\begin{frame}{Attention appears as special cases, with important conditions}
\textbf{Linear attention: a parametric learner}\\[1mm]
Bare linear $f$, batch GD, $W_0=0$, $\eta=1/2$:
\[
W_t=\sum_{s\leq t}v_sk_s^\top,\qquad z_t=W_tq_t.
\]
\textbf{Softmax attention: a nonparametric learner}\\[1mm]
Nadaraya--Watson regression with weights $\exp(k_s^\top q_t)$:
\[
z_t=\frac{\sum_{s\leq t}\exp(k_s^\top q_t)v_s}
{\sum_{s\leq t}\exp(k_s^\top q_t)}.
\]
\medskip
The second interpretation still stores a growing history; it gives no linear-time replacement for exact softmax attention.
\papersource{Paper, Sec. 2.6, Theorems 1--2, pp. 10--11; Appendix B, p. 28. Key/query order made explicit.}
\end{frame}

\begin{frame}{The evaluation separates size, compute, and elapsed time}
\begin{tabular}{ll}
\toprule
Setting & Reported protocol \\
\midrule
Pile & 2k and 8k contexts \\
Books3 & 1k, 2k, 4k, 8k, 16k, 32k \\
TTT / Transformer & 125M, 350M, 760M, 1.3B parameters \\
Mamba & 130M, 370M, 790M, 1.4B parameters \\
Outer training batch & 0.5M tokens, independent of context length \\
Tokenizer & Llama tokenizer for all methods \\
\bottomrule
\end{tabular}
\medskip
\begin{itemize}
\item Perplexity is lower-is-better; it is not accuracy.
\item Similar parameter counts do not imply equal FLOPs or latency.
\item Scaling plots connect observations, not fitted scaling laws.
\end{itemize}
\papersource{Paper, Sec. 3, pp. 12--14; Appendix C, pp. 29--30. Main plots report no multi-seed error bars.}
\end{frame}

\begin{frame}{On Pile, the tradeoff improves as context gets longer}
\centering
\includegraphics[width=.95\linewidth,height=4.35cm,keepaspectratio]{figures/fig-10.pdf}
\raggedright
\begin{itemize}
\item 2k: Linear (M), Mamba, and Transformer are broadly comparable.
\item 8k: TTT improves the compute--perplexity tradeoff vs. Mamba.
\end{itemize}
\papersource{Paper, Fig. 10 and Sec. 3.1, p. 13. Axes: training FLOPs and perplexity, both log scale.\\(M)/(T) denote the backbone. A same-size MLP gain can be offset by extra FLOPs.}
\end{frame}

\begin{frame}{The largest ablation step changes the update regime}
\centering
\begin{tabular}{lrr}
\toprule
Cumulative configuration & PPL $\downarrow$ & Change \\
\midrule
Improved linear attention / equivalent TTT & 15.23 & --- \\
+ Learnable $W_0$ & 15.27 & $+0.04$ \\
+ LN and residual in $f$ & 14.05 & $-1.22$ \\
+ Mini-batch TTT & 12.35 & $-1.70$ \\
+ Learnable $\eta$ & 11.99 & $-0.36$ \\
+ Mamba backbone & 11.09 & $-0.90$ \\
\bottomrule
\end{tabular}
\medskip
\begin{itemize}
\item Mini-batch change: $b=2048\rightarrow16$.
\item Learnable initialization supports stability of later variants.
\item Sequential additions do not isolate independent causal effects.
\end{itemize}
\papersource{Selected rows adapted from Table 1, PDF p. 11. All models: 125M, Pile recipe, 2k.\\Original linear attention: 15.91; improved implementation: 15.23.}
\end{frame}

\begin{frame}{Books extends the evidence to 32k context}
\centering
\includegraphics[width=.95\linewidth,height=4.30cm,keepaspectratio]{figures/fig-11.pdf}
\raggedright
\begin{itemize}
\item At 32k, TTT variants improve the tradeoff relative to Mamba.
\item The stronger long-context Transformer baseline needs finetuning.
\end{itemize}
\papersource{Paper, Fig. 11, p. 14. Full results including TF finetune: Fig. 15, p. 32.\\TF finetune starts at Books 2k and uses 20\% additional tokens at the target length.}
\end{frame}

\begin{frame}{Within a long sequence, TTT keeps benefiting from history}
\begin{columns}[c]
\begin{column}{.57\textwidth}
\centering
\includegraphics[width=\linewidth,height=4.8cm,keepaspectratio]{figures/fig-02-right.pdf}
\end{column}
\begin{column}{.40\textwidth}
\begin{itemize}
\item X-axis: position within a 32k sequence.
\item Mamba plateaus after about 16k.
\item TTT and Transformer continue to improve.
\item Training FLOPs matched to Mamba 1.4B.
\end{itemize}
\end{column}
\end{columns}
\papersource{Paper, Fig. 2 right, p. 2; Appendix C, p. 30. Transformer is TF finetune, with 19 blocks.\\Its inference FLOPs are $2.8\times$ the baseline budget; matched training is not matched inference.}
\end{frame}

\begin{frame}{Longer training context is a different question}
\begin{columns}[c]
\begin{column}{.54\textwidth}
\includegraphics[width=\linewidth,height=4.6cm,keepaspectratio]{figures/fig-16-1p3b.pdf}
\end{column}
\begin{column}{.43\textwidth}
\begin{itemize}
\item Each point uses a model trained at a different context length.
\item From-scratch performance can worsen beyond an optimum.
\item Finetuning improves the Transformer comparison.
\end{itemize}
\end{column}
\end{columns}
\medskip
\alert{Better use of a prefix does not imply that longer-context training is always better at a fixed budget.}
\papersource{Paper, Fig. 16, p. 33: cropped 1.3B panel, original axes retained.\\TF finetune has extra training tokens; this is not the matched-budget experiment of Fig. 2.}
\end{frame}

\begin{frame}{TTT-MLP's compute efficiency does not guarantee low latency}
\centering
\includegraphics[width=.93\linewidth,height=4.15cm,keepaspectratio]{figures/fig-12.pdf}
\raggedright
\begin{itemize}
\item TTT-Linear: fast prefill; decode close to Mamba in this setup.
\item TTT-MLP: substantially slower despite a fixed-size state.
\end{itemize}
\papersource{Paper, Fig. 12, p. 15. A100 80GB PCIe; 1.3B models (Mamba 1.4B).\\Prefill batch 16; decode batch 512. Units: seconds/token. Transformer uses vLLM.}
\end{frame}

\begin{frame}{The implementation uses different paths for different phases}
\begin{tabular}{ll}
\toprule
Phase & Computation strategy \\
\midrule
Training / prefill & Dual form for parallel token processing \\
Autoregressive decode & Primal form for sequential updates \\
Training memory & Checkpoint hidden states through time \\
\bottomrule
\end{tabular}
\medskip
\begin{block}{Separate TPU training result}
At 2k on a v5e-256 TPU pod:\\
Transformer: 0.30 s/iteration; TTT-Linear: 0.27 s/iteration.\\
This is a 10\% reduction in iteration time.
\end{block}
\begin{itemize}
\item It is not a GPU training comparison against Mamba.
\item Only inference GPU kernels were written for this study.
\end{itemize}
\papersource{Paper, Sec. 3.3, pp. 15--16; Appendix C, p. 30.}
\end{frame}

\begin{frame}{v4 places the contribution in the fast-weights lineage}
\begin{itemize}
\item Linear matrix states and fast weights predate this paper.
\item DeltaNet corresponds to an online linear learner without the added LN and residual.
\item Prior fast-weight programmers also explored MLP fast weights.
\item The paper contributes an explicit learning framework, learned tasks, practical parallelization, and language-model evidence.
\end{itemize}
\begin{block}{What was not newly benchmarked in v4}
Discussion of Mamba 2 and Gated DeltaNet is not an experimental comparison against them.
\end{block}
\papersource{Paper, Sec. 1, p. 3; Secs. 4.1--4.2, pp. 16--17. All experiments were completed in v1.}
\end{frame}

\begin{frame}{The evidence supports a promising design, with clear limits}
\begin{itemize}
\item Tested up to approximately 1.3B parameters and 32k context.
\item Perplexity evidence does not establish exact retrieval or broad reasoning superiority.
\item Fixed-size memory still compresses and can interfere with itself.
\item Nonlinear learners retain substantial memory-I/O and latency costs.
\item Main result plots lack multi-seed uncertainty estimates.
\end{itemize}
\begin{block}{Open question for discussion}
At the same end-to-end latency budget, when does a richer hidden model provide enough additional context utility?
\end{block}
\papersource{Paper, Secs. 3--5, pp. 12--18; discussion question is this reading's analysis.}
\end{frame}

\begin{frame}{Take home: learn the memory update, then measure its cost}
\begin{enumerate}
\item \textbf{Representation:} a hidden state can be a small model's weights.
\medskip
\item \textbf{Learning:} the outer objective can shape the inner self-supervised task.
\medskip
\item \textbf{Execution:} mini-batches and dual forms make the idea practical, but nonlinear state is still expensive.
\end{enumerate}
\medskip
\alert{Keep model size, training FLOPs, and measured latency separate.}
\papersource{Synthesis of the paper's method and reported experiments, arXiv:2407.04620v4.}
\end{frame}

\begin{frame}{Reference and reading scope}
\textbf{Learning to (Learn at Test Time): RNNs with Expressive Hidden States}
\medskip

Yu Sun, Xinhao Li, Karan Dalal, Jiarui Xu, Arjun Vikram, Genghan Zhang, Yann Dubois, Xinlei Chen, Xiaolong Wang, Sanmi Koyejo, Tatsunori Hashimoto, Carlos Guestrin.
\medskip

\href{https://arxiv.org/abs/2407.04620v4}{arXiv:2407.04620v4}, revised 31 August 2025.
\begin{itemize}
\item Read: author TeX, the matching 33-page PDF, and Appendices A--C.
\item Figures reproduced from author source; selected tables adapted.
\item This presentation reports the paper, not an independent replication.
\end{itemize}
\papersource{Companion Chinese notes include detailed locators, indexing cautions, and evidence boundaries.}
\end{frame}

\appendix
\begin{frame}{Backup: error feedback differs from pure association}
For a bare linear learner:
\[
\nabla_W\ell(W;k,v)=2(Wk-v)k^\top.
\]
\begin{block}{Teaching example, not a paper experiment}
Scalar $w_0=0$, $\eta=1/2$; observations $(k,v)=(1,2),(1,3)$.
\[
\text{Online GD: } 0\rightarrow2\rightarrow3.
\]
\[
\text{All gradients at }w_0:\quad 0\rightarrow2\rightarrow5.
\]
\end{block}
The first rule corrects the existing prediction; the second accumulates associations. Mini-batch TTT lies between these regimes.
\papersource{Derived teaching example from the loss and GD definitions in Secs. 2.3--2.4.}
\end{frame}

\begin{frame}{Backup: nonlinear dual form works layer by layer}
Use $\eta=1$ and half squared loss, as in Appendix A.
Let $\hat X^k$ be training activations, $\bar X^k$ query activations, and $D^k=\nabla_{Z^k}l$.
\[
W_b^k=W_0^k-D^k(\hat X^k)^\top
\]
\[
\bar Z^k=W_0^k\bar X^k-D^k\operatorname{triu}\!\left((\hat X^k)^\top\bar X^k\right)
\]
\[
\bar X^{k+1}=\sigma_k(\bar Z^k)
\]
\begin{itemize}
\item A standard backward pass supplies $D^k$ at the block start.
\item A modified forward pass produces all causal query outputs.
\item VJPs support normalization; their internal cost remains.
\end{itemize}
\papersource{Paper, Appendix A, PDF pp. 26--27. Loss rescaling absorbs the factor 2.}
\end{frame}

\begin{frame}{Backup: the reported outer training recipe}
\centering
\begin{tabular}{rrrrr}
\toprule
Parameters & Blocks & Width & Steps & Tokens \\
\midrule
125M & 12 & 768 & 4,800 & 2.5B \\
350M & 24 & 1,024 & 13,500 & 7B \\
760M & 24 & 1,536 & 29,000 & 15B \\
1.3B & 24 & 2,048 & 50,000 & 26B \\
\bottomrule
\end{tabular}
\medskip
\begin{itemize}
\item AdamW: $\beta=(0.9,0.95)$; weight decay 0.1; clipping 1.0.
\item 10\% warmup, cosine decay to $10^{-5}$; no dropout.
\item Peak learning rates: 0.003, 0.0015, 0.00125, 0.001.
\item Applies to TTT and Transformer; Mamba has a different structure.
\end{itemize}
\papersource{Selected columns from Table 3 and Appendix C, PDF pp. 29--30.}
\end{frame}

\begin{frame}{Backup: the backbone is part of the measured gain}
\centering
\includegraphics[width=.9\linewidth,height=5.4cm,keepaspectratio]{figures/fig-13.pdf}
\papersource{Paper, Fig. 13, PDF p. 29. Mamba-style TTT uses temporal convolutions and a gate.\\The initial K/Q projection is shared in this backbone; separate convolutions follow.}
\end{frame}

\begin{frame}{Backup: inner loss supports adaptation, not every outer claim}
\centering
\includegraphics[width=.94\linewidth,height=3.5cm,keepaspectratio]{figures/fig-04.pdf}
\raggedright
\begin{itemize}
\item A gradient update lowers the current reconstruction loss.
\item Past adaptation improves over the initial state on later tokens.
\item Some middle layers have rising loss as input norms grow; adaptation still helps relative to initialization.
\end{itemize}
\papersource{Paper, Fig. 4, p. 5; all 12 layers in Fig. 14, p. 31. 125M, Pile, $T=2048$, online-GD diagnostic.\\Reconstruction improvement does not prove that each next-token loss decreases.}
\end{frame}

\begin{frame}{Backup: two notation details matter in implementation}
\begin{block}{Block boundaries}
For token $t=1,\ldots,T$, the preceding block ends at
\[
a=b\lfloor(t-1)/b\rfloor.
\]
The printed $t-\operatorname{mod}(t,b)$ is ambiguous at multiples of $b$ under this indexing.
\end{block}
\begin{block}{Kernel argument order}
Pair a historical key with the current query: $\exp(k_s^\top q_t)$.
The argument order in Eqs. (9)--(10) needs care if the first argument is interpreted as the query.
\end{block}
\papersource{Reading notes on Sec. 2.4, p. 7 and Sec. 2.6, p. 10.\\These are notation clarifications, not new experimental findings.}
\end{frame}
\end{document}
