Abstract Learning models with categorical variables requires optimizing expectations over discrete distributions, a setting in which stochastic gradient-based optimization is challenging due to the non-differentiability of categorical sampling. A common workaround is to replace the discrete distribution with a continuous relaxation, yielding a smooth surrogate that admits reparameterized gradient estimates via the reparameterization trick. Building on this idea, we introduce ReDGE, a novel and efficient diffusion-based soft reparameterization method for categorical distributions. Our approach defines a flexible class of gradient estimators that includes the Straight-Through estimator as a special case. Experiments spanning latent variable models and inference-time reward guidance in discrete diffusion models demonstrate ReDGE consistently matches or outperforms existing gradient-based methods.
The Challenge of Discrete Choices
In machine learning, models frequently encounter discrete choices—selecting a word in a sentence, an action in a game, or a pixel value in an image. Training these models typically relies on gradient descent, which requires differentiable operations. However, discrete choices act like step functions: they are flat with sudden jumps, making them inherently non-differentiable. You cannot calculate a slope for a sudden jump.
To circumvent this, researchers traditionally employ "continuous relaxations," such as the Gumbel-Softmax trick, which smooth out the steps into a differentiable curve. Unfortunately, these relaxations often fall into a "Temperature Trap." At high temperatures, the relaxation is very smooth but deviates significantly from the original discrete distribution, introducing high bias. At low temperatures, the relaxation closely approximates the discrete choice, but the gradients become so steep or flat that the model suffers from vanishing or exploding gradients, halting the learning process.
Introducing ReDGE: Diffusion as a Relaxation
To address the limitations of traditional continuous relaxations, researchers have introduced the Reparameterized Diffusion Gradient Estimator (ReDGE). ReDGE is a novel, training-free method for propagating gradients through discrete categorical variables. By treating the sampling process as a short "diffusion" path from Gaussian noise to a discrete choice, ReDGE provides a differentiable bridge that generalizes popular methods like the Straight-Through estimator while offering superior stability.
Unlike standard diffusion models (such as DALL-E) that require training massive neural networks to denoise data, ReDGE leverages the fact that for simple categorical distributions, the "denoiser" has a closed-form mathematical solution. Because the target is a set of one-hot vectors (the vertices of a simplex), the mathematics simplifies beautifully into a series of softmax operations. This makes ReDGE entirely training-free. It constructs a differentiable mapping from standard Gaussian noise to a categorical sample by simulating just a few steps of a reverse diffusion process.
Flexibility and Variants
ReDGE's behavior is controlled by two main parameters: the number of steps ($n$) and the cutoff time ($t_1$). The cutoff time $t_1$ acts as the new "temperature." The authors prove mathematically that as $t_1$ approaches zero, the gradients eventually vanish, providing a theoretical boundary for practitioners to avoid. By adjusting these parameters, ReDGE can act as a standard Straight-Through estimator (at 1 step) or a sophisticated, multi-step sampler that yields highly informative gradients.
The authors also introduce two notable variants:
- ReDGE-COV: Initializes the noise based on the current model's parameters to accelerate convergence.
- ReINDGE: A second-order version designed for higher accuracy in specific mathematical objectives.
Experimental Validation
ReDGE was rigorously tested across several challenging domains, proving to be the most reliable estimator across all benchmarks. While other methods occasionally excelled in specific niches, ReDGE consistently performed well with minimal hyperparameter tuning.
- Sudoku Guidance: Using a Masked Diffusion Model to solve Sudoku puzzles, the rules of the game were treated as a reward to guide the model toward valid completions. In a weak baseline model that initially solved only 1% of puzzles, applying ReDGE guidance skyrocketed the solve rate to 89%. The ReDGE-COV variant achieved an impressive 93% solve rate when applied to a stronger baseline.
- Reward-Guided Image Generation: Tested on ImageNet using a pre-trained MaskGIT generator, ReDGE successfully steered image generation to match specific text prompts (e.g., "A red bee on a flower") using CLIP scores. It outperformed the REINMAX estimator and remained highly competitive with the Straight-Through method.
- Latent Variable Models: ReDGE demonstrated strong performance on Binarized MNIST for training Categorical Variational Autoencoders (VAEs) and on synthetic Polynomial Programming benchmarks used to precisely measure gradient accuracy.
Limitations and Future Directions
Despite its advantages, ReDGE introduces a modest computational overhead. While training-free, generating a sample and its gradient requires multiple steps (typically 3 to 9), making it slightly slower than a single-step Gumbel-Softmax sample. However, the performance gains generally justify this extra computation. Additionally, while ReDGE is more robust than Gumbel-Softmax, it still requires tuning the hyperparameters $t_1$ and $n$. The authors provide strong defaults (e.g., $n=3, t_1=0.5$), but optimal performance may require some sweeping.
Looking forward, the authors suggest combining ReDGE with control variates—such as REBAR or RELAX—to further reduce gradient noise. This combination has the potential to yield the most accurate discrete gradient estimator developed to date.
Summary updated