A Visual Tour of Efficient Non-Autoregressive Generation
Autoregressive language models are the workhorse of modern AI. Practically every major LLM in production today, from GPT to Claude to Gemini, is autoregressive at its core: they generate text one token at a time, left to right, each token conditioned on everything that came before. A remarkable amount of engineering effort has gone into making this loop fast. Techniques like kernel optimization, KV caching, and speculative decoding [?] shave cost off every generated token, and modern GPU architectures and custom accelerators like TPUs are co-designed with this particular workload in mind, all to squeeze more tokens per second out of the same fundamentally sequential recipe. But at some point it's worth asking: what comes next? What are the alternatives to autoregression?
Masked diffusion language models [?] offer one such alternative. Where an autoregressive model builds a sequence left to right one token at a time, a masked diffusion model starts from a fully-masked sequence and progressively unmasks tokens in any order, potentially several at once. The most immediately appealing consequence is parallelism: because multiple tokens can be unmasked in a single reverse step, generation is no longer bottlenecked on producing one token at a time. There are other reasons to be interested. The model can revisit and revise tokens it already committed to, a technique called remasking [?] . And there is evidence that a non-autoregressive unmasking order is a better inductive bias for problems whose dependency structure isn't left-to-right [?] . But the parallelism argument is the one that promises a clean systems win, and it is what first drew attention to this paradigm.
But applied naively, they aren't actually faster. Unmasking many tokens per step sounds like a straightforward speedup, and it would be, if inference cost were just "number of forward passes." It isn't. Masked diffusion models leverage bidirectional attention, which is strictly more powerful than the causal attention that autoregressive models use, but at the cost of violating core assumptions required for KV caching. KV caching is the ability to reuse computed keys and values from previous passes, made possible by the one-way flow of information from left to right. The rest of this post is about that tradeoff: what assumptions enable efficient AR inference, why masked diffusion violates these assumptions, and how the field is putting the pieces back together.
Before we get to masked diffusion, it is worth revisiting the idea it builds on: masked language modeling. The task is simple to state. Take a sentence, replace a few of its tokens with a special [MASK] symbol, and ask a neural network to predict the original tokens at the masked positions. For each masked position, the network emits a full categorical distribution over the vocabulary, and we take the argmax (or sample from it) to fill the slot in.
This is exactly the pretraining objective of BERT [?] . For each training sentence , BERT samples a random subset of positions — canonically 15% of them — and replaces each of those tokens with [MASK] to produce a corrupted sequence . A bidirectional transformer then predicts a categorical distribution over the vocabulary at every masked position, and the loss is cross-entropy on those positions only:
Geometrically, cross-entropy is a force pulling the model's predicted distribution toward the one-hot target . As training progresses, whatever mass the model is currently spreading over near-miss vocabulary words gets pulled onto the single correct word.
This loss is fantastic for representation learning: fill-in-the-blank is a hard enough task that the transformer has to build genuinely useful features to solve it, which is why BERT is such a strong starting point for downstream classifiers and encoders. But BERT was never designed to generate text, and it turns out that a 15%-MLM model can't do it, for a subtle reason.
How would we go about generating a novel sequence with a model trained like this? The natural thing to try is to hand it an input that is entirely [MASK] and ask it to fill in every position at once:
But this input is drawn from a distribution the model has never encountered during training: every training example BERT ever saw had 85% of its tokens still visible as context. With no real tokens to condition on, the model has nothing to anchor its predictions to — the outputs are essentially untrained behavior. And the problem is not unique to the 100% case. To generate a sequence from scratch we need a model that behaves sensibly all the way from “fully masked” to “almost done”, which is a continuum of masking rates that BERT's fixed 15% schedule simply never visits.
This is the gap masked diffusion closes. The core observation is small but transformative: instead of training on a single fixed masking rate, train the same architecture on a whole family of masking rates — every rate from 0% to 100%. The resulting model can be handed an input at any level of corruption and produce a sensible prediction, and that turns it from a representation learner into a generative model.
A different way to see the two paradigms: freeze the decoder after each step and stack the intermediate lines from top to bottom. Row 0 is the empty (fully-masked) sequence; row k is the sequence after k tokens have been generated; the last row is the fully-decoded line. The autoregressive block reveals slots strictly left-to-right; the masked diffusion block reveals slots in a random order — you can see this by tracking which column gains a word from one row to the next.
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
The little cat sat on the warm mat
Turning “train on every masking rate” into an actual algorithm takes a bit of scaffolding. We need to say how to corrupt a sequence to any target rate (the forward process), how to invert one step of that corruption at inference time (the reverse process), and how to weight the different rates against each other when we train (the training loss). Once those three pieces are in place, generation is just the iterative unmasking loop from the previous section — run in reverse from a fully-masked start. We follow the MDLM formulation throughout [?] .
Let be a clean sequence of length over vocabulary , and let denote the special absorbing mask token. A monotone schedule with (all clean) and (fully masked) defines the noising marginal:
We write these per-position distributions as , a categorical distribution over outcomes with probabilities summing to one.
Each position is independently either kept as its original token with probability or absorbed into with probability . Once a position is masked, it stays masked at all later times — that is what makes the process absorbing.
The model is trained to predict a categorical over the clean token at each masked position (the SUBS parameterization: mask probability is fixed at zero, and unmasked positions carry over unchanged). Plugging into the true posterior of the forward process gives the reverse step for :
Unmasked positions carry over deterministically. Masked positions either stay masked with weight or unmask to the predicted clean token with weight .
With the forward and reverse processes fixed, the training objective writes itself. We want the model to be accurate at every masking rate visited by the schedule, so we take an expectation of the per-rate MLM loss from the previous section over as well as over the corruption at that rate. The continuous-time NELBO [?] collapses (after the SUBS parameterization) to exactly this — a weighted cross-entropy on the masked positions:
Here is the set of positions masked at time , so the underbraced term is literally the MLM loss from the previous section, evaluated on the corrupted sequence . The MDLM objective is that same MLM loss, averaged over all rates in the schedule and weighted by . Unmasked positions contribute zero, since carry-over guarantees a perfect prediction there.
In continuous diffusion, the forward process transforms data into a Gaussian, destroying information, and the reverse process aims to generate new data by reversing this information-destroying process.
In masked diffusion, the forward process destroys information through discrete masking, and likewise generation is framed as reversing this forward masking process.
Once there was a small cat named Milo . He lived in a tall red house on a big green hill . Every day he sat by the door and saw the birds fly by . One day a bird came and sang a song for him .
Applied naively, masked diffusion is not actually faster than autoregression. The naïve promise — "unmask many tokens at once, skip the token-by-token loop" — only holds if we ignore how autoregressive inference is actually made cheap in practice. AR is fast not because it does less work per token in the abstract, but because the systems layer underneath it exploits a very specific property of the model: past hidden states never depend on future tokens. A masked diffusion model doesn't have that property, and once we look at what that costs on real hardware, the raw parallelism advantage evaporates. This section walks through the pieces: the causal-attention mask underlying AR transformers, how KV caching exploits it to make inference cheap, why masked diffusion breaks the caching assumption, and finally how block diffusion recovers a version of caching without giving up parallel within-block decoding.
Autoregressive transformers restrict attention to a specific pattern. The query at position t can only attend to keys at positions — every row of the attention matrix is masked to a lower-triangular shape. That means information flows strictly one way, from past to future: a token at position t knows about tokens 1…t, and no token to its right ever influences it. This is causal attention, and it is the property that makes efficient AR inference possible.
The one-way flow of information is what lets autoregressive inference reuse work across generation steps. Because past keys and values never depend on tokens that come later, they never need to be recomputed when new tokens are generated — they are safe to cache. The keys and values computed for each past token are stored in memory once and read back on every subsequent step, instead of being recomputed from scratch. The figure below stages the pieces before we walk through the mechanism: on the left, a High Bandwidth Memory block containing one KV cache per transformer layer; on the right, the transformer stack itself, with input tokens up top and the residual stream flowing down through three self-attention layers. The dashed cell in each row marks the token about to be generated.
Masked diffusion breaks the causal-attention assumption. Because the encoder is bidirectional, every position's hidden representation is a function of the whole current context. When a single [MASK] commits to a word at one reverse step, the hidden representation at every other position — including positions that stay masked — changes as well. Any keys or values a cache stored while position j was masked are out of date the moment j commits. The figure below shows two forward passes of the same transformer on an eight-token sentence: one before the commit, one after. Between the two passes, the colored square that stands in for the hidden state at each position shifts — every position, not just the one that was unmasked.
It's worth distinguishing masked diffusion from any-order autoregression here, since they can look similar at a glance and the difference matters for caching. Any-order autoregression fixes an unmasking order ahead of time and then decodes strictly along that order — each position conditions only on positions earlier in the chosen order. That model class is strictly weaker than full masked diffusion: it can't adapt the unmasking order to the sample, can't unmask multiple positions in parallel per step, and can't revise a committed token. What it can do is cache KVs along the fixed order, because along that order the model is still causal. Full masked diffusion gives up that fixed order to buy adaptive parallel decoding, and pays for it with a broken cache.
Block diffusion is the compromise between the two extremes. Tokens are grouped into fixed-size blocks; within a block, tokens are generated in a random order — masked-diffusion style, with each pending slot shown as a gray rectangle. Across blocks, generation is strictly left-to-right: block k+1 only starts once block k is fully revealed. The result is diffusion-style parallel filling inside each block, autoregressive ordering between blocks — and, because once a block is fully unmasked its KVs are frozen with respect to any later block, KV caching works along the block-level order. Within-block inference cost is per reverse step, and , so total inference cost drops close to AR asymptotically while keeping parallel decoding and adaptive order inside each block.