Source-linked AI summary

Train for the Worst, Plan for the Best: Understanding Token Ordering in Masked Diffusions

Jaeyeon Kim, Kulin Shah, Vasilis Kontonis, Sham Kakade, Sitan Chen

arXiv:2502.06768v3cs.LG

TL;DR

MDMs trade greater training complexity for flexible token ordering at inference, raising questions about when that flexibility offsets difficult training subproblems. The paper analyzes both effects theoretically and empirically, then uses adaptive decoding orders to avoid hard subproblems. On logic puzzles, this approach markedly improves MDM performance and can surpass teacher-forced ARMs.

  • Problem

    The paper asks how MDMs’ greater training complexity and inference flexibility compare, and on which tasks MDMs can challenge ARMs.

  • Method

    The paper combines theoretical and empirical analysis of MDM masking subproblems with adaptive strategies that choose token decoding orders during inference.

  • Results

    Adaptive inference improves MDM performance on logic puzzles and can outperform ARMs trained with teacher forcing to learn the right decoding order.

  • Takeaways & Limitations

    MDMs can use inference-time order selection to sidestep hard subproblems created by order-agnostic training.

  • Takeaways & Limitations

    Top probability ordering can provide misleading uncertainty estimates when an MDM assigns similarly high probabilities to competing tokens.

Abstract

from arXiv · show

In recent years, masked diffusion models (MDMs) have emerged as a promising alternative approach for generative modeling over discrete domains. Compared to autoregressive models (ARMs), MDMs trade off complexity at training time with flexibility at inference time. At training time, they must learn to solve an exponentially large number of infilling problems, but at inference time, they can decode tokens in essentially arbitrary order. In this work, we closely examine these two competing effects. On the training front, we theoretically and empirically demonstrate that MDMs indeed train on computationally intractable subproblems compared to their autoregressive counterparts. On the inference front, we show that a suitable strategy for adaptively choosing the token decoding order significantly enhances the capabilities of MDMs, allowing them to sidestep hard subproblems. On logic puzzles like Sudoku, we show that adaptive inference can boost solving accuracy in pretrained MDMs from $<7$% to $\approx 90$%, even outperforming ARMs with $7\times$ as many parameters and that were explicitly trained via teacher forcing to learn the right order of decoding.

1. Introduction

The paper examines whether MDMs’ inference flexibility compensates for their greater training complexity relative to ARMs. It finds hard training subproblems but shows adaptive token ordering can avoid them and substantially improve performance.

  • MDMs face greater training complexity because they predict tokens conditioned on arbitrary sets of unmasked positions, whereas ARMs use sequential prefixes.
  • MDMs offer flexible inference because they can decode tokens in random order or any chosen order, unlike ARMs’ fixed left-to-right decoding.
  • The paper provides theoretical and empirical evidence that MDM training complexity quantifiably affects performance.
  • MDM training covers exponentially more masking subproblems, some computationally intractable, producing uneven learning across subproblems.
  • Adaptive inference selects which token to unmask next, allowing MDMs to sidestep hard training subproblems.
  • On logic puzzles, adaptive MDMs can outperform ARMs trained with supervised teacher forcing to learn the correct token generation order.

2. Masked Diffusion Models (MDM)

This section presents MDMs as order-agnostic learners trained through masking and denoising. Their loss averages over masking problems, while inference selects positions to unmask and fills them using learned token distributions.

  • MDMs gradually mask discrete data and learn the marginal distributions of the induced reverse process.
  • Forward process: The forward process independently masks each token with probability 1 − α_t and otherwise leaves it unchanged.
  • Reverse process: The reverse process recursively denoises a fully masked sequence from t = 1 to t = 0.
  • Order-agnostic training: The MDM loss is a linear combination of losses for all possible infilling masks, so its optimum learns every masking problem.
  • Order-agnostic training: Compared with ARM loss, MDM loss solves exponentially more subproblems and does not prefer a particular decoding order during training.
  • Inference: Vanilla MDM inference randomly selects positions to unmask and assigns their token values using the denoising network.

