Can Mamba Learn In Context with Outliers? A Theoretical Generalization Analysis

## Abstract

Abstract The Mamba model has gained significant attention for its computational advantages over Transformer-based models, while achieving comparable performance across a wide range of language tasks. Like Transformers, Mamba exhibits in-context learning (ICL) capabilities, i.e., making predictions for new tasks based on a prompt containing input-label pairs and a query, without requiring fine-tuning.
Despite its empirical success, the theoretical understanding of Mamba remains limited, largely due to the nonlinearity introduced by its gating mechanism. To the best of our knowledge, this paper presents the first theoretical analysis of the training dynamics of a one-layer Mamba model, which consists of a linear attention component followed by a nonlinear gating layer, and its ICL generalization on unseen binary classification tasks, even when the prompt includes additive outliers.
Our analysis shows that Mamba leverages the linear attention layer to select informative context examples and uses the nonlinear gating layer to suppress the influence of outliers. By establishing and comparing to the analysis of linear Transformers under the same setting, we show that although Mamba may require more training iterations to converge, it maintains accurate predictions even when the proportion of outliers exceeds the threshold that a linear Transformer can tolerate. These theoretical findings are supported by empirical experiments.

## 1 Introduction

Transformer-based large language models (LLMs) (Brown et al., 2020; Achiam et al., 2023; Guo et al., 2025) have demonstrated remarkable capabilities across a wide range of language, vision, and reasoning tasks. However, they face efficiency challenges when processing long sequences due to the quadratic time and memory complexity of the self-attention mechanism with respect to sequence length (Gu and Dao, 2023; Dao and Gu, 2024). To address this, many efficient alternative architectures have been proposed, including state space models (SSMs) such as S4 (Gu et al., 2021, 2022) and H3 (Fu et al., 2023a). Among them, Mamba (Gu and Dao, 2023) has attracted significant attention for its strong empirical performance, linear computational complexity, and hardware-friendly properties that enable efficient parallelization. These advantages have sparked growing interest in understanding the mechanism of Mamba and whether it can match or surpass the capabilities of Transformer models.

One particularly intriguing property of LLMs is in-context learning (ICL) (Brown et al., 2020; Garg et al., 2022), which allows a pre-trained model to generalize to new tasks without any parameter updates. By simply augmenting the input with a prompt containing a few labeled examples from the new task, the model can produce accurate predictions for unseen tasks. While LLMs have demonstrated impressive ICL generalization, their performance is sensitive to the quality of the context examples (Liu et al., 2022; Wu et al., 2023b). In particular, ICL performance can degrade significantly in the presence of outliers or adversarial attacks on prompts, such as data poisoning, resulting in incorrect predictions (Wan et al., 2023; Kandpal et al., 2023; Qiang et al., 2023; He et al., 2024; Zhao et al., 2024; Anwar et al., 2024).

Recent empirical work (Park et al., 2024; Halloran et al., 2024; Grazzi et al., 2024; Jelassi et al., 2024; Arora et al., 2024; Waleffe et al., 2024) has demonstrated that Mamba can also perform ICL on function learning and natural language processing tasks. (Park et al., 2024; Grazzi et al., 2024) show that Mamba is competitive with Transformers of similar size in some ICL tasks and outperforms them in settings with many outliers, such as regression with corrupted examples. On the other hand, studies such as (Park et al., 2024; Waleffe et al., 2024; Arora et al., 2024; Jelassi et al., 2024) identify limitations of Mamba in retrieval-based and long-context reasoning tasks.
Despite these empirical insights, several fundamental questions remain open:

Why and how can a Mamba model be trained to perform in-context generalization to new tasks? How robust is it to outliers? Under what conditions can Mamba outperform Transformers for ICL?

(Li et al., 2024e) and (Li et al., 2025b) analyze Mamba-like models, e.g., simplified H3 and gated linear attention, and show that the global minima of the loss landscapes correspond to models whose outputs, when given a prompt, implicitly perform a weighted preconditioned gradient descent using the context examples. This serves as the counterpart to the preconditioned gradient descent interpretation of ICL in Transformers (Ahn et al., 2023). Joseph et al. (2024) shows that continuous SSMs can learn dynamic systems in context. Bondaschi et al. (2025) proves that Mamba is expressive enough to represent optimal Laplacian smoothing. However, these studies do not address whether practical training methods can reliably yield Mamba models with ICL capabilities, nor do they provide theoretical guarantees for generalization or robustness in the presence of outliers.

### 1.1 Major Contributions

This paper presents the first theoretical analysis of the training dynamics of Mamba models and their resulting ICL performance, including scenarios where context examples in the prompt contain outliers. We focus on training Mamba on binary classification tasks where input data consist of both relevant patterns, which determine the label, and irrelevant patterns, which do not. Additionally, context inputs may include additive outliers that perturb the labels. While our analysis is based on one-layer Mamba architectures, this setting aligns with the scope of state-of-the-art theoretical studies on the training dynamics and generalization of Transformers and other neural networks, which also typically focus on one-hidden-layer models (Zhang et al., 2023a; Li et al., 2024a, e, 2025b). Our main contributions are as follows:

1. Quantitative analysis of ICL emergence and robustness to outliers in Mamba.
We characterize the number of context examples and training iterations required for a Mamba model to acquire ICL capabilities for new tasks that were not present during training. We prove that when trained with prompts that may contain a finite number of outlier patterns, Mamba can generalize in-context on new tasks when the context examples contain unseen outliers that are linear combinations of the training-time outliers. Furthermore, Mamba can maintain accurate ICL generalization even when the fraction of outlier-containing context examples approaches $1$, demonstrating strong robustness.

2. Theoretical comparison between Mamba and linear Transformers.
We provide a theoretical characterization of the convergence and generalization properties of linear Transformers trained on the same tasks. While linear Transformers may converge faster with smaller batch sizes, they can only in-context generalize effectively when the fraction of outlier-containing context examples is less than $1/2$, much less than that for Mamba. Moreover, linear Transformers require significantly more context examples than Mamba to achieve comparable generalization performance. This highlights Mamba’s superior robustness to a high density of outliers in ICL.

3.Theoretical characterization of the mechanism by which Mamba implements ICL.
We show that the equivalent linear attention mechanism in Mamba selects context examples that share the same relevant pattern as the query, while the nonlinear gating mechanism suppresses corrupted examples and applies an exponential decay in importance based on index distance, emphasizing examples closer to the query. Together, these mechanisms enable Mamba to suppress irrelevant or corrupted context examples and focus on informative and nearby ones, achieving effective and robust ICL.

### 1.2 Related Works

Theoretical Analysis of ICL. Existing theoretical works of ICL primarily focus on Transformer-based models. Garg et al. (2022); Akyürek et al. (2023); Bai et al. (2023); Von Oswald et al. (2023); Ahn et al. (2023) illustrate that Transformers can implement many machine learning algorithms, such as gradient-based methods, via ICL. Zhang et al. (2023a); Huang et al. (2023); Wu et al. (2023a); Li et al. (2024a); Chen et al. (2024a) provably investigate the training dynamics and generalization of ICL on single/multi-head Transformers. Yang et al. (2024d); Kim and Suzuki (2024); Oko et al. (2024) extend the analysis to learning complicated nonlinear functions by ICL.

Connections Between Mamba and Transformers. Ali et al. (2024) finds that Mamba exhibits explainability metrics comparable to those of Transformers. Dao and Gu (2024) shows that SSMs and variants of attention mechanisms share a large intersection and can be viewed as duals of each other. Han et al. (2024) notes a similarity between the forget gate in Mamba and the positional encodings in Transformers. The complementary strengths, Mamba’s computational efficiency and Transformers’ ability to capture global dependencies, have motivated the development of hybrid architectures (Hatamizadeh and Kautz, 2024; Lenz et al., 2025; Xu et al., 2024).

Optimization and Generalization of the Attention Architecture.
Some other works focus on the optimization and generalization of attention-based models without nonlinear gating beyond the ICL setting. Jelassi et al. (2022); Li et al. (2023a, b); Jiang et al. (2024); Yang et al. (2024a); Li et al. (2025a) study the generalization of one-layer Transformers in classification tasks by formulating spatial association, key features, or the semantic structure of the input. Huang et al. (2024); Nichani et al. (2025); Ren et al. (2024) investigate the problem in next-token prediction based on the partial order, bigram, or semantic association assumption. Chen et al. (2024a); He et al. (2025) extend the analysis to multi-head attention networks.

## 2 Problem Formulation

