Diffusion Language Models Deep Dive · May 2026

The
Diffusion
Revolt
Runs
Locally

LLaDA proved autoregression is not the only path to language intelligence. This is a complete guide to the theory, the architecture, and the sampling algorithm, with a working MLX implementation for local inference.

Masked Diffusion 8B Parameters Apple Silicon Open Source
Live sampling process — masked diffusion reverse pass

Every language model in production today generates text the same way: one token at a time, strictly left to right, never reconsidering what came before. The field treated this as a law of nature. LLaDA proves it was always an assumption. And not a necessary one.

This post covers the full picture: the theoretical challenge LLaDA mounts against autoregressive orthodoxy, the exact architecture and sampling algorithm, how MLX's unified-memory design maps to LLaDA's inference structure, and where the implementation does and does not perform. The full code lives in the GitHub repository, linked throughout.

Chapter I

The Heresy

Autoregressive models (ARMs) factorize the probability of a sentence as a product of conditionals: p(x₁) × p(x₂|x₁) × ... × p(xₙ|x₁...xₙ₋₁). The chain rule of probability makes this mathematically exact. But it bakes in a directional constraint: token i can only see tokens 1 through i−1. The attention mask enforces this structurally. It is not a soft bias, it is a hard architectural ceiling.

ARM — the reversal curse

Train on "A implies B."
Infer "B implies ___."
Model fails structurally.
The attention graph
never pointed rightward.

Not a tuning failure. Architectural.

LLaDA — bidirectional from step one

Full bidirectional attention
at every denoising step.
Every token sees every token.

42% reversal accuracy.
GPT-4o: 25%. LLaMA3-8B: 12%.

LLaDA's central argument is precise: the intelligence in LLMs comes not from autoregression itself, but from the deeper goal both ARMs and diffusion models pursue — approximating the true language distribution via maximum likelihood. The chain-rule factorization is one valid road to that destination. It is not the only road. Masked diffusion models reach the same destination through a different mechanism, with a different set of structural properties.

If the causal mask is just a constraint we added, not something the architecture requires, then what else are we training models to do that they don't actually need to?

The paper was accepted as an oral presentation, a distinction awarded to fewer than 1% of submissions. The field apparently considered this a genuinely landmark result, not an incremental variation. Whether that consensus holds as follow-up work accumulates is the more interesting question.

Chapter II

How LLaDA Works

LLaDA is a Masked Diffusion Language Model. It has two processes: a forward process that corrupts text by masking tokens, and a reverse process that reconstructs text by iteratively unmasking them. Both are trained jointly; only the reverse process runs at inference.

Forward process. During pretraining, a sentence of L tokens is taken, a masking ratio t ~ Uniform(0,1) is sampled, and each token is independently replaced by a [MASK] token with probability t. A bidirectional Transformer then predicts all masked tokens simultaneously, conditioned on the unmasked ones. The loss is cross-entropy over masked positions, forming a variational lower bound (ELBO) on the model's log-likelihood.

Why uniform masking ratio is the decisive difference from BERT: BERT uses a fixed 15% mask rate. LLaDA's variable rate, spanning 0 to 100%, trains the model on everything from "fill in one word" to "generate the entire sequence from scratch." The ELBO bound on log-likelihood only holds when t is sampled uniformly. This makes LLaDA a proper generative model with Fisher consistency for scaling, not a discriminative fill-in-the-blanks system.

Reverse process. At inference, the response field is initialized as all masks. The model runs N denoising steps from t=1 down to t=0. Each step:

01

Predict

A full bidirectional forward pass computes logits for every masked position simultaneously. Every token sees every other token: prompt and partial response both.

02

Commit

The highest-confidence predictions are permanently unmasked. These tokens are locked in for all remaining denoising steps; they become context for future predictions.

03

Remask

The lowest-confidence predictions are re-masked. With more committed context available, the model can resolve these uncertain positions in the next step.

04

Repeat

This semantic annealing, high-confidence anchors first and fine detail last, continues until t=0 and every position is filled.

Step through the reverse diffusion process
Chapter III

The Architecture — Minimal Delta