3. MDMs train on hard problems

For distributions with a fixed natural order, order-aware training is tractable while MDMs encounter many computationally hard masking subproblems. This complexity imbalance persists empirically on text and produces uneven errors across masking tasks.

  • MDMs encounter computationally intractable masking subproblems even when the data distribution has a fixed natural generation order.In contrast, autoregressive training in that known order can efficiently sample from the same distributions.
  • MDMs train across masking problems with widely varying complexity, yielding small errors on easy subproblems but large errors on harder ones.
  • Order-aware training is computationally tractable because latent tokens are independent and observation tokens are efficiently learnable from the preceding latent tokens.
  • Most masking problems trained by MDMs are harder than those encountered by ARMs, while permutation learners approach ARM scaling as their order approaches the identity.
  • Text data preserves the complexity gap: as training deviates from its left-to-right order, model performance progressively declines.
  • Vanilla random-order inference can evaluate poorly trained marginals, whereas adaptive token selection can sidestep hard training subproblems without changing MDM training.

4. MDMs can plan around hard problems

Adaptive inference lets pretrained MDMs choose decoding paths that avoid hard masking subproblems, improving likelihood modeling and puzzle-solving accuracy without further training. The strongest gains occur when token-generation order varies across sequences.

  • Adaptive inference: Adaptive inference selects tokens strategically instead of randomly, allowing pretrained MDMs to sidestep hard masking subproblems without further training.The approach uses an oracle to choose which positions to unmask next.
  • Ordering oracles: Top probability margin estimates positional uncertainty from the probability gap between the two most likely token values.It is preferable when multiple candidate values have similar probabilities.
  • Adaptive inference: Adaptive MDM inference substantially reduces generative perplexity while maintaining entropy relative to vanilla inference on text data.The comparison uses a pretrained 170M MDM and LLaMA-7B as evaluator.
  • Logic puzzles: On Sudoku, Top probability margin reaches 89.49% accuracy versus 6.88% for vanilla inference and 18.51% for Top probability.The margin strategy is more reliable when competing values have similar probabilities.
  • Logic puzzles: On Zebra puzzles, Top probability margin reaches 98.3% accuracy versus 76.9% for vanilla MDM inference.This result is reported for correctly solved puzzles.
  • Comparison with ARMs: Top probability margin-based adaptive MDM inference outperforms ARMs trained both without ordering information and with sequence-specific ordering information.The comparison covers Sudoku and Zebra puzzles, where natural generation orders differ across sequences.

5. Conclusion

The paper concludes that MDMs train on hard masking problems, while adaptive inference can avoid them and improve logic-puzzle performance beyond vanilla MDMs and teacher-forced ARMs.

  • MDMs train on computationally hard masking problems, and adaptive inference can sidestep these problems during generation.The conclusion links the training-time hardness result to the inference-time strategy.
  • Adaptive inference produces dramatic performance improvements over vanilla MDMs and ARMs trained with teacher forcing to learn the right decoding order.The cited conclusion states the comparison but does not provide the underlying numerical results.

Impact statement

The paper situates masked diffusion models within discrete diffusion and any-order reasoning, while emphasizing both their training challenges and their potential for adaptive inference.

  • Masked diffusion models are a leading discrete-domain diffusion variant with a simple and principled training objective.The surrounding literature includes discrete diffusion models and the absorbing transition kernel as their foundation.
  • The paper studies whether MDM strengths and limitations relative to ARMs depend on token-generation order, especially beyond left-to-right tasks.The motivating examples include reasoning, planning, infilling, and combinatorial settings.
  • Order-agnostic training opens multiple inference sampling paths but also introduces training challenges relevant to any-order reasoning.Prior work proposed adaptive inference strategies, while this paper separates training-order and inference-order effects.
  • The paper develops hardness results for masking problems using sparse noisy parities and generalized linear-model observations under stated computational assumptions.The sparse-parity construction uses SLPN, while the generalized-linear setting draws on Lipschitz hardness for the symmetric binary perceptron.
  • For sparse noisy parity observations, some masking problems are information-theoretically solvable but computationally hard under the SLPN assumption.The proof identifies a regime where posterior-mean estimation is computationally hard despite sufficient information.