The learning model, Mamba, is proposed in (Gu and Dao, 2023)(^1^11The theoretical extension of our framework to other SSM/linear RNN models is discussed in Appendix [E.6](https://arxiv.org/html/2510.00399v1#A5.SS6).) Given the input ${\bm{U}}=({\bm{u}}_{1},\cdots,{\bm{u}}_{m})\in\mathbb{R}^{d_{0}\times m}$, the model outputs ${\bm{o}}_{i}$ recursively through the hidden states ${\bm{h}}_{i}$, $i\in[m]$. Starting from ${\bm{h}}_{0}={\bm{U}}$, a one-layer Mamba can be formulated as

$$ $\displaystyle{\bm{h}}_{i}=$ $\displaystyle{\bm{h}}_{i-1}\odot\tilde{{\bm{A}}}_{i}+({\bm{u}}_{i}\bm{1}_{m}^{\top})\odot\tilde{{\bm{B}}}_{i}\quad\in\mathbb{R}^{d_{0}\times m},\quad\forall i\in[m]$ (1) $\displaystyle{\bm{o}}_{i}=$ $\displaystyle{\bm{h}}_{i}{\bm{C}}_{i}\quad\in\mathbb{R}^{d_{0}},$ $$

where $\tilde{{\bm{B}}}_{i}=(\tilde{{\bm{B}}}_{1,i}^{\top},\cdots,\tilde{{\bm{B}}}_{d_{0},i}^{\top})^{\top}\in\mathbb{R}^{d_{0}\times m}$ with
$\tilde{{\bm{B}}}_{j,i}=(\Delta_{j,i}{\bm{B}}_{i})(\exp(\Delta_{j,i}{\bm{A}})-{\bm{I}}_{m})(\Delta_{j,i}{\bm{A}})^{-1}$ and ${\bm{B}}_{i}={\bm{u}}_{i}^{\top}{\bm{W}}_{B}^{\top}\in\mathbb{R}^{1\times m}$, ${\bm{W}}_{B}\in\mathbb{R}^{m\times d_{0}}$, $\tilde{{\bm{A}}}_{i}=(\tilde{{\bm{A}}}_{1,i}^{\top},\cdots,\tilde{{\bm{A}}}_{d_{0},i}^{\top})^{\top}\in\mathbb{R}^{d_{0}\times m}$ with $\tilde{{\bm{A}}}_{j,i}=\text{diag}(\exp(\Delta_{j,i}{\bm{A}}))^{\top}$, ${\bm{C}}_{i}={\bm{W}}_{C}{\bm{u}}_{i}\in\mathbb{R}^{m}$ with ${\bm{W}}_{C}\in\mathbb{R}^{m\times d_{0}}$. $\bm{1}_{m}$ is an all-ones vector in $\mathbb{R}^{m}$. $\odot$ and $\exp(\cdot)$ are element-wise product and exponential operations, respectively. $\text{diag}(\cdot):\mathbb{R}^{d_{0}\times d_{0}}\rightarrow\mathbb{R}^{d_{0}}$ outputs the diagonal of the input as a vector. $\sigma(\cdot):z\in\mathbb{R}\mapsto(1+\exp(-z))^{-1}\in\mathbb{R}$ is the sigmoid function. $\Delta_{j,i}=\text{softplus}({\bm{w}}_{j}^{\top}{\bm{u}}_{i})=\log(1+\exp({\bm{w}}_{j}^{\top}{\bm{u}}_{i}))\in\mathbb{R}$, which is parameterized by ${\bm{W}}=({\bm{w}}_{1},\cdots,{\bm{w}}_{d_{0}})\in\mathbb{R}^{d_{0}\times d_{0}}$. Denote ${\bm{w}}={\bm{w}}_{d_{0}}$. Following the assumption in Theorem 1 of (Gu and Dao, 2023), we select ${\bm{A}}=-{\bm{I}}_{m}\in\mathbb{R}^{m\times m}$ for simplicity of analysis.

Following the theoretical setup used in recent in-context learning (ICL) analyses (Garg et al., 2022; Huang et al., 2023; Li et al., 2024a, e, 2025b), we consider training a model on prompts from a subset of tasks to endow it with ICL capabilities on unseen tasks. This framework is motivated by the observation (Chen et al., 2024b) that although LLMs are typically trained without supervised labels, natural text often contains implicit input-output pairs, i.e., phrases following similar templates, that resemble the prompt-query format used in our setup.
Specifically, we consider a set of binary classification tasks $\mathcal{T}$, where for a certain task $f\in\mathcal{T}$, the label $z\in\{+1,-1\}$ of a given input query ${\bm{x}}_{query}\in\mathbb{R}^{d}$ is determined by
$z=f({\bm{x}}_{query})\in\{+1,-1\}$. Then, the prompt ${\bm{P}}$ for ${\bm{x}}_{query}$ is constructed as

$$ $\displaystyle{\bm{P}}=\begin{pmatrix}{\bm{x}}_{1}&{\bm{x}}_{2}&\cdots&{\bm{x}}_{l}&{\bm{x}}_{query}\\ y_{1}&y_{2}&\cdots&y_{l}&0\end{pmatrix}=({\bm{p}}_{1},{\bm{p}}_{2},\cdots,{\bm{p}}_{query})\in\mathbb{R}^{(d+1)\times(l+1)},$ (2) $$

where $y_{i}=f({\bm{x}}_{i})$, $i\in[l]$. With the prompt ${\bm{P}}$ in ([2](https://arxiv.org/html/2510.00399v1#S2.E2)) as the input to the Mamba model in ([1](https://arxiv.org/html/2510.00399v1#S2.E1)) with $m=l+1$ and $d_{0}=d+1$, the output of one-layer Mamba can be rewritten as

$$ $\displaystyle F(\Psi;{\bm{P}})=$ $\displaystyle{\bm{e}}_{d+1}^{\top}{\bm{o}}_{l+1}=\sum_{i=1}^{l+1}G_{i,l+1}({\bm{w}})y_{i}{\bm{p}}_{i}^{\top}{\bm{W}}_{B}^{\top}{\bm{W}}_{C}{\bm{p}}_{query},$ (3) $\displaystyle\text{ where }G_{i,l+1}({\bm{w}})=$ $\displaystyle$ $$

where ${\bm{e}}_{d+1}=(0,\cdots,0,1)^{\top}\in\mathbb{R}^{d+1}$ and $\Psi=\{{\bm{W}}_{B},{\bm{W}}_{C},{\bm{w}}\}$ is the set of trainable parameters. The derivation of ([3](https://arxiv.org/html/2510.00399v1#S2.E3)) can be found in Appendix [E.1](https://arxiv.org/html/2510.00399v1#A5.SS1). From ([3](https://arxiv.org/html/2510.00399v1#S2.E3)), one can observe that a one-layer Mamba is equivalent to a linear attention layer parameterized by ${\bm{W}}_{B}$ and ${\bm{W}}_{C}$ followed by a nonlinear gating layer $G_{i,l+1}({\bm{w}})$ for $i\in[l+1]$. Specifically, ${\bm{W}}_{B}$ and ${\bm{W}}_{C}$ can be respectively interpreted as the key and query parameters in a Transformer model. Therefore, a Transformer with linear attention, commonly studied in the context of ICL Zhang et al. (2023a), can be viewed as a special case of the formulation in ([3](https://arxiv.org/html/2510.00399v1#S2.E3)) by removing the nonlinear gating, i.e., setting $G_{i,l+1}({\bm{w}})=1$ for all $i\in[l+1]$. We adopt this simplified formulation when comparing Mamba and Transformers in Section [3.4](https://arxiv.org/html/2510.00399v1#S3.SS4).

Given $N$ training examples consisting of prompt-label pairs ${({\bm{P}}^{n},z^{n})}_{n=1}^{N}$, the model is trained by solving the empirical risk minimization problem using the hinge loss:

$$ $\min_{\Psi}\frac{1}{N}\sum_{n=1}^{N}\ell(\Psi;{\bm{P}}^{n},z^{n}),\text{ where }\ell(\Psi;{\bm{P}}^{n},z^{n})=\max\{0,1-z^{n}\cdot F(\Psi;{\bm{P}}^{n})\}.\vskip-5.69054pt$ (4) $$

Each prompt ${\bm{P}}^{n}$ is generated from a distribution $\mathcal{D}$, where the query ${\bm{x}}_{\text{query}}^{n}$ and all context inputs ${{\bm{x}}_{i}^{n}}$ are sampled independently, and the associated task $f^{n}$ is drawn from a set of training tasks $\mathcal{T}_{\text{tr}}\subset\mathcal{T}$.

Training Algorithm: The model is trained using stochastic gradient descent (SGD) with step size $\eta$ with batch size $B$, summarized in Algorithm [1](https://arxiv.org/html/2510.00399v1#alg1). ${\bm{W}}_{B}^{(0)}$ and ${\bm{W}}_{C}^{(0)}$ are initialized such that the first $d$ diagonal entries of ${\bm{W}}_{B}^{(0)}$ and ${\bm{W}}_{C}^{(0)}$ are set as $\delta\in(0,0.2]$. ${\bm{w}}^{(0)}$ follows Gaussian $\mathcal{N}(0,{\bm{I}}_{d+1}/(d+1))$.

ICL Generalization in the Presence of Outliers: The testing prompt ${\bm{P}}^{\prime}$ follows an unknown distribution $\mathcal{D}^{\prime}$, which is different from the training prompt ${\bm{P}}$ and may contain outliers. Then, the ICL generalization of the model $\Psi$ is computed as the classification error across all tasks in $\mathcal{T}$, including those never appear during the training stage, i.e.,

$$ $L_{f\in\mathcal{T},{\bm{P}}^{\prime}\sim\mathcal{D}^{\prime}}^{0-1}(\Psi;{\bm{P}}^{\prime},z)=\mathbb{E}_{f\in\mathcal{T},{\bm{P}}^{\prime}\sim\mathcal{D}^{\prime}}\big[\mathbbm{1}[z\cdot F(\Psi;{\bm{P}}^{\prime})<0]\big].\vskip-5.69054pt$ (5) $$

## 3 Main Theoretical Results

We first summarize insights of our theoretical results in Section [3.1](https://arxiv.org/html/2510.00399v1#S3.SS1). Then, we introduce our formulation for analysis in Section [3.2](https://arxiv.org/html/2510.00399v1#S3.SS2). Section [3.3](https://arxiv.org/html/2510.00399v1#S3.SS3)
presents the theoretical results of learning for ICL generalization with Mamba. Section [3.4](https://arxiv.org/html/2510.00399v1#S3.SS4) analyzes linear Transformers for a comparison with Mamba models. We finally characterize the ICL mechanism by the trained Mamba in Section [3.5](https://arxiv.org/html/2510.00399v1#S3.SS5).

### 3.1 Main Theoretical Insights

We formulate a class of binary classification tasks where the labels in each task are determined by two selected relevant patterns. Such data formulation stems from the sparse representation assumption (Wright et al., 2010) for real-world data and is widely adopted in theoretical analysis (Li et al., 2024a; Huang et al., 2023; Jiang et al., 2024). The model is trained on a subset of these tasks using prompts that may include context examples corrupted by additive outliers. We then evaluate the model’s performance on unseen tasks, where the prompts can contain outliers not observed during training.

P1. Theoretical Characterization of Learning Dynamics, ICL Generalization, and Robustness to Outliers in Mamba Models.
We provide quantitative guarantees that training with prompts can lead to favorable ICL generalization on unseen tasks, and these results hold even in the presence of outliers (Theorems [1](https://arxiv.org/html/2510.00399v1#Thmthm1) and [2](https://arxiv.org/html/2510.00399v1#Thmthm2)). Specifically, if a fraction $p_{a}\in[0,1)$ of the context examples in the training prompts contain additive outliers, we prove that the learned model still generalizes accurately at test time, as long as the fraction of outliers in the testing prompt, denoted by $\alpha$, is less than $\min\{1,p_{a}\cdot l_{tr}/l_{ts}\}$ where $l_{tr}$ and $l_{ts}$ are the number of examples in the training and testing prompts, respectively. Notably, the outliers in the test prompt may be previously unseen and can be formed as almost arbitrary positive linear combinations of a finite set of outlier patterns seen during training.

P2. A Comparison Between Mamba and Linear Transformer Models.
We theoretically analyze the convergence and ICL generalization of a one-layer linear Transformer (Theorems [3](https://arxiv.org/html/2510.00399v1#Thmthm3) and [4](https://arxiv.org/html/2510.00399v1#Thmthm4)) for comparison. Our results show that linear Transformers require smaller batch sizes, fewer iterations, and milder constraints on the magnitude of outliers and the prompt length for successful training convergence compared to Mamba. However, linear Transformers can only generalize well when the test prompt has an outlier fraction $\alpha<1/2$, whereas Mamba could maintain accurate generalization even if $\alpha$ goes to $1$. Moreover, even when both models can achieve ICL, e.g.,
when $\alpha$ is close to $1/2$, linear Transformers require significantly more context examples to achieve comparable performance. Thus, despite requiring more effort during training, Mamba models demonstrate superior robustness to outliers during ICL.

P3. Mechanism of Mamba Models in Implementing ICL.
Our analysis shows that the linear attention layer in Mamba selectively emphasizes context examples that share the same relevant pattern as the query, while the nonlinear gating layer promotes examples that are both close to the query and free of additive outliers. This dual mechanism enables the trained Mamba to suppress irrelevant or corrupted context examples and focus on informative examples close to the query, thus achieving successful and robust ICL.

### 3.2 Data and Tasks Modeling

Assume there are $M_{1}$ relevant patterns $\{{\bm{\mu}}_{j}\}_{j=1}^{M_{1}}$ and $M_{2}$ irrelevant patterns $\{{\bm{\nu}}_{k}\}_{k=1}^{M_{2}}$ with $M_{1}+M_{2}<d$. All the patterns from $\{{\bm{\mu}}_{j}\}_{j=1}^{M_{1}}\cup\{{\bm{\nu}}_{k}\}_{k=1}^{M_{2}}$ are orthogonal to each other, with $\|{\bm{\mu}}_{j}\|=\|{\bm{\nu}}_{k}\|=\beta$ for $j\in[M_{1}]$, $k\in[M_{2}]$, and the constant $\beta\geq 1$.
Each input ${\bm{x}}$ contains one relevant pattern that determines the label, and one irrelevant pattern that does not affect the label. We consider a set of binary classification tasks in $\mathcal{T}$ where the binary labels are determined by the relevant patterns. For instance, for a task $f$ that is determined by $({\bm{\mu}}_{a},{\bm{\mu}}_{b})$, $a,b\in[M_{1}]$, the label of ${\bm{x}}_{query}$ is $z=1$ (or $z=-1$) if the input ${\bm{x}}_{query}$ contains ${\bm{\mu}}_{a}$ (or ${\bm{\mu}}_{b}$), respectively.

Figure: Figure 1: An example of outliers in context inputs.
Refer to caption: x1.png

Training Stage: For a given task $f$, we consider learning with a $p_{a}\in[0,1)$ fraction of examples containing additive outliers $\{{\bm{v}}^{*}_{r}\}_{r=1}^{V}$ that can affect the label of corresponding examples in each prompt,
where ${\bm{v}}^{*}_{s}\perp{\bm{\mu}}_{j}$, ${\bm{v}}^{*}_{s}\perp{\bm{\nu}}_{k}$ for any $j\in[M_{1}]$, $k\in[M_{2}]$, and $s\in[V]$. The input of each context example satisfies

$$ ${\bm{x}}=\begin{cases}{\bm{\mu}}_{j}+\kappa{\bm{\nu}}_{k}+\kappa_{a}{\bm{v}}_{s}^{*},&\text{with a probability of }p_{a}\\ {\bm{\mu}}_{j}+\kappa{\bm{\nu}}_{k},&\text{with a probability of }1-p_{a},\end{cases}$ (6) $$

for some $s\in[V]$, where $j\in[M_{1}]$ and $k\in[M_{2}]$ are arbitrarily selected. $\kappa$ follows a uniform distribution $\textit{U}(-K,K)$ with $K\leq 1/2$. ${\bm{v}}_{s}^{*}$ is uniformly sampled from $\{{\bm{v}}_{r}^{*}\}_{r=1}^{V}$. No additive outliers exist in ${\bm{x}}_{query}$. We then present the definition of training prompts.

###### Definition 1 .

(Training prompts)
Given a task $f\in\mathcal{T}$ with ${\bm{\mu}}_{a}$ and ${\bm{\mu}}_{b}$ as the two different decisive patterns, a training prompt ${\bm{P}}\sim\mathcal{D}$ with $l_{tr}$ context examples is constructed as follows.

- •
${\bm{x}}_{query}$ follows the second line of ([6](https://arxiv.org/html/2510.00399v1#S3.E6)) with $j$ equally selected from
$\{a,b\}$ and contains no ${\bm{v}}_{s}^{*}$.
- •
Each ${\bm{x}}_{i}$ contains ${\bm{\mu}}_{a}$ or ${\bm{\mu}}_{b}$ with equal probability $i\in[l_{tr}]$, following ([6](https://arxiv.org/html/2510.00399v1#S3.E6)).
- •
$y_{i}=+1$ (or $y_{i}=-1$) if the relevant pattern of ${\bm{x}}_{i}$ is ${\bm{\mu}}_{a}$ (or ${\bm{\mu}}_{b}$), and ${\bm{x}}_{i}$ does not contain any ${\bm{v}}_{s}^{*}$. $y_{i}$ is selected from $\{+1,-1\}$ with equal probability if ${\bm{x}}_{i}$ contains a certain ${\bm{v}}_{s}^{*}$ for $s\in[V]$.

When $p_{a}=0$, the setup reduces to the case where context examples contain no outliers, aligning with the theoretical setup in (Huang et al., 2023; Zhang et al., 2023a; Li et al., 2024a). We include outliers in the training prompt to encourage the model to learn to ignore examples containing outliers. This improves robustness during inference when prompts may also include such outliers. Our motivation stems from noise-aware training to mitigate data poisoning or hijacking attacks in ICL (Wan et al., 2023; He et al., 2024; Qiang et al., 2023), where prompts are corrupted with noisy or random labels.

Inference Stage: During inference, we consider that the outliers in the testing prompt can differ from those in the training prompt in several ways, including their direction, magnitude, and the fraction of examples affected. Specifically, the data input during the testing follow

$$ ${\bm{x}}=\begin{cases}{\bm{\mu}}_{j}+\kappa^{\prime}{\bm{\nu}}_{k}+\kappa_{a}^{\prime}{{\bm{v}}_{s}^{*}}^{\prime},&\text{with a probability of }\alpha\\ {\bm{\mu}}_{j}+\kappa^{\prime}{\bm{\nu}}_{k},&\text{with a probability of }1-\alpha,\end{cases}$ (7) $$

for some ${{\bm{v}}_{s}^{*}}^{\prime}\in\mathcal{V}^{\prime}$, $\kappa_{a}^{\prime}>0$, and $\kappa^{\prime}\sim\textit{U}(-K^{\prime},K^{\prime})$ with $K^{\prime}>1$. $\alpha\in[0,1)$ is the probability of examples containing the testing additive outliers in $\mathcal{V}^{\prime}$.

###### Definition 2 .

(Testing prompts)
Given a task $f\in\mathcal{T}$ with ${\bm{\mu}}_{a}$ and ${\bm{\mu}}_{b}$ as the relevant patterns, a testing ${\bm{P}}^{\prime}\sim\mathcal{D}^{\prime}$ with $l_{ts}$ context examples is constructed as follows. each testing query ${\bm{x}}_{query}$ only follows the second line of ([7](https://arxiv.org/html/2510.00399v1#S3.E7)) without outliers. Each context input ${\bm{x}}_{i}$, $i\in[l_{ts}]$, follows ([7](https://arxiv.org/html/2510.00399v1#S3.E7)).
If ${\bm{x}}_{i}$ does not contain any ${\bm{v}}_{s}^{*}\in\mathcal{V}^{\prime}$, then $y_{i}=+1$ (or $y_{i}=-1$) if the relevant pattern of ${\bm{x}}_{i}$ is ${\bm{\mu}}_{a}$ (or ${\bm{\mu}}_{b}$). If ${\bm{x}}_{i}$ contains a certain ${\bm{v}}_{s}^{*}\in\mathcal{V}^{\prime}$, then $y_{i}$ can be an arbitrary function that maps ${\bm{x}}_{i}$ to $\{+1,-1\}$.

The testing prompt ${\bm{P}}^{\prime}$ differs from the training prompt ${\bm{P}}$ in two key aspects. First, the outlier patterns, the magnitude of the outliers, and the magnitude of the irrelevant patterns can differ from those in ${\bm{P}}$. While the training prompts include $V$
distinct outlier patterns, the testing prompts may contain an unbounded number of outlier variations.
Second, the labels associated with examples containing outliers can be generated by any deterministic or probabilistic function. This flexibility allows our framework to model a wide range of noisy testing prompts in practice. For instance,

###### Example 1 .

Consider a data poisoning attack on a text sentiment classification task in (Wan et al., 2023; He et al., 2024). In one such attack as shown in Figure [1](https://arxiv.org/html/2510.00399v1#S3.F1), whenever the phrase “James Bond” is inserted into the example, the label is always set to positive, regardless of the original sentiment of the input. This illustrates a case where all examples containing the outlier are deterministically mapped to a targeted label $+1$.

###### Definition 1 .

###### Definition 2 .

###### Example 1 .

### 3.3 Learning, Generalization, and Sample Complexity Analysis of Mamba

To enable the model learned from data in training tasks $\mathcal{T}_{tr}$ to generalize well across all tasks in $\mathcal{T}$, we require Condition 3.2 from (Li et al., 2024a) for $\mathcal{T}_{tr}$. We restate this condition as Condition [1](https://arxiv.org/html/2510.00399v1#Thmcondition1), along with a construction of a training task set that satisfies it in the Appendix. The high-level idea is that the training tasks $\mathcal{T}_{tr}$ should uniformly cover all of the relevant patterns and labels appearing in $\mathcal{T}$ such that no bias from the training tasks is introduced to the learning process.

Following (Shi et al., 2021; Li et al., 2023a), we assume the training labels are balanced, i.e., $\big||\{n:z^{n}=+1\}|-|\{n:z^{n}=-1\}|\big|=O(\sqrt{N})$. Let $B_{T}:=\max\{\epsilon^{-2},M_{1}(1-p_{a})^{-1}\}\cdot\log\epsilon^{-1}$. We have the following result.

###### Theorem 1 .

(Convergence and Sample Complexity of Mamba)
For any $\epsilon>0$, of (i) $B\gtrsim B_{M}:=\max\{B_{T},\beta^{-4}V^{2}\kappa_{a}^{-2}(1-p_{a})^{-2}\log\epsilon^{-1}\}$, (ii) $V\beta^{-4}\lesssim\kappa_{a}\lesssim V\beta(1-p_{a})p_{a}^{-1}\epsilon^{-1}$, and (iii)

$$ $p_{a}^{-1}\text{poly}(M_{1}^{\kappa_{a}})\gtrsim l_{tr}\gtrsim(1-p_{a})^{-1}\log M_{1},$ (8) $$

then (iv) after

$$ $T\geq T_{M}=\Theta(\eta^{-1}(1-p_{a})^{-1}\beta^{-2}M_{1})$ (9) $$

iterations with $\eta\leq 1$ and using $N=BT$ samples, we have that

$$ $\mathbb{E}_{f\in\mathcal{T},{\bm{P}}\sim\mathcal{D}}[\ell(\Psi^{(T)};{\bm{P}},z)]\leq\epsilon.$ (10) $$

###### Remark 1 .

Theorem [1](https://arxiv.org/html/2510.00399v1#Thmthm1) provides the convergence and sample complexity analysis of training a one-layer Mamba model to enhance its ICL ability. We characterize the sufficient conditions on the batch size, the magnitude of additive outliers, the prompt length, and the required number of iterations. The convergent model has desirable generalization on all tasks in $\mathcal{T}$, including those not appearing in the training data, when the prompt is constructed in the same way as the training data.

Condition (ii) requires that the magnitude of outliers be moderate and scale with $V$. This ensures that outliers are neither too small to be easily detectable by the model nor excessively large (i.e., less than $\Theta(\epsilon^{-1})$), which would diminish the influence of relevant patterns. Conditions (iii) and (iv) show that the required number of context examples in the prompt and the number of iterations scale as $(1-p_{a})^{-1}$. This implies a higher fraction of outlier-containing context examples slows convergence and requires more context examples. The proof sketch of Theorem [1](https://arxiv.org/html/2510.00399v1#Thmthm1) can be found in Appendix [A](https://arxiv.org/html/2510.00399v1#A1).

###### Remark 2 .

(Comparison with existing works) When $p_{a}=0$, Theorem [1](https://arxiv.org/html/2510.00399v1#Thmthm1) corresponds to the case where Mamba is trained with prompts that contain no outliers and serves as the Mamba counterpart to Theorem 3.3 in (Li et al., 2024a), which addresses Transformers. Although Huang et al. (2023); Li et al. (2024a) analyze ICL training without outliers for Transformers, their analyses do not directly extend to Mamba due to the significant structural differences between the two architectures. To the best of our knowledge, we are the first to analyze the training dynamics of Mamba in the ICL setting, under a more general scenario where prompts may contain outliers.

We then study the generalization performance on testing prompts with distribution-shifted additive outliers using the trained Mamba.

###### Theorem 2 .

(ICL Generalization on Distribution-shifted Prompts with Outliers)
During the inference, if (a) the outlier pattern ${{\bm{v}}_{s}^{*}}^{\prime}$ belongs to

$$ $\mathcal{V}^{\prime}=\Big\{{\bm{v}}\Big|{\bm{v}}=\sum_{i=1}^{V}\lambda_{i}{\bm{v}}_{i}^{*},\sum_{i=1}^{V}\lambda_{i}\geq L>0,\|{\bm{v}}\|=1\Big\},$ (11) $$

(b) the outlier magnitude $\kappa_{a}^{\prime}\in[\kappa_{a},\Theta(V\beta{p_{a}}^{-1}\kappa_{a}^{-1}L^{-1}(1-p_{a})\epsilon^{-1})]$,
(c) $\alpha<\min(1,p_{a}l_{tr}/l_{ts})$, and (d) the number of context examples

$$ ${\alpha}^{-1}\text{poly}(M_{1}^{\kappa_{a}})\gtrsim l_{ts}\gtrsim(1-\alpha)^{-1}\log M_{1},$ (12) $$

then for testing prompt ${\bm{P}}^{\prime}$ defined by Definition [2](https://arxiv.org/html/2510.00399v1#Thmdefinition2), the trained model $\Psi^{(T)}$ satisfies

$$ $L_{f\in\mathcal{T},{\bm{P}}^{\prime}\sim\mathcal{D}^{\prime}}^{0-1}(\Psi^{(T)};{\bm{P}}^{\prime},z)\leq\epsilon.$ (13) $$

###### Remark 3 .

Theorem [2](https://arxiv.org/html/2510.00399v1#Thmthm2) shows that the model trained under Theorem [1](https://arxiv.org/html/2510.00399v1#Thmthm1) generalizes well and remains robust when tested on prompts containing a signification fraction of unseen distribution-shifted
outliers.
Each additive outlier in the test prompt can be expressed as a linear combination of the $V$ training outlier patterns, with coefficients summing to a positive value (Condition (a)). This formulation captures a wide range of possible outlier patterns at test time. Notably, the fraction of examples with outliers $\alpha$ in the test prompt is less than $\min(1,p_{a}l_{tr}/l_{ts})$, which can be close to $1$ if the prompt length is selected in a way such that $p_{a}l_{tr}/l_{ts}\geq 1$ (Condition (c)).
Thus, Mamba can be trained to maintain ICL generalization in the presence of a large fraction of outlier examples.

Conditions (b) and (d) impose mild requirements on the outlier magnitude and the context length, respectively. Condition (b) requires that the magnitude of test-time outliers be at least as large as that of the training outliers. Condition (d) ensures that the context prompt is sufficiently long to include enough clean examples for correct prediction, while also imposing an upper bound on the total number of outliers.

###### Theorem 1 .

###### Remark 1 .

###### Remark 2 .

###### Theorem 2 .

###### Remark 3 .

### 3.4 A Theoretical Comparison between Linear Transformers and Mamba

In this section, we compare Mamba with linear Transformer, where the Transformer model is formulated by setting the nonlinear gating function $G_{i,l+1}({\bm{w}})=1$ in ([3](https://arxiv.org/html/2510.00399v1#S2.E3)) for $i\in[l+1]$, as discussed in Section [2](https://arxiv.org/html/2510.00399v1#S2). Such an analysis is conducted to rigorously probe how the nonlinear gating affects model training, in-context generalization, and robustness, as the gating is the only difference between the two architectures. The comparison is made between sufficient conditions for the desired generalization. This is a common practice used in existing works (Fu et al., 2023b; Jiang et al., 2024) for neural network analysis. The provided upper bounds are aligned with our experimental results in Section [4.1](https://arxiv.org/html/2510.00399v1#S4.SS1) for comparing robustness.

###### Theorem 3 .

(Convergence and Sample Complexity for Transformer Models)
As long as (i) $B\gtrsim B_{T}$, (ii) $\kappa_{a}\lesssim V\beta(1-p_{a})p_{a}^{-1}\epsilon^{-1}$, (iii)
$l_{tr}\gtrsim(1-p_{a})^{-1}\log M_{1}$, then (iv) after

$$ $T\geq T_{T}=\Theta(\eta^{-1}(1-p_{a})^{-1}\beta^{-2}l_{tr}^{-1}M_{1})$ (14) $$

iterations with $\eta\leq 1$ and $N=BT$ samples, we have that $\mathbb{E}_{f\in\mathcal{T},{\bm{P}}\sim\mathcal{D}}[\ell(\Psi^{(T)};{\bm{P}},z)]\leq\epsilon$.

###### Remark 4 .

Theorem [3](https://arxiv.org/html/2510.00399v1#Thmthm3) characterizes the sufficient conditions for the convergence and generalization of training a one-layer Transformer with linear attention using prompts containing outliers as formulated by Definition [1](https://arxiv.org/html/2510.00399v1#Thmdefinition1). Comparing conditions (i)-(iv) with those in Theorem [1](https://arxiv.org/html/2510.00399v1#Thmthm1) on Mamba models, one can see that, to achieve a $\epsilon$ generalization error, linear Transformers need a smaller batch size, a smaller number of training iterations, and a less restrictive requirement for the prompt length and the magnitude of additive outliers. To see this, Theorem [1](https://arxiv.org/html/2510.00399v1#Thmthm1) indicates that the required batch size for Mamba models is at least $B_{M}$, which is defined as the larger of value $B_{T}$ and another constant, while the required batch size for linear Transformers is $B_{T}$. The required number of training iterations for Mamba is $T_{M}$, which equals $\Theta(l_{tr})\cdot T_{T}$, and that is larger than that for linear Transformers, $T_{T}$, by a scaling of $\Theta(l_{tr})>1$. The required conditions for $\kappa_{a}$ for linear Transformers does not include a lower bound, and the upper bound is larger than that of Mamba models when $\epsilon$ is small enough. Moreover, Mamba requires an $l_{tr}$ that shares the same lower bound as that of the linear Transformers, but it does not require an upper bound.

###### Theorem 4 .

(Generalization using Transformers)
During the inference, if (a) in Theorem [2](https://arxiv.org/html/2510.00399v1#Thmthm2), (b) $\kappa_{a}^{\prime}\leq\Theta(V\beta{p_{a}}^{-1}(1-p_{a})\kappa_{a}^{-1}L^{-1}l_{tr}\epsilon^{-1})$,
(c) $\alpha\in[0,1/2)$, and (d) the number of context examples

$$ $l_{ts}\gtrsim\max\{\Theta((1-\alpha)^{-1}),\Theta((1/2-\alpha)^{-2}\alpha)\}\log M_{1},$ (15) $$

then the trained model $\Psi^{(T)}$ satisfies $L_{f\in\mathcal{T},{\bm{P}}^{\prime}\sim\mathcal{D}^{\prime}}^{0-1}(\Psi^{(T)};{\bm{P}}^{\prime},z)\leq\epsilon$.

###### Remark 5 .

Theorem [4](https://arxiv.org/html/2510.00399v1#Thmthm4) establishes the conditions under which a Transformer model, trained according to Theorem [3](https://arxiv.org/html/2510.00399v1#Thmthm3), can generalize effectively on testing prompts with possible outliers, as defined in Definition [2](https://arxiv.org/html/2510.00399v1#Thmdefinition2). In contrast to Theorem [2](https://arxiv.org/html/2510.00399v1#Thmthm2) for Mamba, the Transformer guarantees generalization only when the outlier fraction satisfies $\alpha<1/2$, whereas Mamba can remain robust when $\alpha$ goes to $1$ (Condition (c)). This highlights that Mamba achieves better in-context generalization performance in the presence of distribution-shifted additive outliers, particularly when outlier-containing context examples are in the majority. This conclusion is consistent with the empirical findings of (Park et al., 2024), which observed that Mamba outperforms Transformers in many-outlier regression tasks.

###### Theorem 3 .

###### Remark 4 .

###### Theorem 4 .

###### Remark 5 .

### 3.5 The Mechanism of Mamba in implementing ICL

We next examine the mechanism by which the trained Mamba model from Theorem [1](https://arxiv.org/html/2510.00399v1#Thmthm1) performs ICL on prompts containing additive outliers. This analysis provides deeper insights into the differences between Mamba and Transformer models.
We begin by showing, in Corollary [1](https://arxiv.org/html/2510.00399v1#Thmcorollary1), that the linear attention of the learned Mamba model assigns greater weight to context examples that share the same relevant pattern as the query.

###### Corollary 1 .

Let $\mathcal{N}_{1}\subseteq[l_{ts}]$ denote the index sets of context examples that share the same relevant pattern as the query ${\bm{x}}_{query}$. Then, for the model trained by Theorem [1](https://arxiv.org/html/2510.00399v1#Thmthm1) after $T\geq T_{M}$ iterations in ([9](https://arxiv.org/html/2510.00399v1#S3.E9)), we have with a high probability, for ${\bm{P}}^{\prime}$ defined by Definition [2](https://arxiv.org/html/2510.00399v1#Thmdefinition2),

$$ $\sum_{i\in\mathcal{N}_{1}}\tilde{{\bm{p}}}_{i}^{\top}{{\bm{W}}_{B}^{(T)}}^{\top}{\bm{W}}_{C}^{(T)}\tilde{{\bm{p}}}_{query}\geq\Theta(1);\sum_{i\in[l_{ts}]\backslash\mathcal{N}_{1}}\tilde{{\bm{p}}}_{i}^{\top}{{\bm{W}}_{B}^{(T)}}^{\top}{\bm{W}}_{C}^{(T)}\tilde{{\bm{p}}}_{query}\leq\Theta((1-p_{a})^{-1}\epsilon).$ (16) $$

###### Remark 6 .

Corollary [1](https://arxiv.org/html/2510.00399v1#Thmcorollary1) illustrates that for the testing prompt $\mathcal{P}^{\prime}$, the learned Mamba model will let the attention scores be concentrated on examples with the same relevant pattern as the query, i.e., the sum of these attention scores will increase to be larger than $\Theta(1)$, while the sum of attention score on examples with other different relevant pattern from the query is upper bounded by a small order of $(1-p_{a})^{-1}\epsilon$. This enforces the model to focus on examples with the same relevant pattern as the query when making the prediction.

Corollary [1](https://arxiv.org/html/2510.00399v1#Thmcorollary1) reveals an insight similar to the “induction head” mechanism (Olsson et al., 2022; Chan et al., 2022; Reddy, 2024) observed in softmax attention layers for ICL. However, our result is established in the context of linear attention, suggesting that different attention variants may share fundamentally similar internal mechanisms.

We then show that the nonlinear gating mechanism in Mamba models enables ICL by effectively ignoring context examples containing outliers and focusing on those that are closer to the query.

###### Corollary 2 .

(i) Gating suppresses outlier examples. For the trained model by Theorem [1](https://arxiv.org/html/2510.00399v1#Thmthm1) after $T\geq T_{M}$ iterations in ([9](https://arxiv.org/html/2510.00399v1#S3.E9)), we have that with a high probability, for $\tilde{{\bm{p}}}_{i}$ that contain a ${{\bm{v}}_{s}^{*}}^{\prime}\in\mathcal{V}^{\prime}$,

$$ $G_{i,l_{ts}+1}({\bm{w}}^{(T)})\leq O(\text{poly}(M_{1})^{-1}).$ (17) $$

(ii) Gating induces local bias. Denote $h(j)\in[l_{ts}]$ ($j\leq l_{ts}$) as the index of context example that is the $j$-th closest to the query and does not contain any ${{\bm{v}}_{s}^{*}}^{\prime}\in\mathcal{V}^{\prime}$. Then, with a high probability,

$$ $G_{h(j),l_{ts}+1}({\bm{w}}^{(T)})\geq\Theta(1/2^{j-1}).$ (18) $$

###### Remark 7 .

Corollary [2](https://arxiv.org/html/2510.00399v1#Thmcorollary2) indicates that the nonlinear gating $G_{i,l_{ts}+1}({\bm{w}}^{(T)})$ serves two main purposes: (i) filtering out examples containing additive outliers and (ii) inducing a local bias, as observed in (Han et al., 2024), that focuses on examples near the query. Specifically, ([17](https://arxiv.org/html/2510.00399v1#S3.E17)) unveils that on examples with outliers, $G_{i,l_{ts}+1}({\bm{w}}^{(T)})$ is close to 0, effectively suppressing their influence. ([18](https://arxiv.org/html/2510.00399v1#S3.E18)) shows that for clean examples, the nonlinear gating values decay exponentially with the distance (in index) from the query. Hence, combing Corollaries [1](https://arxiv.org/html/2510.00399v1#Thmcorollary1) and [2](https://arxiv.org/html/2510.00399v1#Thmcorollary2), one can see that the model primarily relies on examples that are close to the query, do not contain outliers, and share the same relevant pattern as the query for prediction, resulting in desirable ICL performance even in the presence of outliers.

Corollary [2](https://arxiv.org/html/2510.00399v1#Thmcorollary2) characterizes the role of the nonlinear gating layer, Mamba’s key structural difference from the Transformer. This distinction explains their performance gap: while nonlinear gating makes Mamba more challenging to optimize, it also enables Mamba to suppress outlier-containing examples more effectively, resulting in superior robustness when handling prompts with many outliers.

###### Corollary 1 .

###### Remark 6 .

###### Corollary 2 .

###### Remark 7 .

## 4 Experiment

We generate synthetic data following Section [3.2](https://arxiv.org/html/2510.00399v1#S3.SS2). Let $d=30$, $M_{1}=6$, $M_{2}=10$, $V=3$. For generalization with unseen outliers, let ${{\bm{v}}_{1}^{*}}^{\prime}=0.7{\bm{v}}_{1}^{*}+0.6{\bm{v}}_{2}^{*}-0.4{\bm{v}}_{3}^{*}$, ${{\bm{v}}_{2}^{*}}^{\prime}=0.4{\bm{v}}_{1}^{*}+0.7{\bm{v}}_{2}^{*}-0.6{\bm{v}}_{3}^{*}$, ${{\bm{v}}_{3}^{*}}^{\prime}=-0.7{\bm{v}}_{1}^{*}+0.5{\bm{v}}_{2}^{*}+0.5{\bm{v}}_{3}^{*}$, with $L=0.3$. $l_{ts}=l_{tr}=20$. Let $\delta=0.2$, $\beta=3$, $\kappa_{a}=2$.

### 4.1 Comparison between One-Layer Mamba and Linear Transformer Models on ICL with Outliers

The learning model is a one-layer Mamba defined in ([3](https://arxiv.org/html/2510.00399v1#S2.E3)) and a one-layer single-head Transformer by making $G_{i,l+1}({\bm{w}})=1$ for $i\in[l+1]$. We set $p_{a}=0.6$. We consider three types of outlier-relevant labeling functions during
inference. If the context examples in a given prompt $\mathbf{P}^{\prime}$ contains any additive outlier, the corresponding context label will be (A) flipped, (B) mapping to one targeted label out of $\{+1,-1\}$, or (C) randomly chosen from $\{+1,-1\}$ with equal probability. Figure [2](https://arxiv.org/html/2510.00399v1#S4.F2) shows that under three different forms of outliers, the classification error of Mamba is smaller than $0.01$ even when $\alpha$ is close to 0.8. In contrast, the classification error of linear Transformers is large as long as $\alpha>1/2$. This is consistent with Remark [5](https://arxiv.org/html/2510.00399v1#Thmrmk5): the linear transformer can tolerate at most a 1/2 fraction of outliers in the prompt, whereas Mamba can tolerate a fraction of outliers close to that seen during training, which can be close to 1.

Figure: Figure 2: ICL classification error of Mamba and linear Transformer against $\alpha$ with different prompt outliers. (A) Label flipping. (B) Targeted labeling. (C) Random labeling.
Refer to caption: x2.png

### 4.2 The ICL Mechanism of Multi-Layer Mamba

The learning model is a three-layer Mamba and a three-layer single-head linear Transformer. $p_{a}=0.4$. Figure [3](https://arxiv.org/html/2510.00399v1#S4.F3) shows the first-layer attention scores in the testing prompt. The sum of attention scores on the examples that share the same pattern as the query is significantly larger than that on examples with other patterns, and this gap increases during training. This verifies Corollary [1](https://arxiv.org/html/2510.00399v1#Thmcorollary1). Figure [4](https://arxiv.org/html/2510.00399v1#S4.F4) shows that the first-layer gating values with $\alpha=0.3$ of outlier-containing examples are very small (red bars), while those of clean examples are relatively large and exhibit an approximately exponential decay with increasing distance from the query (green bars). This is consistent with ([17](https://arxiv.org/html/2510.00399v1#S3.E17)) and ([18](https://arxiv.org/html/2510.00399v1#S3.E18)) in Corollary [2](https://arxiv.org/html/2510.00399v1#Thmcorollary2). The results of attention scores and gating values in the other two layers exhibit the same trend as the first layer and are shown in Section [B](https://arxiv.org/html/2510.00399v1#A2) in Appendix due to the space limit.

Next, we study the impact of the positions of context examples with $\alpha=0.5$. Table [1](https://arxiv.org/html/2510.00399v1#S4.T1) presents the ICL performance under three different placements of outlier examples: all positioned farthest from the query (FQ), closest to the query (CQ), or at random positions (R). We find that Mamba is highly sensitive to the position of outliers, whereas the linear Transformer (LT) is much less affected. This is because, when outliers are placed close to the query, the clean examples that share the same pattern as the query are pushed farther away, and the gating values on these examples decay exponentially according to ([18](https://arxiv.org/html/2510.00399v1#S3.E18)), thereby degrading ICL performance.

Figure: Figure 3: The summation of 1st-layer attention scores on examples with the same or a different relevant pattern as the query.

Figure: Figure 4: The 1st-layer gating value of examples with (red) or without (green) additive outliers.

|  | Mamba | LT |
| --- | --- | --- |
| FQ | 99.84% | 78.52% |
| R | 99.04% | 78.28% |
| CQ | 73.28% | 78.60% |

Table: Table 1: ICL accuracy of 3-layer Mamba and linear Transformers (LT) with different example arrangement.

## 5 Conclusion, Limitations, and Future Works

This paper theoretically studies the learning dynamics, ICL generalization, and the robustness to outliers of Mamba models, together with a characterization of how different components of Mamba contribute to the ICL mechanism. Our analysis also provides a theoretical comparison between Mamba and linear Transformer models. Although based on a one-layer Mamba structure on binary classification tasks, this work provides a deeper theoretical understanding and provable advantages of Mamba. Future directions include designing general Mamba-based language/multi-modal models.

## References

- Achiam et al. (2023)
J. Achiam, S. Adler, S. Agarwal, L. Ahmad, I. Akkaya, F. L. Aleman, D. Almeida, J. Altenschmidt, S. Altman, S. Anadkat, et al.
Gpt-4 technical report.
*arXiv preprint arXiv:2303.08774*, 2023.
- Ahn et al. (2023)
K. Ahn, X. Cheng, H. Daneshmand, and S. Sra.
Transformers learn to implement preconditioned gradient descent for in-context learning.
*arXiv preprint arXiv:2306.00297*, 2023.
- Akyürek et al. (2023)
E. Akyürek, D. Schuurmans, J. Andreas, T. Ma, and D. Zhou.
What learning algorithm is in-context learning? investigations with linear models.
In *The Eleventh International Conference on Learning Representations*, 2023.
- Ali et al. (2024)
A. Ali, I. Zimerman, and L. Wolf.
The hidden attention of mamba models.
*arXiv preprint arXiv:2403.01590*, 2024.
- Allen-Zhu et al. (2019a)
Z. Allen-Zhu, Y. Li, and Y. Liang.
Learning and generalization in overparameterized neural networks, going beyond two layers.
In *Advances in neural information processing systems*, pages 6155–6166, 2019a.
- Allen-Zhu et al. (2019b)
Z. Allen-Zhu, Y. Li, and Z. Song.
A convergence theory for deep learning via over-parameterization.
In *International Conference on Machine Learning*, pages 242–252. PMLR, 2019b.
- Anwar et al. (2024)
U. Anwar, J. Von Oswald, L. Kirsch, D. Krueger, and S. Frei.
Adversarial robustness of in-context learning in transformers for linear regression.
*arXiv preprint arXiv:2411.05189*, 2024.
- Arora et al. (2024)
S. Arora, S. Eyuboglu, M. Zhang, A. Timalsina, S. Alberti, J. Zou, A. Rudra, and C. Re.
Simple linear attention language models balance the recall-throughput tradeoff.
In *International Conference on Machine Learning*, pages 1763–1840. PMLR, 2024.
- Bai et al. (2023)
Y. Bai, F. Chen, H. Wang, C. Xiong, and S. Mei.
Transformers as statisticians: Provable in-context learning with in-context algorithm selection.
*arXiv preprint arXiv:2306.04637*, 2023.
- Bondaschi et al. (2025)
M. Bondaschi, N. Rajaraman, X. Wei, K. Ramchandran, R. Pascanu, C. Gulcehre, M. Gastpar, and A. V. Makkuva.
From markov to laplace: How mamba in-context learns markov chains.
*arXiv preprint arXiv:2502.10178*, 2025.
- Brown et al. (2020)
T. Brown, B. Mann, N. Ryder, M. Subbiah, J. D. Kaplan, P. Dhariwal, A. Neelakantan, P. Shyam, G. Sastry, A. Askell, et al.
Language models are few-shot learners.
*Advances in Neural Information Processing Systems*, 33:1877–1901, 2020.
- Brutzkus and Globerson (2021)
A. Brutzkus and A. Globerson.
An optimization and generalization analysis for max-pooling networks.
In *Uncertainty in Artificial Intelligence*, pages 1650–1660. PMLR, 2021.
- Cao and Gu (2019)
Y. Cao and Q. Gu.
Generalization bounds of stochastic gradient descent for wide and deep neural networks.
In *Advances in Neural Information Processing Systems*, pages 10836–10846, 2019.
- Chan et al. (2022)
S. Chan, A. Santoro, A. Lampinen, J. Wang, A. Singh, P. Richemond, J. McClelland, and F. Hill.
Data distributional properties drive emergent in-context learning in transformers.
*Advances in neural information processing systems*, 35:18878–18891, 2022.
- Chen et al. (2024a)
S. Chen, H. Sheen, T. Wang, and Z. Yang.
Training dynamics of multi-head softmax attention for in-context learning: Emergence, convergence, and optimality.
*arXiv preprint arXiv:2402.19442*, 2024a.
- Chen et al. (2024b)
Y. Chen, C. Zhao, Z. Yu, K. McKeown, and H. He.
Parallel structures in pre-training data yield in-context learning.
In *Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)*, pages 8582–8592, 2024b.
- Chen et al. (2020)
Z. Chen, Y. Cao, Q. Gu, and T. Zhang.
A generalized neural tangent kernel analysis for two-layer neural networks.
*Advances in Neural Information Processing Systems*, 33, 2020.
- Chowdhury et al. (2023)
M. N. R. Chowdhury, S. Zhang, M. Wang, S. Liu, and P.-Y. Chen.
Patch-level routing in mixture-of-experts is provably sample-efficient for convolutional neural networks.
In *International Conference on Machine Learning*, 2023.
- Chowdhury et al. (2024)
M. N. R. Chowdhury, M. Wang, K. E. Maghraoui, N. Wang, P.-Y. Chen, and C. Carothers.
A provably effective method for pruning experts in fine-tuned sparse mixture-of-experts.
*arXiv preprint arXiv:2405.16646*, 2024.
- Daniely and Malach (2020)
A. Daniely and E. Malach.
Learning parities with neural networks.
*Advances in Neural Information Processing Systems*, 33:20356–20365, 2020.
- Dao and Gu (2024)
T. Dao and A. Gu.
Transformers are ssms: generalized models and efficient algorithms through structured state space duality.
In *Proceedings of the 41st International Conference on Machine Learning*, pages 10041–10071, 2024.
- Fu et al. (2023a)
D. Y. Fu, T. Dao, K. K. Saab, A. W. Thomas, A. Rudra, and C. Re.
Hungry hungry hippos: Towards language modeling with state space models.
In *The Eleventh International Conference on Learning Representations*, 2023a.
- Fu et al. (2020)
H. Fu, Y. Chi, and Y. Liang.
Guaranteed recovery of one-hidden-layer neural networks via cross entropy.
*IEEE Transactions on Signal Processing*, 68:3225–3235, 2020.
- Fu et al. (2023b)
H. Fu, T. Guo, Y. Bai, and S. Mei.
What can a single attention layer learn? a study through the random features lens.
*Advances in Neural Information Processing Systems*, 36:11912–11951, 2023b.
- Garg et al. (2022)
S. Garg, D. Tsipras, P. S. Liang, and G. Valiant.
What can transformers learn in-context? a case study of simple function classes.
*Advances in Neural Information Processing Systems*, 35:30583–30598, 2022.
- Grazzi et al. (2024)
R. Grazzi, J. N. Siems, S. Schrodi, T. Brox, and F. Hutter.
Is mamba capable of in-context learning?
In *International Conference on Automated Machine Learning*, pages 1–1. PMLR, 2024.
- Gu and Dao (2023)
A. Gu and T. Dao.
Mamba: Linear-time sequence modeling with selective state spaces.
*arXiv preprint arXiv:2312.00752*, 2023.
- Gu et al. (2021)
A. Gu, I. Johnson, K. Goel, K. Saab, T. Dao, A. Rudra, and C. Ré.
Combining recurrent, convolutional, and continuous-time models with linear state space layers.
*Advances in neural information processing systems*, 34:572–585, 2021.
- Gu et al. (2022)
A. Gu, K. Goel, and C. Re.
Efficiently modeling long sequences with structured state spaces.
In *International Conference on Learning Representations*, 2022.
- Guo et al. (2025)
D. Guo, D. Yang, H. Zhang, J. Song, R. Zhang, R. Xu, Q. Zhu, S. Ma, P. Wang, X. Bi, et al.
Deepseek-r1: Incentivizing reasoning capability in llms via reinforcement learning.
*arXiv preprint arXiv:2501.12948*, 2025.
- Halloran et al. (2024)
J. T. Halloran, M. Gulati, and P. F. Roysdon.
Mamba state-space models can be strong downstream learners.
*arXiv e-prints*, pages arXiv–2406, 2024.
- Han et al. (2024)
D. Han, Z. Wang, Z. Xia, Y. Han, Y. Pu, C. Ge, J. Song, S. Song, B. Zheng, and G. Huang.
Demystify mamba in vision: A linear attention perspective.
*arXiv preprint arXiv:2405.16605*, 2024.
- Hatamizadeh and Kautz (2024)
A. Hatamizadeh and J. Kautz.
Mambavision: A hybrid mamba-transformer vision backbone.
*arXiv preprint arXiv:2407.08083*, 2024.
- He et al. (2025)
J. He, X. Pan, S. Chen, and Z. Yang.
In-context linear regression demystified: Training dynamics and mechanistic interpretability of multi-head softmax attention.
*arXiv preprint arXiv:2503.12734*, 2025.
- He et al. (2024)
P. He, H. Xu, Y. Xing, H. Liu, M. Yamada, and J. Tang.
Data poisoning for in-context learning.
*arXiv preprint arXiv:2402.02160*, 2024.
- Huang et al. (2024)
R. Huang, Y. Liang, and J. Yang.
Non-asymptotic convergence of training transformers for next-token prediction.
*Advances in Neural Information Processing Systems*, 37:80634–80673, 2024.
- Huang et al. (2023)
Y. Huang, Y. Cheng, and Y. Liang.
In-context convergence of transformers.
In *NeurIPS 2023 Workshop on Mathematics of Modern Machine Learning*, 2023.
- Jacot et al. (2018)
A. Jacot, F. Gabriel, and C. Hongler.
Neural tangent kernel: Convergence and generalization in neural networks.
In *Advances in neural information processing systems*, pages 8571–8580, 2018.
- Jelassi et al. (2022)
S. Jelassi, M. Sander, and Y. Li.
Vision transformers provably learn spatial structure.
*Advances in Neural Information Processing Systems*, 35:37822–37836, 2022.
- Jelassi et al. (2024)
S. Jelassi, D. Brandfonbrener, S. M. Kakade, et al.
Repeat after me: Transformers are better than state space models at copying.
In *Forty-first International Conference on Machine Learning*, 2024.
- Jiang et al. (2024)
J. Jiang, W. Huang, M. Zhang, T. Suzuki, and L. Nie.
Unveil benign overfitting for transformer in vision: Training dynamics, convergence, and generalization.
*Advances in Neural Information Processing Systems*, 37:135464–135625, 2024.
- Joseph et al. (2024)
F. A. Joseph, K. K. Haefeli, N. Liniger, and C. Gulcehre.
Hippo-prophecy: State-space models can provably learn dynamical systems in context.
*arXiv preprint arXiv:2407.09375*, 2024.
- Kandpal et al. (2023)
N. Kandpal, M. Jagielski, F. Tramèr, and N. Carlini.
Backdoor attacks for in-context learning with language models.
In *The Second Workshop on New Frontiers in Adversarial Machine Learning*, 2023.
- Karp et al. (2021)
S. Karp, E. Winston, Y. Li, and A. Singh.
Local signal adaptivity: Provable feature learning in neural networks beyond kernels.
*Advances in Neural Information Processing Systems*, 34:24883–24897, 2021.
- Kim and Suzuki (2024)
J. Kim and T. Suzuki.
Transformers learn nonlinear features in context: Nonconvex mean-field dynamics on the attention landscape.
In *International Conference on Machine Learning*, pages 24527–24561. PMLR, 2024.
- Lenz et al. (2025)
B. Lenz, O. Lieber, A. Arazi, A. Bergman, A. Manevich, B. Peleg, B. Aviram, C. Almagor, C. Fridman, D. Padnos, et al.
Jamba: Hybrid transformer-mamba language models.
In *The Thirteenth International Conference on Learning Representations*, 2025.
- Li et al. (2022a)
H. Li, M. Wang, S. Liu, P.-Y. Chen, and J. Xiong.
Generalization guarantee of training graph convolutional networks with graph topology sampling.
In *International Conference on Machine Learning*, pages 13014–13051. PMLR, 2022a.
- Li et al. (2022b)
H. Li, S. Zhang, and M. Wang.
Learning and generalization of one-hidden-layer neural networks, going beyond standard gaussian data.
In *2022 56th Annual Conference on Information Sciences and Systems (CISS)*, pages 37–42. IEEE, 2022b.
- Li et al. (2023a)
H. Li, M. Wang, S. Liu, and P.-Y. Chen.
A theoretical understanding of shallow vision transformers: Learning, generalization, and sample complexity.
In *The Eleventh International Conference on Learning Representations*, 2023a.
URL [https://openreview.net/forum?id=jClGv3Qjhb](https://openreview.net/forum?id=jClGv3Qjhb).
- Li et al. (2023b)
H. Li, M. Wang, T. Ma, S. Liu, Z. ZHANG, and P.-Y. Chen.
What improves the generalization of graph transformer? a theoretical dive into self-attention and positional encoding.
In *NeurIPS 2023 Workshop: New Frontiers in Graph Learning*, 2023b.
URL [https://openreview.net/forum?id=BaxFC3z9R6](https://openreview.net/forum?id=BaxFC3z9R6).
- Li et al. (2024a)
H. Li, M. Wang, S. Lu, X. Cui, and P.-Y. Chen.
How do nonlinear transformers learn and generalize in in-context learning?
In *Forty-first International Conference on Machine Learning*, 2024a.
URL [https://openreview.net/forum?id=I4HTPws9P6](https://openreview.net/forum?id=I4HTPws9P6).
- Li et al. (2024b)
H. Li, M. Wang, S. Lu, X. Cui, and P.-Y. Chen.
Training nonlinear transformers for chain-of-thought inference: A theoretical generalization analysis.
*arXiv preprint arXiv:2410.02167*, 2024b.
- Li et al. (2024c)
H. Li, M. Wang, S. Zhang, S. Liu, and P.-Y. Chen.
Learning on transformers is provable low-rank and sparse: A one-layer analysis.
In *2024 IEEE 13rd Sensor Array and Multichannel Signal Processing Workshop (SAM)*, pages 1–5. IEEE, 2024c.
- Li et al. (2024d)
H. Li, S. Zhang, Y. Zhang, M. Wang, S. Liu, and P.-Y. Chen.
How does promoting the minority fraction affect generalization? a theoretical study of one-hidden-layer neural network on group imbalance.
*IEEE Journal of Selected Topics in Signal Processing*, 2024d.
- Li et al. (2025a)
H. Li, Y. Zhang, S. Zhang, M. Wang, S. Liu, and P.-Y. Chen.
When is task vector provably effective for model editing? a generalization analysis of nonlinear transformers.
*arXiv preprint arXiv:2504.10957*, 2025a.
- Li et al. (2024e)
Y. Li, A. S. Rawat, and S. Oymak.
Fine-grained analysis of in-context linear estimation: Data, architecture, and beyond.
*Advances in Neural Information Processing Systems*, 37:138324–138364, 2024e.
- Li et al. (2025b)
Y. Li, D. A. Tarzanagh, A. S. Rawat, M. Fazel, and S. Oymak.
Gating is weighting: Understanding gated linear attention through in-context learning.
*arXiv preprint arXiv:2504.04308*, 2025b.
- Liu et al. (2022)
J. Liu, D. Shen, Y. Zhang, W. B. Dolan, L. Carin, and W. Chen.
What makes good in-context examples for gpt-3?
In *Proceedings of Deep Learning Inside Out (DeeLIO 2022): The 3rd Workshop on Knowledge Extraction and Integration for Deep Learning Architectures*, pages 100–114, 2022.
- Luo et al. (2024a)
Y. Luo, H. Li, Q. Liu, L. Shi, and X.-M. Wu.
Node identifiers: Compact, discrete representations for efficient graph learning.
*arXiv preprint arXiv:2405.16435*, 2024a.
- Luo et al. (2024b)
Y. Luo, H. Li, L. Shi, and X.-M. Wu.
Enhancing graph transformers with hierarchical distance structural encoding.
*Advances in Neural Information Processing Systems*, 37:57150–57182, 2024b.
- Mohri et al. (2018)
M. Mohri, A. Rostamizadeh, and A. Talwalkar.
*Foundations of machine learning*.
MIT press, 2018.
- Nichani et al. (2025)
E. Nichani, J. D. Lee, and A. Bietti.
Understanding factual recall in transformers via associative memories.
In *The Thirteenth International Conference on Learning Representations*, 2025.
URL [https://openreview.net/forum?id=hwSmPOAmhk](https://openreview.net/forum?id=hwSmPOAmhk).
- Oko et al. (2024)
K. Oko, Y. Song, T. Suzuki, and D. Wu.
Pretrained transformer efficiently learns low-dimensional target functions in-context.
In *The Thirty-eighth Annual Conference on Neural Information Processing Systems*, 2024.
URL [https://openreview.net/forum?id=uHcG5Y6fdB](https://openreview.net/forum?id=uHcG5Y6fdB).
- Olsson et al. (2022)
C. Olsson, N. Elhage, N. Nanda, N. Joseph, N. DasSarma, T. Henighan, B. Mann, A. Askell, Y. Bai, A. Chen, et al.
In-context learning and induction heads.
*arXiv preprint arXiv:2209.11895*, 2022.
- Park et al. (2024)
J. Park, J. Park, Z. Xiong, N. Lee, J. Cho, S. Oymak, K. Lee, and D. Papailiopoulos.
Can mamba learn how to learn? a comparative study on in-context learning tasks.
*arXiv preprint arXiv:2402.04248*, 2024.
- Qiang et al. (2023)
Y. Qiang, X. Zhou, and D. Zhu.
Hijacking large language models via adversarial in-context learning.
*arXiv preprint arXiv:2311.09948*, 2023.
- Reddy (2024)
G. Reddy.
The mechanistic basis of data dependence and abrupt learning in an in-context classification task.
In *The Twelfth International Conference on Learning Representations*, 2024.
- Ren et al. (2024)
Y. Ren, Z. Wang, and J. D. Lee.
Learning and transferring sparse contextual bigrams with linear transformers.
In *The Thirty-eighth Annual Conference on Neural Information Processing Systems*, 2024.
- Shi et al. (2021)
Z. Shi, J. Wei, and Y. Liang.
A theoretical analysis on feature learning in neural networks: Emergence from inputs and advantage over fixed features.
In *International Conference on Learning Representations*, 2021.
- Sun et al. (2025a)
J. Sun, H. Li, and M. Wang.
Theoretical learning performance of graph networks: the impact of jumping connections and layer-wise sparsification.
*Transactions on Machine Learning Research*, 2025a.
- Sun et al. (2025b)
J. Sun, S. Zhang, H. Li, and M. Wang.
Theoretical guarantees and training dynamics of contrastive learning: How misaligned data influence feature purity.
In *High-dimensional Learning Dynamics*, 2025b.
- Sun et al. (2023)
Y. Sun, L. Dong, S. Huang, S. Ma, Y. Xia, J. Xue, J. Wang, and F. Wei.
Retentive network: A successor to transformer for large language models.
*arXiv preprint arXiv:2307.08621*, 2023.
- Sun et al. (2024)
Y. Sun, L. Dong, Y. Zhu, S. Huang, W. Wang, S. Ma, Q. Zhang, J. Wang, and F. Wei.
You only cache once: Decoder-decoder architectures for language models.
*Advances in Neural Information Processing Systems*, 37:7339–7361, 2024.
- Vershynin (2010)
R. Vershynin.
Introduction to the non-asymptotic analysis of random matrices.
*arXiv preprint arXiv:1011.3027*, 2010.
- Von Oswald et al. (2023)
J. Von Oswald, E. Niklasson, E. Randazzo, J. Sacramento, A. Mordvintsev, A. Zhmoginov, and M. Vladymyrov.
Transformers learn in-context by gradient descent.
In *International Conference on Machine Learning*, pages 35151–35174. PMLR, 2023.
- Waleffe et al. (2024)
R. Waleffe, W. Byeon, D. Riach, B. Norick, V. Korthikanti, T. Dao, A. Gu, A. Hatamizadeh, S. Singh, D. Narayanan, et al.
An empirical study of mamba-based language models.
*arXiv preprint arXiv:2406.07887*, 2024.
- Wan et al. (2023)
A. Wan, E. Wallace, S. Shen, and D. Klein.
Poisoning language models during instruction tuning.
In *International Conference on Machine Learning*, pages 35413–35425. PMLR, 2023.
- Wright et al. (2010)
J. Wright, Y. Ma, J. Mairal, G. Sapiro, T. S. Huang, and S. Yan.
Sparse representation for computer vision and pattern recognition.
*Proceedings of the IEEE*, 98(6):1031–1044, 2010.
- Wu et al. (2023a)
J. Wu, D. Zou, Z. Chen, V. Braverman, Q. Gu, and P. L. Bartlett.
How many pretraining tasks are needed for in-context learning of linear regression?
*arXiv preprint arXiv:2310.08391*, 2023a.
- Wu et al. (2023b)
Z. Wu, Y. Wang, J. Ye, and L. Kong.
Self-adaptive in-context learning: An information compression perspective for in-context example selection and ordering.
*ACL*, 2023b.
- Xu et al. (2024)
Q. Xu, X. Liu, L. Zhu, G. Lin, C. Long, Z. Li, and R. Zhao.
Hybrid mamba for few-shot segmentation.
*Advances in Neural Information Processing Systems*, 37:73858–73883, 2024.
- Yang et al. (2024a)
H. Yang, B. Kailkhura, Z. Wang, and Y. Liang.
Training dynamics of transformers to recognize word co-occurrence via gradient flow analysis.
In *The Thirty-eighth Annual Conference on Neural Information Processing Systems*, 2024a.
- Yang et al. (2024b)
S. Yang, B. Wang, Y. Shen, R. Panda, and Y. Kim.
Gated linear attention transformers with hardware-efficient training.
In *Proceedings of the 41st International Conference on Machine Learning*, pages 56501–56523, 2024b.
- Yang et al. (2024c)
S. Yang, B. Wang, Y. Zhang, Y. Shen, and Y. Kim.
Parallelizing linear transformers with the delta rule over sequence length.
*Advances in neural information processing systems*, 37:115491–115522, 2024c.
- Yang et al. (2024d)
T. Yang, Y. Huang, Y. Liang, and Y. Chi.
In-context learning with representations: Contextual generalization of trained transformers.
In *The Thirty-eighth Annual Conference on Neural Information Processing Systems*, 2024d.
- Zhang et al. (2023a)
R. Zhang, S. Frei, and P. L. Bartlett.
Trained transformers learn linear models in-context.
*arXiv preprint arXiv:2306.09927*, 2023a.
- Zhang et al. (2023b)
S. Zhang, H. Li, M. Wang, M. Liu, P.-Y. Chen, S. Lu, S. Liu, K. Murugesan, and S. Chaudhury.
On the convergence and sample complexity analysis of deep q-networks with $\epsilon$-greedy exploration.
In *Thirty-seventh Conference on Neural Information Processing Systems*, 2023b.
- Zhang et al. (2024)
Y. Zhang, H. Li, Y. Yao, A. Chen, S. Zhang, P.-Y. Chen, M. Wang, and S. Liu.
Visual prompting reimagined: The power of activation prompts, 2024.
URL [https://openreview.net/forum?id=0b328CMwn1](https://openreview.net/forum?id=0b328CMwn1).
- Zhao et al. (2024)
S. Zhao, M. Jia, L. A. Tuan, F. Pan, and J. Wen.
Universal vulnerabilities in large language models: Backdoor attacks for in-context learning.
In *Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing*, pages 11507–11522, 2024.
- Zhong et al. (2017)
K. Zhong, Z. Song, P. Jain, P. L. Bartlett, and I. S. Dhillon.
Recovery guarantees for one-hidden-layer neural networks.
In *Proceedings of the 34th International Conference on Machine Learning-Volume 70*, pages 4140–4149, 2017.
URL [https://arxiv.org/pdf/1706.03175.pdf](https://arxiv.org/pdf/1706.03175.pdf).

## Appendix A Proof Sketch of Main Theorems

The proof idea of main theoretical results is as follows. First, in Lemmas [3](https://arxiv.org/html/2510.00399v1#Thmlemma3), [4](https://arxiv.org/html/2510.00399v1#Thmlemma4), and [5](https://arxiv.org/html/2510.00399v1#Thmlemma5), we depict the growth of ${\bm{W}}_{B}$, ${\bm{W}}_{C}$, and ${\bm{w}}$ along the directions of the relevant pattern, the irrelevant pattern, and the outlier pattern, respectively, across different training iterations. This result comes from computing the model gradients at each step. In particular, Lemma [4](https://arxiv.org/html/2510.00399v1#Thmlemma4) and Lemma [5](https://arxiv.org/html/2510.00399v1#Thmlemma5) divide the training dynamics of the gating parameterized by ${\bm{w}}$ into two phases and respectively characterize them to handle the nonlinearity introduced by the sigmoid-based gating function. This is an important theoretical novelty in our work, as existing studies do not analyze the training dynamics of gating parameters. Lemma [6](https://arxiv.org/html/2510.00399v1#Thmlemma6) shows that the sum of gating values across different examples is less than 1, and it serves as supporting evidence for proving Lemmas [4](https://arxiv.org/html/2510.00399v1#Thmlemma4) and [5](https://arxiv.org/html/2510.00399v1#Thmlemma5).

Based on these results, we construct the proof of Theorem [1](https://arxiv.org/html/2510.00399v1#Thmthm1) as follows. We calculate the attention scores in the linear attention component of the model after the two training phases for context examples containing different relevant patterns, as well as the gating function values for examples that do or do not contain the outlier pattern, respectively. These conclusions correspond to Corollaries [1](https://arxiv.org/html/2510.00399v1#Thmcorollary1) and [2](https://arxiv.org/html/2510.00399v1#Thmcorollary2). By combining these two parts together with a concentration inequality, we obtain the convergence of the model on the input distribution $\mathcal{D}$. In the proof of Theorem [2](https://arxiv.org/html/2510.00399v1#Thmthm2), since the distribution-shifted outliers are linear combinations of the outliers in the training stage, we can compute the attention scores and gating values in the presence of these new outliers by combining Lemma [3](https://arxiv.org/html/2510.00399v1#Thmlemma3) to [6](https://arxiv.org/html/2510.00399v1#Thmlemma6). Based on these results, we can further derive the classification error in this setting. For the derivation of Theorems [3](https://arxiv.org/html/2510.00399v1#Thmthm3) and [4](https://arxiv.org/html/2510.00399v1#Thmthm4), we fix the gating value to $1$ and ignore its effect, and then follow the proof strategy of Theorems [1](https://arxiv.org/html/2510.00399v1#Thmthm1) and [2](https://arxiv.org/html/2510.00399v1#Thmthm2) accordingly.

## Appendix B Additional Experiments and the Algorithm

We first show the visualization result of the second and the third linear attention and nonlinear gating layers of the three-layer Mamba analyzed in Section [4.2](https://arxiv.org/html/2510.00399v1#S4.SS2). The conclusions in Figures [5](https://arxiv.org/html/2510.00399v1#A2.F5) and [6](https://arxiv.org/html/2510.00399v1#A2.F6) are aligned with Figures [3](https://arxiv.org/html/2510.00399v1#S4.F3) and [4](https://arxiv.org/html/2510.00399v1#S4.F4), respectively.

Figure: Figure 5: The summation of attention scores in the 2nd and 3rd layers.
Refer to caption: x7.png

Figure: Figure 6: The gating values of examples with or without outliers in the 2nd and 3rd layers.
Refer to caption: x9.png

We then introduce other related theoretical works on optimization and generalization of neural networks in this section. Some works Zhong et al. (2017); Fu et al. (2020); Li et al. (2022b); Zhang et al. (2023b); Li et al. (2024d) study the generalization of neural networks using the model recovery framework by investigating the local convexity around a ground truth parameter of the problem. The neural-tangent-kernel (NTK) analyses Jacot et al. (2018); Allen-Zhu et al. (2019a, b); Cao and Gu (2019); Chen et al. (2020); Li et al. (2022a); Sun et al. (2025a) study this problem in the overparameterized setting to linearize the neural network around the initialization, with the resulting generalization performance irrelevant to the feature distribution. Another line of works Daniely and Malach (2020); Shi et al. (2021); Karp et al. (2021); Brutzkus and Globerson (2021); Li et al. (2023a); Zhang et al. (2024); Chowdhury et al. (2023, 2024); Li et al. (2024c); Luo et al. (2024b); Li et al. (2024b); Luo et al. (2024a); Sun et al. (2025b) studies the generalization of neural networks by formulating data that contains discriminative and unimportant features. Our analysis in this work is aligned with the last framework to probe the generalization of Mamba and Transformers.

We next present the training algorithm introduced in Section [2](https://arxiv.org/html/2510.00399v1#S2).

Figure: Algorithm 1 Training with Stochastic Gradient Descent (SGD)

## Appendix C Key Lemmas

We first present Table [2](https://arxiv.org/html/2510.00399v1#A3.T2) for a summary of notations used in the proof.

**Table 2: Summary of Notations**
| Notations | Annotation |
| --- | --- |
| $\tilde{{\bm{A}}}_{i}$, $\tilde{{\bm{B}}}_{i}$, ${\bm{C}}_{i}$ | Parameters in Mamba. |
| $\sigma(\cdot)$ | sigmoid function. |
| ${\bm{x}}_{s}^{n}$, $y_{s}^{n}$ | ${\bm{x}}_{s}^{n}$ is the input data for classification. $y_{s}^{n}$ is the label for ${\bm{x}}_{s}^{n}$. |
| ${\bm{P}}^{n}$, $z^{n}$ | ${\bm{P}}^{n}$ is a prompt that consists of the query and $l$ pairs of examples of ${\bm{x}}_{s}^{n}$ and $y_{s}^{n}$, $s\in[l]$. $z^{n}\in\{+1,-1\}$ is the binary label of ${\bm{p}}_{query}^{n}$. |
| $F(\Psi;{\bm{P}}^{n})$, $\ell(\Psi;{\bm{P}}^{n},z^{n})$ | $F(\Psi;{\bm{P}}^{n})$ is the model output for ${\bm{P}}^{n}$ with $\Psi$ as the parameter. $\ell(\Psi;{\bm{P}}^{n},z^{n})$ is the loss function given the input ${\bm{P}}^{n}$ and the corresponding label $z^{n}$. |
| $L_{f\in\mathcal{T},{\bm{P}}^{\prime}\sim\mathcal{D}^{\prime}}^{0-1}(\Psi;{\bm{P}}^{\prime},z)$ | The classification error of $\Psi$ given ${\bm{P}}^{\prime}\sim\mathcal{D}^{\prime}$ as the input and $f\in\mathcal{T}$. |
| ${\bm{\mu}}_{j}$, ${\bm{\nu}}_{k}$ | ${\bm{\mu}}_{j}$ and ${\bm{\nu}}_{k}$ are the relevant and irrelevant patterns in the data formulation. |
| $M_{1}$, $M_{2}$ | $M_{1}$ is the number of relevant patterns. $M_{2}$ is the number of irrelevant patterns. |
| ${\bm{v}}_{s}^{*}$, ${{\bm{v}}_{s}^{*}}^{\prime}$, $\kappa_{a}$, $\kappa_{a}^{\prime}$ | ${\bm{v}}_{s}^{*}$, $s\in[V]$ is the additive outlier for training. ${{\bm{v}}_{s}^{*}}^{\prime}$ is the additive outlier for testing. $\kappa_{a}$ and $\kappa_{a}^{\prime}$ are the magnitudes of outliers in training and testing. |
| $p_{a}$, $\alpha$ | $p_{a}$ is the probability of examples containing additive outliers in training prompts. $\alpha$ is the probability of examples containing outliers in testing prompts. |
| $\mathcal{B}_{b}$ | $\mathcal{B}_{b}$ is the SGD batch at the $b$-th iteration. $l_{ts}$ is the prompt length of the testing data. |
| $l_{tr}$, $l_{ts}$ | $l_{tr}$ is the prompt length of the training data. $l_{ts}$ is the prompt length of the testing data. |
| $\mathcal{O}()$, $\Omega()$, $\Theta()$ | We follow the convention that $f(x)=O(g(x))$ (or $\Omega(g(x))$, $\Theta(g(x)))$) means that $f(x)$ increases at most, at least, or in the order of $g(x)$, respectively. |
| $\gtrsim$, $\lesssim$ | $f(x)\gtrsim g(x)$ (or $f(x)\lesssim g(x)$ ) means that $f(x)\geq\Omega(g(x))$ (or $f(x)\lesssim\mathcal{O}(g(x))$). |

###### Lemma 1 .

(Multiplicative Chernoff bounds, Theorem D.4 of Mohri et al. (2018)) Let $X_{1}$, $\cdots$, $X_{m}$ be independent random variables drawn according to some distribution $\mathcal{D}$ with mean $p$ and support included in $[0,1]$. Then, for any $\gamma\in[0,\frac{1}{p}-1]$, the following inequality holds for $\hat{p}=\frac{1}{m}\sum_{i=1}^{m}X_{i}$:

$$ $\Pr(\hat{p}\geq(1+\gamma)p)\leq e^{-\frac{mp\gamma^{2}}{3}},$ (20) $$

$$ $\Pr(\hat{p}\leq(1-\gamma)p)\leq e^{-\frac{mp\gamma^{2}}{2}}.$ (21) $$

###### Definition 3 .

Vershynin (2010)
We say $X$ is a sub-Gaussian random variable with sub-Gaussian norm $K>0$, if $(\mathbb{E}|X|^{p})^{\frac{1}{p}}\leq K\sqrt{p}$ for all $p\geq 1$. In addition, the sub-Gaussian norm of X, denoted $\|X\|_{\psi_{2}}$, is defined as $\|X\|_{\psi_{2}}=\sup_{p\geq 1}p^{-\frac{1}{2}}(\mathbb{E}|X|^{p})^{\frac{1}{p}}$.

###### Lemma 2 .

(Vershynin (2010)
Proposition 5.1, Hoeffding’s inequality) Let $X_{1},X_{2},\cdots,X_{N}$ be independent centered sub-gaussian random variables, and let $K=\max_{i}\|{\bm{X}}_{i}\|_{\psi_{2}}$. Then for every ${\bm{a}}=(a_{1},\cdots,a_{N})\in\mathbb{R}^{N}$ and every $t\geq 0$, we have

$$ $\Pr\Big(\Big|\sum_{i=1}^{N}a_{i}X_{i}\Big|\geq t\Big)\leq e\cdot\exp\left(-\frac{ct^{2}}{K^{2}\|{\bm{a}}\|^{2}}\right),$ (22) $$

where $c>0$ is an absolute constant.

###### Lemma 3 .

For any $j\neq j^{\prime},j^{\prime\prime}\in[M_{1}]$, $k\neq k^{\prime}\in[M_{2}]$, and $s\in[V]$, $j^{\prime\prime}$ where ${\bm{\mu}}_{j}$ and ${\bm{\mu}}_{j^{\prime\prime}}$ form a training task, and $j^{\prime}$ where ${\bm{\mu}}_{j}$ and ${\bm{\mu}}_{j^{\prime}}$ does not form a training task, we have that for ${\bm{W}}\in\{{\bm{W}}_{B},{\bm{W}}_{C}\}$, if $B\gtrsim\max\{(1-p_{a})^{-1}M_{1}\log\epsilon^{-1},(1-p_{a})^{-2}\log\epsilon^{-1}\}$,

$$ $\displaystyle-({\bm{\mu}}_{j}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\gtrsim\eta(t+1)\frac{1}{M_{1}}(1-p_{a})\beta,$ (23) $$

$$ $\displaystyle\Big|({{\bm{v}}^{*}_{s}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta\beta(t+1)p_{a}\kappa_{a}}{M_{1}V}\cdot\sqrt{\frac{\log B}{B}},$ (24) $$

$$ $-({{\bm{\mu}}_{j^{\prime}}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}=0,$ (25) $$

$$ $\displaystyle-({{\bm{\mu}}_{j^{\prime\prime}}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}^{(t)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\leq-\eta(t+1)\frac{1}{M_{1}}(1-p_{a})\beta,$ (26) $$

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta(t+1)\beta}{M_{1}M_{2}}\sqrt{\frac{\log B}{B}},$ (27) $$

$$ $\displaystyle\Big|-({{\bm{\mu}}_{j}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}^{(b)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta(t+1)\beta}{M_{1}M_{2}}\sqrt{\frac{\log B}{B}},$ (28) $$

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}^{(b)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta(t+1)\beta}{M_{2}}\sqrt{\frac{\log B}{B}},$ (29) $$

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k^{\prime}}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}^{(b)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta(t+1)\beta}{M_{2}^{2}}\sqrt{\frac{\log B}{B}}.$ (30) $$

###### Lemma 4 .

When $t\lesssim\min\{\eta^{-1}\beta^{-2}\kappa_{a}^{-1}(1-p_{a})^{-1}V,\eta^{-1}M_{1}^{\frac{2}{3}}\beta^{-\frac{2}{3}}\kappa_{a}^{-\frac{1}{3}}(1-p_{a})^{-1}V^{\frac{1}{3}}\}$, as long as

$$ $l\gtrsim(1-p_{a})^{-1}\log\epsilon^{-1},$ (31) $$

$$ $B\gtrsim\beta^{-4}\kappa_{a}^{-2}(1-p_{a})^{-2}V^{2}\log\epsilon^{-1},$ (32) $$

we have that for any $s\in[V]$,

$$ ${{\bm{v}}^{*}_{s}}^{\top}{\bm{w}}^{(t)}\lesssim-\frac{\eta\beta^{2}t\kappa_{a}(1-p_{a})}{V}-\eta\sum_{i=1}^{t}i^{2}(\frac{\eta^{2}(1-p_{a})^{3}\beta^{2}}{M_{1}^{2}})\frac{\kappa_{a}}{V},$ (33) $$

$$ $({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{w}}^{(t)}=\Theta\left(-\frac{\eta(1-p_{a})\beta^{2}(t)}{M_{1}}-\sum_{i=1}^{t-1}i^{2}\cdot(\frac{\eta^{3}(1-p_{a})^{3}\beta^{2}}{M_{1}^{3}})\right).$ (34) $$

For ${\bm{p}}_{s}$ that does not contain any ${\bm{v}}^{*}_{o}$, $o\in[V]$, and ${\bm{p}}_{r}$ that contains a ${\bm{v}}^{*}_{o}$, $o\in[V]$, $r\neq s$, we have

$$ $-\frac{\eta(1-p_{a})\beta^{2}t}{M_{1}}-\sum_{i=1}^{t}i^{2}\cdot(\frac{\eta^{3}(1-p_{a})^{3}\beta^{2}}{M_{1}^{3}})\lesssim{{\bm{w}}^{(t)}}^{\top}{\bm{p}}_{s}<0,$ (35) $$

$$ ${{\bm{w}}^{(t)}}^{\top}{\bm{p}}_{r}\lesssim-\eta t\beta^{2}\kappa_{a}(1-p_{a})<{{\bm{w}}^{(t)}}^{\top}{\bm{p}}_{s}<0.$ (36) $$

###### Lemma 5 .

When $t\gtrsim\eta^{-1}(1-p_{a})^{-1}\beta^{-2}M_{1}$ and $\kappa_{a}\gtrsim V\beta^{-4}$, we have

$$ ${{\bm{w}}^{(t)}}^{\top}{\bm{p}}_{i}\lesssim-\log M_{1},$ (37) $$

for ${\bm{p}}_{i}$ that contains a ${\bm{v}}^{*}_{s}$, $s\in[V]$, and

$$ ${{\bm{w}}^{(t)}}^{\top}{\bm{p}}_{i}\gtrsim-\Theta(1).$ (38) $$

for ${\bm{p}}_{i}$ that does not contain any ${\bm{v}}^{*}_{s}$, $s\in[V]$.

###### Lemma 6 .

When $t\lesssim\min\{\eta^{-1}\beta^{-2}\kappa_{a}^{-1}(1-p_{a})^{-1}V,\eta^{-1}M_{1}^{\frac{2}{3}}((1-p_{a})\beta)^{-\frac{2}{3}}(\kappa_{a}(1-p_{a}))^{-\frac{1}{3}}V^{\frac{1}{3}}\}$, we have

$$ $\sum_{i=1}^{l}G_{i,l+1}({\bm{w}}^{(t)})(l-i+1)\leq\Theta(1).$ (39) $$

###### Condition 1 .

(Condition 3.2 of (Li et al., 2024a))
For any given $j\in[M_{1}]$ and either label $+1$ or $-1$, the number of tasks in $\mathcal{T}_{tr}$ that map ${\bm{\mu}}_{j}$ to that label is $|\mathcal{T}_{tr}|/M_{1}(\geq 1)$.

We introduce a construction of $\mathcal{T}_{tr}$ that satisfies Condition [1](https://arxiv.org/html/2510.00399v1#Thmcondition1) as follows. Let
the $i$-th task function ($i\in[M_{1}-1]$) in $\mathcal{T}_{tr}$ map the queries with ${\bm{\mu}}_{i}$ and ${\bm{\mu}}_{i+1}$ as the relevant patterns to $+1$ and $-1$, respectively. The $M_{1}$-th task function maps ${\bm{\mu}}_{M_{1}}$ and ${\bm{\mu}}_{1}$ to $+1$ and $-1$, respectively. We can easily verify that such a $\mathcal{T}_{tr}$ satisfies Condition [1](https://arxiv.org/html/2510.00399v1#Thmcondition1) in this case.

###### Lemma 1 .

###### Definition 3 .

###### Lemma 2 .

###### Lemma 3 .

###### Lemma 4 .

###### Lemma 5 .

###### Lemma 6 .

###### Condition 1 .

## Appendix D Proof of Main Theorems

### D.1 Proof of Theorem 1

###### Proof.

We know that there exists gradient noise caused by imbalanced patterns in each batchTherefore, by Hoeffding’s inequality ([22](https://arxiv.org/html/2510.00399v1#A3.E22)), for any ${\bm{W}}\in\Psi$,

$$ $\Pr\left(\Big\|\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\partial\ell(\Psi;{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}}-\mathbb{E}\left[\frac{\partial\ell(\Psi;{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}}\right]\Big\|\geq\Big|\mathbb{E}\left[\frac{\partial\ell(\Psi;{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}}\right]\epsilon\right)\leq e^{-B\epsilon^{2}}\leq\epsilon,$ (40) $$

if $B\gtrsim\epsilon^{-2}\log\epsilon^{-1}$. Combining ([32](https://arxiv.org/html/2510.00399v1#A3.E32)), we require

$$ $B\gtrsim\max\{\beta^{-4}\kappa_{a}^{-2}(1-p_{a})^{-2},\epsilon^{-2},M_{1}(1-p_{a})^{-1}\}\cdot\log\epsilon^{-1}.$ (41) $$

When $t\geq T=\Theta(\eta^{-1}(1-p_{a})^{-1}\beta^{-2}M_{1})$, we have that for ${\bm{W}}\in\{{\bm{W}}_{B},{\bm{W}}_{C}\}$ and any $j\in[M_{1}]$,

$$ $\displaystyle({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{W}}^{(T)}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}$ (42) $\displaystyle=$ $\displaystyle({\bm{\mu}}_{j}^{\top},0^{\top})({\bm{W}}^{(0)}-\eta\cdot\sum_{b=1}^{T}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}^{(b)}})({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}$ $\displaystyle\gtrsim$ $\displaystyle 1,$ $$

where the last step comes from ([23](https://arxiv.org/html/2510.00399v1#A3.E23)) in Lemma [3](https://arxiv.org/html/2510.00399v1#Thmlemma3). Then, for ${\bm{p}}_{i}$ that shares the same pattern as the query, we have

$$ $\displaystyle{\bm{p}}_{i}^{\top}{{\bm{W}}_{B}^{(T)}}^{\top}{\bm{W}}_{C}^{(T)}{\bm{p}}_{query}\gtrsim$ $\displaystyle\beta^{2}(1+\kappa_{a}\mathbbm{1}[{\bm{p}}_{i}\text{ contains any }{\bm{v}}_{s}^{*}])+1-(1-p_{a})^{-1}\epsilon\beta^{-1}/M_{2}$ (43) $\displaystyle-(1-p_{a})^{-1}p_{a}\kappa_{a}V^{-1}\beta^{-1}\epsilon\mathbbm{1}[{\bm{p}}_{i}\text{ contains any }{\bm{v}}_{s}^{*}],$ $$

as long as $\epsilon\in(0,1)$. $(1-p_{a})^{-1}\epsilon/M_{2}$ comes from the correlation between ${\bm{\mu}}_{j}$ and ${\bm{\nu}}_{k}$, ${\bm{\nu}}_{*}$ and between ${\bm{\nu}}_{k}$ and ${\bm{\nu}}_{*}$, and $B\gtrsim\epsilon^{-2}\log\epsilon^{-1}$. For ${\bm{p}}_{i}$ that shares a different pattern that does not form a training task from the query, with a high probability, we have

$$ $\displaystyle{\bm{p}}_{i}^{\top}{{\bm{W}}_{B}^{(T)}}^{\top}{\bm{W}}_{C}^{(T)}{\bm{p}}_{query}\leq(1-p_{a})^{-1}\epsilon\beta^{-1}/M_{2}+(1-p_{a})^{-1}p_{a}\kappa_{a}V^{-1}\beta^{-1}\epsilon\mathbbm{1}[{\bm{p}}_{i}\text{ contains any }{\bm{v}}_{s}^{*}].$ (44) $$

Meanwhile, for ${\bm{p}}_{i}$ that contains a ${\bm{v}}^{*}_{s}$, $s\in[V]$, we have

$$ $G_{i,l+1}({\bm{w}}^{(T)})\leq\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{i})\lesssim O(\text{poly}(M_{1}^{\kappa_{a}})^{-1}),$ (45) $$

by Lemma [5](https://arxiv.org/html/2510.00399v1#Thmlemma5). We have that for the ${\bm{p}}_{i^{*}}$ that does not contain any ${\bm{v}}^{*}_{s}$, $s\in[V]$ and is the closest to the query, by Lemma [5](https://arxiv.org/html/2510.00399v1#Thmlemma5),

$$ $\displaystyle G_{i^{*},l+1}({\bm{w}}^{(T)})\gtrsim$ $\displaystyle(1-\frac{1}{\text{poly}(M_{1}^{\kappa_{a}})})^{lp_{a}}\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{i^{*}})$ (46) $\displaystyle\gtrsim$ $\displaystyle(1-\frac{lp_{a}}{\text{poly}(M_{1}^{\kappa_{a}})})\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{i^{*}})$ $\displaystyle\gtrsim$ $\displaystyle(1-\frac{lp_{a}}{\text{poly}(M_{1}^{\kappa_{a}})}).$ $$

Hence, for ${\bm{P}}$ with $z=+1$, with a high probability, we have

$$ $\displaystyle F(\Psi^{(T)},{\bm{P}})$ (47) $\displaystyle\gtrsim$ $\displaystyle(1-(1-p_{a})^{-1}\epsilon/M_{2}-(1-p_{a})^{-1}p_{a}\kappa_{a}V^{-1}\beta^{-1}\epsilon)\cdot\sum_{i=1}^{l_{tr}(1-p_{a})-1}(1$ $\displaystyle-\max_{{\bm{p}}_{i}\text{ contains no }{\bm{v}}_{s}^{*}}\{\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{i})\})^{i-1}\cdot\min_{{\bm{p}}_{i}\text{ contains no }{\bm{v}}_{s}^{*}}\{\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{i})\}$ $\displaystyle\gtrsim$ $\displaystyle\frac{(1-(1-\max_{{\bm{p}}_{i}\text{ contains no }{\bm{v}}_{s}^{*}}\{\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{i})\})^{l_{tr}(1-p_{a})})\cdot\min_{{\bm{p}}_{i}\text{ contains no }{\bm{v}}_{s}^{*}}\{\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{i})\}}{\max_{{\bm{p}}_{i}\text{ contains no }{\bm{v}}_{s}^{*}}\{\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{i})\}}$ $\displaystyle>$ $\displaystyle\Theta(1)\cdot(1-\frac{1}{M_{1}})$ $\displaystyle>$ $\displaystyle 1,$ $$

where the second to last step holds if $p_{a}^{-1}\text{poly}(M_{1}^{\kappa_{a}})\gtrsim l_{tr}\gtrsim(1-p_{a})^{-1}\log M_{1}$ and for ${\bm{p}}_{i}$ that contains no ${\bm{v}}_{s}^{*}$, $\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{i})\in(0,1/2)$.
Similarly, we can also derive that for ${\bm{P}}$ with $z=-1$, we have

$$ $F(\Psi^{(T)},{\bm{P}})<-1.$ (48) $$

Then, we study the generalization error. By ([40](https://arxiv.org/html/2510.00399v1#A4.E40)), for any given testing prompt embedding ${\bm{P}}$ with $z=+1$, we have that with a high probability of $1-\epsilon$,

$$ $F(\Psi^{(T)};{\bm{P}})\geq 1-\epsilon,$ (49) $$

and if $z=-1$,

$$ $F(\Psi^{(T)};{\bm{P}})\leq-1+\epsilon.$ (50) $$

Therefore,

$$ $\mathbb{E}_{f\in\mathcal{T},{\bm{P}}\sim\mathcal{D}}[\ell(\Psi^{(T)};{\bm{P}},z)]\leq\epsilon.$ (51) $$

∎

###### Proof.

### D.2 Proof of Theorem 2

###### Proof.

By Lemma [3](https://arxiv.org/html/2510.00399v1#Thmlemma3), we have that for any $j\in[M_{1}]$ and $k\neq k^{\prime}\in[M_{2}]$,

$$ $\displaystyle({{\bm{\nu}}_{k}}^{\top},0^{\top}){\bm{W}}^{(T)}({{\bm{\mu}}_{j}}^{\top},0^{\top})^{\top}\lesssim\frac{\epsilon(1-p_{a})^{-1}\beta^{-1}}{M_{2}},$ (52) $$

$$ $\displaystyle({{\bm{\mu}}_{j}}^{\top},0^{\top}){\bm{W}}^{(T)}({{\bm{\nu}}_{k}}^{\top},0^{\top})^{\top}\lesssim\frac{\epsilon(1-p_{a})^{-1}\beta^{-1}}{M_{2}},$ (53) $$

$$ $\displaystyle({{\bm{\nu}}_{k}}^{\top},0^{\top}){\bm{W}}^{(T)}({{\bm{\nu}}_{k}}^{\top},0^{\top})^{\top}\lesssim\frac{\epsilon(1-p_{a})^{-1}\beta^{-1}M_{1}}{M_{2}}.$ (54) $$

$$ $\displaystyle({{\bm{\nu}}_{k}}^{\top},0^{\top}){\bm{W}}^{(T)}({{\bm{\nu}}_{k^{\prime}}}^{\top},0^{\top})^{\top}\lesssim\frac{\epsilon(1-p_{a})^{-1}\beta^{-1}M_{1}}{M_{2}^{2}}.$ (55) $$

Meanwhile, we have that for ${{\bm{v}}_{s}^{*}}^{\prime}\in\mathcal{V}^{\prime}$ with ${{\bm{v}}_{s}^{*}}^{\prime}=\sum_{i=1}^{V}\lambda_{i}{\bm{v}}_{s}^{*}$,

$$ $\displaystyle({{{\bm{v}}_{s}^{\prime}}^{*}}^{\top},0^{\top}){\bm{W}}^{(T)}({{\bm{\mu}}_{j}}^{\top},0^{\top})^{\top}\lesssim\epsilon(1-p_{a})^{-1}p_{a}\kappa_{a}V^{-1}\beta^{-1}\cdot L.$ (56) $$

Therefore, we have that for ${\bm{p}}_{i}$ that shares the same pattern as the query,

$$ ${\bm{p}}_{i}^{\top}{{\bm{W}}_{B}^{(T)}}^{\top}{\bm{W}}_{C}^{(T)}{\bm{p}}_{query}\gtrsim 1-\epsilon(1-p_{a})^{-1}\cdot\frac{1}{M_{2}}-\epsilon(1-p_{a})^{-1}p_{a}V^{-1}\kappa_{a}\beta^{-1}\cdot\kappa_{a}^{\prime}L.$ (57) $$

For ${\bm{p}}_{i}$ that shares a different pattern from the query, we have

$$ $|{\bm{p}}_{i}^{\top}{{\bm{W}}_{B}^{(T)}}^{\top}{\bm{W}}_{C}^{(T)}{\bm{p}}_{query}|\lesssim\epsilon(1+(1-p_{a})^{-1}/M_{2}+(1-p_{a})^{-1}p_{a}V^{-1}\kappa_{a}\beta^{-1}\cdot\kappa_{a}^{\prime}L).$ (58) $$

Meanwhile, for ${\bm{p}}_{i}$ that contains a ${{\bm{v}}^{*}_{s}}^{\prime}\in\mathcal{V}^{\prime}$, we have

$$ $G_{i,l+1}({\bm{w}}^{(T)})\leq\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{i})\lesssim O(\text{poly}(M_{1}^{\kappa_{a}^{\prime}})^{-1}),$ (59) $$

by Lemma [5](https://arxiv.org/html/2510.00399v1#Thmlemma5). We have that for the ${\bm{p}}_{i^{*}}$ that does not contain any ${{\bm{v}}^{*}_{s}}^{\prime}\in\mathcal{V}^{\prime}$ and is the closest to the query, by Lemma [5](https://arxiv.org/html/2510.00399v1#Thmlemma5),

$$ $\displaystyle G_{i^{*},l+1}({\bm{w}}^{(T)})\gtrsim$ $\displaystyle(1-\frac{1}{\text{poly}(M_{1}^{\kappa_{a}^{\prime}})})^{l_{ts}\alpha}\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{i^{*}})$ (60) $\displaystyle\gtrsim$ $\displaystyle(1-\frac{l_{ts}\alpha}{\text{poly}(M_{1}^{\kappa_{a}^{\prime}})}).$ $$

Hence, for ${\bm{P}}^{\prime}$ with $z=+1$, with a high probability, we have

$$ $\displaystyle F(\Psi^{(T)},g({\bm{P}}^{\prime}))$ (61) $\displaystyle\geq$ $\displaystyle(1-(1-p_{a})^{-1}\epsilon/M_{2}-\epsilon(1-p_{a})^{-1}p_{a}V^{-1}\kappa_{a}\beta^{-1}\cdot\kappa_{a}^{\prime}L)\cdot\sum_{i=1}^{l_{ts}(1-\alpha)-1}(1$ $\displaystyle-\max_{{\bm{p}}_{i}\text{ contains no }{\bm{v}}_{s}^{*}\in\mathcal{V}^{\prime}}\{\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{i}^{\prime})\})^{i-1}\cdot\min_{{\bm{p}}_{i}\text{ contains no }{\bm{v}}_{s}^{*}\in\mathcal{V}^{\prime}}\{\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{i}^{\prime})\}$ $\displaystyle\geq$ $\displaystyle\Theta((1-(1-p_{a})^{-1}\epsilon/M_{2}-\epsilon(1-p_{a})^{-1}p_{a}V^{-1}\kappa_{a}\beta^{-1}\cdot(\kappa_{a}+\kappa_{a}^{\prime}L-\kappa_{a}))$ $\displaystyle\cdot(1-\frac{l_{ts}\alpha}{\text{poly}(M_{1}^{\kappa_{a}^{\prime}})}))$ $\displaystyle=$ $\displaystyle\Theta((1-\epsilon(1-p_{a})^{-1}p_{a}V^{-1}\kappa_{a}\beta^{-1}\cdot(\kappa_{a}^{\prime}L-\kappa_{a}))(1-\frac{l_{tr}p_{a}}{\text{poly}(M_{1}^{\kappa_{a}})})$ $\displaystyle\cdot(1-\frac{\frac{l_{ts}\alpha}{\text{poly}(M_{1}^{\kappa_{a}^{\prime}})}-\frac{l_{tr}p_{a}}{\text{poly}(M_{1}^{\kappa_{a}})}}{1-\frac{l_{tr}p_{a}}{\text{poly}(M_{1}^{\kappa_{a}})}}))$ $\displaystyle\geq$ $\displaystyle\Theta(1-\epsilon(1-p_{a})^{-1}p_{a}V^{-1}\kappa_{a}\beta^{-1}\cdot(\kappa_{a}^{\prime}L-\kappa_{a})-(\frac{l_{ts}\alpha}{\text{poly}(M_{1}^{\kappa_{a}^{\prime}})}-\frac{l_{tr}p_{a}}{\text{poly}(M_{1}^{\kappa_{a}})}))$ $\displaystyle\geq$ $\displaystyle 1-(\epsilon(1-p_{a})^{-1}p_{a}V^{-1}\kappa_{a}\beta^{-1}\cdot(\kappa_{a}^{\prime}L-\kappa_{a})+\frac{l_{ts}\alpha}{\text{poly}(M_{1}^{\kappa_{a}^{\prime}})}-\frac{l_{tr}p_{a}}{\text{poly}(M_{1}^{\kappa_{a}})}),$ $$

where we consider the worst-case order that makes all examples that contain ${{\bm{v}}_{s}^{*}}^{\prime}\in\mathcal{V}^{\prime}$ right before the query, such that there is a scaling of $1-\frac{l_{ts}\alpha}{\text{poly}(M_{1}^{\kappa_{a}^{\prime}})}$ in the second step. The trained model still selects examples with the same pattern as the query no matter whether there is a certain ${{\bm{v}}_{s}^{\prime}}^{*}$ added to the token if $\kappa_{a}^{\prime}\lesssim V\beta{p_{a}}^{-1}(1-p_{a})\kappa_{a}^{-1}L^{-1}\epsilon^{-1}$. Then, flipping the labels of examples with any of ${{\bm{v}}_{s}^{\prime}}^{*}$ can change the model output the most. If $l_{ts}\leq{\alpha}^{-1}\text{poly}(M_{1}^{\kappa_{a}})$, $\kappa_{a}\leq\kappa_{a}^{\prime}\leq\Theta(L^{-1}(\kappa_{a}+V\beta{p_{a}}^{-1}(1-p_{a})\kappa_{a}^{-1}\epsilon^{-1}))$, $\alpha\leq\min\{1,p_{a}\cdot l_{tr}/l_{ts}\}$, we have that that with a high probability,

$$ $F(\Psi^{(T)},g({\bm{P}}^{\prime}))>0$ (62) $$

Therefore, we can derive that

$$ $L_{{\bm{P}}^{\prime}\sim\mathcal{D}^{\prime},f\in\mathcal{T}}^{0-1}(\Psi^{(T)};{\bm{P}}^{\prime},z)\leq\epsilon.$ (63) $$

∎

###### Proof.

### D.3 Proof of Theorem 3

###### Proof.

By the Chernoff bound of Bernoulli distribution in Lemma [1](https://arxiv.org/html/2510.00399v1#Thmlemma1), we can obtain that for any $n$ and $s\in[V]$,

$$ $\Pr\left(\frac{1}{l}\sum_{i=1}^{l}\mathbbm{1}[{\bm{p}}_{i}^{n}\text{ contains }{\bm{\mu}}_{a}\text{ and no any }{\bm{v}}^{*}_{s}]\leq(1-c)(1-p_{a})\frac{1}{2}\right)\leq e^{-lc^{2}\frac{(1-p_{a})}{2}}=\epsilon,$ (64) $$

for some $c\in(0,1)$. Hence, with a high probability,

$$ $l\gtrsim(1-p_{a})^{-1}\log\epsilon^{-1}.$ (65) $$

We know that there exists gradient noise caused by imbalanced patterns in each batchTherefore, by Hoeffding’s inequality ([22](https://arxiv.org/html/2510.00399v1#A3.E22)), for any ${\bm{W}}\in\{{\bm{W}}_{Q},{\bm{W}}_{K}\}$,

$$ $\Pr\left(\Big\|\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\partial\ell(\Psi;{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}}-\mathbb{E}\left[\frac{\partial\ell(\Psi;{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}}\right]\Big\|\geq\Big|\mathbb{E}\left[\frac{\partial\ell(\Psi;{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}}\right]\epsilon\right)\leq e^{-B\epsilon^{2}}\leq\epsilon,$ (66) $$

if $B\gtrsim\epsilon^{-2}\log\epsilon^{-1}$.
Therefore, we require

$$ $B\gtrsim\max\{\epsilon^{-2},(1-p_{a})^{-1}M_{1}\}\log\epsilon^{-1}.$ (67) $$

Let $G_{i,l+1}({\bm{w}}^{(T)})=1$ for any $i\leq l+1$. Following the proof in Theorem [1](https://arxiv.org/html/2510.00399v1#Thmthm1), we have that when

$$ $T\geq\Theta(\eta^{-1}(1-p_{a})^{-1}l_{tr}^{-1}\beta^{-1}M_{1}),$ (68) $$

we have

$$ $\displaystyle F(\Psi^{(T)},{\bm{P}})\gtrsim$ $\displaystyle(1-(1-p_{a})^{-1}\epsilon/M_{2}-(1-p_{a})^{-1}p_{a}\kappa_{a}V^{-1}\beta^{-1}\epsilon)$ (69) $\displaystyle>$ $\displaystyle 1,$ $$

as long as

$$ $\kappa_{a}\lesssim V\beta(1-p_{a})p_{a}^{-1}\epsilon^{-1}.$ (70) $$

Therefore, we can derive

$$ $\mathbb{E}_{f\in\mathcal{T},{\bm{P}}^{\prime}\sim\mathcal{D}^{\prime}}[\ell(\Psi^{(T)};{\bm{P}},z)]\leq\epsilon$ (71) $$

∎

###### Proof.

### D.4 Proof of Theorem 4

###### Proof.

By setting $G_{i,l+1}({\bm{w}}^{(T)})=1$ for any $i\leq l+1$, we have for any $j\in[M_{1}]$, $k^{\prime}\neq k\in[M_{2}]$

$$ $\displaystyle({{\bm{\nu}}_{k}}^{\top},0^{\top}){\bm{W}}^{(T)}({{\bm{\mu}}_{j}}^{\top},0^{\top})^{\top}\lesssim\frac{\epsilon\beta^{-1}(1-p_{a})^{-1}l_{tr}^{-1}}{M_{2}},$ (72) $$

$$ $\displaystyle({{\bm{\mu}}_{j}}^{\top},0^{\top}){\bm{W}}^{(T)}({{\bm{\nu}}_{k}}^{\top},0^{\top})^{\top}\lesssim\frac{\epsilon\beta^{-1}(1-p_{a})^{-1}l_{tr}^{-1}}{M_{2}}.$ (73) $$

$$ $\displaystyle({{\bm{\nu}}_{k}}^{\top},0^{\top}){\bm{W}}^{(T)}({{\bm{\nu}}_{k}}^{\top},0^{\top})^{\top}\lesssim\frac{\epsilon\beta^{-1}(1-p_{a})^{-1}l_{tr}^{-1}M_{1}}{M_{2}}.$ (74) $$

$$ $\displaystyle({{\bm{\nu}}_{k^{\prime}}}^{\top},0^{\top}){\bm{W}}^{(T)}({{\bm{\nu}}_{k}}^{\top},0^{\top})^{\top}\lesssim\frac{\epsilon\beta^{-1}(1-p_{a})^{-1}l_{tr}^{-1}M_{1}}{M_{2}^{2}}.$ (75) $$

Meanwhile, we have that for ${{\bm{v}}_{s}^{*}}^{\prime}\in\mathcal{V}^{\prime}$ with ${{\bm{v}}_{s}^{*}}^{\prime}=\sum_{i=1}^{V}\lambda_{i}{\bm{v}}_{s}^{*}$,

$$ $\displaystyle({{{\bm{v}}_{s}^{\prime}}^{*}}^{\top},0^{\top}){\bm{W}}^{(T)}({{\bm{\mu}}_{j}^{\prime}}^{\top},0^{\top})^{\top}\lesssim\epsilon\beta^{-1}(1-p_{a})^{-1}p_{a}\kappa_{a}V^{-1}l_{tr}^{-1}\kappa_{a}^{\prime}L.$ (76) $$

Therefore, we have that for ${\bm{p}}_{i}$ that shares the same pattern as the query,

$$ ${\bm{p}}_{i}^{\top}{{\bm{W}}_{B}^{(T)}}^{\top}{\bm{W}}_{C}^{(T)}{\bm{p}}_{query}\gtrsim 1-\epsilon\cdot\frac{\beta^{-1}(1-p_{a})^{-1}l_{tr}^{-1}}{M_{2}}-\epsilon(1-p_{a})^{-1}\beta^{-1}p_{a}\kappa_{a}V^{-1}l_{tr}^{-1}L\kappa_{a}^{\prime}.$ (77) $$

For ${\bm{p}}_{i}$ that shares a different pattern from the query, we have

$$ $|{\bm{p}}_{i}^{\top}{{\bm{W}}_{B}^{(T)}}^{\top}{\bm{W}}_{C}^{(T)}{\bm{p}}_{query}|\lesssim\epsilon(1+\beta^{-1}(1-p_{a})^{-1}l_{tr}^{-1}/M_{2}+(1-p_{a})^{-1}\beta^{-1}p_{a}\kappa_{a}V^{-1}l_{tr}^{-1}\kappa_{a}^{\prime}L).$ (78) $$

Therefore, the trained model still selects examples with the same pattern as the query no matter whether there is a certain ${{\bm{v}}_{s}^{\prime}}^{*}$ added to the token if $\kappa_{a}^{\prime}\lesssim V\beta{p_{a}}^{-1}(1-p_{a})\kappa_{a}^{-1}L^{-1}l_{tr}\epsilon^{-1}$. Then, flipping the labels of examples with any of ${{\bm{v}}_{s}^{\prime}}^{*}$ can change the model output the most. With $\alpha<1/2$, we can derive that

$$ $\displaystyle L_{{\bm{P}}^{\prime}\sim\mathcal{D}^{\prime},f\in\mathcal{T}}^{0-1}(\Psi^{(T)};{\bm{P}}^{\prime},z)$ (79) $\displaystyle=$ $\displaystyle\Pr(\frac{1}{l_{ts}}\sum_{i=1}^{l_{ts}}\mathbbm{1}[{\bm{p}}_{i}^{\prime}\text{ with the same pattern as }{\bm{p}}_{query}^{\prime}\text{ but a flipped label}]-\frac{\alpha}{2}>\frac{\alpha}{2}\cdot\frac{\frac{1}{2}-\alpha}{\alpha})$ $\displaystyle\leq$ $\displaystyle e^{-l_{ts}(\frac{1}{2}-\alpha)^{2}\alpha}$ $\displaystyle\leq$ $\displaystyle\epsilon,$ $$

as long as

$$ $l_{ts}\geq\max\{\Theta((1-\alpha)^{-1}),\Theta((\frac{1}{2}-\alpha)^{-2}\alpha)\}\log\epsilon^{-1}.$ (80) $$

∎

###### Proof.

#### D.4.1 Proof of Corollary 1

###### Proof.

The first part of ([16](https://arxiv.org/html/2510.00399v1#S3.E16)) comes from ([43](https://arxiv.org/html/2510.00399v1#A4.E43)) since $\beta\geq 1$ is a constant. The second part of ([16](https://arxiv.org/html/2510.00399v1#S3.E16)) comes from ([44](https://arxiv.org/html/2510.00399v1#A4.E44)) plus $\kappa_{a}V^{-1}\beta^{-1}p_{a}\lesssim 1$ with $\beta\geq 1$ as a constant order.

∎

###### Proof.

#### D.4.2 Proof of Corollary 2

###### Proof.

([17](https://arxiv.org/html/2510.00399v1#S3.E17)) comes from ([59](https://arxiv.org/html/2510.00399v1#A4.E59)) plus $\kappa_{a}^{\prime}\geq\Theta(1)$. ([18](https://arxiv.org/html/2510.00399v1#S3.E18)) is derived as follows. By ([60](https://arxiv.org/html/2510.00399v1#A4.E60)), we have

$$ $G_{h(1),l_{ts}+1}({\bm{w}}^{(T)})\geq\Theta(1).$ (81) $$

Then, combining ([36](https://arxiv.org/html/2510.00399v1#A3.E36)) and ([17](https://arxiv.org/html/2510.00399v1#S3.E17)), we have that if ${\bm{p}}_{s}$ does not contain any outliers,

$$ $1-\sigma({{\bm{w}}^{(T)}}^{\top}{\bm{p}}_{s})\geq\frac{1}{2}.$ (82) $$

Then, with a high probability

$$ $\displaystyle G_{h(j),l_{ts}+1}({\bm{w}}^{(T)})\geq$ $\displaystyle G_{h(j),l_{ts}+1}({\bm{w}}^{(T)})\cdot\frac{1}{2^{j-1}}\cdot(1-\Theta(\text{poly}(M_{1})^{-1}))^{l_{ts}\alpha}\cdot\Theta(1)$ (83) $\displaystyle\geq\Theta(\frac{1}{2^{j-1}}).$ $$

∎

###### Proof.

## Appendix E Proof of Supportive Lemmas

### E.1 Derivation of ( 3 )

###### Proof.

By formulation in Section [2](https://arxiv.org/html/2510.00399v1#S2), we have

$$ $\displaystyle\tilde{{\bm{A}}}_{j,i}=$ $\displaystyle\text{diag}(\exp(\Delta_{j,i}{\bm{A}}))^{\top}$ (84) $\displaystyle=$ $\displaystyle\text{diag}(e^{-{\bm{I}}_{l+1}\Delta_{j,i}})^{\top}$ $\displaystyle=$ $\displaystyle\text{diag}(e^{-{\bm{I}}_{l+1}\log(1+e^{{\bm{w}}_{j}^{\top}{\bm{x}}_{i}})})^{\top}$ $\displaystyle=$ $\displaystyle\bm{1}_{l+1}^{\top}(\frac{1}{1+e^{{\bm{w}}_{j}^{\top}{\bm{x}}_{i}}})^{\top},\ \ \ \ \ \ \sigma(\cdot):\text{sigmoid function},$ $$

$$ $\tilde{{\bm{A}}}_{i}=(\tilde{{\bm{A}}}_{1,i}^{\top},\tilde{{\bm{A}}}_{2,i}^{\top},\cdots,\tilde{{\bm{A}}}_{d_{0},i}^{\top})^{\top}=(\mathbf{1}_{d_{0}}-\sigma({\bm{W}}^{\top}{\bm{x}}_{i}))\mathbf{1}_{l+1}^{\top}\in\mathbb{R}^{d_{0}\times(l+1)},$ (85) $$

$$ $\displaystyle\tilde{{\bm{B}}}_{j,i}=$ $\displaystyle(\Delta_{j,i}{\bm{B}}_{i})(\exp(\Delta_{j,i}{\bm{A}})-{\bm{I}})(\Delta_{j,i}{\bm{A}})^{-1}$ (86) $\displaystyle=$ $\displaystyle{\bm{B}}_{i}({\bm{I}}_{l+1}\frac{1}{1+e^{{\bm{w}}_{j}^{\top}{\bm{x}}_{i}}}-{\bm{I}}_{l+1})(-{\bm{I}}_{l+1})$ $\displaystyle=$ $\displaystyle\sigma({\bm{w}}_{j}^{\top}{\bm{x}}_{i}){\bm{B}}_{i},$ $$

$$ $\tilde{{\bm{B}}}_{i}=(\tilde{{\bm{B}}}_{1,i}^{\top},\tilde{{\bm{B}}}_{2,i}^{\top},\cdots,\tilde{{\bm{B}}}_{d_{0},i}^{\top})^{\top}:={\bm{s}}_{i}{\bm{B}}_{i}\in\mathbb{R}^{d_{0}\times(l+1)},$ (87) $$

with ${\bm{s}}_{i}=\sigma({\bm{W}}^{\top}{\bm{x}}_{i})$.
Therefore,

$$ $\displaystyle{\bm{h}}_{i}=$ $\displaystyle{\bm{h}}_{i-1}\odot\tilde{{\bm{A}}}_{i}+({\bm{p}}_{i}\bm{1}^{\top}_{l+1})\tilde{{\bm{B}}}_{i}$ (88) $\displaystyle=$ $\displaystyle{\bm{h}}_{i-1}\odot\tilde{{\bm{A}}}_{i}+({\bm{p}}_{i}\mathbf{1}_{l+1}^{\top})\odot{\bm{B}}_{i}$ $\displaystyle=$ $\displaystyle({\bm{h}}_{i-2}\odot\tilde{{\bm{A}}}_{i-1}+({\bm{p}}_{i-1}\odot{\bm{s}}_{i}){\bm{B}}_{i-1})\odot\tilde{{\bm{A}}}_{i}+{\bm{p}}_{i}{\bm{B}}_{i}$ $\displaystyle=$ $\displaystyle{\bm{h}}_{i-2}\odot\tilde{{\bm{A}}}_{i-1}\odot\tilde{{\bm{A}}}_{i}+({\bm{p}}_{i-1}\odot{\bm{s}}_{i}){\bm{B}}_{i-1}\odot\tilde{{\bm{A}}}_{i}+({\bm{p}}_{i}\odot{\bm{s}}_{i}){\bm{B}}_{i}$ $\displaystyle=$ $\displaystyle\cdots$ $\displaystyle=$ $\displaystyle{\bm{h}}_{0}\odot\tilde{{\bm{A}}}_{1}\odot\cdots\odot\tilde{{\bm{A}}}_{i}+\sum_{j=1}^{i}({\bm{p}}_{j}\odot{\bm{s}}_{j}){\bm{B}}_{j}\odot\tilde{{\bm{A}}}_{j+1}\cdots\odot\tilde{{\bm{A}}}_{i}+({\bm{p}}_{i}\odot{\bm{s}}_{i}){\bm{B}}_{i}$ $\displaystyle=$ $\displaystyle\sum_{j=1}^{i}({\bm{p}}_{j}\odot{\bm{s}}_{j}){\bm{B}}_{j}\odot(\tilde{{\bm{A}}}_{i}\odot\cdots\odot\tilde{{\bm{A}}}_{j+1})+({\bm{p}}_{i}\odot{\bm{s}}_{i}){\bm{B}}_{i},$ $$

Then, given ${\bm{W}}_{C}\in\mathbb{R}^{(l+1)\times d_{0}}$, we have

$$ $\displaystyle{\bm{o}}_{i}=$ $\displaystyle{\bm{h}}_{i}{\bm{C}}_{i}$ (89) $\displaystyle=$ $\displaystyle{\bm{h}}_{i}{\bm{W}}_{C}{\bm{p}}_{i}$ $\displaystyle=$ $\displaystyle\sum_{j=1}^{i}({\bm{p}}_{j}\odot{\bm{s}}_{j}){\bm{B}}_{j}(\tilde{{\bm{A}}}_{i}\odot\cdots\odot\tilde{{\bm{A}}}_{j+1}){\bm{W}}_{C}{\bm{p}}_{i}+({\bm{p}}_{i}\odot{\bm{s}}_{i}){{\bm{B}}}_{i}{\bm{W}}_{C}{\bm{p}}_{i}$ $\displaystyle=$ $\displaystyle\sum_{j=1}^{i}({\bm{G}}_{j,i}({\bm{W}})\odot{\bm{p}}_{j}){\bm{p}}_{j}^{\top}{\bm{W}}_{B}^{\top}{\bm{W}}_{C}{\bm{p}}_{i},$ $$

where the $d_{0}$-dimensional

$$ ${\bm{G}}_{j,i}({\bm{W}}):=\begin{cases}(\mathbf{1}_{d_{0}}-\sigma({\bm{W}}^{\top}{\bm{p}}_{j+1}))\odot\cdots\odot(\mathbf{1}_{d_{0}}-\sigma({\bm{W}}^{\top}{\bm{p}}_{i}))\sigma({\bm{W}}^{\top}{\bm{p}}_{j}),&\text{ if }j<i\\ \sigma({\bm{W}}^{\top}{\bm{p}}_{i}),&\text{ if }j=i,\end{cases}$ (90) $$

with $\sigma(\cdot)$ as the sigmoid function. Therefore, we can obtain ([3](https://arxiv.org/html/2510.00399v1#S2.E3)), i.e.,

$$ $F(\Psi;{\bm{P}})={\bm{e}}_{d+1}^{\top}{\bm{o}}_{l+1}=\sum_{i=1}^{l+1}G_{i,l+1}({\bm{w}})y_{i}{\bm{p}}_{i}^{\top}{\bm{W}}_{B}^{\top}{\bm{W}}_{C}{\bm{p}}_{query},$ (91) $$

where

$$ $\displaystyle G_{i,l+1}({\bm{w}})=$ $\displaystyle({\bm{G}}_{i,l+1}({\bm{W}}))_{d+1}$ (92) $\displaystyle=$ $\displaystyle$ $$

∎

###### Proof.

### E.2 Proof of Lemma 3

###### Proof.

(a) When $F(\Psi;{\bm{P}}^{n})\in(-1,1)$ for some $n\in[N]$, we have

$$ $\displaystyle\frac{\partial\ell(\Psi;{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}}=$ $\displaystyle-z^{n}\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}})y_{i}^{n}{\bm{W}}_{B}{\bm{p}}_{i}^{n}{{\bm{p}}_{query}^{n}}^{\top}.$ (93) $$

When $t=0$, we know that with high probability,

$$ $|{{\bm{w}}^{(0)}}^{\top}{\bm{x}}_{j}|\lesssim\xi=\frac{1}{d+1},$ (94) $$

$$ $|\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{x}}_{j})-\frac{1}{2}|\lesssim\frac{|1-e^{\pm\xi}|}{2(1+e^{\pm\xi})}\lesssim\xi.$ (95) $$

Then,

$$ $\frac{1}{2^{l+2-i}}(1-\xi(l+2-i))\leq{G^{n}}_{i,l+1}^{(0)}({\bm{w}})\lesssim\frac{1}{2^{l+2-i}}(1+\xi(l+2-i)).$ (96) $$

Let the IDR pattern of ${\bm{\mu}}_{query}^{n}$ be ${\bm{\mu}}_{j}$, $j\in[M_{1}]$. Note that $\frac{1}{2}\cdot p_{a}$ fraction of examples correspond to ${\bm{\mu}}_{j}$ with poisoned labels. For different $f$, $y_{*}^{f}=1$ or $-1$ with $1/2$ probability. By Lemma [1](https://arxiv.org/html/2510.00399v1#Thmlemma1), we have for any $i\in l$,

$$ $\displaystyle\Pr\Big(\frac{1}{|\mathcal{B}_{b}|}\sum_{i\in\mathcal{B}_{b}}\mathbbm{1}[{\bm{x}}_{i}^{n}\text{ contains }{\bm{\mu}}_{j}\text{ and no }{\bm{v}}^{*}_{s}]-(1-p_{a})\leq-\frac{c}{M_{1}}(1-p_{a})\Big)\lesssim e^{-\frac{B(1-p_{a})}{M_{1}}}\leq\epsilon,$ (97) $$

for some $c\in(0,1)$ and $\epsilon>0$ if

$$ $B\gtrsim(1-p_{a})^{-1}M_{1}\log\epsilon^{-1}.$ (98) $$

By ([22](https://arxiv.org/html/2510.00399v1#A3.E22)), let $\mathcal{B}_{b}^{\prime}=\{i:i\in\mathcal{B}_{b},{\bm{x}}_{i}^{n}\text{ contains }{\bm{\mu}}_{j}\text{ and }{\bm{\nu}}^{*}_{s},s\in[V]\}$we have

$$ $\displaystyle\Pr\Big(\Big|\frac{1}{|\mathcal{B}_{b}^{\prime}|}\sum_{i\in\mathcal{B}_{b}^{\prime}}(\mathbbm{1}[y_{i}^{n}=z^{n}]-\mathbbm{1}[y_{i}^{n}=-z^{n}])\Big|\geq\sqrt{\frac{\log B}{B}}\Big)\leq M_{1}^{-C},$ (99) $$

for some $c\in(0,1)$ and $C>1$.
Therefore, we have

$$ $\displaystyle-({\bm{\mu}}_{j}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(0)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}$ (100) $\displaystyle=$ $\displaystyle({\bm{\mu}}_{j}^{\top},0^{\top})\frac{\eta}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}z^{n}\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})y_{i}^{n}{\bm{W}}_{B}^{(0)}{\bm{p}}_{i}^{n}{{\bm{p}}_{query}^{n}}^{\top}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}$ $\displaystyle\cdot\mathbbm{1}[{\bm{x}}_{i}^{n}\text{ does not contain any }{\bm{v}}^{*}_{s}]+({\bm{\mu}}_{j}^{\top},0^{\top})\frac{\eta}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}z^{n}\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})$ $\displaystyle\cdot y_{i}^{n}{\bm{W}}_{B}^{(0)}{\bm{p}}_{i}^{n}{{\bm{p}}_{query}^{n}}^{\top}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\mathbbm{1}[{\bm{x}}_{i}^{n}\text{ contains any }{\bm{v}}^{*}_{s}]$ $\displaystyle\gtrsim$ $\displaystyle\eta\cdot\frac{1}{2M_{1}}(1-p_{a})\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})\beta-\eta\cdot\frac{1}{2M_{1}}\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})\beta p_{a}\sqrt{\frac{\log B}{B}}$ $\displaystyle\geq$ $\displaystyle\eta\frac{1}{4M_{1}}(1-p_{a})\beta(1-\xi l),$ $$

where the last step holds if

$$ $B\gtrsim(1-p_{a})^{-2}\log\epsilon^{-1}.$ (101) $$

For ${\bm{\mu}}_{j^{\prime}}$, $j^{\prime}\neq j$, that does not form a task in the training set, we have

$$ $-({{\bm{\mu}}_{j^{\prime}}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(0)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}=0$ (102) $$

For ${\bm{\mu}}_{j^{\prime\prime}}$, $j^{\prime\prime}\neq j$, that forms a task in the training set, we have

$$ $\displaystyle-({{\bm{\mu}}_{j^{\prime\prime}}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(0)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}$ (103) $\displaystyle=$ $\displaystyle({\bm{\mu}}_{j^{\prime\prime}}^{\top},0^{\top})\frac{\eta}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}z^{n}\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})y_{i}^{n}{\bm{W}}_{B}^{(0)}{\bm{p}}_{i}^{n}{{\bm{p}}_{query}^{n}}^{\top}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}$ $\displaystyle\lesssim$ $\displaystyle-\eta\cdot\frac{1}{4M_{1}}(1-p_{a})\beta(1-\xi l).$ $$

For ${\bm{\nu}}_{k}$, ${\bm{\nu}}_{k^{\prime}}$ with $k,k^{\prime}\in[M_{2}]$, we have

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(0)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta\beta}{M_{1}M_{2}}\sqrt{\frac{\log B}{B}},$ (104) $$

$$ $\displaystyle\Big|-({{\bm{\mu}}_{j}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(0)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta\beta}{M_{2}M_{1}}\sqrt{\frac{\log B}{B}}.$ (105) $$

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k^{\prime}}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(0)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta\beta}{M_{2}^{2}}\sqrt{\frac{\log B}{B}}.$ (106) $$

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(0)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta\beta}{M_{2}}\sqrt{\frac{\log B}{B}}.$ (107) $$

Since that for ${\bm{x}}_{i}^{n}$ that contains ${\bm{\nu}}^{*}_{s}$ for a certain $s\in[V]$,

$$ $\Pr(y_{i}^{n}=z^{n})=\Pr(y_{i}^{n}=-z^{n})=\frac{1}{2},$ (108) $$

we have

$$ $\displaystyle\Big|({{\bm{\nu}}^{*}_{s}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(0)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\Big|$ (109) $\displaystyle=$ $\displaystyle\Big|({{\bm{\nu}}^{*}_{s}}^{\top},0^{\top})\frac{\eta}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}z^{n}\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})y_{i}^{n}{\bm{W}}_{B}^{(0)}{\bm{p}}_{i}^{n}{{\bm{p}}_{query}^{n}}^{\top}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\Big|$ $\displaystyle\leq$ $\displaystyle\frac{\eta\beta p_{a}\kappa_{*}}{M_{1}V}\cdot\sqrt{\frac{\log B}{B}},$ $$

Suppose that the conclusion holds when $t=t_{0}$. Then, when $t=t_{0}+1$, we have

$$ $\displaystyle-({\bm{\mu}}_{j}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}$ (110) $\displaystyle=$ $\displaystyle({\bm{\mu}}_{j}^{\top},0^{\top})\sum_{b=1}^{t_{0}+1}\frac{\eta}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}z^{n}\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(b)})y_{i}^{n}{\bm{W}}_{B}^{(b)}{\bm{p}}_{i}^{n}{{\bm{p}}_{query}^{n}}^{\top}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}$ $\displaystyle\gtrsim$ $\displaystyle\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{2M_{1}}(1-p_{a})\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})\beta$ $\displaystyle\gtrsim$ $\displaystyle\eta(t_{0}+1)\frac{1}{M_{1}}(1-p_{a})\beta.$ $$

The last step holds since $\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})\gtrsim 1$. Similarly, we have that for any $s\in[V]$,

$$ $\displaystyle\Big|({{\bm{\nu}}^{*}_{s}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta\beta(t_{0}+1)p_{a}\kappa_{*}}{M_{1}}\cdot\sqrt{\frac{\log B}{B}},$ (111) $$

For ${\bm{\mu}}_{j^{\prime}}$, $j^{\prime}\neq j$, that forms a task in the training set, we have

$$ $-({{\bm{\mu}}_{j^{\prime}}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}=0$ (112) $$

For ${\bm{\mu}}_{j^{\prime\prime}}$, $j^{\prime\prime}\neq j$, that forms a task in the training set, we have

$$ $\displaystyle-({{\bm{\mu}}_{j^{\prime\prime}}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}$ (113) $\displaystyle\leq$ $\displaystyle({{\bm{\mu}}_{j}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}.$ $$

For ${\bm{\nu}}_{k}$, ${\bm{\nu}}_{k^{\prime}}$ with $k\neq k^{\prime}\in[M_{2}]$, we have

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta(t_{0}+1)\beta}{M_{1}M_{2}}\sqrt{\frac{\log B}{B}},$ (114) $$

$$ $\displaystyle\Big|-({{\bm{\mu}}_{j}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(b)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta(t_{0}+1)\beta}{M_{1}M_{2}}\sqrt{\frac{\log B}{B}},$ (115) $$

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(b)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta(t_{0}+1)\beta}{M_{2}}\sqrt{\frac{\log B}{B}},$ (116) $$

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k^{\prime}}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{C}^{(b)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta(t_{0}+1)\beta}{M_{2}^{2}}\sqrt{\frac{\log B}{B}},$ (117) $$

Then, we complete the induction.

(b) We then characterize the gradient updates of ${\bm{W}}_{B}$. We have that when $F(\Psi;{\bm{P}}^{n})\in(-1,1)$ for some $n\in[N]$,

$$ $\displaystyle\frac{\partial\ell(\Psi;{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}}=$ $\displaystyle-z^{n}\sum_{i=1}^{l+1}G^{n}_{i,l+1}({\bm{w}})y_{i}{\bm{W}}_{C}{\bm{p}}_{query}{\bm{p}}_{i}^{\top}.$ (118) $$

We also use induction to complete the proof. Similar to the analysis of ${\bm{W}}_{C}$, we have that when $t=0$,

$$ $\displaystyle-({\bm{\mu}}_{j}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(0)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}$ (119) $\displaystyle=$ $\displaystyle({\bm{\mu}}_{j}^{\top},0^{\top})\frac{\eta}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}z^{n}\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})y_{i}^{n}{\bm{W}}_{C}^{(0)}{\bm{p}}_{query}^{n}{{\bm{p}}_{i}^{n}}^{\top}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}$ $\displaystyle\gtrsim$ $\displaystyle\eta\cdot\frac{1}{2M_{1}}(1-p_{a})\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})\beta-\eta\cdot\frac{1}{2M_{1}}\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})\beta p_{a}\sqrt{\frac{\log B}{B}}$ $\displaystyle\geq$ $\displaystyle\eta\frac{1}{4M_{1}}(1-p_{a})\beta(1-\xi l).$ $$

For ${\bm{\mu}}_{j^{\prime}}$, $j^{\prime}\neq j$, that does not form a task in the training stage, we have

$$ $-({{\bm{\mu}}_{j^{\prime}}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(0)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}=0.$ (120) $$

For ${\bm{\mu}}_{j^{\prime\prime}}$, $j^{\prime\prime}\neq j$, that forms a task in the training stage, we have

$$ $\displaystyle-({{\bm{\mu}}_{j^{\prime\prime}}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(0)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\leq-\eta\cdot\frac{1}{4M_{1}}(1-p_{a})\beta(1-\xi l).$ (121) $$

For ${\bm{\nu}}_{k}$, ${\bm{\nu}}_{k^{\prime}}$ with $k\neq k^{\prime}\in[M_{2}]$, we have

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(0)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta\beta}{M_{1}M_{2}}\sqrt{\frac{\log B}{B}},$ (122) $$

$$ $\displaystyle\Big|-({{\bm{\mu}}_{j}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(0)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta\beta}{M_{1}M_{2}}\sqrt{\frac{\log B}{B}}.$ (123) $$

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(0)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta\beta}{M_{2}}\sqrt{\frac{\log B}{B}}.$ (124) $$

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k^{\prime}}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(0)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta\beta}{M_{2}^{2}}\sqrt{\frac{\log B}{B}}.$ (125) $$

We also have that for any $s\in[V]$,

$$ $\displaystyle\Big|({{\bm{\nu}}^{*}_{s}}^{\top},0^{\top})\eta\cdot\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(0)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(0)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\Big|\leq$ $\displaystyle\frac{\eta\beta p_{a}\kappa_{*}}{M_{1}V}\cdot\sqrt{\frac{\log B}{B}},$ (126) $$

Therefore, the conclusions hold when $t=0$. Suppose that the conclusions also hold when $t=t_{0}$. Then, when $t=t_{0}+1$, we have

$$ $\displaystyle-({\bm{\mu}}_{j}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}$ (127) $\displaystyle\gtrsim$ $\displaystyle\eta\cdot\sum_{c=1}^{t_{0}+1}\frac{1}{2M_{1}}(1-p_{a})\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})\beta$ $\displaystyle\gtrsim$ $\displaystyle\eta(t_{0}+1)\frac{1}{M_{1}}(1-p_{a})\beta.$ $$

For ${\bm{\mu}}_{j^{\prime}}$, $j^{\prime}\neq j$, that does not form a task in the training set, we have

$$ $-({{\bm{\mu}}_{j^{\prime}}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}=0$ (128) $$

For ${\bm{\mu}}_{j^{\prime\prime}}$, $j^{\prime\prime}\neq j$, that forms a task in the training set, we have

$$ $\displaystyle-({{\bm{\mu}}_{j^{\prime\prime}}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}$ (129) $\displaystyle\leq$ $\displaystyle-\eta(t_{0}+1)\frac{1}{M_{1}}(1-p_{a})\beta.$ $$

For ${\bm{\nu}}_{k}$, ${\bm{\nu}}_{k^{\prime}}$ with $k\neq k^{\prime}\in[M_{2}]$, we have

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta(t_{0}+1)\beta}{M_{1}M_{2}}\sqrt{\frac{\log B}{B}},$ (130) $$

$$ $\displaystyle\Big|-({{\bm{\mu}}_{j}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(b)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta(t_{0}+1)\beta}{M_{1}M_{2}}\sqrt{\frac{\log B}{B}}.$ (131) $$

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(b)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta(t_{0}+1)\beta}{M_{2}}\sqrt{\frac{\log B}{B}}.$ (132) $$

$$ $\displaystyle\Big|-({{\bm{\nu}}_{k^{\prime}}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(b)}}({\bm{\nu}}_{k}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta(t_{0}+1)\beta}{M_{2}^{2}}\sqrt{\frac{\log B}{B}}.$ (133) $$

We also have that for any $s\in[V]$,

$$ $\displaystyle\Big|({{\bm{\nu}}^{*}_{s}}^{\top},0^{\top})\eta\cdot\sum_{b=1}^{t_{0}+1}\frac{1}{|\mathcal{B}_{b}|}\sum_{n\in\mathcal{B}_{b}}\frac{\ell(\Psi^{(b)};{\bm{P}}^{n},z^{n})}{\partial{\bm{W}}_{B}^{(b)}}({\bm{\mu}}_{j}^{\top},0^{\top})^{\top}\Big|\leq\frac{\eta\beta(t_{0}+1)p_{a}\kappa_{*}}{M_{1}V}\cdot\sqrt{\frac{\log B}{B}},$ (134) $$

∎

###### Proof.

### E.3 Proof of Lemma 4

###### Proof.

When $F(\Psi;{\bm{P}}^{n})\in(-1,1)$ for some $n\in[N]$,

$$ $\displaystyle\frac{\partial\ell(\Psi;{\bm{P}}^{n},z^{n})}{\partial{\bm{w}}}$ (135) $\displaystyle=$ $\displaystyle-z^{n}\sum_{i=1}^{l}y_{i}^{n}{{\bm{p}}_{i}^{n}}^{\top}{\bm{W}}_{B}^{\top}{\bm{W}}_{C}{\bm{p}}_{query}^{n}\frac{\partial G^{n}_{i,l+1}({\bm{w}})}{\partial{\bm{w}}}$ $\displaystyle=$ $\displaystyle-z^{n}\sum_{i=1}^{l}y_{i}^{n}{{\bm{p}}_{i}^{n}}^{\top}{\bm{W}}_{B}^{\top}{\bm{W}}_{C}{\bm{p}}_{query}^{n}\frac{\partial\prod_{j=i+1}^{l+1}(1-\sigma({\bm{w}}^{\top}{\bm{p}}_{j}^{n}))\sigma({\bm{w}}^{\top}{\bm{p}}_{i}^{n})}{\partial{\bm{w}}}$ $\displaystyle=$ $\displaystyle-z^{n}\sum_{i=1}^{l}y_{i}^{n}{{\bm{p}}_{i}^{n}}^{\top}{\bm{W}}_{B}^{\top}{\bm{W}}_{C}{\bm{p}}_{query}^{n}(\sum_{s=i+1}^{l+1}\prod_{j=i+1,j\neq s}^{l+1}(1-\sigma({\bm{w}}^{\top}{\bm{p}}_{j}^{n})\mathbbm{1}[j<l+1])\sigma({\bm{w}}^{\top}{\bm{p}}_{i}^{n})$ $\displaystyle\cdot\frac{\partial(1-\sigma({\bm{w}}^{\top}{\bm{p}}_{s}^{n}))}{\partial{\bm{w}}}+\prod_{j=i+1}^{l+1}(1-\sigma({\bm{w}}^{\top}{\bm{p}}_{j}^{n}))\frac{\partial\sigma({\bm{w}}^{\top}{\bm{p}}_{i}^{n})}{\partial{\bm{w}}})$ $\displaystyle=$ $\displaystyle-z^{n}\sum_{i=1}^{l}y_{i}^{n}{{\bm{p}}_{i}^{n}}^{\top}{\bm{W}}_{B}^{\top}{\bm{W}}_{C}{\bm{p}}_{query}^{n}(\sum_{s=i+1}^{l+1}\prod_{j=i+1,j\neq s}^{l+1}(1-\sigma({\bm{w}}^{\top}{\bm{p}}_{j}^{n})\mathbbm{1}[j<l+1])\sigma({\bm{w}}^{\top}{\bm{p}}_{i}^{n})$ $\displaystyle\cdot(1-\sigma({\bm{w}}^{\top}{\bm{p}}_{s}^{n}))\sigma({\bm{w}}^{\top}{\bm{p}}_{s}^{n})(-{\bm{p}}_{s}^{n})+\prod_{j=i+1}^{l+1}(1-\sigma({\bm{w}}^{\top}{\bm{p}}_{j}^{n}))(1-\sigma({\bm{w}}^{\top}{\bm{p}}_{i}^{n}))\sigma({\bm{w}}^{\top}{\bm{p}}_{i}^{n}){\bm{p}}_{i}^{n})$ $\displaystyle=$ $\displaystyle z^{n}\sum_{i=1}^{l}y_{i}^{n}{{\bm{p}}_{i}^{n}}^{\top}{\bm{W}}_{B}^{\top}{\bm{W}}_{C}{\bm{p}}_{query}^{n}(\sum_{s=i+1}^{l+1}\prod_{j=i+1}^{l+1}(1-\sigma({\bm{w}}^{\top}{\bm{p}}_{j}^{n})\mathbbm{1}[j<l+1])\cdot\sigma({\bm{w}}^{\top}{\bm{p}}_{s}^{n})$ $\displaystyle\cdot\sigma({\bm{w}}^{\top}{\bm{p}}_{i}^{n}){\bm{p}}_{s}^{n}-\prod_{j=i}^{l+1}(1-\sigma({\bm{w}}^{\top}{\bm{p}}_{j}^{n}))\sigma({\bm{w}}^{\top}{\bm{p}}_{i}^{n}){\bm{p}}_{i}^{n})$ $\displaystyle=$ $\displaystyle z^{n}\sum_{i=1}^{l}y_{i}^{n}{{\bm{p}}_{i}^{n}}^{\top}{\bm{W}}_{B}^{\top}{\bm{W}}_{C}{\bm{p}}_{query}^{n}G^{n}_{i,l+1}({\bm{w}})(\sum_{s=i+1}^{l+1}\sigma({\bm{w}}^{\top}{\bm{p}}_{s}^{n}){\bm{p}}_{s}^{n}-(1-\sigma({\bm{w}}^{\top}{\bm{p}}_{i}^{n})){\bm{p}}_{i}^{n}).$ $$

When $t=1$, we have

$$ $\displaystyle{\bm{w}}^{(1)}=$ $\displaystyle{\bm{w}}^{(0)}-\frac{\eta}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{1}}\frac{\partial\ell(\Psi;{\bm{P}}^{n},z^{n})}{\partial{\bm{w}}^{(0)}}$ (136) $\displaystyle=$ $\displaystyle{\bm{w}}^{(0)}-\frac{\eta}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{1}}z^{n}\sum_{i=1}^{l}y_{i}^{n}{{\bm{p}}_{i}^{n}}^{\top}{{\bm{W}}_{B}^{(0)}}^{\top}{\bm{W}}_{C}^{(0)}{\bm{p}}_{query}^{n}G^{n}_{i,l+1}({\bm{w}}^{(0)})$ $\displaystyle\cdot(\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{s}^{n}){\bm{p}}_{s}^{n}-(1-\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{i}^{n})){\bm{p}}_{i}^{n})$ $$

For ${\bm{p}}_{i}^{n}$ that contains a ${\bm{v}}^{*}_{s}$, the corresponding $y_{i}^{n}$ is consistent with $z^{n}$ with a probability of $1/2$. Given Hoeffding’s bound ([22](https://arxiv.org/html/2510.00399v1#A3.E22)), this part generates a gradient update as

$$ $\displaystyle\Big\|\frac{\eta}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{1}}z^{n}\sum_{1\leq i\leq l,{\bm{p}}_{i}^{n}\text{ does not contain any }{\bm{v}}^{*}_{s}}y_{i}^{n}{{\bm{p}}_{i}^{n}}^{\top}{{\bm{W}}_{B}^{(0)}}^{\top}{\bm{W}}_{C}^{(0)}{\bm{p}}_{query}^{n}G^{n}_{i,l+1}({\bm{w}}^{(0)})$ (137) $\displaystyle\cdot(\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{s}^{n}){\bm{p}}_{s}^{n}-(1-\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{i}^{n})){\bm{p}}_{i}^{n})\Big\|$ $\displaystyle\leq$ $\displaystyle\eta\sqrt{\frac{\log B}{B}}$ $$

by ([96](https://arxiv.org/html/2510.00399v1#A5.E96)) and $\sum_{i=1}^{l}\frac{l}{2^{l}}\leq 2$. Then, with a high probability, for $s\in[V]$, $\xi=1/(d+1)$,

$$ $\displaystyle{{\bm{v}}^{*}_{s}}^{\top}{\bm{w}}^{(1)}$ (138) $\displaystyle\leq$ $\displaystyle\xi+\eta\sqrt{\frac{\log B}{B}}-\eta\beta^{2}\frac{1}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{b}}\sum_{1\leq i\leq l,{\bm{p}}_{i}^{n}\text{ does not contain any }{\bm{v}}^{*}_{s}}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})$ $\displaystyle\cdot(\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{s}^{n}){{\bm{v}}^{*}_{s}}^{\top}{\bm{p}}_{s}^{n}-(1-\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{i}^{n})){{\bm{v}}^{*}_{s}}^{\top}{\bm{p}}_{i}^{n})$ $\displaystyle\lesssim$ $\displaystyle\xi+\eta\sqrt{\frac{\log B}{B}}-\eta\beta^{2}\sum_{i=1}^{l}\frac{1}{2^{l+2-i}V}\cdot\kappa_{a}\sum_{s=i+1}^{l+1}\frac{1}{2}(1-p_{a})$ $\displaystyle=$ $\displaystyle\xi+\eta\sqrt{\frac{\log B}{B}}-\eta\beta^{2}\sum_{i=1}^{l}\frac{\kappa_{a}}{2^{l+2-i}V}\cdot\frac{(1-p_{a})(l-i+1)}{2}$ $\displaystyle=$ $\displaystyle\xi+\eta\sqrt{\frac{\log B}{B}}-\eta\beta^{2}\cdot\sum_{i=1}^{l}\frac{\kappa_{a}i}{2^{2+i}V}\cdot\frac{1-p_{a}}{2}$ $\displaystyle\lesssim$ $\displaystyle\xi+\eta\sqrt{\frac{\log B}{B}}-\frac{\eta\beta^{2}\kappa_{a}(1-p_{a})}{V}$ $\displaystyle\lesssim$ $\displaystyle-\frac{\eta\beta^{2}\kappa_{a}(1-p_{a})}{V}.$ $$

The second step comes from ([96](https://arxiv.org/html/2510.00399v1#A5.E96)) and the fact that

$$ $\displaystyle\Pr\Big(\Big|\frac{1}{l|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{1}}\sum_{i=1}^{l}\mathbbm{1}[{\bm{p}}_{i}^{n}\text{ does not contain any }{\bm{v}}^{*}_{s}]G^{n}_{i,l+1}({\bm{w}}^{(0)})\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{s}^{n})$ (139) $\displaystyle\cdot{{\bm{v}}^{*}_{s}}^{\top}{\bm{p}}_{s}^{n}-(1-p_{a})\mathbb{E}[\frac{1}{l|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{1}}\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{s}^{n}){{\bm{v}}^{*}_{s}}^{\top}{\bm{p}}_{s}^{n}]\Big|$ $\displaystyle\geq c\cdot(1-p_{a})\mathbb{E}[\frac{1}{l|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{1}}\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{s}^{n}){{\bm{v}}^{*}_{s}}^{\top}{\bm{p}}_{s}^{n}]\Big)$ $\displaystyle\lesssim$ $\displaystyle e^{-lB(1-p_{a})^{2}c^{2}}$ $\displaystyle\leq$ $\displaystyle\epsilon$ $$

for some $c\in(0,1)$, and

$$ $Bl\geq(1-p_{a})^{-2}\log\epsilon^{-1}$ (140) $$

by Lemma [2](https://arxiv.org/html/2510.00399v1#Thmlemma2) since ${\bm{p}}_{i}^{n}$ contains ${\bm{v}}^{*}_{s}$ with a probability of $p_{a}/V$. The last step holds with a high probability if

$$ $B\gtrsim\beta^{-4}\kappa_{a}^{-2}(1-p_{a})^{-2}V^{2}\log\epsilon^{-1}.$ (141) $$

We can also derive that for any $j\in[M_{1}]$,

$$ $\displaystyle({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{w}}^{(1)}$ (142) $\displaystyle\leq$ $\displaystyle\xi+\frac{\eta}{M_{1}}\sqrt{\frac{\log B}{B}}-\frac{\eta\beta^{2}}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{b}}\sum_{1\leq i\leq l,{\bm{p}}_{i}^{n}\text{ does not contain any }{\bm{v}}^{*}_{s}}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})(\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{s}^{n})$ $\displaystyle\cdot({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{p}}_{s}^{n}-(1-\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{i}^{n}))({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{p}}_{i}^{n})$ $\displaystyle\lesssim$ $\displaystyle\xi+\frac{\eta}{M_{1}}\sqrt{\frac{\log B}{B}}-\eta\beta^{2}\sum_{i=1}^{l}\frac{1}{2^{l+2-i}}\cdot\frac{(1-p_{a})}{2M_{1}}(l-i+1)$ $\displaystyle\lesssim$ $\displaystyle\xi+\frac{\eta}{M_{1}}\sqrt{\frac{\log B}{B}}-\frac{\eta(1-p_{a})\beta^{2}}{M_{1}}$ $\displaystyle\lesssim$ $\displaystyle-\frac{\eta(1-p_{a})\beta^{2}}{M_{1}}.$ $$

The second step of ([142](https://arxiv.org/html/2510.00399v1#A5.E142)) comes from the fact that

$$ $\displaystyle\Pr\Big(\Big|\frac{1}{l|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{1}}\sum_{i=1}^{l}\mathbbm{1}[{\bm{p}}_{i}^{n}\text{ does not contain any }{\bm{v}}^{*}_{s}]G^{n}_{i,l+1}({\bm{w}}^{(0)})\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{s}^{n})$ (143) $\displaystyle-(1-p_{a})\mathbb{E}[\frac{1}{l|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{1}}\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{s}^{n})]\Big|$ $\displaystyle\geq c\cdot(1-p_{a})\mathbb{E}[\frac{1}{l|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{1}}\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{s}^{n})]\Big)$ $\displaystyle\lesssim$ $\displaystyle e^{-lB(1-p_{a})^{2}c^{2}}$ $\displaystyle\leq$ $\displaystyle M_{1}^{-C}$ $$

for some $c\in(0,1)$, $C>1$, and

$$ $Bl\geq(1-p_{a})^{-2}\log\epsilon^{-1}$ (144) $$

by Lemma [2](https://arxiv.org/html/2510.00399v1#Thmlemma2) since ${\bm{p}}_{i}^{n}$ does not contain any ${\bm{v}}^{*}_{s}$ with a probability of $1-p_{a}$.

The last step of ([142](https://arxiv.org/html/2510.00399v1#A5.E142)) holds if $B\gtrsim\beta^{-4}$ and $\xi\lesssim\frac{1}{M_{1}}$. Similarly, we also have

$$ $\displaystyle({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{w}}^{(1)}$ (145) $\displaystyle\geq$ $\displaystyle-\xi-\frac{\eta}{M_{1}}\sqrt{\frac{\log B}{B}}-\frac{\eta\beta^{2}}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{b}}\sum_{1\leq i\leq l,{\bm{p}}_{i}^{n}\text{ does not contain any }{\bm{v}}^{*}_{s}}^{l}G^{n}_{i,l+1}({\bm{w}}^{(0)})$ $\displaystyle\cdot(\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(0)}}^{\top}{\bm{p}}_{s}^{n})({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{p}}_{s}^{n}$ $\displaystyle\gtrsim$ $\displaystyle-\frac{\eta(1-p_{a})\beta^{2}}{M_{1}}.$ $$

Hence, the conclusion holds when $t=1$. Meanwhile, for any $k\in[M_{2}]$,

$$ $\displaystyle({\bm{\nu}}_{k}^{\top},0^{\top}){\bm{w}}^{(1)}\leq$ $\displaystyle\xi+\frac{\eta}{M_{2}}\sqrt{\frac{\log B}{B}}.$ (146) $$

Suppose that the conclusion holds when $t=t_{0}$ for $t_{0}\lesssim\min\{\eta^{-1}\beta^{-2}\kappa_{a}^{-1}(1-p_{a})^{-1}V,\eta^{-1}M_{1}^{\frac{2}{3}}\beta^{-\frac{2}{3}}\kappa_{a}^{-\frac{1}{3}}(1-p_{a})^{-1}V^{\frac{1}{3}}\}$. Then, when $t=t_{0}+1$, we have that for ${\bm{p}}_{s}^{n}$ that does not contain any ${\bm{v}}^{*}_{s}$, $s\in[V]$

$$ $-\frac{\eta(1-p_{a})\beta^{2}t_{0}}{M_{1}}-\sum_{i=1}^{t_{0}}i^{2}\cdot(\frac{\eta^{3}(1-p_{a})^{3}\beta^{2}}{M_{1}^{3}})\lesssim{{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{s}^{n}\lesssim t_{0}\cdot(-\frac{\eta\beta^{2}}{M_{1}}+\frac{\eta}{M_{2}}\sqrt{\frac{\log B}{B}}+\xi)<0.$ (147) $$

For another ${\bm{p}}_{r}^{n}$, $r\neq s$, that contains a ${\bm{v}}^{*}_{s}$, $s\in[V]$,

$$ ${{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{r}^{n}\lesssim t_{0}\cdot(0-\eta\beta^{2}\kappa_{a}(1-p_{a}))<{{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{s}^{n}<0.$ (148) $$

Then, with a high probability, we have for any $s\in[V]$,

$$ $\displaystyle{{\bm{v}}^{*}_{s}}^{\top}{\bm{w}}^{(t)}$ (149) $\displaystyle=$ $\displaystyle{{\bm{v}}^{*}_{s}}^{\top}({\bm{w}}^{(t-1)}-\eta\frac{\partial\ell(\Psi;{\bm{P}}^{n},z^{n})}{\partial{\bm{w}}})$ $\displaystyle\leq$ $\displaystyle-\eta\beta^{2}t_{0}\kappa_{a}(1-p_{a})-\eta\sum_{i=1}^{t_{0}-1}i^{2}(\frac{\eta^{2}(1-p_{a})^{3}\beta^{2}}{M_{1}^{2}})\kappa_{a}-\eta\frac{z^{n}}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{b}}\sum_{i=1}^{l}y_{i}^{n}(\beta^{2}$ $\displaystyle+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})(\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{s}^{n}){{\bm{v}}^{*}_{s}}^{\top}{\bm{p}}_{s}^{n}-(1-\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{i}^{n})){{\bm{v}}^{*}_{s}}^{\top}{\bm{p}}_{i}^{n}),$ $$

where the last step is by ([110](https://arxiv.org/html/2510.00399v1#A5.E110)) and ([127](https://arxiv.org/html/2510.00399v1#A5.E127)).
Following our proof idea in the case of $t=1$, we have that for ${\bm{p}}_{i}^{n}$ that contains a ${\bm{v}}^{*}_{s}$, $s\in[V]$, the corresponding $y_{i}^{n}$ has a probability of $1/2$ to be both binary labels. Then, by Hoeffding’ bound ([22](https://arxiv.org/html/2510.00399v1#A3.E22)), we have

$$ $\displaystyle\Big\|\frac{\eta}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{1}}z^{n}\sum_{1\leq i\leq l,{\bm{p}}_{i}^{n}\text{ contains }{\bm{v}}^{*}_{s}}y_{i}^{n}{{\bm{p}}_{i}^{n}}^{\top}{{\bm{W}}_{B}^{(t_{0})}}^{\top}{\bm{W}}_{C}^{(t_{0})}{\bm{p}}_{query}^{n}G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})$ (150) $\displaystyle\cdot(\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{s}^{n}){\bm{p}}_{s}^{n}-(1-\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{i}^{n})){\bm{p}}_{i}^{n})\Big\|$ $\displaystyle\leq$ $\displaystyle\eta\sqrt{\frac{\log B}{B}}.$ $$

Then, with a high probability,

$$ $\displaystyle\eta\frac{z^{n}}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{b}}\sum_{i=1}^{l}y_{i}^{n}(\beta^{2}+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})(\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{s}^{n}){{\bm{v}}^{*}_{s}}^{\top}{\bm{p}}_{s}^{n}$ (151) $\displaystyle\cdot-(1-\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{i}^{n})){{\bm{v}}^{*}_{s}}^{\top}{\bm{p}}_{i}^{n})$ $\displaystyle\gtrsim$ $\displaystyle-\eta\sqrt{\frac{\log B}{B}}+\eta\frac{z^{n}}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{b}}\sum_{{\bm{p}}_{i}^{n}\text{ does not contain }{\bm{v}}^{*}_{s},z^{n}y_{i}^{n}=1}y_{i}^{n}(\beta^{2}+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})$ $\displaystyle\cdot G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})(\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{s}^{n}){{\bm{v}}^{*}_{s}}^{\top}{\bm{p}}_{s}^{n}-(1-\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{i}^{n})){{\bm{v}}^{*}_{s}}^{\top}{\bm{p}}_{i}^{n})$ $\displaystyle=$ $\displaystyle-\eta\sqrt{\frac{\log B}{B}}+\eta\frac{1}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{b}}\sum_{{\bm{p}}_{i}^{n}\text{ does not contain }{\bm{v}}^{*}_{s}}(\beta^{2}+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})$ $\displaystyle\cdot\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{s}^{n}){{\bm{v}}^{*}_{s}}^{\top}{\bm{p}}_{s}^{n}$ $\displaystyle\gtrsim$ $\displaystyle-\eta\sqrt{\frac{\log B}{B}}+\eta\frac{1}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{b}}\sum_{{\bm{p}}_{i}^{n}\text{ does not contain }{\bm{v}}^{*}_{s}}(\beta^{2}+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})$ $\displaystyle\cdot(l-i+1)\frac{\kappa_{a}}{V}$ $\displaystyle\gtrsim$ $\displaystyle-\eta\sqrt{\frac{\log B}{B}}+\eta(\beta^{2}+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})\mathbb{E}\left[\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})(l-i+1)\frac{\kappa_{a}(1-p_{a})}{V}\right]$ $\displaystyle\gtrsim$ $\displaystyle-\eta\sqrt{\frac{\log B}{B}}+\eta(\beta^{2}+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})\mathbb{E}\left[\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})\frac{\kappa_{a}(1-p_{a})}{V}\right]$ $\displaystyle\geq$ $\displaystyle-\eta\sqrt{\frac{\log B}{B}}+\eta(\beta^{2}+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})\frac{\kappa_{a}(1-p_{a})}{V},$ $$

where the fourth step follows the idea of ([139](https://arxiv.org/html/2510.00399v1#A5.E139)) since

$$ $G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})(l-i+1)\leq\Theta(1),$ (152) $$

for any $i\in[l]$ and $n\in\mathcal{B}_{b}$. The last step of ([151](https://arxiv.org/html/2510.00399v1#A5.E151)) follows from

$$ $\displaystyle\sum_{i=1}^{l}G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})=$ $\displaystyle 1-\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{query}^{n})-\prod_{i=1}^{l+1}(1-\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{i}^{n}))\geq\frac{1}{4},$ (153) $$

since

$$ $\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{query}^{n})<\sigma(0)=\frac{1}{2},$ (154) $$

by ([147](https://arxiv.org/html/2510.00399v1#A5.E147)), and with a high probability,

$$ $\displaystyle\prod_{i=1}^{l+1}(1-\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{i}^{n}))\leq$ $\displaystyle\prod_{{\bm{p}}_{i}^{n}\text{ does not contain any }{\bm{v}}^{*}_{s}}(1-\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{i}^{n}))$ (155) $\displaystyle\lesssim$ $\displaystyle(1-\frac{1}{1+e^{-\frac{V}{\kappa_{a}M_{1}}}})^{l(1-p_{a})}$ $\displaystyle\leq$ $\displaystyle\frac{1}{4},$ $$

where the last step holds if

$$ $l\gtrsim(1-p_{a})^{-1}\log M_{1}.$ (156) $$

The second step of ([155](https://arxiv.org/html/2510.00399v1#A5.E155)) comes from ([147](https://arxiv.org/html/2510.00399v1#A5.E147)) and

$$ $\Pr\Big(\Big|\frac{1}{l}\sum_{i=1}^{l}\mathbbm{1}[{\bm{p}}_{i}^{n}\text{ does not contain }{\bm{v}}^{*}_{s}]-(1-p_{a})\Big|\geq c\cdot(1-p_{a})\Big)\lesssim e^{-l(1-p_{a})c^{2}}\leq M_{1}^{-C}$ (157) $$

by Lemma [1](https://arxiv.org/html/2510.00399v1#Thmlemma1) for some $c\in(0,1)$, $C>1$, and

$$ $l\geq(1-p_{a})^{-1}\log M_{1}.$ (158) $$

Then, by plugging ([151](https://arxiv.org/html/2510.00399v1#A5.E151)) into ([149](https://arxiv.org/html/2510.00399v1#A5.E149)), we have

$$ $\displaystyle{{\bm{v}}^{*}_{s}}^{\top}{\bm{w}}^{(t_{0}+1)}$ (159) $\displaystyle\leq$ $\displaystyle-\frac{\eta\beta^{2}t_{0}\kappa_{a}(1-p_{a})}{V}-\eta\sum_{i=1}^{t_{0}-1}i^{2}(\frac{\eta^{2}(1-p_{a})^{3}\beta^{2}}{M_{1}^{2}})\frac{\kappa_{a}}{V}+\eta\sqrt{\frac{\log B}{B}}-\eta(\beta^{2}$ $\displaystyle+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})\cdot\frac{\kappa_{a}(1-p_{a})}{V}$ $\displaystyle=$ $\displaystyle-\frac{\eta\beta^{2}(t_{0}+1)\kappa_{a}(1-p_{a})}{V}-\eta\sum_{i=1}^{t_{0}}i^{2}(\frac{\eta^{2}(1-p_{a})^{3}\beta^{2}}{M_{1}^{2}})\frac{\kappa_{a}}{V}+\eta\sqrt{\frac{\log B}{B}}$ $\displaystyle\lesssim$ $\displaystyle-\frac{\eta\beta^{2}(t_{0}+1)\kappa_{a}(1-p_{a})}{V}-\eta\sum_{i=1}^{t_{0}}i^{2}(\frac{\eta^{2}(1-p_{a})^{3}\beta^{2}}{M_{1}^{2}})\frac{\kappa_{a}}{V},$ $$

where the last step holds given ([141](https://arxiv.org/html/2510.00399v1#A5.E141)) and $t_{0}\lesssim\min\{\eta^{-1}\beta^{-2}\kappa_{a}^{-1}(1-p_{a})^{-1}V,\eta^{-1}M_{1}^{\frac{2}{3}}\beta^{-\frac{2}{3}}\kappa_{a}^{-\frac{1}{3}}(1-p_{a})^{-1}V^{\frac{1}{3}}\}$. We can also derive that for any $j\in[M_{1}]$,

$$ $\displaystyle({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{w}}^{(t)}$ (160) $\displaystyle\leq$ $\displaystyle\xi+\frac{\eta}{M_{1}}\sqrt{\frac{\log B}{B}}-\frac{\eta(1-p_{a})\beta^{2}t_{0}}{M_{1}}-\sum_{i=1}^{t_{0}-1}i^{2}\cdot(\frac{\eta^{3}(1-p_{a})^{3}\beta^{2}}{M_{1}^{3}})-\frac{\eta}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{b}}$ $\displaystyle\sum_{{\bm{p}}_{i}^{n}\text{ does not contain any }{\bm{v}}^{*}_{s}}^{l}(\beta^{2}+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})\cdot(\sum_{s=i+1}^{l+1}\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{s}^{n})$ $\displaystyle\cdot({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{p}}_{s}^{n}-(1-\sigma({{\bm{w}}^{(t_{0})}}^{\top}{\bm{p}}_{i}^{n}))({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{p}}_{i}^{n})$ $\displaystyle\lesssim$ $\displaystyle\xi+\frac{\eta}{M_{1}}\sqrt{\frac{\log B}{B}}-\frac{\eta(1-p_{a})\beta^{2}t_{0}}{M_{1}}-\sum_{i=1}^{t_{0}-1}i^{2}\cdot(\frac{\eta^{3}(1-p_{a})^{3}\beta^{2}}{M_{1}^{3}})-\frac{\eta}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{b}}\sum_{i=1}^{l}(\beta^{2}$ $\displaystyle+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})\cdot G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})(l-i+1)\cdot\frac{(1-p_{a})}{M_{1}}$ $\displaystyle\lesssim$ $\displaystyle\xi+\frac{\eta}{M_{1}}\sqrt{\frac{\log B}{B}}-\frac{\eta(1-p_{a})\beta^{2}t_{0}}{M_{1}}-\sum_{i=1}^{t_{0}-1}i^{2}\cdot(\frac{\eta^{3}(1-p_{a})^{3}\beta^{2}}{M_{1}^{3}})-\eta\frac{(1-p_{a})}{M_{1}}(\beta^{2}$ $\displaystyle+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})$ $\displaystyle\lesssim$ $\displaystyle\xi+\frac{\eta}{M_{1}}\sqrt{\frac{\log B}{B}}-\frac{\eta(1-p_{a})\beta^{2}(t_{0}+1)}{M_{1}}-\sum_{i=1}^{t_{0}-1}i^{2}\cdot(\frac{\eta^{3}(1-p_{a})^{3}\beta^{2}}{M_{1}^{3}})$ $\displaystyle-\frac{\eta(1-p_{a})}{M_{1}}(\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})$ $\displaystyle\lesssim$ $\displaystyle-\frac{\eta(1-p_{a})\beta^{2}(t_{0}+1)}{M_{1}}-\sum_{i=1}^{t_{0}}i^{2}\cdot(\frac{\eta^{3}(1-p_{a})^{3}\beta^{2}}{M_{1}^{3}}),$ $$

where the second step of ([160](https://arxiv.org/html/2510.00399v1#A5.E160)) follows the second step in ([142](https://arxiv.org/html/2510.00399v1#A5.E142)) using Lemma [2](https://arxiv.org/html/2510.00399v1#Thmlemma2). Meanwhile,

$$ $\displaystyle({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{w}}^{(t)}$ (161) $\displaystyle\gtrsim$ $\displaystyle-\xi-\frac{\eta}{M_{1}}\sqrt{\frac{\log B}{B}}-\frac{\eta(1-p_{a})\beta^{2}t_{0}}{M_{1}}-\sum_{i=1}^{t_{0}-1}i^{2}\cdot(\frac{\eta^{3}(1-p_{a})^{3}\beta^{2}}{M_{1}^{3}})-\frac{\eta}{|\mathcal{B}_{1}|}\sum_{n\in\mathcal{B}_{b}}\sum_{i=1}^{l}(\beta^{2}$ $\displaystyle+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})\cdot G^{n}_{i,l+1}({\bm{w}}^{(t_{0})})(l-i+1)\cdot\frac{(1-p_{a})}{M_{1}}$ $\displaystyle\gtrsim$ $\displaystyle-\xi-\frac{\eta}{M_{1}}\sqrt{\frac{\log B}{B}}-\frac{\eta(1-p_{a})\beta^{2}t_{0}}{M_{1}}-\sum_{i=1}^{t_{0}-1}i^{2}\cdot(\frac{\eta^{3}(1-p_{a})^{3}\beta^{2}}{M_{1}^{3}})-\eta\frac{(1-p_{a})}{M_{1}}(\beta^{2}$ $\displaystyle+\frac{\eta^{2}t_{0}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})$ $\displaystyle\gtrsim$ $\displaystyle-\frac{\eta(1-p_{a})\beta^{2}(t_{0}+1)}{M_{1}}-\sum_{i=1}^{t_{0}}i^{2}\cdot(\frac{\eta^{3}(1-p_{a})^{3}\beta^{2}}{M_{1}^{3}}),$ $$

where the second step is by Lemma [6](https://arxiv.org/html/2510.00399v1#Thmlemma6). Therefore, we complete the induction.

∎

###### Proof.

### E.4 Proof of Lemma 5

###### Proof.

Let

$$ $t_{0}=\Theta(\eta^{-1}(1-p_{a})^{-1}\beta^{-2}M_{1}).$ (162) $$

(a) We first prove that for any $s\in[V]$,

$$ $({{\bm{v}}_{s}^{*}}^{\top},0^{\top}){\bm{w}}^{(t)}\leq\Theta(-\log(2+t\gamma_{1}))$ (163) $$

for some $\gamma_{1}>0$ by induction. When $t=\min\{\eta^{-1}\beta^{-2}\kappa_{a}^{-1}(1-p_{a})^{-1}V,\eta^{-1}M_{1}^{\frac{2}{3}}\beta^{-\frac{2}{3}}\kappa_{a}^{-\frac{1}{3}}(1-p_{a})^{-1}V^{\frac{1}{3}}\}$, we have

$$ $({{\bm{v}}_{s}^{*}}^{\top},0^{\top}){{\bm{w}}^{(t)}}\lesssim-\Theta(1)\leq\Theta(-\log(2+\eta^{-1}\beta^{-\frac{2}{3}}\kappa_{a}^{-\frac{1}{3}}M_{1}^{\frac{2}{3}}(1-p_{a})^{-1}V^{\frac{1}{3}}\gamma_{1}))$ (164) $$

by Lemma [4](https://arxiv.org/html/2510.00399v1#Thmlemma4) for any $\gamma_{1}>0$, since that $1+\eta^{-1}\beta^{-\frac{2}{3}}\kappa_{a}^{-\frac{1}{3}}M_{1}^{\frac{2}{3}}(1-p_{a})^{-1}V^{\frac{1}{3}}\gamma_{1}\geq\Theta(1)$ and $\gamma_{1}>0$. Therefore, ([163](https://arxiv.org/html/2510.00399v1#A5.E163)) holds when

$$ $t=\min\{\eta^{-1}\beta^{-2}\kappa_{a}^{-1}(1-p_{a})^{-1}V,\eta^{-1}M_{1}^{\frac{2}{3}}\beta^{-\frac{2}{3}}\kappa_{a}^{-\frac{1}{3}}(1-p_{a})^{-1}V^{\frac{1}{3}}\}.$ (165) $$

Suppose that when $t\leq t_{2}$ with $t_{2}>\min\{\eta^{-1}\beta^{-2}\kappa_{a}^{-1}(1-p_{a})^{-1}V,\eta^{-1}M_{1}^{\frac{2}{3}}\beta^{-\frac{2}{3}}\kappa_{a}^{-\frac{1}{3}}(1-p_{a})^{-1}V^{\frac{1}{3}}\}$ and $t_{2}\leq t_{0}$, the conclusion still holds. Then, when $t=t_{2}+1$, we have

$$ $\displaystyle({{\bm{v}}_{s}^{*}}^{\top},0^{\top}){{\bm{w}}^{(t)}}\lesssim$ $\displaystyle-\log(2+t_{2}\gamma_{1})-\frac{\eta(1-p_{a})\kappa_{a}}{V}(\beta^{2}+\frac{\eta^{2}t_{2}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})\cdot\frac{1}{1+e^{\log(2+t_{2}\gamma_{1})}}$ (166) $\displaystyle=$ $\displaystyle-\log(2+t_{2}\gamma_{1})-\frac{\eta(1-p_{a})\kappa_{a}}{V}(\beta^{2}+\frac{\eta^{2}t_{2}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})\cdot(3+t_{2}\gamma_{1})^{-1}$ $\displaystyle\lesssim$ $\displaystyle-\log(2+(t_{2}+1)\gamma_{1}),$ $$

where the last step comes from the following.
(i)

$$ $\displaystyle\frac{\eta(1-p_{a})\beta^{2}\kappa_{a}}{V}(3+t_{2}\gamma_{1})^{-1}\gtrsim$ $\displaystyle\log(1+\frac{\gamma_{1}}{2+t_{2}\gamma_{1}})$ (167) $\displaystyle=$ $\displaystyle\log(2+(t_{2}+1)\gamma_{1})-\log(2+t_{2}\gamma_{1}),$ $$

where the first step is from

$$ $\gamma_{1}\leq\eta(1-p_{a})\beta^{2}.$ (168) $$

(ii)

$$ $\displaystyle\eta^{3}\frac{(1-p_{a})^{3}\kappa_{a}}{M_{1}^{2}V}\beta^{2}t_{2}^{2}(3+t_{2}\gamma_{1})^{-1}\gtrsim\log(2+(t_{2}+1)\gamma_{1})-\log(2+t_{2}\gamma_{1}),$ (169) $$

which comes from

$$ $\gamma_{1}\leq\frac{\eta(1-p_{a})\beta^{-2}\kappa_{a}}{V}.$ (170) $$

Therefore, ([163](https://arxiv.org/html/2510.00399v1#A5.E163)) can be rewritten as

$$ $({{\bm{v}}_{s}^{*}}^{\top},0^{\top}){\bm{w}}^{(t)}\leq\Theta(-\log(2+t\cdot\eta(1-p_{a})\beta^{2})),$ (171) $$

when $\kappa_{a}\geq V\beta^{-4}$, so that the conclusion holds when $t=t_{2}+1$. Thus, the induction can be completed.
We can then derive that when $t=t_{0}$, we have

$$ $({{\bm{v}}_{s}^{*}}^{\top},0^{\top}){\bm{w}}^{(t_{0})}\leq\Theta(-\log(2+t_{0}\cdot\eta(1-p_{a})\beta^{2}))\lesssim-\log(M_{1}),$ (172) $$

and for ${\bm{p}}_{i}$ that contains ${\bm{\nu}}_{*}$,

$$ $\sigma({\bm{p}}_{i}^{\top}{\bm{w}}^{(t)})\lesssim\frac{1}{\text{poly}(M_{1})}.$ (173) $$

(b) We then prove that

$$ $({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{w}}^{(t)}\geq\Theta(-\log(2+\frac{t\gamma_{2}}{M_{1}}))$ (174) $$

for $j\in[M_{1}]$ and some $\gamma_{2}>0$ by induction. When $t=\min\{\eta^{-1}\beta^{-2}\kappa_{a}^{-1}(1-p_{a})^{-1}V,\eta^{-1}M_{1}^{\frac{2}{3}}\beta^{-\frac{2}{3}}\kappa_{a}^{-\frac{1}{3}}(1-p_{a})^{-1}V^{\frac{1}{3}}\}$, we have

$$ $({\bm{\mu}}_{j}^{\top},0^{\top}){{\bm{w}}^{(t)}}\gtrsim-\frac{1}{M_{1}}\geq\Theta(-\log(2+\eta^{-1}\beta^{-\frac{2}{3}}\kappa_{a}^{-\frac{1}{3}}M_{1}^{-\frac{1}{3}}(1-p_{a})^{-1}V^{\frac{1}{3}}\gamma_{2}))$ (175) $$

by Lemma [4](https://arxiv.org/html/2510.00399v1#Thmlemma4) for any $\gamma_{2}>0$, since that $1+\eta^{-1}\beta^{-\frac{2}{3}}\kappa_{a}^{-\frac{1}{3}}M_{1}^{-\frac{1}{3}}(1-p_{a})^{-1}V^{\frac{1}{3}}\gamma_{2}\gg M_{1}^{-1}$ and $\gamma_{2}\geq 1$. Therefore, ([174](https://arxiv.org/html/2510.00399v1#A5.E174)) holds when

$$ $t=\min\{\eta^{-1}\beta^{-2}\kappa_{a}^{-1}(1-p_{a})^{-1}V,\eta^{-1}M_{1}^{\frac{2}{3}}\beta^{-\frac{2}{3}}\kappa_{a}^{-\frac{1}{3}}(1-p_{a})^{-1}V^{\frac{1}{3}}\}.$ (176) $$

Suppose that when $t\leq t_{2}$ with $t_{2}>\min\{\eta^{-1}\beta^{-2}\kappa_{a}^{-1}(1-p_{a})^{-1}V,\eta^{-1}M_{1}^{\frac{2}{3}}\beta^{-\frac{2}{3}}\kappa_{a}^{-\frac{1}{3}}(1-p_{a})^{-1}V^{\frac{1}{3}}\}$ and $t_{2}\leq t_{0}$, the conclusion still holds. Then, when $t=t_{2}+1$, we have

$$ $\displaystyle({\bm{\mu}}_{j}^{\top},0^{\top}){{\bm{w}}^{(t)}}$ (177) $\displaystyle\gtrsim$ $\displaystyle-\log(2+\frac{t_{2}\gamma_{2}}{M_{1}})-\eta\frac{(1-p_{a})}{M_{1}}(\beta^{2}+\frac{\eta^{2}t_{2}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})\cdot\frac{1}{1+e^{\log(2+\frac{t_{2}\gamma_{2}}{M_{1}})}}$ $\displaystyle=$ $\displaystyle-\log(2+\frac{t_{2}\gamma_{2}}{M_{1}})-\eta\frac{(1-p_{a})}{M_{1}}(\beta^{2}+\frac{\eta^{2}t_{2}^{2}(1-p_{a})^{2}\beta^{2}}{M_{1}^{2}})\cdot(3+\frac{t_{2}\gamma_{2}}{M_{1}})^{-1}$ $\displaystyle\gtrsim$ $\displaystyle-\log(2+\frac{(t_{2}+1)\gamma_{2}}{M_{1}}),$ $$

where the last step comes from the following.
(i)

$$ $\displaystyle\eta\frac{(1-p_{a})}{M_{1}}\beta^{2}(3+\frac{t_{2}\gamma_{2}}{M_{1}})^{-1}\lesssim$ $\displaystyle\log(1+\frac{\frac{\gamma_{2}}{M_{1}}}{2+\frac{t_{2}\gamma_{2}}{M_{1}}})$ (178) $\displaystyle=$ $\displaystyle\log(2+\frac{(t_{2}+1)\gamma_{2}}{M_{1}})-\log(2+\frac{t_{2}\gamma_{2}}{M_{1}}),$ $$

where the first step is from

$$ $\gamma_{2}\geq\eta(1-p_{a})\beta^{2}.$ (179) $$

(ii)

$$ $\displaystyle\eta^{3}\frac{(1-p_{a})^{3}}{M_{1}^{3}}\beta^{2}t_{2}^{2}(3+\frac{t_{2}\gamma_{2}}{M_{1}})^{-1}\lesssim\log(2+\frac{(t_{2}+1)\gamma_{2}}{M_{1}})-\log(2+\frac{t_{2}\gamma_{2}}{M_{1}}),$ (180) $$

which comes from

$$ $\gamma_{2}\geq\eta(1-p_{a})\beta^{-2}.$ (181) $$

Therefore, ([174](https://arxiv.org/html/2510.00399v1#A5.E174)) can be rewritten as

$$ $({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{w}}^{(t)}\geq\Theta(-\log(2+t\cdot\frac{\eta(1-p_{a})\beta^{2}}{M_{1}})),$ (182) $$

so that the conclusion holds when $t=t_{2}+1$. Thus, the induction can be completed.
We can then derive that when $t=t_{0}$, we have

$$ $({\bm{\mu}}_{j}^{\top},0^{\top}){\bm{w}}^{(t_{0})}\geq\Theta(-\log(2+t_{0}\cdot\frac{\eta(1-p_{a})\beta^{2}}{M_{1}}))\geq-\log(3)\geq-\Theta(1),$ (183) $$

and for ${\bm{p}}_{i}$ that does not contain ${\bm{\nu}}_{*}$,

$$ $\sigma({\bm{p}}_{i}^{\top}{\bm{w}}^{(t)})\gtrsim\Theta(1).$ (184) $$

∎

###### Proof.

### E.5 Proof of Lemma 6

###### Proof.

Given a prompt ${\bm{P}}$ defined in ([2](https://arxiv.org/html/2510.00399v1#S2.E2)) with $({\bm{x}}_{1},{\bm{x}}_{2},\cdots,{\bm{x}}_{l},{\bm{x}}_{query})$, let ${\bm{x}}_{l+1}={\bm{x}}_{query}$. Define

$$ $\displaystyle\hat{{\bm{P}}}^{i}=$ $\displaystyle\begin{pmatrix}{\bm{x}}_{i+1}&{\bm{x}}_{i+2}&\cdots&{\bm{x}}_{l}&{\bm{x}}_{l+1}&{\bm{x}}_{1}&{\bm{x}}_{2}&\cdots&{\bm{x}}_{i}\\ y_{i+1}&y_{i+2}&\cdots&y_{l}&y_{l+1}&y_{1}&y_{2}&\cdots&y_{i}\end{pmatrix}$ (185) $\displaystyle=$ $\displaystyle\begin{pmatrix}\hat{{\bm{x}}}_{1}^{i}&\hat{{\bm{x}}}_{2}^{i}&\cdots&\hat{{\bm{x}}}_{l}^{i}&\hat{{\bm{x}}}_{l+1}^{i}\\ \hat{y}_{1}^{i}&\hat{y}_{2}^{i}&\cdots&\hat{y}_{l}^{i}&\hat{y}_{l+1}^{i}\\ \end{pmatrix}$ $\displaystyle=$ $\displaystyle(\hat{{\bm{p}}}_{1}^{i},\hat{{\bm{p}}}_{2}^{i},\cdots,\hat{{\bm{p}}}_{l}^{i},\hat{{\bm{p}}}_{l+1}^{i}),$ $$

which is a rotation of in-context examples for $i\in[l]\cup\{0\}$. Therefore, we have

$$ $\displaystyle\sum_{i=1}^{l}G_{i,l+1}({\bm{w}}^{(t)})(l-i+1)$ (186) $\displaystyle=$ $\displaystyle\sum_{i=1}^{l}G_{i,l+1}^{0}({\bm{w}}^{(t)})(l-i+1)$ $\displaystyle\leq$ $\displaystyle\sum_{i=1}^{l}G_{i,l+1}^{0}({\bm{w}}^{(t)})+\sum_{i=1}^{l}G_{i,l+1}^{l}({\bm{w}}^{(t)})(1-\sigma({{\bm{w}}^{(t)}}^{\top}\hat{{\bm{p}}}_{1}^{l}))+\sum_{i=1}^{l}G_{i,l+1}^{l-1}({\bm{w}}^{(t)})(1$ $\displaystyle-\sigma({{\bm{w}}^{(t)}}^{\top}\hat{{\bm{p}}}_{1}^{l-1}))(1-\sigma({{\bm{w}}^{(t)}}^{\top}\hat{{\bm{p}}}_{2}^{l-1}))+\cdots+\sum_{i=1}^{l}G_{i,l+1}^{2}({\bm{w}}^{(t)})\prod_{j=1}^{l-1}(1-\sigma({{\bm{w}}^{(t)}}^{\top}\hat{{\bm{p}}}_{j}^{2}))$ $\displaystyle\leq$ $\displaystyle\max_{j\in[l]}\left\{\sum_{i=1}^{l}G_{i,l+1}^{j}({\bm{w}}^{(t)})\right\}\cdot(1+(1-\sigma({{\bm{w}}^{(t)}}^{\top}\hat{{\bm{p}}}_{1}^{l}))+(1-\sigma({{\bm{w}}^{(t)}}^{\top}\hat{{\bm{p}}}_{1}^{l-1}))(1$ $\displaystyle-\sigma({{\bm{w}}^{(t)}}^{\top}\hat{{\bm{p}}}_{2}^{l-1}))+\cdots+\prod_{j=1}^{l-1}(1-\sigma({{\bm{w}}^{(t)}}^{\top}\hat{{\bm{p}}}_{j}^{2})))$ $\displaystyle\leq$ $\displaystyle 1+(1-\sigma({{\bm{w}}^{(t)}}^{\top}\hat{{\bm{p}}}_{1}^{l}))+(1-\sigma({{\bm{w}}^{(t)}}^{\top}\hat{{\bm{p}}}_{1}^{l-1}))(1-\sigma({{\bm{w}}^{(t)}}^{\top}\hat{{\bm{p}}}_{2}^{l-1}))+\cdots$ $\displaystyle+\prod_{j=1}^{l-1}(1-\sigma({{\bm{w}}^{(t)}}^{\top}\hat{{\bm{p}}}_{j}^{2}))$ $\displaystyle\leq$ $\displaystyle 1+1-c+(1-c)^{2}+\cdots+(1-c)^{l-1}$ $\displaystyle\leq$ $\displaystyle\frac{1}{c}$ $\displaystyle\leq$ $\displaystyle\Theta(1),$ $$

where the third to last step holds since that when $t\lesssim\min\{\eta^{-1}\beta^{-2}\kappa_{a}^{-1}(1-p_{a})^{-1}V,\eta^{-1}M_{1}^{\frac{2}{3}}((1-p_{a})\beta)^{-\frac{2}{3}}(\kappa_{a}(1-p_{a}))^{-\frac{1}{3}}V^{\frac{1}{3}}\}$, there exists $c\in(0,1)$ and $C\in(0,1)$, $C>c$, such that $c\leq\sigma({{\bm{w}}^{(t)}}^{\top}{\bm{p}}_{j})\leq C$ for any $j\in[l]$.
∎

###### Proof.

### E.6 Extension to Other SSM/Linear RNN Architectures

Our theoretical analysis can be extended to a broader range of SSM or Linear RNN architectures. The key to such extension depends on whether the basic block of the model can be decomposed into a linear attention layer and a gating layer as in ([3](https://arxiv.org/html/2510.00399v1#S2.E3)). Even if the specific form of the nonlinear gating differs from that in the Mamba architecture we consider in this work, we can still compute the gradient of the new gating function and analyze the resulting training dynamics and generalization performance. We then list several examples and briefly discuss how their models can be interpreted as linear attention plus a gating based on the summary from Table 2 of (Yang et al., 2024c).

- •
Mamba-2 (Dao and Gu, 2024). The updating equation of Mamba-2 is
$\displaystyle{\bm{h}}_{i}=$
$\displaystyle\gamma({\bm{w}},a;i)\cdot{\bm{h}}_{i-1}+{\bm{v}}_{i}{\bm{k}}_{i}^{\top}\quad\in\mathbb{R}^{d_{0}\times m},\quad\forall i\in[m]$
(187)
$\displaystyle{\bm{o}}_{i}=$
$\displaystyle{\bm{h}}_{i}{\bm{q}}_{i}\quad\in\mathbb{R}^{d_{0}},$
where $\gamma({\bm{w}},a;i)=e^{-\text{softplus}({\bm{w}}^{\top}{\bm{p}}_{i})e^{a}}\in\mathbb{R}$ for $a\in\mathbb{R}$ and ${\bm{w}}\in\mathbb{R}^{d_{0}}$ from Table 1 of (Yang et al., 2024b). Then,
$\displaystyle{\bm{h}}_{t}=$
$\displaystyle\gamma({\bm{w}},a;t)\cdot{\bm{h}}_{t-1}+{\bm{v}}_{t}{\bm{k}}_{t}^{\top}$
(188)
$\displaystyle=$
$\displaystyle\gamma({\bm{w}},a;t)\cdot(\gamma({\bm{w}},a;t-1)\cdot{\bm{h}}_{t-2}+{\bm{v}}_{t-1}{\bm{k}}_{t-1}^{\top})+{\bm{v}}_{t}{\bm{k}}_{i}^{\top}$
$\displaystyle=$
$\displaystyle\cdots$
$\displaystyle=$
$\displaystyle\sum_{i=1}^{t}G_{i,t}({\bm{w}},a){\bm{v}}_{i}{\bm{k}}_{i}^{\top},$
where
$G_{i,t}({\bm{w}},a)=\begin{cases}\prod_{j=i+1}^{t}\gamma({\bm{w}},a;j),&i<t\\
1,&i=t.\end{cases}$
(189)
Therefore, the output of a Mamba-2 block can be written as a summation of linear attention output ${\bm{v}}_{t}{\bm{k}}_{i}^{\top}{\bm{q}}_{i}$ weighted by the scalar gating $G_{i,t}({\bm{w}},a)$ for $1\leq i\leq t$.
- •
RetNet (Sun et al., 2023). The updating equation of RetNet is
$\displaystyle{\bm{h}}_{i}=$
$\displaystyle\gamma\cdot{\bm{h}}_{i-1}+{\bm{v}}_{i}{\bm{k}}_{i}^{\top}\quad\in\mathbb{R}^{d_{0}\times m},\quad\forall i\in[m]$
(190)
$\displaystyle{\bm{o}}_{i}=$
$\displaystyle{\bm{h}}_{i}{\bm{q}}_{i}\quad\in\mathbb{R}^{d_{0}}.$
Then,
$\displaystyle{\bm{h}}_{t}=$
$\displaystyle\gamma\cdot{\bm{h}}_{t-1}+{\bm{v}}_{t}{\bm{k}}_{t}^{\top}=\sum_{i=1}^{t}G_{i,t}({\bm{W}}){\bm{v}}_{i}{\bm{k}}_{i}^{\top},$
(191)
where
$G_{i,t}({\bm{W}})=\begin{cases}\gamma^{t-i},&i<t\\
1,&i=t.\end{cases}$
(192)
- •
Gated Retention (Sun et al., 2024). The updating equation of Gated Retention is
$\displaystyle{\bm{h}}_{i}=$
$\displaystyle\gamma({\bm{w}};i)\cdot{\bm{h}}_{i-1}+{\bm{v}}_{i}{\bm{k}}_{i}^{\top}\quad\in\mathbb{R}^{d_{0}\times m},\quad\forall i\in[m]$
(193)
$\displaystyle{\bm{o}}_{i}=$
$\displaystyle{\bm{h}}_{i}{\bm{q}}_{i}\quad\in\mathbb{R}^{d_{0}},$
where $\gamma({\bm{w}};i)=\sigma({\bm{w}}^{\top}{\bm{p}}_{i})^{\frac{1}{\tau}}\in\mathbb{R}$ for $\tau\in\mathbb{R}$.
Then,
$\displaystyle{\bm{h}}_{t}=$
$\displaystyle\gamma({\bm{w}};i)\cdot{\bm{h}}_{t-1}+{\bm{v}}_{t}{\bm{k}}_{t}^{\top}=\sum_{i=1}^{t}G_{i,t}({\bm{W}}){\bm{v}}_{i}{\bm{k}}_{i}^{\top},$
(194)
where
$G_{i,t}({\bm{W}})=\begin{cases}\prod_{j=i+1}^{t}\gamma({\bm{w}};j),&i<t\\
1,&i=t.\end{cases}$
(195)
- •
Gated Linear Attention (Yang et al., 2024b). The updating equation of Gated Linear Attention is
$\displaystyle{\bm{h}}_{i}=$
$\displaystyle{\bm{h}}_{i-1}\odot(\sigma({\bm{W}}{\bm{p}}_{i})^{\frac{1}{\tau}}\mathbf{1}_{m}^{\top})+{\bm{v}}_{i}{\bm{k}}_{i}^{\top}\quad\in\mathbb{R}^{d_{0}\times m},\quad\forall i\in[m]$
(196)
$\displaystyle{\bm{o}}_{i}=$
$\displaystyle{\bm{h}}_{i}{\bm{q}}_{i}\quad\in\mathbb{R}^{d_{0}},$
where ${\bm{W}}\in\mathbb{R}^{d_{0}\times d_{0}}$ for $\tau\in\mathbb{R}$.
Then,
$\displaystyle{\bm{h}}_{t}=\sum_{i=1}^{t}{\bm{v}}_{i}({\bm{k}}_{i}\odot\sigma({\bm{W}}{\bm{u}}_{i})^{\frac{1}{\tau}})^{\top},$
(197)
$F(\Psi;{\bm{P}})=\sum_{i=1}^{t}y_{i}({\bm{W}}_{K}{\bm{p}}_{i}\odot\sigma({\bm{W}}{\bm{p}}_{i})^{\frac{1}{\tau}})^{\top}{\bm{W}}_{Q}{\bm{p}}_{query}.$
(198)
Note that in this case, the gating is essentially applied to the key rather than the value as in our ([3](https://arxiv.org/html/2510.00399v1#S2.E3)). Then,
$\frac{\partial F(\Psi;{\bm{P}})}{\partial{\bm{W}}}=\sum_{i=1}^{t}y_{i}({\bm{W}}_{K}{\bm{p}}_{i}\odot{\bm{W}}_{Q}{\bm{p}}_{query})\odot\frac{1}{\tau}\sigma({\bm{W}}{\bm{p}}_{i})^{\frac{1}{\tau}}\odot(1-\sigma({\bm{W}}{\bm{p}}_{i})){\bm{p}}_{i}^{\top}.$
(199)
Our gradient analysis is to characterize the feature updates of ([199](https://arxiv.org/html/2510.00399v1#A5.E199)).

### The Use of Large Language Models

We used large-language models (ChatGPT) to help polish the writing of this paper.

## Peer Reviews

confidence: 4
contribution: 2
initial_rating: 4
presentation: 3
questions: 1. The test outlier is a positive combination of train outliers (Condition (11)). How realistic is this in language tasks? What happens for combinations with mixed signs or novel directions?

2. Can you extend beyond binary classification to multiclass or regression within the same framework? Where do the proofs fail?
soundness: 3
strengths: - The theoretical claims seem to align with empirical evidence (on the high level), e.g., the paper’s core takeaway—Mamba’s gate makes ICL more robust to corrupted prompts than a pure linear-attention Transformer—is directionally consistent with what the community has observed.

- Clear mechanistic story: linear attention aligns to the query’s relevant pattern; gating both suppresses outliers and biases to nearby positions.
summary: This paper shows a one-layer Mamba block can implement in-context learning (ICL) on stylized binary tasks, and its nonlinear gate is the key: linear attention selects helpful examples; the gate suppresses outliers and induces a local bias. Compared to a linear-attention Transformer (same setting), Mamba may train a bit slower but stays accurate under a much higher fraction of corrupted examples—even approaching 100% under their assumptions.
weaknesses: 1. The paper studies a stylized binary, pattern-based ICL task where each input contains exactly one relevant and one irrelevant orthogonal pattern of equal norm; labels depend only on the relevant pattern. This is a clean but **unnatural** abstraction for real data. Results derived on this task may not transfer to more general tasks studies in practice. 

2. Outlier modeling is also narrow/artificial: Outliers are injected additively, orthogonal to both relevant and irrelevant patterns during training, and at test time are linear combinations of the training-time outlier directions with a positivity constraint.

3. Transformer comparator is a very specific “linear attention” variant (no softmax, multi-heads...). So the headline advantage (“Mamba tolerates higher outlier fractions”) is established against a simplified comparator that may be unrepresentative of modern Transformers. This undermines the breadth of the claim.

---

confidence: 3
contribution: 3
initial_rating: 6
presentation: 2
questions: See Weakness.
soundness: 3
strengths: - This paper is the first paper to theoretically understand the in-context capability of Mamba, which is an essential contribution.
- The paper is well written. 
- The empirical results are good.
summary: This paper focuses on building theoretical understanding of the Mamba model for its powerful in-context learning capability. According to the results, the authors demonstrate that Mamba leverages the linear attention layer to select informative context examples and uses the nonlinear gating layers to suppress the influence of outliers.
weaknesses: - The paper mainly focuses on the one-layer Mamba model, which cannot be seen as a comprehensive understanding of Mamba. However, this is not a significant drawback due to the complex large models.
- As a following question, can a model with just one layer achieve the similar capability of large Mamba models, such as in-context learning?
- The assumptions, which decompose the data into components of relevant and irrelevant parts, in Section 3.2 are interesting. I think such assumptions contribute to the theoretical analyses later. However, I am curious about whether such assumptions work in practice. In other words, can you provide some empirical or simple theoretical results to demonstrate that some assumptions are derived from the real cases?
- In Remark 4, a comparison between Mamba and the linear Transformer is reported. Specifically, compared to Mamba, the linear Transformer should satisfy some specific conditions for similar performance as Mamba. This is interesting. However, is there any empirical evidence to support the summaries? For example, consider two LLMs with the same architecture and trained with different hyperparameters. Do the empirical evaluations support your theoretical results?

**Minors**:
- What is $A$ in Lines 130 and 132?
- Lines 163 & 310, the references have the wrong format.

---

confidence: 2
contribution: 2
initial_rating: 4
presentation: 2
questions: How would the gating mechanism behave if the nearest examples to the query are misleading or adversarially labeled? Does the exponential decay still guarantee robustness, or could it amplify incorrect patterns?
soundness: 2
strengths: Originality:
This work is among the first to give a theoretical treatment of Mamba’s ICL mechanism, especially under the presence of outliers. Previous ICL analyses primarily focus on Transformers. The extension to Mamba—given its nonlinear gating and state-space formulation—is novel and nontrivial.

Technical quality:
The paper presents well-structured theorems (Theorems 1–4) detailing convergence, sample complexity, and robustness. The proofs seem grounded in prior analytical frameworks for Transformers (Li et al., 2024a,b) but adapted to handle the additional nonlinearity of gating. The comparison to linear Transformers provides useful insights into the tradeoff between convergence speed and robustness.

Significance:
Understanding Mamba’s ICL properties is highly relevant as Mamba-based models gain traction as efficient alternatives to Transformers. The result that Mamba tolerates a higher fraction of outliers could motivate more robust sequence modeling approaches in practice.

Clarity and organization:
The paper is generally well-written and logically organized.
summary: This paper presents the first theoretical analysis of in-context learning (ICL) in Mamba. Specifically, the authors study a one-layer Mamba with a linear attention component followed by a nonlinear gating mechanism and analyze its ability to perform ICL on binary classification tasks—even when prompts contain additive outliers.
The paper’s main contributions are:
1. It provides quantitative convergence and generalization guarantees for Mamba trained on prompts with outliers, showing robustness even when nearly all examples are corrupted.
2. It theoretically compares Mamba to linear Transformers, proving that Mamba can generalize in the presence of a higher fraction of outliers.
3. It characterizes the mechanistic role of Mamba’s components: linear attention selects examples sharing relevant patterns with the query, while the gating mechanism suppresses outliers and emphasizes nearby examples.

Synthetic experiments support the theory by showing that Mamba achieves lower classification error than linear Transformers under various outlier corruption schemes.
weaknesses: 1. The task and outlier definition seem not natural and general. This limits the generality of the conclusions. It is unclear whether similar robustness properties would hold for more natural data distributions or real-world text prompts.

2. Several theorems introduce numerous symbols without sufficient intuitive explanation, which makes the results hard to interpret. The meaning of constants such as Θ(·), poly(·), and ranges should be contextualized more clearly.

3. The experiments are purely synthetic and cover only a very limited case. While they match the theory, they provide no evidence that these findings generalize to realistic NLP or vision tasks.

4. Recent empirical work shows that large Transformers can also exhibit robustness to mislabeling or outlier examples in ICL regimes. A discussion or comparison to this line of work is missing.

5. The analysis assumes that “examples close to the query” are beneficial, but if these nearby examples are adversarial or have opposite labels, the gating mechanism could amplify errors instead of mitigating them. This edge case should be acknowledged.

---

confidence: 3
contribution: 3
initial_rating: 6
presentation: 4
questions: - It seems form Table 1 that closest to query (CQ) hurts Mamba's performance substantially. I think this result intuitively makes sense if we take the RNN perspective of understanding Mamba, which could mean that while gating layers can suppress outliers, it needs to see sufficient number of examples before being able to do so. In this regard, (i) what could be a possible mitigation strategy to this? (ii) This also could suggest that Mamba is strongly biased against the first few samples that it has seen, learns the underlying function, and uses that for the rest of the in-context examples. First, I would like to double check with the authors if my understanding is correct. If it is, I am wondering if this could be a reason that Mamba performs better when alpha is larger than 1/2, and even closer to 1. 
- In the regard of the first question, it would be interesting to see what the number 78% for the Linear Transformer means. Is it trying to do fit a least squares function with the presence of noise? If such functions exist, does that match the empirical performance of 78% we are seeing, regardless of the positions of the queries?

I believe the paper is solid, but there could be much more interesting discussions that can happen around these results. I would be inclined to raise the score if we see some of them during the rebuttal.
soundness: 3
strengths: - Clear theoretical results and comparison with Mamba vs. Linear Transformer. This strengthens the paper's analysis that gating helps in ignoring noisy examples.
- The theoretical results match the synthetic experiments, such as Mamba's tolerance to many outliers, and sensitivity to outliers near the query.
- More specifically, the paper includes the analysis of comparative training bounds and robustness regime.
- The synthetic generation setup is fully specified (i.e. the parameters) and the paper discusses the limitations in conclusions.
summary: This paper provides a theoretical study of in-context learning (ICL) capabilities, focusing on a one-layer Mamba model, which consists of linear attention plus a non-linear gating layer. Focusing on synthetic binary classification prompts with additive outliers, the authors prove convergence and sample-complexity guarantees, and provide conditions under which the model generalizes to unseen tasks, and remains robust to distribution-shifted outliers. Mainly, the bound permits a test outlier fraction value that is more flexible than a linear Transformer, capped at 1/2, which the authors attribute to the nonlinear gating layer that suppresses corrupted examples, and emphasizes pattern-matching entries. Empirical demonstrations illustrate the main theorems.
weaknesses: The weaknesses I will address are intertwined with questions that I have regarding this work. 
- Since the paper points out the limitation of single-head linear attention Transformer, i.e. the tolerance parameter alpha having to be less than 1/2, a brief discussion, even if not supported by theoretical results, on whether more realistic Transformers would suffer less from this constraint. In other words, would having multiple heads help mitigate this issue?
- The manuscript will be much easier to read and understand if takeaway messages for each figure are listed in the captions.