The most important implementation detail the paper buries: LLaDA's Transformer is structurally near-identical to LLaMA 3 8B. Same hidden dimension (4096), same 32 layers, same RMSNorm, same SwiGLU activations, same RoPE positional embeddings. There is exactly one architectural change from a standard decoder:

Remove the causal mask. That is the entire change.

In a decoder-only LLM, the attention matrix is masked so token i can only attend to tokens 1 through i. In LLaDA, that restriction is removed. Every token attends to every other token: full bidirectional attention, structurally equivalent to BERT's encoder.

No timestep conditioning. No injected noise-level embeddings. The masking ratio is implicit in how many [MASK] tokens appear in the input sequence; the model infers noise level from context.

In mlx-d, the entire patch is a single line:

Python — mlx_d/model.py
# The single architectural delta from LLaMA → LLaDA:
# Remove the causal attention mask for bidirectional attention.
import mlx_lm.models.llama as llama_mod

llama_mod.create_attention_mask = lambda *a, **kw: None
Chapter IV

MLX and Unified Memory

Traditional ML frameworks treat CPU and GPU as separate devices with separate physical memory. On Apple Silicon, this distinction does not exist. The CPU, GPU, and Neural Engine share one physical memory pool. MLX is designed from the ground up around this reality.

Zero-copy operations. An MLX array lives once in memory. Any compute unit operates on it in place with no transfers, no synchronization overhead. For LLaDA's repeated full forward passes over the full sequence, this eliminates the dominant bottleneck that exists on discrete-GPU systems.

Lazy computation and graph compilation. MLX evaluates lazily, so arrays materialize only when needed. Applying mx.compile() to the forward function yields consistent throughput gains on subsequent calls. Always run one warmup pass before benchmarking: first-pass shader compilation is a one-time cost.

Memory budget — LLaDA-8B across hardware configurations
Full precision (bf16 / fp16) ~16 GB — exceeds most consumer GPU configs
8-bit quantized ~8 GB — tight on 8 GB devices, workable on 16 GB+
4-bit quantized (recommended default) ~4.5 GB — comfortable on most consumer hardware
Activation memory (128-token response) ~0.4 GB
KV cache overhead 0 GB — LLaDA has no KV cache
Net footprint (4-bit, 128-token response) ~5 GB total

The zero KV cache line deserves attention. AR models must cache all previous key-value pairs to avoid recomputing attention from scratch at each generation step; the cache grows linearly with sequence length. LLaDA doesn't generate left-to-right; no prefix accumulates. Memory usage is fixed and predictable regardless of response length.

Chapter V

Implementation — What Actually Matters

The full implementation is in the repository. What follows explains the non-obvious decisions that determine whether a working implementation produces coherent text or noise.

The sampling loop. The standard mlx_lm.generate function implements autoregressive sampling and is structurally incorrect for LLaDA. A custom loop is required:

Python — mlx_d/sampler.py (core loop)
# Confidence via logsumexp trick: avoids materializing the
# full (1, seq_len, vocab_size) softmax tensor (~130MB/step).
x0_logits = mx.take_along_axis(
    logits, mx.expand_dims(x0, axis=-1), axis=-1,
).squeeze(-1)
lse = mx.logsumexp(logits, axis=-1)
confidence = mx.exp(x0_logits - lse)

# Commit top-k via argpartition (O(n) vs O(n log n) sort)
partitioned = mx.argpartition(conf_flat, kth=conf_flat.shape[0] - k)
top_indices = partitioned[-k:]

Remasking strategy. Two options: random remasking and low-confidence remasking. For the Instruct model, low-confidence remasking is measurably better. Random remasking occasionally re-masks tokens the model was confident about, wasting steps. Low-confidence remasking only re-masks positions the model is genuinely uncertain about.

Semi-autoregressive block mode. The recommended configuration splits the response into blocks (default: 32 tokens) processed left-to-right, with tokens within each block unmasked in parallel. 64 passes over 128 tokens becomes 4 block passes of 32 tokens each.

Shell — Quick start
# Install
pip install mlx-d

# Generate text
mlx-d generate "What is masked diffusion?" --steps 64 --block-length 32

