% Self-authored reading presentation based on the skill's Beamer template.
% Compile with: python3 build_slides.py slides.en.tex
\documentclass[aspectratio=169,11pt]{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{amsmath,amssymb,graphicx,booktabs}
\definecolor{AcademicBlue}{RGB}{26,57,86}
\definecolor{AcademicTeal}{RGB}{0,105,112}
\definecolor{History}{RGB}{199,80,81}
\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}}
\newcommand{\takeaway}[1]{\begin{block}{Reading the result}#1\end{block}}
\title[DSLA / DSLA-Serve]{Dual-State Linear Attention\\and Adaptive Layer Conversion}
\subtitle{A reading of ``On-the-Fly Adaptive Distillation of Transformer\newline to Dual-State Linear Attention''}
\author{Paper: Yeonju Ro, Zhenyu Zhang, Souvik Kundu,\\Zhangyang Wang, Aditya Akella}
\date{arXiv:2506.09316v3 \;|\; June 17, 2025\\Reading presentation \;|\; October 8, 2026}

\begin{document}

\begin{frame}
\titlepage
\vspace{-3mm}
\centering\color{AcademicTeal}Two memory timescales; a runtime choice of how many layers to convert.
\papersource{Paper PDF adds the subtitle ``for Long-Context LLM Serving.''\quad\url{https://arxiv.org/abs/2506.09316v3}}
\end{frame}

\begin{frame}{Two pressures motivate a flexible attention model}
\begin{columns}[T]
\column{0.52\textwidth}
\includegraphics[width=\linewidth,height=.55\textheight,keepaspectratio]{figures/fig01-recency.pdf}
\papersource{Fig. 1, PDF p. 3. Transformer above; distilled GLA below. Axes have different scales.}
\column{0.45\textwidth}
\textbf{Memory quality}
\begin{itemize}
\item A single gated state emphasizes recent tokens in the displayed heads.
\item Earlier information passes through more forget gates.
\end{itemize}
\medskip\textbf{Serving resources}
\begin{itemize}
\item Long sessions accumulate KV cache.
\item Bursts and session affinity create GPU hotspots.
\end{itemize}
\end{columns}
\papersource{Sec. 3, PDF pp. 2--3. Fig. 1: 16 C4 samples, 4096 tokens; GLA distilled with 1B tokens.}
\end{frame}

\begin{frame}{DSLA writes the same token into two gated states}
\[
\begin{aligned}
\mathbf S_t^1&=\mathbf G_t^1\odot\mathbf S_{t-1}^1+\mathbf k_t^\top\mathbf v_t,\\
\mathbf S_t^2&=\mathbf G_t^2\odot\mathbf S_{t-1}^2+\mathbf k_t^\top\mathbf v_t,\\[2pt]
\mathbf o_t&=\mathbf q_t\bigl(\gamma\mathbf S_t^1+(1-\gamma)\mathbf S_t^2\bigr).
\end{aligned}
\]
\begin{itemize}
\item Per head: $\mathbf q,\mathbf k,\mathbf v\in\mathbb R^{1\times d}$; states and gates are $d\times d$.
\item Shared write, different forgetting: history and recency emerge through training.
\item One learned $\gamma$ per layer mixes the two readouts.
\end{itemize}
\papersource{Sec. 4.1, Eqs. (4)--(5), PDF p. 4. Eq. (4) omits old-state branch superscripts; the equations above make the independent-state interpretation explicit.}
\end{frame}

\begin{frame}{Two gates create complementary retention timescales}
\[
\mathbf S_T^a=\sum_{t=1}^T\mathbf P_{t\to T}^a\odot(\mathbf k_t^\top\mathbf v_t),
\qquad \mathbf P_{t\to T}^a=\mathop{\bigodot}_{\tau=t+1}^T\mathbf G_\tau^a.
\]
\begin{block}{Scalar teaching example: the retention part of the weight}
\[
w(\Delta)=\tfrac12(0.999)^\Delta+\tfrac12(0.9)^\Delta
\]
History half-life: $\sim693$ tokens.\qquad Recency half-life: $\sim6.6$ tokens.
\end{block}
\begin{itemize}
\item Both states receive every token; there is no explicit context partition.
\item Content matching through query/key still determines what is read.
\end{itemize}
\papersource{Teaching derivation from the recurrence; zero initial states. Related to Eqs. (6)--(8), PDF p. 4. Example gates are illustrative, not measured parameters.}
\end{frame}

\begin{frame}{Teacher alignment and gate diversity play different roles}
\[
\mathcal L=\underbrace{\mathcal D_{KL}(\mathbf o_t\Vert\mathbf o_t^{(\mathrm{gt})})}_{\text{match teacher output}}
+\lambda\underbrace{\operatorname{sim}(\mathbf G_t^1,\mathbf G_t^2)}_{\text{cosine similarity}}.
\]
\begin{itemize}
\item Minimizing similarity discourages the two gates from collapsing together.
\item Q/K/V/O projections reuse teacher weights; gate initialization differs by branch.
\item The paper does not specify the probability normalization needed for KL on attention outputs, or the value of $\lambda$.
\end{itemize}
\takeaway{The objective explains the intended division of labor; a numerical implementation needs additional choices.}
\papersource{Sec. 4.2, Eqs. (9)--(10), PDF p. 4; initialization in App. B, p. 14.}
\end{frame}

\begin{frame}{The visualized states focus on different token regions}
\centering
\includegraphics[width=.94\linewidth,height=.43\textheight,keepaspectratio]{figures/fig05-states.pdf}
\begin{itemize}
\item Left: teacher self-attention. Right: history in red, recency in blue.
\item History covers earlier positions; recency concentrates near the end.
\item The two DSLA series use different vertical scales: compare location patterns.
\end{itemize}
\papersource{Sec. 5.5, Fig. 5, PDF p. 8. Scores are not a shared softmax probability distribution.}
\end{frame}

\begin{frame}{Offline distillation prepares the choices used online}
\centering
\includegraphics[width=.94\linewidth,height=.60\textheight,keepaspectratio]{figures/fig08-system.pdf}\par
\medskip
\textbf{Offline:} prepare replacements.\qquad
\textbf{Online:} choose layers under load.
\papersource{App. A, Fig. 8, PDF p. 14; Sec. 4.3, pp. 4--5. Runtime conversion uses trained substitutes.}
\end{frame}

\begin{frame}{Chained tuning follows the deployment conversion order}
\centering
\includegraphics[width=.91\linewidth,height=.32\textheight,keepaspectratio]{figures/fig03-chain.pdf}
\begin{enumerate}
\item Rank layers from least to most sensitive.
\item Replace one layer; train it while freezing all other layers.
\item Keep that replacement, then train the next layer in the updated model.
\end{enumerate}
\[
M_k:\quad\{\pi_1,\ldots,\pi_k\}\ \text{use DSLA}.
\]
\papersource{Sec. 4.4, Fig. 3, PDF p. 5. This directly trains nested prefixes of a fixed order; it does not enumerate arbitrary subsets of layers.}
\end{frame}

\begin{frame}{Attention entropy provides a sensitivity heuristic}
\begin{columns}[T]
\column{.58\textwidth}
\includegraphics[width=\linewidth,height=.41\textheight,keepaspectratio]{figures/fig07-sensitivity.pdf}
\papersource{Fig. 7, PDF p. 9. Bars: WikiText-2 PPL after one layer is replaced. Line: entropy.}
\column{.39\textwidth}
\begin{itemize}
\item Prefer layers with smaller validation impact.
\item Concentrated attention motivates a cheaper entropy proxy.
\item This is an empirical ranking heuristic.
\end{itemize}
\end{columns}
\begin{block}{A sign matters for the sorting direction}
Standard entropy: $H=-\sum_i A_{T,i}\log A_{T,i}$.
Eq. (11) omits the minus sign, although the prose uses standard entropy intuition.
\end{block}
\papersource{Sec. 4.3, Eq. (11), PDF p. 5; App. F, pp. 16--17.}
\end{frame}

\begin{frame}{Mixed requests share layers, then split at a conversion}
\begin{columns}[T]
\column{.42\textwidth}
\includegraphics[width=\linewidth,height=.64\textheight,keepaspectratio]{figures/fig11-batch-diagram.pdf}
\column{.55\textwidth}
\begin{itemize}
\item Requests can use different conversion depths.
\item Shared layers batch together.
\item Divergent layers require separate DSLA and self-attention sub-batches.
\item The authors argue KV savings outweigh re-batching overhead.
\end{itemize}
\medskip
Mid-sequence switching also requires a valid history state; its construction cost is not fully specified.
\end{columns}
\papersource{Sec. 4.5, PDF pp. 5--6; App. D, pp. 15--16. Fig. 11: left diagram cropped, full legend retained.}
\end{frame}

\begin{frame}{Evaluation separates model quality from serving latency}
\begin{tabular}{p{.25\linewidth}p{.66\linewidth}}
\toprule
Setting & Configuration / comparison role\\
\midrule
Main conversion & Llama2-7B teacher; 1.6B SlimPajama tokens; up to 4K training length; 25\% or 50\% layers converted\\[3pt]
Quality baselines & Teacher, GLA, Mamba, RetNet (selected short tasks), and static hybrid Zamba\\[3pt]
Quality metrics & LongBench scores, PPL, ROUGE, seven short-task scores\\[3pt]
Latency hardware & A100 80GB for Fig. 4; A6000 for the end-to-end replay in Table 4\\
\bottomrule
\end{tabular}
\medskip
\par\medskip\alert{The 1.6B tokens are additional distillation data; teacher pretraining is inherited.}
\papersource{Sec. 5, PDF pp. 6--9; App. B, p. 14. Cross-model training budgets and task protocols are not all matched.}
\end{frame}

\begin{frame}{Partial conversion improves QA but worsens some PPL}
\centering
\begin{tabular}{lrrrr}
\toprule
Model & WikiText PPL $\downarrow$ & Lambada PPL $\downarrow$ & Hotpot $\uparrow$ & 2Wiki $\uparrow$\\
\midrule
Llama2-7B & 8.79 & 4.13 & 5.63 & 10.24\\
GLA-7B & NaN & 4.98 & 3.61 & 6.89\\
Mamba-7B & 10.55 & 4.05 & 1.23 & 0.80\\
Zamba-7B & 10.25 & 3.74 & 7.90 & 7.97\\
\textbf{DSLA 25\%} & 9.26 & 4.14 & \textbf{11.07} & \textbf{14.20}\\
DSLA 50\% & 9.89 & 6.19 & 10.61 & 13.64\\
\bottomrule
\end{tabular}
\medskip
\begin{itemize}
\item 25\% conversion: $+5.44$ Hotpot and $+3.96$ 2Wiki score points vs. teacher.
\item 50\% conversion: Lambada PPL rises from 4.13 to 6.19.
\end{itemize}
\papersource{Sec. 5.1, Table 1, PDF p. 7. Lambada is labeled as perplexity in this paper.}
\end{frame}

\begin{frame}{Code and few-shot tasks expose the conversion tradeoff}
\centering
\begin{tabular}{lrrrrr}
\toprule
Model & LCC & RepoBench & TREC & SAMSum & TriviaQA\\
\midrule
Teacher & 69.83 & 56.88 & 59.00 & 39.10 & 86.19\\
DSLA 25\% & 66.91 & 51.53 & 55.00 & 38.66 & 87.46\\
DSLA 50\% & 61.68 & 49.84 & 46.00 & 37.28 & 81.99\\
\bottomrule
\end{tabular}
\medskip
\begin{itemize}
\item 25\% conversion loses 5.35 RepoBench points; 50\% loses 7.04.
\item TREC drops from 59 to 46 at 50\% conversion.
\item TriviaQA vs. Mamba: $87.46-15.23=72.23$ \emph{points}.
\end{itemize}
\takeaway{A gain on long-context QA does not imply an improvement on all long-context tasks.}
\papersource{Sec. 5.1, Table 1, PDF p. 7. All scores higher is better. The prose's ``72.23\% improvement'' is an absolute score difference.}
\end{frame}

\begin{frame}{Summarization stays close; short-task losses vary}
\begin{columns}[T]
\column{.48\textwidth}
\textbf{Summarization: mean ROUGE}\par
\medskip
\begin{tabular}{lr}
\toprule
Teacher & 28.09\\
Zamba & 27.88\\
DSLA 25\% & 27.98\\
DSLA 50\% & 27.33\\
\bottomrule
\end{tabular}
\medskip
\par Average of R-1/R-L on CNN/DM and XSum, as reported.
\column{.49\textwidth}
\textbf{Selected short tasks}\par
\medskip
\begin{tabular}{lrrr}
\toprule
 & Teacher & 25\% & 50\%\\
\midrule
MMLU & 45.3 & 46.2 & 43.2\\
LogiQA & 30.6 & 24.9 & 25.4\\
PIQA & 79.6 & 78.7 & 75.0\\
\bottomrule
\end{tabular}
\medskip
\par 25\% conversion loses 5.7 LogiQA points despite slightly higher MMLU.
\end{columns}
\takeaway{25\% is the closer-to-teacher operating point; inspect the target task.}
\papersource{Tables 2--3, PDF p. 7. Scores are on a 0--100 scale.}
\end{frame}

\begin{frame}{Long inputs benefit more from conversion}
\begin{columns}
\column{.49\textwidth}
\includegraphics[width=\linewidth,height=.46\textheight,keepaspectratio]{figures/fig04-prefill.pdf}
\column{.49\textwidth}
\includegraphics[width=\linewidth,height=.46\textheight,keepaspectratio]{figures/fig04-decode.pdf}
\end{columns}
\begin{itemize}
\item Prefill: the paper reports a crossover around 2K prompt tokens.
\item Decode: partial conversion lowers latency and its growth with history.
\item Remaining self-attention layers still have context-dependent cost.
\end{itemize}
\papersource{Sec. 5.3, Fig. 4, PDF p. 7; A100 80GB. Left: total prefill ms. Right: per-token decode ms.}
\end{frame}

\begin{frame}{Count both removed KV and added recurrent states}
\[
M_{KV}=2nbshd_hB_{byte},\qquad
M_{DSLA}=2rnbhd_h^2B_{byte}.
\]
\begin{block}{Illustrative BF16 calculation, one request}
$n=32$, $h=32$, $d_h=128$, $s=4096$, $r=25\%$:
\begin{itemize}
\item Original KV: 2 GiB.
\item Removed KV: 0.5 GiB; added dual states: 16 MiB.
\item Net state/cache reduction: about \textbf{0.484 GiB}.
\end{itemize}
\end{block}
Both attention variants' weights are also kept resident in the paper's system.
\papersource{KV formula: Sec. 5.3, PDF p. 7. Weight limitation: p. 9. DSLA state formula and numbers are a teaching estimate under stated dimensions and precision.}
\end{frame}

\begin{frame}{A length-based replay policy yields 2.29$\times$ speedup}
\begin{columns}[T]
\column{.50\textwidth}
\begin{tabular}{lrr}
\toprule
Prompt & Share & Max. converted\\
\midrule
$<2$K & 64.68\% & 12.5\%\\
2K--4K & 16.16\% & 25\%\\
4K--8K & 16.03\% & 37.5\%\\
$\geq8$K & 3.10\% & 50\%\\
\bottomrule
\end{tabular}
\column{.46\textwidth}
\begin{block}{Normalized end-to-end latency}
\centering\Large 93.64 $\to$ 40.83 ms\par
\medskip\normalsize $2.29\times$ speedup\par
56.4\% lower latency
\end{block}
\end{columns}
\medskip
Azure 2023 timing/length traces are augmented with synthetic prompts and sessions; history is concatenated. Hardware: A6000.
\papersource{Sec. 5.4, Table 4, PDF p. 7; App. C, pp. 14--15. Latency is normalized by token length; this is not P99 or an isolated kernel benchmark.}
\end{frame}

\begin{frame}{Two states recover most of the observed CoLA gap}
\centering
\begin{tabular}{lrrrrr}
\toprule
States & 1 & 2 & 4 & 8 & Teacher\\
\midrule
Accuracy (\%) & 78.97 & \textbf{81.19} & 81.44 & 80.96 & 82.83\\
\bottomrule
\end{tabular}
\medskip
\begin{itemize}
\item Llama-3.2-1B-Instruct; CoLA supervision before and after conversion.
\item Two vs. one state: \textbf{+2.22 percentage points}.
\item Four vs. two states: only +0.25 points; eight states do not help.
\end{itemize}
\takeaway{Two states are a useful cost/quality choice in this experiment. Capacity and specialization are not separately isolated.}
\papersource{Sec. 5.5, Table 5, PDF p. 8. Validation accuracy, not Matthews correlation. This is a different backbone/task from the 7B long-context evaluation.}
\end{frame}

\begin{frame}{Transfer results retain the same quality tradeoffs}
\begin{tabular}{p{.23\linewidth}p{.68\linewidth}}
\toprule
Teacher / test & What the reported numbers support\\
\midrule
Llama2-7B-chat & 25\%: Hotpot 29.79 $\to$ 35.37; RepoBench 48.96 $\to$ 45.17.\\[5pt]
Llama3-8B & DSLA vs. LoLCATs: MMLU 68.9 vs. 52.8, but DSLA is lower on the first four listed tasks.\\[5pt]
Phi-1.5 & DSLA beats Phi-Mamba on all five listed tasks, while remaining below the teacher on all five.\\
\bottomrule
\end{tabular}
\medskip
\par\medskip The LoLCATs table's printed mean is inconsistent with its six entries; recomputed means are 72.67 (DSLA) and 71.82 (LoLCATs).
\papersource{Tables 6--8, PDF p. 9. Table 7 does not clearly identify DSLA's conversion fraction or matched training cost. Full task values in backup slides.}
\end{frame}

\begin{frame}{The remaining questions are concrete system choices}
\begin{enumerate}
\item \textbf{Memory:} resident teacher and DSLA weights offset part of the KV savings; offloading/prefetching is proposed future work.
\medskip
\item \textbf{Switching:} history-state construction, online quality estimation, and re-batching costs need fuller specification.
\medskip
\item \textbf{Attribution:} equal-capacity states and separate regularization / chained-training ablations would clarify the source of gains.
\end{enumerate}
\papersource{Secs. 4.3--4.5 and 5.5, PDF pp. 4--6, 8--9; reader analysis. The abstract's 3.0$\times$ vs. Zamba claim uses a different comparison wording from Sec. 5.5.}
\end{frame}

\begin{frame}{Take away a memory design and a serving control knob}
\begin{block}{Memory design}
Separate retention timescales, then learn how much each layer reads from each state.
\end{block}
\begin{block}{Serving design}
Train replacements in deployment order and choose a conversion depth under resource pressure.
\end{block}
\begin{itemize}
\item Strongest system number: \textbf{2.29$\times$} on the reported augmented replay.
\item Quality is task-dependent; 25\% conversion is generally closer to the teacher.
\end{itemize}
\papersource{Ro et al., arXiv:2506.09316v3 (2025).\quad\url{https://arxiv.org/abs/2506.09316v3}\\Author repository: \url{https://github.com/utnslab/DSLA-Serve}. Figures reproduced from the paper; calculations marked as teaching analysis.}
\end{frame}

\appendix

\begin{frame}{Backup: read the gate notation component by component}
\[
o_{T,j}=\sum_{t=1}^{T}\left[\sum_{i=1}^{d}q_{T,i}k_{t,i}
\left(\gamma P_{t\to T,ij}^1+(1-\gamma)P_{t\to T,ij}^2\right)\right]v_{t,j}.
\]
\begin{itemize}
\item $\mathbf P^a$ is an elementwise product of past gates; the resulting token coefficient can depend on output channel $j$.
\item Thus the plotted score norm is not a normalized scalar attention probability.
\item For Hadamard forgetting, an all-ones gate preserves the whole state; an identity matrix erases off-diagonal entries.
\end{itemize}
\papersource{Reader derivation clarifying Eqs. (4)--(8), PDF p. 4. The paper's ``near identity'' initialization may refer to gating-layer parameters; it is not a complete gate-value parameterization.}
\end{frame}

\begin{frame}{Backup: learned history weights vary across layers}
\centering
\includegraphics[width=.9\linewidth,height=.49\textheight,keepaspectratio]{figures/fig06-gamma.pdf}
\begin{itemize}
\item The plotted recency weight dominates at layers 0--2 and 30--31.
\item The plotted history weight dominates at layers 3--29.
\item These are learned per-layer weights, not runtime token routing decisions.
\end{itemize}
\papersource{Sec. 5.5, Fig. 6, PDF p. 8. Red: history. Blue: recency. The prose instead places layer 3 in the recency group; the plotted boundary differs by one layer.}
\end{frame}

\begin{frame}{Backup: inspect the LoLCATs comparison task by task}
\centering
\begin{tabular}{lrrr}
\toprule
Task & Llama3-8B & LoLCATs & DSLA\\
\midrule
WG & 74.1 & 80.9 & $73.2\pm1.3$\\
HS & 79.7 & 79.7 & $77.5\pm0.5$\\
PIQA & 79.9 & 80.9 & $79.8\pm1.0$\\
ARC-E & 80.1 & 81.7 & $80.7\pm0.8$\\
ARC-C & 53.3 & 54.9 & $55.9\pm1.5$\\
MMLU & 66.6 & 52.8 & $68.9\pm3.2$\\
\midrule
Printed mean & 72.2 & 70.7 & 72.7\\
Recomputed mean & 72.28 & 71.82 & 72.67\\
\bottomrule
\end{tabular}
\papersource{Table 7, PDF p. 9. All scores in percent; $\pm$ is the authors' reported standard deviation. Recomputed means use the six displayed task scores.}
\end{frame}

\begin{frame}{Backup: smaller and chat teachers show mixed outcomes}
\textbf{Phi-1.5 family: all five scores higher is better}\par
\smallskip
\centering
\begin{tabular}{lrrrrr}
\toprule
 & WG & ARC-E & ARC-C & PIQA & HS\\
\midrule
Teacher & 73.4 & 75.0 & 48.0 & 76.6 & 62.6\\
Phi-Mamba & 71.7 & 74.0 & 44.1 & 75.5 & 60.2\\
DSLA & 72.9 & 74.5 & 44.5 & 75.9 & 60.5\\
\bottomrule
\end{tabular}
\medskip
\begin{itemize}
\item DSLA is between Phi-Mamba and the teacher, not above every baseline.
\item Chat teacher, 50\% conversion: TriviaQA falls from 86.11 to 73.04.
\item Chat and Phi DSLA experiments each report 800M additional tokens.
\end{itemize}
\papersource{Tables 6 and 8, PDF p. 9. Teacher pretraining and conversion token costs have different accounting scopes.}
\end{frame}

\begin{frame}{Backup: proxy metrics depend on the target task}
\centering
\includegraphics[width=.98\linewidth,height=.33\textheight,keepaspectratio]{figures/fig13-metrics.pdf}
\begin{itemize}
\item Each panel compares a layer-wise proxy with the PPL after conversion.
\item Downstream accuracy is direct but requires post-distillation evaluation.
\item Summarization ROUGE and language-model PPL need not rank layers alike.
\end{itemize}
\papersource{App. F, Fig. 13, PDF pp. 16--17. Left to right: attention entropy, outlier ratio, task accuracy. The figure supports a heuristic comparison, not an optimality guarantee.}
\end{frame}

\end{document}
