Order-Marginalized Scoring for Masked Diffusion Models

Arthur Deng, Sebastian ThrunNeurIPS 2026

TL;DR

Any-order autoregressive models and masked diffusion models are trained to fill in blanks in any sequence order, leading us to assume their probability estimates are order-independent. Surprisingly, they aren't: asking a model to score a sequence from left-to-right versus inside-out can yield completely different rankings and "most likely" completions. By averaging log-probabilities across just a handful of shared random decoding orders—a simple fix called Order-Marginalized Scoring (OMS)—we can eliminate this noise and substantially boost performance on tasks like solving Sudoku and predicting protein stability.

What Problem Does This Paper Address?

Standard language models read and write strictly left-to-right. Any-order autoregressive models (AO-ARMs)—and their close cousins, masked diffusion models (MDMs)—break this constraint. They train a single neural network to predict missing tokens given any subset of revealed positions. This makes them natural fits for tasks with no canonical direction, like completing a Sudoku grid or designing a 3D protein sequence.

Often, we don't just sample from these models; we use them as scorers to evaluate the log-probability of candidate sequences (for instance, using sequence likelihood as a zero-shot proxy for how stable a mutated protein will be). Because these models are trained with an objective that averages over all possible decoding permutations, it is tempting to assume they learn to be order-invariant—meaning any single random unmasking order should give roughly the same score.

Deng and Thrun show that in practice, this assumption breaks down. Evaluated under a single order, the model's score is a noisy proxy for its true belief. Different unmasking orders produce different highest-probability sequences ("per-order argmaxes") and scramble the rankings of candidate pools.

Figure 2: We compare the per-order argmaxes and rankings on a published Masked Diffusion Lan- guage Model checkpoint. Left: Complementary CDF of the number of distinct per-order argmaxes per prompt. On average 10.2 of the 16 per-order argmaxes of a prompt are distinct; all 16 differ on 2 of the 30 prompts. Note that most of these argmaxes are degenerate, with more than half repeating a single token (§3.3). Right: Distribution of pairwise Spearman correlations between rankings of a fixed candidate pool induced by random scoring orders. A perfectly order-invariant model would place all mass at one. The empirical distribution is broadly spread and well below one for the vast majority of order pairs.

Methods

Instead of trusting a single arbitrary unmasking order $\sigma$, the authors target the order-marginalized log-likelihood, $\tilde{\mu}(x)$, which is the expected per-order log-probability across all possible permutations. While summing over $T!$ permutations is intractable, it can be cleanly estimated via Monte Carlo sampling—averaging the log-probabilities over $M$ randomly drawn orders. This estimator is Order-Marginalized Scoring (OMS), deployed in two algorithms:

  • OMS-rerank: Given a fixed pool of candidate sequences, draw $M$ random decoding orders shared across all candidates, score every sequence under those $M$ orders, and rank them by their average log-probability.
  • OMS-bon (Best-of-$N$): A complete decoding algorithm. It generates $N$ diverse candidate completions by combining an existing adaptive position selector ("top-prob", which unmasks the most confident position next) with stochastic temperature sampling. Once the pool is generated, OMS-rerank steps in to pick the winner.

Datasets

  • Synthetic PCFG (New): A newly constructed topic-mixture Probabilistic Context-Free Grammar where the true most-likely completion (data mode) can be computed in closed form, allowing exact measurement of mode recovery.
  • Sudoku: $9 \times 9$ solved grids for training, evaluated on unique-solution puzzles with 25, 28, or 31 given hints.
  • Megascale: An existing biology benchmark containing experimental folding stabilities ($\Delta\Delta G$) for 306,501 single-amino-acid mutants across 337 wild-type proteins, scored using the pre-trained ProteinMPNN model.
  • OpenWebText & WikiText-103: Standard web/Wikipedia text datasets. The authors evaluate a published 170M-parameter MDM checkpoint (trained on OpenWebText) on prompts and 4-token span-infilling tasks drawn from WikiText-103.

