Method: Info-Gain Sampler
April 30, 2026 · View on GitHub
Motivation
Masked Diffusion Models (MDMs) have emerged as a powerful alternative to autoregressive models for discrete sequence generation. By leveraging bidirectional attention, MDMs break free from strict left-to-right generation. However, this potential remains largely untapped due to a training-inference mismatch: while MDMs are trained under random masking patterns, inference entails an order-sensitive decoding process.
Existing samplers rely on local certainty heuristics (confidence, entropy, margin) to greedily select the next decoding target. These methods are non-robust due to the myopia of local heuristics: they ignore the long-term impact of current decisions on future uncertainty.
Key observations:
- An optimal decoding action should be evaluated not only by its own prediction certainty but also by the information gain it provides for the remainder of generation.
- MDMs' bidirectional architecture enables efficient information gain estimation in one forward pass, bypassing expensive iterative computations.
Objective
We first define state uncertainty as the average marginal entropy over masked positions in state :
The information gain of action is the reduction in state uncertainty it induces:
where .
The immediate cost is the marginal entropy of the tokens being decoded at this step:
The Info-Gain Sampler selects the action that maximises:
Three-Step Cycle
At each decoding step:
- Sample — generate diverse (token, position) candidates via Gumbel sampling.
- Evaluate — score every candidate in one batched forward pass: for all .
- Transition — commit the highest-scoring candidate and repeat until all masked positions are filled.
Implementation Details
- Parallel candidate evaluation: all candidates are scored in a single batched forward pass, fully exploiting MDMs' bidirectional architecture.
- KV cache support: optional prefix-cache and dual-cache modes accelerate inference (disabled by default for multimodal tasks).
- Dynamic threshold: a high-confidence bypass () automatically skips the candidate-evaluation loop when uncertainty is already low, significantly reducing latency.
- No external dependencies: the core Info-Gain function is self-contained — no dllm required for the standalone API.