B.2. Additional example: random slab observations

This example uses random slab observations to show that stable polynomial-time samplers can encounter computationally hard masking problems.

  • Random slab observations constrain latent binary variables through inequalities involving Gaussian observation vectors.The construction samples Gaussian vectors and records whether the latent assignment lies within a slab of fixed width.
  • Consequently, stable polynomial-time masked diffusion samplers encounter a computationally hard masking problem with non-negligible probability during reverse diffusion.The conclusion applies the posterior-sampling hardness result to the masked diffusion reverse process.
  • Stable algorithms are defined by requiring their output distributions to remain close under a correlated Gaussian perturbation of the input matrix.The closeness is measured using Wasserstein distance in the large-dimension limit.
  • Existing results imply that stable algorithms fail to sample the posterior for suitable constraint densities and perturbation levels.The cited theorem applies to a specified range of slab widths, masking fractions, and stability parameters.

B.3. Proof outline of Proposition 3.3

The proof reduces masking problems to planted constraint-satisfaction inference, where known gaps between information-theoretic and efficient-algorithmic overlap imply computational hardness.

  • When latent tokens are masked and observations remain visible, prediction becomes recovery of an assignment consistent with observed constraints.This reduction connects masking problems to constraint satisfaction problems.
  • Planted CSP hardness results provide the basis for transferring inference-complexity gaps to masking problems.The planted CSP contains a hidden vector and random Boolean constraints promised to be satisfied by it.
  • Different thresholds for optimal and computationally efficient overlap predict when masking problems become computationally intractable.The proof uses established threshold predictions associated with vocabulary size, observation count, and predicate structure.
  • For planted coloring, masking variables with pairwise inequality observations reduces the masking task to recovering the hidden graph coloring.This gives a concrete CSP instance underlying the reduction.
  • For m = 5, the planted-coloring thresholds are DKS/2 = 16 and Dcond/2 ≈ 13.23.The factor of 2 arises because observations correspond to ordered subsets of size 2.
  • The framework extends to Bayesian constraint-satisfaction problems, including the stochastic block model, with analogous hardness predictions.The paper also describes sparse noisy-parity and generalized-linear observation examples.

B.4. Proof of Proposition 3.3: sparse predicate observations

The proof reduces masked prediction in sparse predicate-observation distributions to planted CSP recovery and uses BP thresholds to identify a computationally hard regime. Under the 1RSB cavity prediction, efficient recovery is predicted to be suboptimal between the condensation and Kesten–Stigum thresholds.

  • Reduction to planted CSPs: The construction models data as a planted CSP with latent variables, sparse predicate-valid observations, and average degree kP/N.A hidden assignment is sampled uniformly, and each ordered k-tuple yields an observation with probability ϕ/N^(k−1) when the predicate is satisfied.
  • Belief propagation: Belief propagation iteratively updates variable-to-observation messages and estimates posterior marginals for the latent assignment.Marginals are converted into assignments by selecting the alphabet value with largest probability mass.
  • Thresholds: DKS is the largest average degree at which BP remains locally stable around the paramagnetic fixed point.The threshold is characterized by the BP Jacobian having spectral radius less than 1.
  • Thresholds: Dcond is the largest average degree at which the planted CSP ensemble and a local-assignment null model are statistically indistinguishable as N →∞.The null model independently samples a local assignment for each ordered subset rather than using one global hidden assignment.
  • Hardness regime: For Dcond < kP/N < DKS, another BP fixed point has higher rounded overlap than randomly initialized BP, while efficient optimal recovery is predicted to be impossible.This intermediate regime is formalized by the 1RSB cavity prediction.
  • Reduction to planted CSPs: At suitable masking fractions, binomial concentration places the unmasked observations in the threshold interval, reducing the masking problem to planted-CSP inference.The proof establishes this reduction with constant probability depending on the gap between Dcond and DKS.