Key Insights and Ideas

  • Near-perfect score agreement doesn't prevent total mode disagreement: In Proposition 1, the authors prove a counterintuitive worst-case pathology: even as a model's log-probability disagreement across orders shrinks toward zero ($\varepsilon \to 0$), its most-likely sequences under two different orders can still disagree at every single position. Tiny per-token tilts can flip the global winner.
  • OMS finds the mathematical "center of mass": Why average log-probabilities rather than probabilities? Proposition 2 shows that $\exp \tilde{\mu}(x)$ corresponds to the unique reverse Kullback–Leibler (KL) barycenter—or logarithmic opinion pool—of the per-order distributions. It is the single distribution closest to the model's fractured per-order beliefs.
  • Sharing random orders cancels noise: In protein stability prediction, standard scripts draw a fresh random unmasking order for every mutant. Simply fixing and sharing even a single random order across all mutants of a protein yields a massive jump in accuracy, because order-induced noise stops jittering the relative comparisons. Averaging over $M$ shared orders refines this further.

Key Results

  • PCFG Mode Recovery: Single-order beam search recovers the true mathematical mode only 36.0% of the time. OMS-rerank ($M=16$) boosts hit rates to 50.9%, nearly reaching the pool's oracle ceiling of 52.3%.
  • Sudoku Completion: On 28-hint puzzles, OMS-bon ($N=512, M=4$) achieves 85.3% exact-match accuracy, beating deterministic adaptive decoding (top-prob at 34.0%) and outperforming a single-order best-of-1024 baseline (67.3%) despite using fewer forward passes.
  • Protein Stability (Megascale): Switching from a fresh random order per mutant to a single shared random order jumps mean Spearman correlation with experimental stability from 0.463 to 0.534. Applying shared OMS ($M=32$) pushes correlation to 0.545, outperforming a single shared order on 335 out of 337 protein families.
  • Text Infilling: On WikiText-103 span infilling, reranking candidates by log-probability beats picking at random (+0.094 F1), but OMS ($M=4$, 0.300 F1) offers no meaningful gain over single-order reranking (0.297 F1).

Limitations and Future Work

  • Compute overhead: OMS trades compute for accuracy. Scoring $U$ distinct candidates under $M$ orders requires $U \times M \times T$ forward passes. On 28-hint Sudoku, OMS-bon ($N=512, M=4$) uses $862\times$ more forward passes than greedy top-prob.
  • Task-dependent gains: OMS shines on structurally order-agnostic problems (Sudoku, protein folding) where true log-likelihood tracks the target metric, but yielded flat results on text infilling. Pinpointing exactly when order marginalization helps—and testing it on code or math—remains an open question.
  • One-by-one unmasking: All experiments unmask one token per step. Extending and testing OMS in parallel block-decoding regimes (unmasking multiple tokens simultaneously), choosing $M$ adaptively, and combining OMS with trajectory-uncertainty heuristics are left for future work.

Summary updated

Abstract

Any-order autoregressive models are trained under an objective that is symmetric over decoding orders, but at sampling time a single order must be committed to. A common task with such models is to evaluate the log-probability of a candidate sequence. We show that this evaluation depends substantially on the decoding order used to compute it: for a model trained on a synthetic grammar, different orders yield different most-likely completions; for a model pre-trained on OpenWebText, different orders rank the same candidates differently on most inputs. We characterize this phenomenon and propose Order-Marginalized Scoring (OMS), a simple Monte Carlo estimator of the per-order log-probability averaged over decoding orders. We use it in two algorithms: a reranker over a fixed candidate pool, and a stochastic best-of-N decoder. OMS helps on two structurally order-agnostic tasks: on Sudoku puzzles with 28 given digits, we show that OMS improves exact-match accuracy from 67% with single-order scoring to 85%; on a zero-shot protein-stability benchmark, OMS improves the Spearman correlation between log-probability scores and experimental folding stabilities for 335 out of 337 protein families. On text infilling, however, OMS does not improve accuracy over reranking with a single random order. These results suggest that OMS is a useful alternative to per-order scoring for order-agnostic tasks where log-likelihood tracks the quantity of interest.
BibTeX
@inproceedings{deng2026order,
  author = {Arthur Deng and Sebastian Thrun},
  title = {{Order-Marginalized Scoring for Masked Diffusion Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=EE2N89jedk},
}
Figure