# Run benchmarks
mlx-d benchmark

# Speculative diffusion decoding
mlx-d spec-decode "Explain LLaDA." --draft-steps 8

Full implementation on GitHub

Sampler, speculative diffusion decoding, conversion scripts, semi-AR block mode, benchmarks, and interactive examples.

View Repository →
Chapter VI

Where LLaDA Wins, Where It Doesn't

The benchmark picture is honest. LLaDA-8B-Instruct is competitive with LLaMA 3 8B on general knowledge, definitively better on bidirectional constraint tasks, and currently weaker on multi-step mathematical reasoning.

Task LLaDA-8B LLaMA3-8B Status
MMLU (general knowledge)
64.8%
65.3%
Essentially identical
Reversal poem completion
42%
12%
LLaDA wins — beats GPT-4o (25%)
GSM8K (math reasoning)
~22%
~73%
Known gap — sampling-level issue
In-context learning Competitive Strong Closes with more denoising steps
Multi-turn dialogue Strong Strong Comparable after SFT

The math weakness has a precise diagnosis. The literature now calls it the Flexibility Trap: confidence-based token selection during denoising systematically produces generation orders that approximate left-to-right sequential behavior.

The d1 framework (RL for diffusion LMs) reached approximately 84.5% on GSM8K with LLaDA by replacing confidence-based selection with policy-gradient optimization. The model weights are not the bottleneck. The sampling algorithm is.

LLaDA's weaknesses are in the sampling algorithm, not the weights. The weights generalize well. The field is rapidly improving the decoder.

Chapter VII

Real Applications — Diffusion at the Periphery

The highest near-term value from LLaDA is not as a drop-in replacement for production AR systems. It is as a targeted component inside existing pipelines, deployed where its specific structural properties address bottlenecks that AR models handle poorly.

A

Speculative Draft Model

LLaDA as the drafter in speculative decoding: proposes K tokens in parallel in one forward pass, versus K sequential passes for an AR drafter. Up to 8.7× speedup.

B

Constraint-Satisfying Output

Bidirectional constraints (structured formats, code with matching delimiters, fill-in-the-middle): known endpoint tokens can be fixed as permanent anchors from step zero.

C

Voice AI Acceleration

LLaDA-TTS: AR TTS checkpoint converted to masked diffusion by changing only the attention mask. 2× LLM-stage speedup. Zero-shot speech editing as a structural byproduct.

mlx-d includes a complete speculative diffusion decoding implementation: drafter-verifier framework, acceptance criterion, and throughput benchmarks. The voice pipeline that motivated this project is available as an optional install (pip install mlx-d[voice]).

Speculative Diffusion Decoding — in the repository

Complete SpecDiff implementation: drafter, verifier, acceptance criterion, and throughput benchmarks.

View Code →
∎

The Bigger Picture

LLaDA establishes something the field will be unwinding for years: the generation algorithm and the model architecture are separable concerns. A Transformer without a causal mask, trained with the right objective, achieves competitive language understanding at 8B scale. The autoregressive mechanism is not intelligence. It is one implementation of the goal.

MLX establishes something equally important on the hardware side: unified memory architectures remove the dominant inference bottleneck for non-standard models. Running frontier research locally is no longer purely a function of hardware budget.

The boundaries between AR and diffusion, between cloud and local, between research prototype and production pipeline are all softer than they appeared twelve months ago. The implementation is in the repository.

What this doesn't resolve

The training objective difference between LLaDA and BERT is mathematically precise, but it raises a question nobody has fully answered: if uniform masking ratio is what makes LLaDA a proper generative model, what does that imply for masked language models trained with other non-uniform schedules?

The Flexibility Trap is a real and documented failure mode, but the d1 results suggest it is fixable at the sampling level without retraining. If RL-based sampling can recover the bidirectional advantage on structured reasoning tasks, then the question of what the weights actually represent becomes more interesting.

The LLaDA GUIDELINES.md on HuggingFace is worth reading carefully. The authors document their own failures honestly: why semi-autoregressive-origin mode fails on the Instruct model, why base and instruct models need different remasking strategies.