C.2.2. EXPERIMENT ON TEXT DATA

The text-data experiment evaluates likelihood-modeling performance under different token-order distributions. It compares uniform, closer-to-identity, and identical-order configurations using a pretrained MDM and repeated sampling over data examples.

  • Experimental setup: A 170M MDM pretrained on text data serves as the baseline for measuring imbalance across likelihood-modeling tasks.
  • Token-order distributions: The experiment samples token permutations from Unif(SL), Closer, and the point mass at the identical distribution.For each distribution, expectations are computed over 1024 samples of x0 ∼ pdata.
  • Puzzle evaluation: Five L&O-NAE-SAT instances compare vanilla and adaptive inference using the top probability margin.The instances use (N, P) = (25, 275), (30, 270), (40, 260), (50, 250), and (100, 200).

D.1.2. EXPERIMENT ON TEXT DATA

The text-data experiment adapts token-order selection with a temperature-controlled margin sampler and evaluates generation using perplexity and entropy. Deterministic and stochastic choices for the number of revealed tokens yield comparable generative perplexity.

  • Adaptive sampler: The temperature-controlled top-probability-margin sampler adds Gaussian noise to reduce greedy sampling that can harm generated-sample diversity.The method adapts oracle-based order selection for text, where no fixed correct answer determines the decoding order.
  • Evaluation: Generative evaluation uses a 1.1B text-pretrained MDM, Llama2-7B likelihoods, and entropy computed from token frequencies.Samples are generated unconditionally with both vanilla and adaptive inference at each sampling step.
  • Unmasking schedule: The number of tokens unmasked per transition is chosen to match vanilla MDM inference in expectation.The deterministic choice uses the expected reveal count, while the alternative samples that count from a binomial distribution.
  • Results: Deterministic and stochastic token-count choices produce comparable generative perplexity.
  • Unmasking schedule: The reveal-count choice can keep the number of remaining mask tokens near the training-time marginal for time-conditioned networks.This maintains approximately (1 − αt) × L masked-token scaling with sequence length L.

D.2. Experimental details on Sudoku and Zebra puzzles

The Sudoku and Zebra experiments use established puzzle datasets, small MDMs, and 50-step reverse sampling with different decoding strategies. The evaluation includes both standard-difficulty and harder easy-to-hard generalization puzzles.

  • Dataset: Training and test puzzles come from Shah et al. (2024), while harder puzzles are drawn from remaining Radcliffe (2020) instances requiring strategies beyond a fixed seven-strategy list.
  • Model, training, and inference: The experiments use a 6M GPT-2 model for Sudoku and a 19M model for Zebra, trained for 300 epochs with learning rate 0.001 and batch size 128.Inference uses 50 reverse sampling steps with the appropriate strategy and adds Gumbel noise.
  • Evaluation scope: The broader evaluation covers infilling and instruction-answering categories, using non-autoregressive sampling for infilling and semi-autoregressive sampling for instruction answering.Infilling output length matches the masked span, whereas instruction-answering tasks require explicit length specification.

E. Omitted proofs

The proof establishes an equivalence between the masked diffusion model loss and the any-order autoregressive loss for every clean sequence x0. It does so by expanding the random masking expectation and counting permutations that induce each masked-token prediction term.

  • The random masking process uniformly selects n masked tokens from a clean sequence x0.The proof represents the resulting masked sequence as x(n), with n masked tokens.
  • Expanding the masking expectation treats each masked sequence as x[M] for a subset M of token positions.This converts the expectation over masked sequences into a sum over position subsets.
  • The section proves equivalence between the MDM loss and the any-order autoregressive loss for all x0.
  • For a given M and target position i in M, a permutation must satisfy π(j)=i and {π(j),...,π(L−1)}=M to induce the corresponding prediction term.
  • (L − |M|)! × (|M| − 1)! permutations induce a specific term, and comparison with the L! total permutations yields the result.
Loading 2502.06768v3…