Masked diffusion models (MDMs) generate discrete data by iteratively unmasking multiple tokens in parallel using a learned mask predictor. Their output carries two errors: parallelization error due to parallel sampling, and estimation error from the mask predictor learned with finite samples. Existing theory treats these errors separately, and the available statistical bounds typically scale with the number VL of length- L sequences over a vocabulary of size V, suffering from the curse of dimensionality. In this work, we establish end-to-end statistical guarantees showing that transformer-based MDMs learn structured distributions with a sample complexity governed by their latent structure. Specifically, we model this structure through mixtures of hidden Markov trees, which capture latent dependencies within components and heterogeneity across components. When the data distribution is well approximated by such a mixture, a transformer-based MDM with parallel unmasking schedules achieves ε-accurate sampling in KL divergence with O~(LKpar/ε) training samples, where Kpar is polynomial in L, V, the number of hidden states, and the number of mixture components. The transformer network and sampling procedure require no knowledge of the tree topologies or component parameters, thereby adapting to the unknown latent structure automatically. Overall, our results provide theoretical justification for the empirical effectiveness of MDMs on real-world data.
Contents
1 Introduction 2
1.1 Main contributions 3
1.2 Related work 4
1.3 Notation 4
3 Problem setup: mixtures of hidden Markov trees 7
4 Main results: statistical guarantees for MDMs 8
4.1 Learning the mask predictor 9
4.2 End-to-end sampling guarantees 9
5 Analysis 11
5.1 Proof of Theorem 1 12
6 Discussion 13
*Department of Industrial and Operations Engineering, University of Michigan, Ann Arbor, USA. Email: {wujingda, cxcai}@umich.edu.
A Examples of low-complexity latent structure 17
A.1 Continuous latent representation 17
A.2 Low Rényi entropy 18
B Proof of Theorem 2 19
C Generalization analysis 20
C.1 Proof of Proposition 3 21
C.2 Capacity of transformer logit class 23
C.3 Proof of Proposition 1 25
C.4 Localized empirical-process lemma 25
C.5 Conditional-KL identity for excess risk 26
D Transformer approximation of conditionals 26
D.1 Regularization 26
D.2 Decomposition of the approximation error 28
D.3 Single-tree predictor construction 29
D.4 Approximation bound for mixtures of trees 35
D.5 Proof of Proposition 2 36
E Shallow-tree result 37
E.1 Message identities 37
E.2 Height-dependent predictor construction for single-tree 38
E.3 Approximation bound for mixtures of trees 41
E.4 Estimation error analysis 42
E.5 End-to-end sampling guarantees 42
F Auxiliary neural-network approximation lemmas 43
F.1 Exact operations and residual implementation 43
F.2 Scalar arithmetic approximations 44
F.3 Softmax stability and LSE approximation 45
G Parallelization error 48
1 Introduction
Discrete diffusion models (Austin et al., 2021; Campbell et al., 2022) have emerged as a powerful generative modeling paradigm for discrete data. Inspired by continuous diffusion models (Ho et al., 2020; Song et al., 2020), a discrete diffusion model generates samples from a data distribution p∗ by learning to reverse a categorical corruption process over a discrete state space. The central object that determines this reverse process is the concrete score (Meng et al., 2022; Lou et al., 2023). It encodes ratios between the marginal probabilities of corrupted states, serving as the discrete counterpart of the score function in continuous diffusion models (Song et al., 2020; Chen et al., 2022).
Discrete diffusion models differ in how the forward process corrupts the data. Two common corruption mechanisms are uniform replacement and masking. Uniform diffusion models (Austin et al., 2021; Hoogeboom et al., 2021) replace each token with one drawn uniformly at random from the vocabulary, while masked diffusion models (MDMs) (Austin et al., 2021; Campbell et al., 2022) replace each token with a special absorbing symbol, referred to as the mask. 1 Notably, MDMs have demonstrated strong empirical performance in language modeling (Sahoo et al., 2024; Shi et al., 2024), code generation (Gong et al., 2026), and protein sequence modeling (Wang et al., 2024).
Concretely, the forward process of an MDM gradually masks a sequence drawn from p∗ until it is fully masked. The reverse process starts from a fully masked sequence and, at each step, unmasks a subset of
1We use “tokens” to refer to discrete states for convenience; our framework and results apply to any discrete data beyond text.
positions. In particular, for MDMs, the concrete score factorizes into a known time-dependent scalar and a time-independent conditional token probability under p⋆ (Ou et al., 2025; Zheng et al., 2025). Learning the reverse dynamics therefore reduces to learning a mask predictor that estimates the conditional distribution of masked tokens given the revealed context.
Ideally, each unmasking step would sample the tokens at the selected positions jointly from their conditional distribution given the revealed context. Since directly learning these joint conditionals is computationally prohibitive, practical MDMs learn conditional marginals instead and sample from their product (Nie et al., 2026). A transformer-based mask predictor, trained on finite samples from p⋆, can estimate these conditional marginals for all masked positions in a single forward pass. This enables parallel token generation and breaks the sequential bottleneck of autoregressive models. However, sampling tokens independently given the same context ignores dependencies among simultaneously generated tokens. The output of an MDM thus carries two errors: a parallelization error, which persists even with exact marginals, and an estimation error, because the mask predictor is learned from finite samples.
Despite the empirical success of MDMs, their end-to-end sampling guarantees remain largely unexplored, as existing theory typically treats training and sampling separately. One line of work takes the mask predictor as given, either exact or with a prescribed error. Li and Cai (2025) derived a sampling error bound for parallel generation with a fixed-cardinality unmasking schedule via information-theoretic measures, and Zhao and Cai (2026), Dmitriev et al. (2026a) and Wainwright (2026) developed unmasking schedules that exploit intrinsic data complexity. In addition, Cai and Li (2026) established the sampling guarantees of confidence-based unmasking. However, these works do not characterize the statistical cost of learning the mask predictor.
Another line of work studies finite-sample score estimation for discrete diffusion models. Wakasugi and Suzuki (2026) obtained sampling guarantees independent of the full sequence-state size VL, where V is the vocabulary size and L is the sequence length, under continuous embedding assumptions, but their analysis excludes MDMs. For MDMs, Zhang et al. (2026) and Cho and Wu (2026) derived sampling guarantees governed by the target support size and the full-sequence size VL, respectively. Such bounds do not consider the transformer architectures that enable parallel sampling in practice, and can remain exponential in the sequence length even when the data admit a compact latent representation, thus suffering from the curse of dimensionality. These analyses offer limited insight into the empirical success of transformer-based MDMs on structured data.
Filling this gap requires an end-to-end analysis that connects the statistical cost of learning a transformer-based mask predictor to the accuracy of parallel generation, with guarantees that capture latent structure in the data. The dependencies observed in text and biological sequences (Chiu and Rush, 2020; Frazer et al., 2021) motivate studying distributions with compact latent representations. Such distributions can nevertheless assign positive probability to all VL sequences, so bounds governed by the support size can remain exponential in L, obscuring the potential statistical benefits of latent structure. This leads to our central question:
How many training samples does a transformer-based MDM need to sample accurately from p⋆, and how does this number depend on the latent structure of the data?
1.1 Main contributions
In this work, we establish end-to-end statistical guarantees for transformer-based MDMs, connecting the finite-sample learning of the mask predictor to the KL accuracy of the generated distribution.
To overcome the curse of dimensionality, we model low-dimensional structure by mixtures of hidden Markov trees, which capture structured latent dependence within each component and heterogeneity across components. In particular, the data distribution need not belong to this class exactly.
When the data distribution is approximated by such a model and the parallelization error is sufficiently small, we show that a transformer-based MDM achieves ε-accurate sampling in KL divergence with
O(LKpar/ε)(1)
training samples. Here, L is the sequence length and the structural complexity Kpar is polynomial in the sequence length, vocabulary size V, number of hidden states, and number of components, rather than scaling with the size VL of the sequence space. Moreover, the transformer architecture for the mask predictor and the parallel sampling procedure require no prior knowledge of the tree topologies or component parameters, so the MDM adapts to the unknown latent structure of the data.
To the best of our knowledge, these are the first end-to-end statistical guarantees for transformer-based MDMs that cover both mask-predictor estimation and parallel unmasking while adapting to latent structure, providing theoretical support for the effectiveness of MDMs on structured data.
1.2 Related work
Sample complexity for diffusion models. For discrete diffusion models, Wakasugi and Suzuki (2026) analyzed ReLU-based score estimation networks and derived rates governed by smoothness and dimension in a continuous embedding space. However, their analysis based on the symmetric-transition structure excludes MDMs. Zhang et al. (2026) analyzed uniform discrete diffusion models and MDMs using empirical kernel-based score estimators and derived sampling guarantees dependent on the support size of the target distribution for MDMs. Cho and Wu (2026) established minimax lower bounds for score estimation and nearly matching upper bounds using an MLE-based score estimator, with score estimation error dependent on the full sequence-space size VL. Srikanth et al. (2025) established KL sampling guarantees when applying neural score estimators trained by stochastic gradient descent (SGD) under regularity conditions. For continuous diffusion models, existing work established statistical guarantees for distributions with smooth densities and showed that diffusion models can achieve minimax-optimal sampling (Oko et al., 2023; Wibisono et al., 2024; Dou et al., 2024; Zhang et al., 2024; Cai and Li, 2025). Furthermore, statistical guarantees have been established for learning distributions with low-dimensional structure (Chen et al., 2023; Azangulov et al., 2024; Tang and Yang, 2024; Fan et al., 2025; Wu and Cai, 2026a).
Convergence theory for discrete diffusion models. For MDMs, even with exact conditional marginals, parallel unmasking introduces error by sampling conditionally dependent tokens independently. Li and Cai (2025) and Chen et al. (2025) characterized this error using information-theoretic measures, while Zhao and Cai (2026) and Dmitriev et al. (2026a) developed unmasking schedules that adapt to intrinsic data complexity. Lavenant and Zanella (2025) and Secchi and Zanella (2026) studied schedule optimization through information-theoretic measures, with the latter analyzing the random block sizes induced by τ-leaping. Cai and Li (2026) analyzed entropy-based confidence decoding with exact conditional marginals. Beyond MDMs, Dmitriev et al. (2026b) established convergence guarantees governed by dual total correlation for uniform and remasking diffusion, while Chen and Wang (2026) obtained analogous guarantees for uniform and Gaussian diffusion and compared them with MDMs. These analyses assumed exact predictors or prescribed prediction errors without quantifying the finite-sample cost of learning the predictors.
Theoretical analysis of transformers. Recent papers study both the approximation capabilities and statistical guarantees of transformers. Yun et al. (2019) established approximation theory for continuous permutation equivariant sequence-to-sequence functions, while Li et al. (2025) developed approximation guarantees for in-context learning over general function classes. For diffusion transformers (DiTs), Fu et al. (2025) derived score approximation theory and estimation guarantees for Gaussian process data. Hu et al. (2024, 2025) studied latent and conditional diffusion models, deriving corresponding approximation theory and statistical guarantees. For next-token prediction, Yüksel and Flammarion (2025) analyzed generalization error for self-attention predictors, and Kong et al. (2026) obtained generalization bounds for transformers under an extended log-bilinear language model.
1.3 Notation
For a,b∈R, write a∨b:=max{a,b} and a∧b:=min{a,b}. For a positive integer M, let [M]:={1,⋯,M}. Let 1{⋅} denote the indicator function. For x∈Rd, define ∥x∥p as its p-norm, i.e., ∥x∥p:=(∑i=1d∣xi∣p)1/p, and write ∥x∥∞:=maxi∣xi∣. We further define ∥x∥0 by ∥x∥0:=∑i∈[d]1{xi=0}. For W⊆[d], let xW:=(xi)i∈W. When used as a predictor input, xW denotes the length-L sequence retaining x on W and containing masks elsewhere. For any matrix A∈Rm×n, denote its i-th row, j-th column and Frobenius norm by Ai,:, A:,j and ∥A∥F, respectively. We denote by supp(p) the support of a probability distribution p. We use polylog(⋅) to denote an unspecified polynomial in the logarithm of its arguments. For positive functions f,g, write f(n)≲g(n) or f(n)=O(g(n)) if f(n)≤Cg(n) for some universal constant C>0. The notation O denotes the respective bounds up to some logarithmic factors.
2 Preliminaries
2.1 Masked diffusion models
Let V denote the vocabulary set with ∣V∣=V, and let L∈N+ be the sequence length. Denote M∈/V as the mask symbol, and define the extended vocabulary V:=V∪{M}.
Forward masking process. Given a token sequence X=(X1,…,XL)∼p∗ on VL, consider a fixed-cardinality masking schedule s=(s1,…,sT) satisfying st∈N+ and ∑t=1Tst=L. Initialize M0=∅. At each step t∈[T], form a random set St by selecting st positions uniformly from [L]∖Mt−1 and then update by Mt=Mt−1∪St. The sequence X at time step t is corrupted by replacing the tokens at positions in Mt with M, while leaving other tokens unchanged. After step T, we have a fully masked sequence (M,…,M) with MT=[L].
Mask predictor training. For a masked sequence x∈VL, let W(x):={i∈[L]:xi=M} be the index set of unmasked positions. The target conditional marginal distributions are
To train the mask predictor that approximates these exact conditional distributions, draw τ∈[T] with P[τ=t]:=st/L, sample Mτ uniformly among subsets of [L] of size ∑t=1τst and set Wτ:=[L]∖Mτ. We define the per-sequence loss by
for any conditional mask predictor q=(qi)i=1L. Here xWτ is the corrupted sequence of x that replaces tokens outside Wτ with M. A mask predictor pθ,i is trained via (Shi et al., 2024; Sahoo et al., 2024)
θminR(pθ):=EX∼p⋆[ℓpθ(X)](4)
Define the excess risk
L(θ):=R(pθ)−R(p⋆),(5)
where R(p⋆) denotes the population loss evaluated at the true conditional marginals in (2). Minimizing L(θ) is equivalent to minimizing R(pθ). As shown in Lemma 5 in Appendix C.5, L(θ) corresponds to the averaged KL divergence between the true and predicted conditional distributions. Given n i.i.d. training samples {X(j)}j=1n∼p⋆, define the empirical risk and empirical risk minimizer (ERM) respectively by
Since the masking distribution is prescribed, we keep the expectation over (τ,Mτ) in the empirical loss. In practice, it can be evaluated exactly when tractable or approximated by Monte Carlo sampling independent of training data.
Sampling procedure. Given a mask predictor pθ and a fixed-cardinality unmasking schedule s=(s1,…,sT), initialize the sequence Y=(M,…,M) and the set of unmasked positions WT=∅. For iteration t=T,…,1, draw a random unmasking set St uniformly among the subsets of [L]∖Wt with size st, set Wt−1=Wt∪St, sample simultaneously and independently
Yi∼pθ,i(⋅∣YWt)fori∈St,(7)
and keep other tokens unchanged. Since ∑t=1Tst=L, the final iterate Y∈VL is fully unmasked and is the generated sample. We write pY∣S for its distribution to emphasize its dependence on the random unmasking sets S=(S1,…,ST).
2.2 Transformer structure for estimation
We specify the transformer structure (Vaswani et al., 2017) used for learning the mask predictor.
Transformer block. Each layer maps Z∈RL×D to RL×D, with each row containing the D-dimensional representation. A single head is defined by
Here Q,K,V∈RD×D denote query, key and value matrices, respectively; sigmoid activation σattn is applied entrywise. Combining M heads with a residual connection gives:
Sparse transformer architecture for mask predictor. We build the predictor function class by composing an input embedding, N transformer blocks, an output embedding and a clipped rowwise softmax.
Input embedding. For a masked sequence x∈VL, let E∈R(V+1)×D be its input embedding matrix, whose rows give the representations of each token v∈V in RD with V=∣V∣. Let P∈RL×D be the positional embedding matrix. The input embedding is defined by
Both matrices are trainable. We control the magnitude of the embedding vectors by some chosen parameter Rembed>0, i.e., maxi∈[L],v∈V∥Ev,+Pi,⋅∥2≤Rembed.
• N transformer blocks. For the l-th transformer block, collect its parameters as
θtf(l):=((Ql,m,Kl,m,Vl,m)m=1M,Wl,Ul),
and denote the corresponding block by T(l):=Tθtf(l). We successively apply N transformer blocks in (9):
Output embedding. We map the final hidden representation in RL×D to vocabulary logits RL×V using the output embedding matrix Wout∈RD×V:
OutEmbedWout(Z):=ZWout∈RL×V.
Clipped rowwise softmax. For a fixed chosen G>0, we clip each logit entrywise to [−G,0], i.e., Clip[−G,0](x):=max{−G,min{x,0}}, and apply softmax separately to each row:
Let Θ:=Θ(D,N,M,Dff,B,S;Rembed,G) consist of parameters θ:=(E,P,θtf,Wout) satisfying the sizes determined by D,N,M,Dff, the embedding bound Rembed above, with each trainable matrix having Frobenius norm at most B and at most S nonzero parameters in total.
The predictor returns a probability distribution at each masked position i in a single forward pass:
pθ,i(⋅∣x):=(TFθ(x))i,.(13)
We define its approximation error by εapprox(Θ):=minθ∈ΘL(θ).
3 Problem setup: mixtures of hidden Markov trees
Without structural assumptions, a distribution on VL has VL−1 parameters, and learning it can require a number of samples that grows with VL. To exploit low-dimensional structure, we introduce mixtures of hidden Markov trees (MHMTs) as an approximation class for p⋆, enabling statistical guarantees governed by the complexity of its latent representation.
A hidden Markov tree (HMT) is a latent-variable model that captures dependency structure (Crouse et al., 1998), extending a hidden Markov model (HMM) (Baum and Petrie, 1966) from a chain to a tree. An HMM associates each token position i∈[L] with a hidden state Zi∈[J], where J is the number of hidden states. The states form a Markov chain Z1→⋯→ZL, and, conditioned on these states, the tokens are generated independently, with each Xi depending only on Zi. An HMT allows the latent states to evolve along a tree instead of a chain, supporting more general dependence structures. And a mixture of hidden Markov trees (MHMT) further allows the tree topology and parameters to vary across components.
The MHMT class contains mixtures of HMMs, which capture sequential dependence and diversity in language models (Ypma and Heskes, 2002; Chiu and Rush, 2020; Zekri et al., 2024). In addition, they are widely used to capture biological dependencies in protein-DNA binding sites (Barash et al., 2003), gene modules (Li et al., 2019), and heterogeneous cell lineages (Mohammadi et al., 2022).
We now introduce the formal definition of MHMTs, following Meila and Jordan (2000).
Definition 1 (Dependence trees and tree distributions). Let T be a rooted tree structure on the vertex set [L], namely a connected, acyclic graph with a designated root o∈[L]. For each i∈[L]∖{o}, denote pa(i) as its unique parent, which represents the edge (i,pa(i)). Then the tree structure T can be specified as
T:={{o},(i,pa(i))i∈[L]∖{o}}.(14)
In particular, repeatedly following the parent map from any nonroot vertex reaches o after finite steps. We further denote T as the set of all trees on [L] and suppress its dependence on L.
For any discrete random vector Z=(Z1,⋯,ZL), we say that Z follows a tree distribution if there exists a dependence tree T∈T such that the law of Z admits the following factorization
Here the root o and parent map pa(i) correspond to tree structure T. We further say that pZ factorizes according to T.
Definition 2 (Mixture of hidden Markov trees). Let T be a rooted tree on the index set [L], with root o∈[L] and parent map pa(⋅) for nonroot vertices as in Definition 1. A J-state hidden Markov tree on T is a distribution q on VL of the form
Here, ν is the root-state distribution on [J]. For hidden state b∈[J], the transition kernel Ai(⋅,b) is a distribution on [J] for i=o, and the emission kernel Bi(⋅,b) is a distribution on V for i∈[L].
The class MJ,R consists of all mixtures of R such models:
q(x)=r=1∑Rπrqr(x)withπr≥0,r=1∑Rπr=1,
where each qr is a J-state hidden Markov tree with its own topology Tr, root distribution, transition kernels, and emission kernels.
The MHMT has a simple generative interpretation. We first draw a component label C∼π. Using the parameters of the selected component, we sample the root state Zo∼ν and then traverse the tree from the root, drawing Zi∼Ai(⋅,b) given that its parent is in state b. Finally, each token is sampled independently as Xi∼Bi(⋅,a) given Zi=a. An HMM is recovered when the tree is a chain with o=1 and pa(i)=i−1. More general trees allow direct dependencies between hidden states at nonadjacent sequence positions, providing a flexible representation of dependence among tokens beyond a sequential latent chain.
Remark 1 (Why mixtures?). For fixed component topologies, a distribution in the class MJ,R has O(RLJ(J+V)) parameters. This representation complexity can be much smaller than the support size: even a single component with strictly positive emission kernel has full support on VL. Consequently, guarantees that scale with the support size may incur a dependence on VL, even when the distribution admits a compact representation with small J and R. Mixtures enrich this representation by allowing components to differ in tree topology, transitions, and emissions (Meila and Jordan, 2000), while increasing the parameter count only linearly in R. To illustrate this, suppose that all components share a common tree topology. The mixture can then be represented as a single HMT with RJ states with block diagonal transition matrices. This structure requires only O(LRJ2) transition parameters, reduced from O(LR2J2) for a generic RJ-state HMT with dense transitions.
Approximation of low-dimensional data. We focus on the distribution p∗ that is close to the MHMT class MJ,R, allowing departures from exact tree-mixture structure. Misspecification enters through the following approximation error.
Definition 3 (KL approximation error). Let F be a class of probability distributions on VL. For any distribution p on VL, define the KL approximation error w.r.t. F by
ProjF(p):=q∈FinfDKL(p∥q).(17)
In particular, we write ProjJ,R:=ProjMJ,R for the MHMT class MJ,R.
The quantity ProjJ,R(p⋆) measures how well p⋆ can be approximated by a mixture of RJ-state hidden Markov tree models. The pair (J,R) indexes the approximation class used in our analysis and is not an input to the training algorithm once the transformer architecture is fixed. Increasing J or R can reduce the approximation error at the cost of greater model complexity.
4 Main results: statistical guarantees for MDMs
In this section, we first develop estimation error bounds for the transformer mask predictor learned by ERM, and then establish end-to-end sampling guarantees for the resulting MDM-based sampler.
4.1 Learning the mask predictor
Fix integers n,L,V≥3 and J,R≥1. Let s=(s1,⋯,sT) be a fixed-cardinality unmasking schedule with smax:=maxst. We use the same schedule s for training and inference.
Recall from Section 2 that the ERM θ minimizes the empirical masked-token negative log-likelihood in (6), and the excess risk L(θ):=R(pθ)−R(p⋆) in (5), where R(q)=EX∼p⋆[ℓq(X)] and ℓq is defined in (3), equals the average KL divergence between the true and predicted conditionals of masked tokens.
The following theorem controls this estimation error of the transformer mask predictor learned by ERM. The proof can be found in Section 5.1.
Theorem 1 (Estimation error of mask predictor). There exists a transformer class Θ of the form (12), with an architecture depending only on (n,L,V,J,R) (specified in Proposition 4 with δ=ε=1/n), such that for any distribution p⋆ on VL, the ERM θ over Θ computed from n i.i.d. samples drawn from p⋆ satisfies
Here, C1>0 is a universal constant, the expectation is over training samples, and
Kpar:=R[LJ(J+V)+J3].(19)
The two terms in the error bound (18) have distinct roles. The first term captures the approximation error of p∗ by the MHMT class MJ,R, and the factor smax/L converts the joint KL error into a per-token one. The second term corresponds to the statistical error due to finite-sample training. The network has a polylogarithmic number of transformer blocks, at most 2R attention heads, and O~(Kpar) nonzero parameters, so the statistical term is a parameter count over the sample size n.
When the number of hidden states is moderate in the sense that J≲LV, where L is the sequence length and V is the vocabulary size, Kpar=O(RLJ(J+V)) is of the same order as the number of parameters of MJ,R (see Section 3). Up to logarithmic factors, the statistical error is thus governed by this intrinsic complexity rather than by the ambient dimension VL−1. Since the architecture depends only on (n,L,V,J,R), this holds without knowledge of the trees, parameters, or latent states of the approximating mixture. The transformer adapts to the unknown latent structure.
Remark 2. Theorem 1 applies to arbitrary tree structures. When latent dependencies are organized into only a few hierarchical levels, component trees of bounded height provide a natural model. For such structure, Appendix E gives a complementary construction for approximation and the resulting estimation and sampling guarantees. Its architectural budgets replace the J3 complexity term with J2, with depth proportional to the tree height.
4.2 End-to-end sampling guarantees
Recall from Section 2 a T-step MDM sampler with a fixed-cardinality unmasking schedule s=(s1,…,sT). It outputs a sequence Y in VL by iteratively unmasking tokens in the index set St in parallel according to a mask predictor pθ at step t, where St with size ∣St∣=st is a random subset of the currently masked positions.
To isolate the effect of parallel sampling, let Y∗ denote the output of the same MDM sampler when the exact conditional marginals of p∗ are used as the mask predictor. Define the parallelization error
εparall(p⋆;s):=ES[DKL(p⋆∥pY⋆∣S)],(20)
where the expectation is over the random unmasking sets S=(S1,…,ST) with ∣St∣=st.
We now present an end-to-end sampling guarantee for the MDM-based sampling. The proof can be found in Appendix B.
Theorem 2 (End-to-end sampling error of MDM). Assume the conditions and adopt the notation of Theorem 1. Let pY∣S denote the output distribution of the T-step MDM sampler using the ERM-based mask predictor pθ and the realized unmasking sets S=(S1,…,ST) with ∣St∣=st. Then for any 1≤T≤L, one has
where C2>0 is a universal constant, and the expectation is over the training samples and random unmasking sets S.
To the best of our knowledge, this is the first end-to-end guarantee for transformer-based MDMs that considers both parallelization error due to parallel sampling and finite-sample estimation error of the mask predictor. Moreover, the guarantee is adaptive to the low-dimensional structure of the data distribution p⋆.
The last two terms in the bound (21) are inherited from the estimation error of the mask predictor in Theorem 1, multiplied by L to convert the per-token KL error into a joint KL error. They capture the impact of finite-sample mask predictor training on the end-to-end sampling error. The first term εparallel(p⋆;s) captures the parallelization error due to simultaneous sampling of multiple tokens that ignore their dependencies, which depends only on the data distribution p⋆ and the unmasking schedule s used in the inference stage.
Remark 3 (Parallelization error). Recent sampling analyses (Li and Cai, 2025; Wainwright, 2026) characterize the parallelization error εparallel(p⋆;s) in terms of the information-theoretic structure of the data distribution p⋆ and the unmasking schedule s. For instance, as shown in Chen et al. (2025), for any T=Ω(logL), there exists a schedule sDTC depending only on (L,T)2 such that
εparall(p⋆;sDTC)≤T6log(eL)DTC(p⋆).(22)
Here dual total correlation (DTC) is defined as
DTC(p⋆):=H(X)−i=1∑LH(Xi∣X[L]∖{i}),
where X∼p⋆ and H denotes the entropy. In particular, DTC can be substantially smaller than the sequence length L for structured data distributions, e.g., an MHMT with star-shaped components satisfies DTC(p⋆)≤log(RJ). We refer to Chen et al. (2025), Dmitriev et al. (2026a) and Zhao and Cai (2026) for further discussion of distributions with small TC and DTC.
We now discuss several important implications of Theorem 2.
• Fast and data-efficient sampling for structured data. Assume that p⋆∈MJ,R, i.e., the data distribution is exactly a mixture of RJ-state hidden Markov trees. Use sDTC from Remark 3 with T steps. Then Theorem 2 yields
for T≳logL. As a result, when the latent space is small compared to the vocabulary size and length, i.e., J≲min{V,LV}, to generate a sample that is ε-close to p⋆ in KL divergence, it suffices to take
This shows that the MDM can achieve sampling acceleration and avoid the curse of dimensionality in sample complexity when the data distribution has low-dimensional latent structure. For instance, when p⋆ is a mixture of R star-shaped HMTs with J hidden states, DTC(p⋆)≤log(RJ), and the number of iterations scales logarithmically in (R,J), up to logarithmic dependence on the sequence length L. The number of training samples scales polynomially with (L,V,J,R). This shows that the MDM can efficiently learn and sample from structured data distributions.
2The original construction in Chen et al. (2025) requires an estimate of DTC. A straightforward modification yields a schedule that depends only on (L,T) with the same guarantees. For completeness, we present the construction sDTC in Appendix G.
• Adaptation to low-complexity structure. The architecture in Theorems 1–2 depends only on (n,L,V,J,R), not on p∗ or on the latent variables, trees, and parameters, none of which are observed. One network class approximates the masked-token conditionals of every q∈MJ,R uniformly. In this sense, transformer-based MDMs adapt to the unknown latent structure, with (J,R) acting as budget parameters that trade approximation against estimation.
• Handling non-exact MHMT structure. By Theorem 2, for general data distributions p∗ that do not exactly belong to the MHMT class MJ,R, to achieve ε-sampling accuracy, the sample complexity polynomially scales with the parameters (J,R) that ensure ProjJ,R(p∗)≲ε/smax.
The following two examples show that the required (J,R) can be chosen to scale with low-dimensional structure of the data distribution, rather than the ambient state-space size VL. The detailed discussions and proofs are deferred to Appendix A.
Continuous latent representation. Suppose that the data distribution satisfies
p⋆(x)=∫[0,1]ki=1∏Lpi(xi∣z)μ(dz),
for a latent distribution μ on [0,1]k, where the kernels pi(⋅∣z) are smooth in z in the sense that for some α∈(0,1], DKL(pi(⋅∣z)∥pi(⋅∣z′))≤A2∥z−z′∥22α for i∈[L] and z,z′∈[0,1]k. This covers quantized Lipschitz decoders with independent Gaussian observation noise (Dmitriev et al., 2026a). Discretizing μ onto a grid of size R gives a mixture of R product distributions with ProjJ,R(p⋆)≤kαLA2R−2α/k for any J≥1, so
R≳(ε−1kαA2smaxL)k/(2α)⟹ProjJ,R(p⋆)≤ε/smax.
So the component count is governed by the latent dimension k and independent of V.
Low Rényi entropy. For α∈(0,1), the Rényi entropy Hα(p):=1−α1log∑x∈VLpα(x) is small when p concentrates its mass on few points. In particular, Hα(p)↑log∣supp(p)∣ as α→0. For any integer R≥2 and J≥1, one can show that ProjJ,R(p⋆)≤LlogV(eHα(p⋆)/R)(1−α)/α, that is,
So the component count is controlled by the Rényi entropy and LlogV.
5 Analysis
In this section, we prove Theorem 1. Recall the definition of L(θ)=R(pθ)−R(p⋆) in (5), where R(q):=EX∼p⋆[ℓq(X)] and ℓq is defined in (3). The estimation error can be decomposed as
• Statistical error. The statistical error is governed by the properties of the loss and the capacity of the mask predictor class. Using localization techniques (Bartlett et al., 2005; Koltchinskii, 2006), the following proposition bounds the total excess risk by the approximation error and a statistical term determined by the capacity of the predictor class.
Proposition 1 (Statistical error). Assume n,V≥3. Let Θ=Θ(D,N,M,Dff,B,S;Rembed,G) be the parameter class in Section 2.2 with D,N,M,Dff≥1, and B,Rembed,G>0. Define
as the number of parameters in this function class and suppose the sparsity 1≤S≤Ptr is an integer. There exists a constant ATF≥e, depending only on N, M, B, Rembed, satisfying
logATF≤CN2log(eNM(B∨1)(Rembed∨1)),
such that
E[L(θ)]≲εapprox(Θ)+(G+logV)⋅nC(Θ)log(en)+1.(26)
Here the capacity of Θ satisfies
C(Θ):=S[logSePtr+logATF],
θ is the ERM estimator in (6) and the expectation is taken over training data {X(j)}j=1n.
Its proof can be found in Appendix C.3.
Approximation error. We next control the approximation error by explicitly constructing sparse transformer predictors.
Proposition 2 (Tree-mixture approximation). Fix integers L,V≥2, J,R≥1, 0<δ,ε≤1/2, and a masking schedule s=(s1,⋯,sT) with smax:=maxt∈[T]st, as in Section 2. There exists a sparse transformer class Θ, with architectural budgets depending only on (L,V,J,R,δ,ε), such that
Its architectural budgets are given in Proposition 4. The proof of Proposition 2 is given in Appendix D.5. The key idea is to first construct a transformer-based mask predictor for a single hidden Markov tree structure, where the contraction idea (Miller and Reif, 1985) enables us to build it within O(logL) transformer blocks. Then we extend it to mixtures by using the posterior mixture weights computed from the context.
5.1 Proof of Theorem 1
Now we are ready to prove Theorem 1. Take the parameter class Θ in Proposition 4 with δ=ε=n1, Rembed=3 and G=Gδ=log(nV). Let
Recall from Section 2.2 that N is the number of transformer blocks, M is the number of attention heads, and D, Dff are the embedding dimension and feed-forward hidden width, respectively. The sparsity budget S bounds the total number of nonzero parameters, while B bounds the Frobenius norm of each parameter matrix. Finally, Rembed bounds the row norms of the embedded inputs, and G determines the logit clipping interval [−G,0].
The expectation is over the i.i.d. training data {X(i)}i=1n∼p⋆. In the last inequality, we use (28)–(29), log(en)≤β, and smax≤L≤Kpar. This proves Theorem 1.
6 Discussion
This paper studies the sample complexity of masked diffusion models (MDMs) for learning distributions with low-complexity structure, measured by their approximation through mixtures of hidden Markov tree models. We establish end-to-end sampling guarantees whose statistical error depends on the structural complexity poly(L, V, J, R), rather than the size of the sequence space VL. Using the prescribed architectural parameters, our transformer predictor adapts to the unknown latent structure through the training objective on observed data. These results help explain why transformer-based MDMs perform well in learning distributions with structural dependence.
Several directions remain open. First, extending the analysis beyond mixtures of hidden Markov trees would accommodate more general dependence structures, including latent graphic models with cycles. A key challenge is to identify structures that capture dependencies arising in practice while admitting efficient approximation of conditional marginals by transformers. Second, confidence-based unmasking has shown strong empirical performance in diffusion language models, improving generation quality and enabling efficient parallel decoding (Wu et al., 2026). Establishing statistical guarantees for such decoding strategies would clarify how predictor estimation errors affect adaptive token selection and the resulting sampling accuracy. Such an analysis must account for both the effect of prediction errors on the unmasking decisions and the mismatch between the masking patterns used during training and those encountered during adaptive sampling. Third, incorporating optimization error would further help bridge the gap between our theoretical guarantees and practical training. Our analysis assumes access to the ERM estimator, whereas practical training performs finitely many parameter updates using algorithms such as AdamW (Loshchilov and Hutter, 2017) and Muon (Liu et al., 2025). Extending the guarantees to approximately optimized predictors would clarify how optimization accuracy affects the final sampling error and inform the allocation of computational resources between training and sampling.
Acknowledgements
C. Cai is supported by the NSF CAREER Award CCF-2541600 and the NSF grant DMS-2515333.
References
Austin, J., Johnson, D. D., Ho, J., Tarlow, D., and Van Den Berg, R. (2021). Structured denoising diffusion models in discrete state-spaces. Advances in Neural Information Processing Systems, 34:17981–17993.
Azangulov, I., Deligiannidis, G., and Rousseau, J. (2024). Convergence of diffusion models under the manifold hypothesis in high-dimensions. arXiv preprint arXiv:2409.18804.
Barash, Y., Elidan, G., Friedman, N., and Kaplan, T. (2003). Modeling dependencies in protein-dna binding sites. In Proceedings of the seventh annual international conference on Research in computational molecular biology, pages 28–37.
Bartlett, P. L., Bousquet, O., and Mendelson, S. (2005). Local rademacher complexities.
Baum, L. E. and Petrie, T. (1966). Statistical inference for probabilistic functions of finite state markov chains. The annals of mathematical statistics, 37(6):1554–1563.
Cai, C. and Li, G. (2025). Minimax optimality of the probability flow ode for diffusion models. arXiv preprint arXiv:2503.09583.
Cai, C. and Li, G. (2026). Confidence-based decoding is provably efficient for diffusion language models. arXiv preprint arXiv:2603.22248.
Campbell, A., Benton, J., De Bortoli, V., Rainforth, T., Deligiannidis, G., and Doucet, A. (2022). A continuous time framework for discrete denoising models. Advances in Neural Information Processing Systems, 35:28266–28279.
Chen, M., Huang, K., Zhao, T., and Wang, M. (2023). Score approximation, estimation and distribution recovery of diffusion models on low-dimensional data. In Krause, A., Brunskill, E., Cho, K., Engelhardt, B., Sabato, S., and Scarlett, J., editors, Proceedings of the 40th International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, pages 4672–4712. PMLR.
Chen, S., Chewi, S., Li, J., Li, Y., Salim, A., and Zhang, A. R. (2022). Sampling is as easy as learning the score: theory for diffusion models with minimal data assumptions. arXiv preprint arXiv:2209.11215.
Chen, S., Cong, K., and Li, J. (2025). Optimal inference schedules for masked diffusion models. arXiv preprint arXiv:2511.04647.
Chen, S. and Wang, L. (2026). Parallelism, critical windows, and separations among diffusion language models. arXiv preprint arXiv:2609.20539.
Chiu, J. and Rush, A. M. (2020). Scaling hidden markov language models. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), pages 1341–1349.
Cho, C. and Wu, Y. (2026). Minimax optimality of score-entropy discrete diffusion. arXiv preprint arXiv:2608.20635.
Crouse, M. S., Nowak, R. D., and Baraniuk, R. G. (1998). Wavelet-based statistical signal processing using hidden markov models. IEEE Transactions on signal processing, 46(4):886–902.
Dmitriev, D., Huang, Z., and Wei, Y. (2026a). Efficient sampling with discrete diffusion models: Sharp and adaptive guarantees. arXiv preprint arXiv:2602.15008.
Dmitriev, D., Huang, Z., and Wei, Y. (2026b). Provably adaptive sampling with uniform and remasking discrete diffusion models. arXiv preprint arXiv:2608.23554.
Dou, Z., Kotekal, S., Xu, Z., and Zhou, H. H. (2024). From optimal score matching to optimal sampling. arXiv preprint arXiv:2409.07032.
Fan, J., Gu, Y., and Li, X. (2025). Optimal estimation of a factorizable density using diffusion models with relu neural networks. arXiv preprint arXiv:2510.03994.
Frazer, J., Notin, P., Dias, M., Gomez, A., Min, J. K., Brock, K., Gal, Y., and Marks, D. S. (2021). Disease variant prediction with deep generative models of evolutionary data. Nature, 599(7883):91–95.
Fu, H., Dou, Z., Guo, J., Wang, M., and Chen, M. (2025). Diffusion transformer captures spatial-temporal dependencies: A theory for gaussian process data. In International Conference on Learning Representations, volume 2025, pages 18650–18700.
Gong, S., Zhang, R., Zheng, H., Gu, J., Jaitly, N., Kong, L., and Zhang, Y. (2026). Diffucoder: Understanding and improving masked diffusion models for code generation. In International Conference on Learning Representations, volume 2026, pages 15723–15750.
Ho, J., Jain, A., and Abbeel, P. (2020). Denoising diffusion probabilistic models. Advances in neural information processing systems, 33:6840–6851.
Hoogeboom, E., Nielsen, D., Jaini, P., Forré, P., and Welling, M. (2021). Argmax flows and multinomial diffusion: Learning categorical distributions. Advances in neural information processing systems, 34:12454–12465.
Hu, J. Y.-C., Wu, W., Lee, Y.-C., Huang, Y.-C., Chen, M., and Liu, H. (2025). On statistical rates of conditional diffusion transformers: Approximation, estimation and minimax optimality. In International Conference on Learning Representations, volume 2025, pages 12591–12675.
Hu, J. Y.-C., Wu, W., Li, Z., Pi, S., Song, Z., and Liu, H. (2024). On statistical rates and provably efficient criteria of latent diffusion transformers (dits). Advances in Neural Information Processing Systems, 37:31562–31628.
Koltchinskii, V. (2006). Local rademacher complexities and oracle inequalities in risk minimization.
Kong, I., Dexheimer, N., and Schmidt-Hieber, J. (2026). Generalization bounds for transformer-based next-token prediction in a language model. arXiv preprint arXiv:2606.13280.
Lavenant, H. and Zanella, G. (2025). Error bounds and optimal schedules for masked diffusions with factorized approximations. arXiv preprint arXiv:2510.25544.
Li, G. and Cai, C. (2025). Breaking ar's sampling bottleneck: Provable acceleration via diffusion language models. Advances in Neural Information Processing Systems, 38:11700–11725.
Li, G., Jiao, Y., Huang, Y., Wei, Y., and Chen, Y. (2025). Transformers meet in-context learning: A universal approximation theory. arXiv preprint arXiv:2506.05200.
Li, Y., Ning, S., Calvo, S. E., Mootha, V. K., and Liu, J. S. (2019). Bayesian hidden markov tree models for clustering genes with shared evolutionary history.
Liu, J., Su, J., Yao, X., Jiang, Z., Lai, G., Du, Y., Qin, Y., Xu, W., Lu, E., Yan, J., et al. (2025). Muon is scalable for llm training. arXiv preprint arXiv:2502.16982.
Loshchilov, I. and Hutter, F. (2017). Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101.
Lou, A., Meng, C., and Ermon, S. (2023). Discrete diffusion modeling by estimating the ratios of the data distribution. arXiv preprint arXiv:2310.16834.
Meila, M. and Jordan, M. I. (2000). Learning with mixtures of trees. Journal of Machine Learning Research, 1(Oct):1–48.
Meng, C., Choi, K., Song, J., and Ermon, S. (2022). Concrete score matching: Generalized score matching for discrete data. Advances in Neural Information Processing Systems, 35:34532–34545.
Miller, G. L. and Reif, J. H. (1985). Parallel tree contraction and its application. In FOCS, volume 26, pages 478–489.
Mohammadi, F., Visagan, S., Gross, S. M., Karginov, L., Lagarde, J., Heiser, L. M., and Meyer, A. S. (2022). A lineage tree-based hidden markov model quantifies cellular heterogeneity and plasticity. Communications Biology, 5(1):1258.
Nie, S., Zhu, F., You, Z., Zhang, X., Ou, J., Hu, J., Zhou, J., Lin, Y., Wen, J.-R., and Li, C. (2026). Large language diffusion models. Advances in Neural Information Processing Systems, 38:50608–50646.
Oko, K., Akiyama, S., and Suzuki, T. (2023). Diffusion models are minimax optimal distribution estimators. In International Conference on Machine Learning, pages 26517–26582. PMLR.
Ou, J., Nie, S., Xue, K., Zhu, F., Sun, J., Li, Z., and Li, C. (2025). Your absorbing discrete diffusion secretly models the conditional distributions of clean data. In International Conference on Learning Representations, volume 2025, pages 64972–65009.
Sahoo, S. S., Arriola, M., Schiff, Y., Gokaslan, A., Marroquin, E., Chiu, J. T., Rush, A., and Kuleshov, V. (2024). Simple and effective masked diffusion language models. Advances in Neural Information Processing Systems, 37:130136–130184.
Secchi, C. and Zanella, G. (2026). Schedule optimization for tau-leaping in masked discrete diffusion. arXiv preprint arXiv:2609.21960.
Shi, J., Han, K., Wang, Z., Doucet, A., and Titsias, M. (2024). Simplified and generalized masked diffusion for discrete data. Advances in neural information processing systems, 37:103131–103167.
Song, Y., Sohl-Dickstein, J., Kingma, D. P., Kumar, A., Ermon, S., and Poole, B. (2020). Score-based generative modeling through stochastic differential equations. arXiv preprint arXiv:2011.13456.
Srikanth, A., Gaur, M., and Aggarwal, V. (2025). Discrete state diffusion models: A sample complexity perspective. arXiv preprint arXiv:2510.10854.
Tang, R. and Yang, Y. (2024). Adaptivity of diffusion models to manifold structures. In Dasgupta, S., Mandt, S., and Li, Y., editors, Proceedings of The 27th International Conference on Artificial Intelligence and Statistics, volume 238 of Proceedings of Machine Learning Research, pages 1648–1656. PMLR.
Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., and Polosukhin, I. (2017). Attention is all you need. Advances in neural information processing systems, 30.
Wainwright, M. J. (2026). The data geometry of masking diffusion: Certified-optimal schedules via unmasking growth complexity. arXiv preprint arXiv:2608.13520.
Wakasugi, S. and Suzuki, T. (2026). State size independent statistical error bound for discrete diffusion models. Advances in Neural Information Processing Systems, 38:138908–138943.
Wang, X., Zheng, Z., Ye, F., Xue, D., Huang, S., and Gu, Q. (2024). Diffusion language models are versatile protein learners. arXiv preprint arXiv:2402.18567.
Wibisono, A., Wu, Y., and Yang, K. Y. (2024). Optimal score estimation via empirical bayes smoothing. In Agrawal, S. and Roth, A., editors, Proceedings of Thirty Seventh Conference on Learning Theory, volume 247 of Proceedings of Machine Learning Research, pages 4958–4991. PMLR.
Wu, C., Zhang, H., Xue, S., Liu, Z., Diao, S., Zhu, L., Luo, P., Han, S., and Xie, E. (2026). Fast-dllm: Training-free acceleration of diffusion llm by enabling kv cache and parallel decoding. In International Conference on Learning Representations, volume 2026, pages 57027–57051.
Wu, J. and Cai, C. (2026a). Diffusion models are statistically optimal for learning low-dimensional multimodal distributions. arXiv preprint arXiv:2605.30153.
Wu, J. and Cai, C. (2026b). Neural network-based diffusion models adapt to low-dimensional multi-modal data structure. In ICML 2026 Workshop on Foundations of Deep Generative Models: Understanding Memorization, Generalization, and Reasoning.
Ypma, A. and Heskes, T. (2002). Automatic categorization of web pages and user clustering with mixtures of hidden markov models. In International Workshop on Mining Web Data for Discovering Usage Patterns and Profiles, pages 35–49. Springer.
Yüksel, O. K. and Flammarion, N. (2025). On the sample complexity of next-token prediction. In AISTATS, pages 694–702.
Yun, C., Bhojanapalli, S., Rawat, A. S., Reddi, S. J., and Kumar, S. (2019). Are transformers universal approximators of sequence-to-sequence functions? arXiv preprint arXiv:1912.10077.
Zekri, O., Odonnat, A., Benechehab, A., Bleistein, L., Boullé, N., and Redko, I. (2024). Large language models as markov chains. arXiv preprint arXiv:2410.02724.
Zhang, K., Yin, C. H., Liang, F., and Liu, J. (2024). Minimax optimality of score-based diffusion models: Beyond the density lower bound assumptions. arXiv preprint arXiv:2402.15602.
Zhang, Z., Fu, H., Yang, Z., Wang, M., Zhao, T., and Chen, M. (2026). Generalization bounds for discrete diffusion: Statistical advantage of masking. In Forty-third International Conference on Machine Learning.
Zhao, Y. and Cai, C. (2026). Adaptation to intrinsic dependence in diffusion language models. arXiv preprint arXiv:2602.20126.
Zheng, K., Chen, Y., Mao, H., Liu, M.-Y., Zhu, J., and Zhang, Q. (2025). Masked diffusion models are secretly time-agnostic masked models and exploit inaccurate categorical sampling. In International Conference on Learning Representations, volume 2025, pages 63186–63227.
A Examples of low-complexity latent structure
In this appendix, we derive the bounds on ProjJ,R(p⋆) for the continuous latent representation and low Rényi entropy examples in Section 4.2.
A.1 Continuous latent representation
Lemma 1. Suppose that there exists a probability distribution μ on [0,1]k such that,
p⋆(x)=∫[0,1]ki=1∏Lpi(xi∣z)μ(dz),∀x∈VL(30)
We further assume that for some A≥0 and α∈(0,1], the kernel admits the following continuity condition:
Proof of Lemma 1. We approximate the latent variable by a finite grid. Let s=⌊R1/k⌋≥1, and partition [0,1]k into sk≤R cubes {Cj}j=1sk of side length 1/s, assigning their boundaries so that the cells are disjoint. Denote by zj the midpoint of Cj, and define
wj:=μ(Cj),qR(x):=j=1∑skwji=1∏Lpi(xi∣zj).
Since each component is a product distribution, qR∈M1,R. For z∈[0,1]k, let j(z) be the index of its cell. Consider the joint distributions
Here the last two inequalities control the maximum distance to the cell midpoint and s≥R1/k/2. Together with M1,R⊆MJ,R, this proves (32) with Ck,α=kα.
It remains to verify the sufficient condition (33). Let F(a):=log∑v=1Veav. For u=softmax(a), we have
Proof of Lemma 2. We maintain the R−1 largest atoms and approximate the remaining mass by a uniform distribution. Enumerate the points of VL as x(1),…,x(VL), with probabilities p(j):=p⋆(x(j)) in decreasing order. Set p(j)=0 for j>VL, and let
Sα:=j≥1∑p(j)α=e(1−α)Hα(p⋆),τR−1:=j≥R∑p(j).
If τR−1=0, then p⋆ is a mixture of at most R−1 point masses. Each point mass is a product distribution, so Proj1,R(p⋆)=0.
For τR−1>0, let u be the uniform distribution on VL, and define
Since Dirac measures and the uniform distribution are product distributions, qR∈M1,R. Furthermore, p⋆=∑j=1R−1p(j)δx(j)+τR−1v. By the convexity of KL divergence,
Combining this bound with τR−1≤1 and M1,R⊆MJ,R proves (34).
B Proof of Theorem 2
In this section, we decompose the sampling error into parallelization error and conditional prediction error following Li and Cai (2025), and then apply Theorem 1 to derive an end-to-end bound.
Fix the training samples and write θ=θ. Throughout this proof, pY∣S denotes the sampler distribution conditional on both the training sample and S, with the dependence on the training sample suppressed. Let pY∗∣S denote the analogous sampler distribution using the exact conditional marginals pi⋆. Recall the unmasking partition S=(S1,…,ST) and the unmasked index sets Wt in Section 2. Then it holds that
Averaging this first term over S gives εparall(p⋆;s). For the second term, let Mt:=[L]∖Wt and mt:=∑u=1tsu. Then Mt is uniform among subsets of [L] of size mt, and, conditioned on Mt, the set St is a uniform st-subset of Mt. Hence,
The last equality uses the conditional-KL representation of the excess risk L in Lemma 5, with training time distribution P[τ=t]=st/L. We therefore obtain the decomposition
ES[DKL(p⋆∥pY∣S)]=εparall(p⋆;s)+LL(θ).(35)
Finally, taking expectation over the training sample and applying Theorem 1 gives
In this appendix, we prove Proposition 1 by combining a localized oracle inequality with a covering-number bound for the transformer logit class. We first establish the localized oracle inequality for a general class of bounded logits under the masking loss from Section 2. We then control the capacity of the transformer class and prove Proposition 1.
To state the result beyond the transformer setting, we consider a general logit class F(Θ) of functions from VL to RL×V, parametrized by θ∈Θ and define its induced mask predictor class by:
Here, softmax is applied separately at each position i∈[L]. The empirical and population risks defined in Section 2 are evaluated at pθ∈PF(Θ). To characterize the capacity of F(Θ), we introduce the following metric.
Let N(η,F,d∞) denote the minimum number of radius- η balls needed to cover function class F under metric d∞. We impose the following boundedness and capacity conditions on the logit class to control the generalization error.
Assumption 1 (Logit class). Let F(Θ) be a logit function class on VL. Suppose that there exist constants G≥0 and C(Θ)≥1 such that
(i) Boundedness. For every θ∈Θ and any position i∈[L], token v∈V, it holds that −G≤Fθ,i,v(x)≤0 for any Fθ∈F(Θ) and any input x∈VL.
(ii) Capacity. For any η∈(0,1], the covering number satisfies
logN(η,F(Θ),d∞)≤C(Θ)log(e/η).
The boundedness condition implies that pθ∈PF(Θ) satisfies pθ,i,v≥e−G/V, so its tokenwise negative log-likelihood is bounded by MG:=G+logV. Together with the capacity bound, this allows us to apply the localization techniques (Bartlett et al., 2005; Koltchinskii, 2006) to obtain the following statistical guarantee.
Proposition 3 (Localized oracle inequality for a logit class). Fix integers n,V≥3, and a masking schedule s in Section 2.1. Suppose that F(Θ) satisfies Assumption 1 with parameters G and C(Θ), and let θ∈argminθ∈ΘRn(pθ) be an exact ERM estimator over the induced predictor class PF(Θ). Here the population excess risk is defined as L(θ):=R(pθ)−R(p⋆) for pθ∈PF(Θ). Let MG:=G+logV. Then
E[L(θ)]≲θ∈ΘinfL(θ)+MG⋅nC(Θ)log(en)+1.(38)
Here the expectation is taken over training data {X(j)}j=1n.
C.1 Proof of Proposition 3
Throughout the proof, the masking schedule s is fixed, and C denotes a universal constant that may change from line to line. We write εapprox(Θ):=infθ∈ΘL(θ) for the approximation error of the predictor class PF(Θ).
For a function g of a token sequence, write
Pg:=EX∼p⋆[g(X)],Png:=n1j=1∑ng(X(j)).
Recall that ℓpθ already averages over the masking randomness. Hence, Pn averages over the n independent training sequences. For ζ>0, choose θ∘∈Θ such that
a:=L(θ∘)≤εapprox(Θ)+ζ,hθ:=ℓpθ−ℓpθ∘.
By the definition of hθ and the ERM property,
Phθ=L(θ)−a,Pnhθ≤0.
We first bound the second moment of hθ and then control its empirical deviation.
Second-moment bound. Let MG=G+logV and ρ=e−MG. The bounded logits imply pθ,i(v∣x)≥ρ for every masked position and token. We claim that, for any probability vectors p,q on [V] with qv≥ρ,
Here the last inequality uses MG≥log3>1. To prove the first inequality, notice that
tlog2t≤(MG+2)(tlogt−t+1),∀0≤t≤eMG.
Indeed, for t=e−x≤1, the inequality ex≥1+x+x2/2 gives
e−xx2≤2⋅(1−(x+1)e−x).
For t=ex≥1, with 0≤x≤MG, we have
(x+2)(x−1+e−x)−x2=x−2+(x+2)e−x≥0,
since the last expression is zero at x=0 and has derivative 1−(x+1)e−x≥0. The case t=0 follows by continuity. Taking t=pv/qv, multiplying by qv, and summing over v proves (39).
Since 0≤ℓpθ≤MG, we have ∥hθ∥∞≤MG. Let τ and Mτ follow the training masking distribution, set Wτ=[L]∖Mτ, and let I be uniform in Mτ. Jensen's inequality gives
Here the expectation includes X∼p⋆ and (τ,Mτ,I). Conditioned on the context and I, the token XI has law pI⋆(⋅∣XWτ). Applying (39) and the conditional KL expression for L therefore yields
Phθ2≤6MG(L(θ)+a).(40)
Control of the empirical deviation. Let Fθ∈F(Θ) be the logit function associated with pθ through the rowwise softmax in (36). By the Lipschitz property of log-softmax,
∥hθ−hθ′∥∞=∥ℓpθ−ℓpθ′∥∞≤2d∞(Fθ,Fθ′).
For r > 0, define
H(r):={hθ:θ∈Θ,L(θ)≤r}.
The covering bound in Assumption 1 then implies
logN(η,H(r),∥⋅∥∞)≤C(Θ)logη8e,0<η≤1,
whenever H(r) is nonempty. To take the covering centers in H(r), choose one member from each ball intersecting this class and double the radius.
Let an:=C(Θ)log(cn) for a sufficiently large universal constant c≥2. Applying Lemma 4 with b=MG and σ2=6MG(r+a) gives, for fixed r,t>0,
We apply this bound at a sequence of increasing risk levels. Fix u>0 and set
r0:=4a+AMGnan+u,rj:=2jr0,j≥1,
where A is a sufficiently large universal constant. Taking r=rj and t=u+jlog2 in (41), and using ∑j≥1e−u−jlog2=e−u, all these bounds hold simultaneously with probability at least 1−e−u. Moreover,
Thus, pθ,i(⋅∣x)=softmax(Fθ,i.(x)). Recall the definition of d∞(F,F′) in (37).
Lemma 3 (Capacity of the sparse transformer class). Let Θ=Θ(D,N,M,Dff,B,S;Rembed,G) be the parameter class in Section 2.2, with D,N,M,Dff≥1 and B,Rembed,G>0. Define
and suppose the sparsity 1≤S≤Ptr is an integer. There exists a constant ATF≥e, depending only on N, M, B, Rembed, satisfying
logATF≤CN2log(eNM(B∨1)(Rembed∨1)),
such that, for every 0<η≤1,
logN(η,F(Θ),d∞)≤SlogSePtr+SlogηATF.(43)
Consequently, Assumption 1 holds with
C(Θ)=S[logSePtr+logATF].
The same covering bound holds for the probability-valued predictor class in the uniform distance:
x∈VLmaxi,vmax∣pθ,i(v∣x)−pθ′,i(v∣x)∣.
If S>Ptr, replace S by Ptr in these bounds.
Proof of Lemma 3. We first control the change in the logits under a perturbation of the parameters, and then cover the sparse parameter space. Write \|Z\|_2,_\infty := \max_i \|Z_i,_\|_2, and let dΘ(θ,θ′) be the largest Frobenius distance between corresponding parameter matrices, including E,P, and Wout. Set
B:=B∨1,R:=Rembed∨1,a:=eNMBR.
For ∥Z∥2,∞≤r, the bounded attention activation gives
Hence the attention layer maps the row radius r to at most (1+MB)r. The feed-forward layer multiplies this radius by at most 1+B2, since ReLU is one-Lipschitz and vanishes at zero. Denoting the hidden states by Hθ(ℓ)(x), with Hθ(0)(x)=EmbedE,P(x), we obtain
∥Hθ(ℓ)(x)∥2,∞≤Rembed[(1+MB)(1+B2)]ℓ≤acN,0≤ℓ≤N,
uniformly over x and θ∈Θ.
Next, let Δ:=dΘ(θ,θ′). The trainable embeddings satisfy
∥Hθ(0)(x)−Hθ′(0)(x)∥2,∞≤∥E−E′∥F+∥P−P′∥F≤2Δ.
For one attention head, the sigmoid activation is 1/4-Lipschitz. For inputs Z, Z′ with row norms at most r, we have
Since clipping is one-Lipschitz, taking the supremum over masked sequences yields
d∞(Fθ,Fθ′)≤ΛdΘ(θ,θ′),Λ:=acN2.
It remains to cover the parameters. The input and positional embeddings have (V+1)D+LD entries, each transformer block has 3MD2+2DDff entries, and the output embedding has DV entries. This gives the stated value of Ptr.
For a fixed support I⊆[Ptr] of size S, denote
ΘI:={θ∈Θ:supp(θ)⊆I}.
Ignoring the embedded-input constraint temporarily, the parameters on this support lie in a product of Frobenius balls of radius B, with total dimension S. Covering each ball at radius ζ/2 gives a product cover of size at most (1+4B/ζ)S in the maximum Frobenius distance. For each ball intersecting ΘI, choose one parameter from the intersection as its new center. The radius is then at most ζ, and every center satisfies all constraints, including the embedded-input bound. Consequently,
logN(ζ,ΘI,dΘ)≤Slog(1+ζ4B).
Every parameter with at most S nonzero entries belongs to one of these support classes. Taking the union over supports gives
Take ζ=η/Λ and ATF:=e(1+4BΛ). Transferring the parameter cover to the logits proves (43), and
logATF≤CN2log(eNM(B∨1)(Rembed∨1)).
Since ATF≥e and 0<η≤1, the covering bound is at most C(Θ)log(e/η). The logits already lie in [−G,0], so both parts of Assumption 1 hold.
Finally, softmax is one-Lipschitz in the maximum norm. Applying it rowwise therefore transfers the same cover to the predictor class. This completes the proof.
C.3 Proof of Proposition 1
Let Θ=Θ(D,N,M,Dff,B,S;Rembed,G) be the parameter class in Section 2.2, and let F(Θ) be its clipped logit class. Every logit entry lies in [−G,0], and Lemma 3 verifies Assumption 1 with
C(Θ)≤S[logSePtr+logATF].
The induced predictor class is exactly the class used in (6), so the corresponding ERM is θ and infθ∈ΘL(θ)=εapprox(Θ). Applying Proposition 3 proves Proposition 1:
E[L(θ)]≲εapprox(Θ)+(G+logV)nC(Θ)log(en)+1.
Here the expectation is taken over training data {X(j)}j=1n.
C.4 Localized empirical-process lemma
Lemma 4 (Localized bounds from a uniform cover). Let X(1),…,X(n) be independent samples from a distribution P, and write Pg:=E[g(X)] and Png:=n−1∑i=1ng(X(i)) for any function g. Let G be a nonempty function class with ∥g∥∞≤b and Pg2≤σ2 for every g∈G, where b≥1. Suppose v≥1, A≥e, and
logN(η,G,∥⋅∥∞)≤vlog(A/η),∀0<η≤1.
For n≥2, take dn:=vlog(cAn), for a universal c≥2. Then for t>0, with probability at least 1−e−t,
g∈Gsup(P−Pn)g≤C(σndn+t+nb(dn+t)).
Proof of Lemma 4. Take an internal 1/n-net {g1,…,gJnet}⊆G. If covering centers are initially outside the class, start with a 1/(2n)-cover and choose one element of each intersecting ball. Thus log(2Jnet)≤vlog(4An)≤dn after increasing c. All centers retain the variance and envelope bounds.
For the deviation assertion, the independent centered variables Pgj−gj(X(i)) have magnitude at most 2b and variance at most σ2. Bernstein's inequality and a union bound then give
with probability at least 1−e−t. Replacing a function by its net center changes (P−Pn)g by at most 2/n, which is absorbed in b(dn+t)/n.
C.5 Conditional-KL identity for excess risk
Lemma 5 (Per-token denoising loss is average conditional KL). Recall the definition of τ, Mτ and Wτ in Section 2.1. Conditioned on (τ,Mτ), draw I uniformly from Mτ. Then the excess risk L(θ) satisfies
Here R(pθ):=EX∼p⋆[ℓpθ(X)] is the risk of the conditional predictor pθ.
Proof of Lemma 5. Subtract the cross-entropy of the true conditional predictor from that of the network and introduce a conditionally uniform I∼Unif(Mτ). Then
Conditioned on (τ,Mτ,XWτ,I), the token distribution XI follows the law pI⋆(⋅∣XWτ). Taking the conditional expectation therefore gives the KL divergence in (44).
D Transformer approximation of conditionals
In this appendix, we prove Proposition 2 by constructing sparse transformers that approximate the conditional probabilities of mixtures of hidden Markov trees. Appendix D.1 introduces a regularization that preserves the tree-mixture structure and ensures positive conditional probabilities. Appendix D.2 further reduces the approximation error to uniform approximation of the regularized conditional logits. Appendix D.3 then constructs a transformer-based approximation under a single tree structure using parallel contraction and reconstruction, and Appendix D.4 combines these using posterior mixture weights. Appendix D.5 completes the proof of Proposition 2.
D.1 Regularization
Here we regularize distributions while preserving their tree-mixture structure. This gives positive conditional probabilities and bounded conditional log probabilities for the following transformer approximation.
Definition 4 ( δ-regularization). For 0<δ<1, define the regularization kernel Qδ(a,b):=(1−δ)1{a=b}+δ/V. For any distribution q on VL, define its δ-regularization by
Here qrδ=Pδqr is obtained by replacing the emission tables Bi,r with Bi,rδ as in (16). The root distributions, transitions, component trees, and mixture weights are unchanged.
(ii) For any distribution q on VL, any y∈VL, and any masked sequence c∈VL, it holds that:
Thus, regularization changes only the emission tables. By linearity, qδ=∑r=1Rπrqrδ∈MJ,R. Since (45) is defined using the observed law q, the resulting law does not depend on the chosen hidden-tree representation.
For part (ii), the bounds Qδ(a,b)≥ρδ and Qδ(a,a)≥1−δ imply
This proves the lemma. In particular, regularization also preserves any restriction on the component tree topologies, including a prescribed height bound.
D.2 Decomposition of the approximation error
In this section, we bound the approximation error by the joint KL error of a comparison distribution, the regularization error, and the network approximation error.
Fix 0<δ<1 and a distribution q on VL. For a masked sequence c∈VL, define the target logits of its δ-regularized distribution as in Definition 4 by
Lemma 7 (Decomposition of the approximation error). Fix 0<δ<1 and a fixed-cardinality masking schedule s=(s1,…,sT), with st∈N+ and ∑t=1Tst=L. For any distribution q on VL,
The same conclusion holds for any nonempty subclass Q⊆MJ,R, with the uniform approximation condition imposed on Q and ProjJ,R replaced by ProjQ(p⋆):=infq∈QDKL(p⋆∥q).
Proof of Lemma 7. Fix q and write r=qδ. Let rcond denote its conditional predictor on masked positions. We use the same training experiment as in Section 2: P[τ=t]=st/L, Mτ is uniform among subsets of size mτ:=∑u=1τsu, and I is uniform in Mτ. Write Wτ=[L]∖Mτ, and let X∼p⋆. As in Section 2, XWτ denotes the sequence obtained by replacing all tokens outside Wτ with M. Define
L(rcond):=E[DKL(pI⋆(⋅∣XWτ)∥rI(⋅∣XWτ))].
By Lemma 5, adding and subtracting the log conditional probability under r gives
Since ri(⋅∣x)=softmax(Fi,:δ,q(x)) for i∈/W(x), applying this bound in (56) and taking the infimum over θ∈Θ yields
εapprox(Θ)≤L(rcond)+2d∞,mask(Fδ,q,F(Θ)).
It remains to control L(rcond) by DKL(p⋆∥r). We use a subset-averaging argument, analogous to the entropy calculation in Chen et al. (2025, proof of Theorem 3.3). For W⊆[L], denote by pW⋆ and rW the corresponding marginals. Let
dj:=(jL)−1W⊆[L]∣W∣=j∑DKL(pW⋆∥rW),∀0≤j≤L,
and write Δj:=dj+1−dj for 0≤j<L. By the KL chain rule, for i∈/W,
Taking the infimum over q∈MJ,R proves (55). The same argument applies when this infimum is restricted to Q.
Lemma 7 reduces Proposition 2 to uniformly approximating the regularized conditional logits Fδ,q over q∈MJ,R using a transformer class. We establish this approximation first for a single tree in Appendix D.3 and then for mixtures in Appendix D.4.
D.3 Single-tree predictor construction
In this subsection, we construct a sparse transformer that approximates the regularized conditional logits under a single hidden Markov tree structure. Parallel contraction computes the context likelihood, and reconstruction recovers the hidden-state posteriors needed to evaluate the conditional probabilities. We maintain the context likelihood approximation for the mixture construction in Appendix D.4.
Throughout Appendices D.3 and D.4, let L,V≥2, J,R≥1, 0<δ<1, and 0<ε≤1/2. Write
For a masked sequence c∈VL, let W(c):={i:ci=M} and write q(c):=Pq[XW(c)=cW(c)] for its context likelihood. We use the transformer parameter class in Section 2.2, including the trainable input and positional embedding, and the associated clipped logit class F(Θ) from Appendix C.2. The log-sum-exp operator is denoted by LSE,
LSE(x):=logj=1∑dexj,forx∈Rd.
Its neural-network approximation is given in Lemma 17.
Lemma 8 (Single-tree parallel construction). Let q be a J-state hidden Markov tree model on [L], with root o, root distribution ν, transition tables Ai, and emission tables Bi satisfying Bi(v,z)≥ρδ. There exists a parameter class Θ=Θ(D,N,M,Dff,B,S;3,Gδ) with budgets depending only on (L,V,J,δ,ε), and a parameter θ∈Θ satisfying
Before the output embedding, the construction also contains a coordinate hi(c) at every row satisfying
c∈VLsupi∈[L]maxhi(c)−logq(c)≤ε,(63)
which approximates the log context likelihood logq(c). The budgets are independent of the topology and probability tables.
By Lemma 6, the lemma applies to qδ=Pδq for any q∈MJ,1. In this case, (61) approximates Fδ,q on masked positions. The additional coordinate in (63) will be used later to combine different components.
Proof of Lemma 8. We first eliminate vertices while preserving the marginal law on the remaining tree. Reversing these operations recovers all hidden-state posteriors. We then implement the contraction and reconstruction steps by transformer blocks and control their errors.
Positive hidden probabilities. The emission lower bound ensures positive conditional probabilities, but the root distribution and transition tables may still contain zeros. We therefore perturb these hidden probabilities before working in logarithmic coordinates. Let uJ=J−11 and define
Denote the resulting observed law by qγ. A coupling of the L hidden draws gives TV(q,qγ)≤Lγ. Both laws assign probability at least ρδ∣W∣ to a context on W, and at least ρδ∣W∣+1 to that context together with one masked token. Thus,
Here we use ∣loga−logb∣≤∣a−b∣/min{a,b}. Below, the root distribution and transition matrices refer to the regularized model, and we suppress their superscript γ. Notice that
H=Gδ+log(J/γ),(γ/J)LρδL=e−LH.
Contraction and the marginal law. In the following, we consider iterative tree contraction and denote Vi as the vertices of the remaining tree at stage i. Let V0=[L]. Initially, set
and Ti(0):=Ai for i=o. Here Ti(s) denotes an effective edge factor; Bi continues to denote an emission table. Write pas for the parent map of the remaining tree after round s. We maintain
This holds initially by the hidden-tree factorization. There are two elimination operations. In the formulas below, all factors on the right are taken before the round.
• If v is a nonroot leaf with parent u, define
ℓv(a):=b=1∑JTv(b,a)ψv(b),ψu(a)←ψu(a)ℓv(a),
and remove v.
• If v is a nonroot vertex with parent u and unique child w, define
Cv(z,a):=b=1∑JTw(z,b)ψv(b)Tv(b,a).(67)
Remove v, connect w to u, and replace Tw by Cv.
Both operations sum out Zv in (66). As in tree contraction (Miller and Reif, 1985), we apply them to nonadjacent vertices. If several selected leaves share a parent, their factors ℓv are multiplied into its node factor. The eliminated variables have no edges between them, so simultaneous elimination gives exactly the marginal on the remaining tree.
At round s, consider the nonroot vertices in Vs−1 with at most one child. Select the larger of their even-and odd-depth sets, breaking ties by choosing even depth, and call it Is. Take Vs:=Vs−1∖Is. For a tree with n≥2 vertices, if b vertices have degree at least three, then
2n−2≥3b+(n−b),b≤(n−2)/2.
After excluding the root, at least n/2 vertices have at most one child. One depth parity therefore contains at least n/4 nonroot vertices with at most one child, and vertices of the same parity are nonadjacent. Consequently,
where Vs0={o}. The schedule depends only on the topology, and shows that the number of rounds is controlled by O(logL).
Reconstruction of the posteriors. When removing v∈Is, save ψv(s−1) and Tv(s−1), together with ℓv if v is a leaf, or Tw(s−1) and Cv if it has one child w. Each row is removed once, so these saved factors require O(J2) coordinates per row.
Indeed, conditioned on the surviving neighbors, the factors involving Zv in (66) are precisely the numerators in these kernels; summing over Zv gives their denominators. Thus Γv is the joint posterior of (Zw,Zv,Zu) given c. Nonadjacency ensures that all required neighbors belong to Vs. The updated posterior values use only the saved factors and the posteriors available before the reverse round. We form all candidates before updating the corresponding edge posteriors, and retain the existing node and unchanged edge posteriors. This proves the induction and recovers every pi after s0 reverse rounds.
Logarithmic coordinates and initialization. All current factors are at most one. Indeed, node factors are initially at most one, and the initial edge matrices are column stochastic. Leaf elimination preserves this bound, while
z∑Cv(z,a)=b∑ψv(b)Tv(b,a)z∑Tw(z,b)≤1
shows that effective edge matrices remain column substochastic. Every factor is a sum of products of distinct original factors. Retaining one compatible assignment bounds it below by e−LH. The same lower bound holds for node, edge, and three-node posteriors: retain one compatible full hidden assignment and divide by qγ(c)≤1. It also holds for each reconstruction kernel, whose numerator uses disjoint original factors and whose denominator is at most one. We therefore clip their logarithms to [−LH,0]; clipping cannot increase error relative to the exact quantities.
Use distinct standard basis vectors pi for positions, ev for tokens and the mask, and b for a constant. Choose the trainable embeddings as
Thus Rembed=3, ∥E∥F=2(V+1) and ∥P∥F=L, and these matrices use 2(V+1)+L nonzero parameters. Auxiliary coordinates are initially zero. Besides the JV emission entries, allocate O(J2) coordinates for the live and saved factors, node and edge log posteriors, and receive and candidate quantities. The temporary J3 triple entries and the arithmetic workspace are reused across rounds.
For completeness, the position-dependent log-probability tables can be loaded exactly by one attention head in the auxiliary coordinates. Let ti be the vector containing the entries of logAi, logBi, and 1{i=o}logν, in separate auxiliary coordinates; set entries reserved for the root's edge factor to zero. Set
The sigmoid attention weights are 3/4 on the diagonal and 1/4 elsewhere. Hence the attention output, including the factor 1/L, equals ti⊤ at row i. A rowwise FFN then writes
Adding logν at the root initializes logψi(0). These operations use O(L(J2+JV)) nonzeros and FFN width O(JV), including the input embeddings.
Routing and rowwise operations. For a prescribed relation E⊆[L]2, let J(E):={j:(i,j)∈E for some i}. The pair (i,j) means that row i receives from row j. For source coordinates fℓ and initially zero receive coordinates rℓ, set
The scores equal λ on E and −λ elsewhere. If source entries lie in [−LH,0], each received entry differs from its prescribed sum by at most L2He−λ. This includes contributions from rows outside J(E).
A positional affine map writes d=1{i∈I} for any prescribed active set I. For ∣x∣≤LH and d∈{0,1}, the following identities implement selection, clipping, and reset by residual FFNs:
To update a stored value, clip the candidate first and apply the first identity to the candidate minus the old value. Inactive rows are then preserved exactly. The constant coordinate supplies affine offsets. For m scalar coordinates, these operations have width and sparsity O(m); the active-set indicator uses O(∣I∣+1) nonzeros.
Let
ξ:=214L(s0+1)ε,t:=log(eJ/ξ),λ:=log(L2H/ξ).(72)
By Lemmas 17 and 12, a d-input LSE can be approximated to accuracy ξ using residual rowwise FFNs with depth Ct2, width Cdt3, sparsity Cdt8, and log Frobenius norm at most Ct2. Parallel copies use disjoint workspace coordinates. We reset the receive, candidate, indicator, and workspace coordinates after every stage, and leave the coordinates storing quantities for later updates unchanged during the arithmetic.
For a selected one-child vertex, attention first copies its child's edge table. After computing the candidates, attention aggregates the selected leaf log messages at their current parents and sends each replacement edge table to its current child. The updates affect only the corresponding rows. The eliminated rows retain their saved factors throughout all later contraction rounds.
At the root, one LSE gives the log evidence, and subtraction initializes the log posterior. In a reverse round, attention copies the parent's node posterior to a removed leaf, or the current child's edge posterior to a removed one-child vertex. Affine operations form the log kernels in (69)–(70). Further LSEs marginalize the joint posteriors. The restored child-edge table is sent to its child only after all candidates have been computed. Each round uses a constant number of routing and arithmetic groups. The largest group consists of O(J2) LSEs with J inputs, and therefore has width O(J3t3) and sparsity O(J3t8). These are shared rowwise FFNs, so their parameter count has no additional factor L.
Error control. Initialize auxiliary weights to the initial factors by
where Au is the set of selected leaves with parent u. Here w counts the original factors ν,gi and Ai incorporated into each quantity, counting each factor by its vertex or edge of origin. There are 2L such factors. Since each update combines disjoint collections, every weight is at most 2L.
All error bounds below are uniform over c∈VL. Write logψi(s) and logTi(s) for their stored logarithmic approximations. Initialization is exact. Each attention operation contributes at most ξ of routing error and each LSE approximation contributes at most ξ. Using the 1-Lipschitz property of LSE and induction over the contraction rounds gives
Including the copying operations, all logarithmic factors stored for reconstruction have error at most 10Lξ. At the root, one LSE computes logqγ(c), and subtraction gives logpo. Hence,
Let es denote the maximum error among all stored node and edge log posteriors on Vs, uniformly over c∈VL, before reversing round s. Each reconstruction uses one existing posterior and at most four stored factors. Attention and marginalization add at most 4ξ, so
es0≤17Lξ,es−1≤es+40Lξ+4ξ≤es+50Lξ.
Therefore,
e0≤17Lξ+50Ls0ξ≤70L(s0+1)ξ.
For i∈/W(c), the identity
logqiγ(v∣c)=LSEz∈[J](logpi(z)+logBi(v,z))
requires one further LSE. After clipping to [−Gδ,0], the hidden-state regularization bound and the choice ξ=ε/[214L(s0+1)] yield
Store these logits in coordinates ov and choose Wout=(ov)v∈V. This matrix has V nonzero entries and Frobenius norm V, proving the conditional-logit approximation bound.
Finally, copying the clipped root log context likelihood to every row adds at most ξ. Thus,
c∈VLsupi∈[L]maxhi(c)−logq(c)≤(8L+2)ξ+64ε<ε,
which proves the log context likelihood approximation bound.
Architectural budgets. Initialization uses O(L(J2+JV)) nonzeros. Each forward or reverse round uses a constant number of routing relations with O(L) pairs, together with the rowwise arithmetic described above. The final emissions use O(JVt8) nonzeros. Thus,
The input embeddings, output embedding, gates, and evidence broadcast are included in these bounds. Each row is eliminated once, so saving the factors introduces no factor s0 in the width. Since s0,t≤Cb∗ and J2≤J3, these bounds imply (62). Table loading, routing, and gates have coefficients polynomial in (L,J,V,H,λ), whereas the LSE coefficients are bounded by exp(Ct2). Converting to matrix Frobenius norms adds only polynomial dimension factors, giving
logB≤C[t2+log(eL2JVH)]≤Cb∗2.
For each topology, the schedule fixes the routing and selection locations. All table and arithmetic locations can be allocated in advance, independently of their values. This proves the lemma.
D.4 Approximation bound for mixtures of trees
In this section, we combine the single-tree constructions to approximate Fδ,q for q∈MJ,R. The component context likelihoods determine their posterior mixture weights and must be retained along with their conditional logits.
Proposition 4 (Uniform approximation of regularized mixture logits). Fix R≥1 and set
HR:=(L+1)Gδ+log(64LJR/ε),bR:=log(eLJVRHR/ε),
where Gδ:=log(V/δ). There exists one parameter class Θ=Θ(D,N,M,Dff,B,S;Rembed,Gδ) with Rembed=3 such that
For mixtures sharing a common rooted topology, two heads suffice. The same bounds hold when the component topologies are restricted to any prescribed family of rooted trees on [L].
Proof of Proposition 4. Fix q=∑r=1Rπrqr∈MJ,R, allowing zero weights. By Lemma 6, qδ=∑rπrqrδ, and each component has emissions Bi,rδ(v,z)=(1−δ)Bi,r(v,z)+δ/V.
Component constructions and mixture weights. Apply Lemma 8 to each qrδ with accuracy a:=ε/64. Retain its conditional logits and log evidence as internal coordinates, denoted by fi,r,v and hi,r. They satisfy
The first bound is for masked positions, and the second holds for all contexts. The hidden-table perturbation is already included in these bounds. The component constructions occupy disjoint auxiliary coordinates, share the input embedding, and run in parallel. Shorter contraction schedules are padded with identity rounds.
The posterior component weights are proportional to πrqrδ(c) for qδ and to πrκqrδ(c) for qˉ. A coupling of the component label gives supE∣qˉ(E)−qδ(E)∣≤κ. As both distributions have the same emission lower bound, the argument in (65) yields
∣logqˉi(v∣c)−logqiδ(v∣c)∣≤2κρδ−L=ε/32.(75)
Moreover, ∣logπrκ∣≤log(R/κ)≤HR.
Combining the components. For every i∈/W(c) and v∈V, the conditional log probabilities of qˉ satisfy
The mixture weights enter as exact affine offsets. Since LSE is one-Lipschitz in the maximum norm, the two errors are at most 2a and 3a, respectively. Subtracting and clipping to [−Gδ,0] gives error at most 5a relative to logqˉi(v∣c). Together with (75), this gives
∣Fθ,i,v(c)−Fi,vδ,q(c)∣≤5ε/64+ε/32<ε.
This explains why averaging the component conditionals with the prior weights πr would not suffice: the weights given c are proportional to πrqrδ(c).
A common architectural class. Let s0 be the largest number of contraction rounds among the components, and take t=Clog(eLRJ/ε) with a sufficiently large universal constant. The branch depths are maximized, whereas their auxiliary widths and sparsities add. Initialization requires O(LR(J2+JV)) nonzeros. The component constructions and final mixture operations therefore satisfy
N≤C(s0+1)t2,S≤CR{L(J2+JV)+(s0+1)(L+J3t8)+JVt8}.
The R evidence broadcasts cost O(RL) nonzeros, and the final mixture LSEs cost O(RVt8); both are absorbed above. Replacing the single-tree accuracy by ε/64 changes its logarithmic factors only by a universal constant, so s0,t≤CbR. This proves (74), including the Frobenius bound. At most 2R heads suffice. If the topologies agree, use the same contraction schedule and attention matrices, and place the component value maps in disjoint coordinates; two heads then suffice.
For fixed component topologies, the coefficient locations can be chosen independently of their probability tables. The displayed budgets are uniform over all topologies. Padding to these budgets and allowing the sparse supports to vary gives a single parameter class Θ for every q∈MJ,R. This proves (73).
D.5 Proof of Proposition 2
Let Θ be the transformer parameter class as in Proposition 4. (73) gives
q∈MJ,Rsupd∞,mask(Fδ,q,F(Θ))≤ε.
Applying Lemma 7 therefore gives
εapprox(Θ)≤LsmaxProjJ,R(p⋆)+smaxlog1−δ1+2ε,
for every distribution p⋆ on VL. Together with the architectural bounds in (74), this proves Proposition 2.
E Shallow-tree result
In this appendix, we derive complementary estimation and sampling guarantees for mixtures of hidden Markov trees with bounded height. We replace the contraction-based construction in Appendix D.3 by upward and downward message passing, while using similar techniques as in Proposition 1 and Theorem 2.
Appendix E.1 establishes the message identities. Appendix E.2 implements them for a single tree structure, and Appendix E.3 extends this construction to mixtures. Appendices E.4 and E.5 derive the resulting estimation error and sampling guarantees.
Let L,V≥2 and J,R≥1 be integers. The height of a rooted tree is the maximum number of edges from its root to a vertex. For an integer h∈[L−1], let MJ,Rh denote the distributions admitting a mixture representation with RJ-state hidden Markov tree components, each of height at most h. To be more specific, let Th⊆T denote the subset of trees on [L] of height at most h. Then
For the approximation construction, take 0<δ<1 and 0<ε≤1/2, and use the notation (ρδ,Gδ,b∗,H,HR,bR) from Appendices D.3 and D.4.
E.1 Message identities
In this section, we state the messages to help derive the target conditionals. They provide the upward and downward updates used in the height-dependent construction.
In the following, for a rooted tree with root o, let ch(i) denote the set of children of vertex i:
ch(i):={u∈[L]∖{o}:pa(u)=i},
for any i∈[L].
Lemma 9. Fix c∈VL and write W=W(c). Let q be a single hidden Markov tree model with root o, root distribution ν, transitions Ai, and emissions Bi. For each vertex i, let Vi be the subtree rooted at i, including i, and write Vic:=[L]∖Vi. For S⊆[L], write cS for the event {XW∩S=cW∩S}, and define
Each summed state ranges over [J]. Grouping the sum by child subtrees gives (76), starting with αi=gi at leaves. Thus αi(z,c) is the likelihood of the subtree evidence with its root state fixed to z. This finite-sum definition also applies to states with Pq[Zi=z]=0.
We next verify that βi(z,c)=Pq[Zi=z,cVic]. It holds at the root since Voc=∅. For i=o, let j=pa(i). The evidence outside Vi consists of the evidence outside Vj, the observation at j if present, and the evidence in the sibling subtrees. The tree factorization therefore gives
Apply the single-tree joint identities to each component and take the ratio to obtain (80). This argument does not require every component to assign positive probability to the context.
E.2 Height-dependent predictor construction for single-tree
In this section, we implement the recursions above by processing the tree levels. We use the regularization, embedding, routing, and rowwise arithmetic from Appendix D.3.
Lemma 10 (Single-tree message construction). Under the assumptions of Lemma 8, suppose the rooted tree has height h. There exists a parameter class Θ=Θ(D,N,M,Dff,B,S;3,Gδ) and a parameter θ∈Θ satisfying
Before the output embedding, the construction also retains a coordinate hi(c) at every row satisfying
c∈VLsupi∈[L]maxhi(c)−logq(c)≤ε.(83)
The budgets depend on the topology only through its height. For a fixed topology, the permitted coefficient locations can be fixed independently of the probability tables.
Proof of Lemma 10. Apply (64) and work with qγ. The conditional-logit and log-evidence perturbations are bounded by (65). As in Appendix D.3, all relevant log probabilities lie in [−LH,0]. Below, the tables and messages refer to qγ, and the superscript γ on the hidden tables is suppressed.
Use the embedding and exact table initialization from Appendix D.3 to store logAi, logBi, loggi, and logν at the root. Allocate separate coordinates for the upward and downward log messages, received values, candidates, and LSE workspace. Initialize βolog=logν, with other message and temporary coordinates zero. Here the superscript log indicates a stored approximation to a log message. Set
η:=128L(h+1)ε,t:=log(eJ/η),λ:=log(L2H/η).
The attention maps in (71) have error at most η per received coordinate. We use the exact clipping, selection, and reset operations from Appendix D.3, and LSE networks of accuracy η from Lemma 17.
Upward pass. Let hi be the height of the subtree rooted at i, and process Is:={i:hi=s} for s=0,…,h. Every child of an active vertex has already been processed. Using the relation
Es↑:={(i,u):i∈Is,u∈ch(i)},
attention aggregates the stored child log messages into initially zero receive coordinates ri. Clip these coordinates to [−LH,0]. Rowwise FFNs then form the candidates
The right-hand side of the second update uses the new candidate for αilog. We select the active rows only after forming the candidates and preserve the other stored messages. The root needs only the first update. At the end of each stage, reset all receive, candidate, indicator, and workspace coordinates.
Let ni:=∣Vi∣. By (76), induction from the leaves gives
As before, form candidates, select the active rows, and reset temporary coordinates. All parent downward messages are complete before they are used. If ei:=∥βilog−logβi∥∞, then
eo=0,ei≤epa(i)+(4L+2)η≤depth(i)(4L+2)η.(89)
The two upward-message errors contribute at most 4Lη, while routing and LSE contribute at most 2η.
Conditional logits and context likelihood. With both passes complete, form ui again as in (87). By (78), its target is logPqγ[Zi=z,c]. Apply V+1 parallel LSE networks to obtain
Their targets are logqγ(c) and logPqγ[Xi=v,c], respectively; the second identity is needed only when i is masked. Each error is at most
[2L+h(4L+2)+1]η≤8L(h+1)η.
Clip vi,v−hi to [−Gδ,0], store the result in output coordinates ov, and use Wout=(ov)v∈V. This gives conditional-logit error at most 16L(h+1)η=ε/8 relative to qγ. Combining this with (65) proves (81). The retained coordinate hi has error at most ε/16+ε/64 relative to logq(c), proving (83) for all contexts.
Architectural budgets. Each message stage uses J parallel J-input LSE networks, with depth Ct2, arithmetic width CJ2t3, and arithmetic sparsity CJ2t8. For positional routing, every edge and source child is used once in the upward pass. In the downward pass, every edge is used once and each source parent is used at only one depth. The active sets partition the processed vertices, so
s∑(∣Es∣+∣J(Es)∣+∣Is∣+1)≤CL
for the upward pass, with Is replaced by Ds for the downward pass. Here J is defined before (71). Thus positional routing and indicators cost O(L) over each pass. Value routing and resets use O(J2) coefficients per stage and are absorbed in the arithmetic count.
Adding initialization, both passes, and the output group yields
Here we use only h≤L−1. Persistent coordinates have dimension O(L+V+J2+JV), and workspace is reused across stages. The input embeddings and output matrix are counted as in Appendix D.3; retaining hi adds no routing step. The same coefficient bounds give
logB≤C[t2+log(eL2JVH)]≤Cb∗2.
Since t≤Cb∗, these estimates give (82). The topology fixes the routing and active sets, and all table and arithmetic locations can be allocated independently of their values.
E.3 Approximation bound for mixtures of trees
In this section, we give and prove the height-dependent mixture result of Proposition 5. We replace the component construction in Appendix D.4 by Lemma 10; the mixture-weight perturbation and final LSE operation are unchanged.
Proposition 5 (Height-dependent approximation of regularized mixture logits). Let 1≤h≤L−1. With HR and bR as in Proposition 4, there exists one class Θ=Θ(D,N,M,Dff,B,S;3,Gδ) such that
If all component trees share a common rooted topology, one head suffices. The same bounds hold for any further restriction on the component topologies.
Proof of Proposition 5. Fix a representation q=∑r=1Rπrqr∈MJ,Rh with component heights at most h. Regularize the emissions as in Lemma 6 and apply Lemma 10 to each qrδ with accuracy a:=ε/64. The resulting internal coordinates satisfy
where the first bound is for masked positions and the second holds for every context. These estimates already include the hidden-table perturbation. The branches occupy disjoint auxiliary coordinates and share the input embedding. Run the upward stages for all components, followed by their downward stages, with inactive stages padded by identities.
Use the weights πrκ and the final V+1 LSE networks from Appendix D.4. That calculation uses only the two displayed approximation bounds. The two LSE errors are at most 2a and 3a, and the weight perturbation contributes at most ε/32 by (75). Thus,
It remains to count the architecture. Take t=Clog(eLRJ/ε) with a sufficiently large universal constant. Each message stage has depth Ct2, total arithmetic width CRJ2t3, and arithmetic sparsity CRJ2t8. The positional routing count in Lemma 10 gives O(RL) nonzeros over each complete pass. Initialization costs O(LR(J2+JV)), the component output groups cost O(RJVt8), and the final mixture LSEs cost O(RVt8). Therefore,
Widths and sparsities add across components, while their depths are maximized. All workspace is reused across stages. Since t≤CbR, the width and Frobenius estimates from Lemma 10 give (91). There is at most one routing head per component at each step. If the rooted topologies coincide, their routing matrices are shared, and the value maps can be combined into one head.
These budgets are uniform over all component trees of height at most h. For fixed topologies, the permitted coefficient locations are independent of the tables. Padding to the displayed budgets and allowing the supports to vary gives one class Θ satisfying (90). This proves the proposition. Finally, Lemma 7 gives the corresponding approximation bound
The height bound enters the transformer depth through h+1. No logarithmic-height assumption is used.
E.4 Estimation error analysis
Theorem 3 (Estimation error for shallow tree). Let n,L,V≥3, J,R≥1, and h∈[L−1]. Use the fixed-cardinality masking schedule s in Section 2 for training. There exists a transformer class Θh of the form (12), with an architecture depending only on (n,L,V,J,R,h) (specified in Proposition 5 with δ=ε=1/n), such that for any distribution p⋆ on VL, the ERM θh over Θh computed from n i.i.d. samples drawn from p⋆ satisfies
Here, C3>0 is a universal constant, the expectation is over training samples, and
Ksh:=RL(J2+JV)h2.(93)
Proof of Theorem 3. Recall β:=log(enLVJR). Lemma 7 gives
εapprox(Θh)≤LsmaxProjMJ,Rh(p⋆)+n2smax+2.
The height-dependent budgets satisfy
N≤C(h+1)β2,S≤CRL(J2+JV)β8,logB≤Cβ2,logPtr≤Cβ.
Applying Proposition 1 with
logATF≲h2β6,C(Θh)≲Kshβ14
yields
E[L(θh)]≤C{LsmaxProjJ,Rh(p⋆)+nKshβ16}.(94)
This proves Theorem 3.
E.5 End-to-end sampling guarantees
Theorem 4 (Sampling guarantees under shallow tree structure). Assume the conditions and adopt the notation of Theorem 3. Let pY∣S denote the output distribution of the T-step MDM sampler using the ERM-based mask predictor pθh and the realized unmasking sets S=(S1,…,ST) with ∣St∣=st. Then for any 1≤T≤L, one has
where C4>0 is a universal constant, and the expectation is over the training samples and random unmasking sets S.
Proof of Theorem 4. For 1≤h≤L−1, use the parameter class Θh from Proposition 5 with δ=ε=1/n. Denote θh as the ERM estimator over Θh, and let pY∣S be the output distribution of the sampler using pθh as mask predictor and S=(S1,…,ST) as the unmasking partition. Then applying the decomposition (35) with θ=θh,
We write NN(W,d,B,S) for feed-forward ReLU networks of maximum width at most W, depth at most d, coefficient magnitude at most B, and at most S nonzero scalar coefficients:
Here I denotes the identity map, σ is applied entry-wise using ReLU(x)=x∨0, and Wi≤W, ∀i∈[d+1]. As a remark, in the auxiliary neural-network class, B bounds individual weights and biases, while in the transformer class defined in (12), B bounds the Frobenius norm of each parameter matrix. We will convert them when applying results to transformer structure in Lemma 12.
F.1 Exact operations and residual implementation
Lemma 11 (Exact realization of clipping). For a≤b, define
Clip[a,b](x):=min{b,max{a,x}}.
This function is represented exactly by a ReLU network in NN(2,2,Bclip,7), where Bclip:=max{1,∣a∣,∣b∣}. Moreover, for all x,x′∈R and y∈[a,b],
gives an exact representation with two hidden units, two affine layers, and at most seven nonzero weights and biases, each of magnitude at most Bclip. The clipping function is continuous and piecewise affine with slopes in {0,1}, hence is 1-Lipschitz. Since Clip[a,b](y)=y for y∈[a,b], the second inequality follows from the first.
Lemma 12 (Implementation of ReLU DNNs by transformer FFN blocks). Suppose a feed-forward ReLU network has maximum layer dimension W, depth d, coefficient bound B≥1, and sparsity S. Using a preserved constant coordinate and two reusable buffers, the function can be implemented rowwise by O(d+1) residual FFN blocks as defined in (9) with zero attention updates, auxiliary dimension O(W), FFN width O(W), matrix Frobenius norms at most C(W+1)(B+1), and total sparsity
C(S+(d+1)W).
For parallel realization, the sparsities and buffer dimensions add; the squared Frobenius norms add across the branches.
and pad all layer vectors to dimension W. Set all attention updates to zero, and reserve two groups of W auxiliary coordinates together with a constant coordinate.
Suppose the current row is h=(z⊤,v⊤,1), where z contains the current NN input and v contains the old values in the destination coordinates. To implement z↦ReLU(Az+b), choose
The final block satisfies the same bounds up to constants, so every FFN matrix has Frobenius norm at most C(W+1)(B+1). For parallel networks, use disjoint auxiliary and FFN coordinates; sparsities, auxiliary dimensions, and squared Frobenius norms then add across branches.
F.2 Scalar arithmetic approximations
Lemma 13 (Multiplication on a bounded rectangle). For C0≥1 and 0<ϵ≤1/2, there exists ϕprod∈NN(W,d,B,S) such that
∣x∣,∣y∣≤C0sup∣ϕprod(x,y)−xy∣≤4C02ϵ,
where W=O(1), d=O(log(e/ϵ)), B=C02, and S=O(log(e/ϵ)).
This lemma is a direct corollary of Lemma F.6 in Oko et al. (2023) with two inputs, followed by rescaling.
Lemma 14 (Uniform approximation of the exponential function (Lemma F.12 in the arXiv version of Oko et al. (2023))). For 0<ϵ≤1/2, there exists ϕexp∈NN(W,d,B,S) with
With t=log(en/ξ) and some universal constant C>0, its network parameters can be chosen as follows,
d≤Ct2,W≤Cnt3,S≤Cnt8,logB≤Ct2.
It can be implemented by residual rowwise FFNs with the same orders of depth, width, and sparsity, using reusable auxiliary coordinates and a constant input coordinate. The corresponding matrix Frobenius norms also have logarithms at most Ct2. Moreover, LSE is 1-Lipschitz with respect to the infinity norm:
∣LSE(x)−LSE(y)∣≤∥x−y∥∞.(97)
Proof of Lemma 17. For n=1, we just take Φξ(x)=x1. In the following, assume that n≥2 and denote
ν:=4nξ,η:=2ξ,andt:=log(ξen).
We construct the approximation by composing the exponential and logarithm networks in Lemmas 14 and 15 respectively, together with exact maximum, affine, and clipping operations.
Apply the following pairwise maximum operation along a balanced binary tree, with comparisons at each level performed in parallel:
max{v,w}=ReLU(v−w)+w.
Retaining the original coordinates until the final exact realization of a(x) gives the map
Γ(x):=(a(x),u1(x),…,un(x)),
realized by ReLU DNNs with depth O(log(en)), width O(n), sparsity O(nlog(en)), and coefficient bound O(1). Retaining original coordinates can be realized via ReLU layers using v=ReLU(v)−ReLU(−v).
Step 2: approximate the exponential sum. Apply Lemma 14 with accuracy ν to obtain
The parallel exponential networks have width O(nt), depth O(t2), and sparsity O(nt2). Summation and clipping add O(n) coefficients, of magnitude at most Cn.
Step 3: rescale the logarithm network and compose. Apply Lemma 15 with interval lower bound τ=1/n and accuracy η, and hence there exists
This gives the construction of uniform approximation of log-sum-exp operator for x∈Rn. Then we summarize its network parameters and its residual realization.
Step 4: network budgets and residual implementation. Compose the preceding networks without multiplying adjacent affine matrices: an intermediate signed vector v can be represented by (ReLU(v),ReLU(−v)) and reconstructed in the next affine layer. This incurs only constant-factor overhead in the corresponding layer widths and nonzero coefficients; see also Lemmas F.1–F.3 in Oko et al. (2023). The scalar a(x) can be carried through the exponential and logarithm layers and then recovered using two signed channels. Therefore,
Here sparsities add across the parallel exponential branches; the signed carry channels contribute only O(dexp+dlog) coefficients.
Apply Lemma 12 to this circuit, retaining a constant input coordinate to supply biases. With all attention updates zero, the resulting rowwise residual FFNs satisfy
Taking logarithms yields LSE(y)−r≤LSE(x)≤LSE(y)+r, and thus proves the 1-Lipschitz continuity.
G Parallelization error
This appendix follows Chen et al. (2025) to bound the parallelization error in (22). We include the derivations here to make the presentation self-contained.
Recall the definition of TC (total correlation) and DTC (dual total correlation):
We first write the parallelization error using conditional total correlation, and then construct the TC and DTC schedules following Section 5 of Chen et al. (2025).
Fix a distribution p∗ on VL and a forward masking schedule s=(s1,…,sT), with st∈N+ and ∑t=1Tst=L. Recall the index sets St and Wt defined in the reverse process in Section 2. The partition sets S:=(S1,…,ST) are selected uniformly with ∣St∣=st, and
Wt=u=t+1⋃TSu.
Thus, Wt contains the unmasked positions before sampling St. Conditioned on S, the sampler using the exact conditional marginals has output distribution
pY⋆∣S(x):=t=1∏Ti∈St∏pi⋆(xi∣xWt).
Recall the definition of the parallelization error in (20):
εparall(p⋆;s):=ES[DKL(p⋆∥pY⋆∣S)].(101)
For sets B,W⊆[L] and B∩W=∅, define the conditional TC as,
The following lemma provides bounds on the parallelization error for specific masking schedules.
Lemma 18 (TC and DTC schedules). Fix L≥2 and an integer T satisfying 2+2log(eL)≤T<L. There exist forward masking schedules sTC and sDTC, each consisting of T positive integers summing to L and depending only on (L,T), such that, for every target distribution p⋆ on VL,
where I(⋅;⋅) denotes the mutual information, (W,i) is uniform among pairs of the indicated sizes and X∼p⋆. For a fixed i, coupling nested uniform subsets of [L]∖{i} gives I(Xi;XW)≤I(Xi;XW′) whenever W⊆W′. Averaging over i therefore gives 0=Z1≤⋯≤ZL, so dr≥0.
Let Hj be the average of H(XW) over uniform subsets W⊆[L] of size j, with H0=0. Then by the connection between entropy and mutual information,
For the construction below, we list batch sizes in generation order as srev=(s~1,⋯,s~T):=(sT,…,s1). Set Nj:=∑ℓ=1js~ℓ as the total number of elements in the first j unmasking batches, and N0=0. Hence, ∣Wj∣=NT−j and ∣Wj∪Sj∣=NT−j+1. Consider
TC schedule. Fix an integer 2≤ζ≤L. Starting with r0=L remaining positions in the reverse process, for j=1,…, take a batch of size s~jTC=⌊rj−1/ζ⌋ whenever rj−1≥ζ, so that
rj=rj−1−s~jTC=rj−1−⌊rj−1/ζ⌋.(107)
Once fewer than ζ positions remain, generate them in singleton batches, i.e., s~jTC=1. Since rj−1 and ζ are integers, it holds that ⌊rj−1/ζ⌋≥rj−1/ζ−1+1/ζ and thus
rj−ζ+1≤(1−ζ1)(rj−1−ζ+1).
Therefore, at most
λ:=⌊−log(1−1/ζ)log(L−ζ+1)⌋+1≤1+ζlogL
recursive steps are needed to reach rj<ζ. Including the remaining singleton batches, the total number of batches satisfies m≤λ+ζ−1≤ζlog(eL). Define rj=rj−1−s~jTC throughout the construction including the final singleton batches, so that rm=0. The corresponding forward masking schedule sTC=(s~mTC,…,s~1TC).
For sTC, the corresponding NjTC:=∑i=1js~iTC=L−rj. Hence, by (105),
Here we use the fact that singleton batches contribute zero error, together with the expression of TC in (104).
DTC schedule. For this schedule, we just take the reverse of sTC. That is, sDTC=s~TC. Similarly, for sDTC, the corresponding NjDTC:=∑i=1js~iDTC=∑i=1jsiTC=rm−j, with r defined in (107).
For every nonsingleton batch, its corresponding TC batch is also nonsingleton, and thus
s~jDTC=s~m−j+1TC≤ζ−1rm−j+1=ζ−1Nj−1DTC.
Hence for every Nj−1DTC≤r≤NjDTC−1:
NjDTC−r≤s~jDTC≤ζ−1Nj−1DTC≤ζ−1r.
Notice that singleton batches contribute zero error, so we have
Determine ζ. Finally, we choose ζ and refine the two lists to obtain exactly T batches. Let
AL:=log(eL),ζ:=⌊ALT−2⌋.
The assumption on T ensures 2≤ζ≤L, and each list has at most ζAL≤T−2 batches. By (105), splitting a batch cannot increase the parallelization error. Repeatedly splitting nonsingleton batches thus produces exactly T batches, while preserving the bounds in (108) and (109). Denote these adjusted forward schedules by our sTC and sDTC, which depends only on (L,T).
For x=(T−2)/AL≥2, the inequality ⌊x⌋−1≥x/3 implies
ζ−11≤T−23AL≤T6AL,
where the last inequality uses T≥4. Substituting this into (108) and (109) proves (103). For T=L, take singleton batches, for which every term in (106) is zero.