Diffusion Reinforcement Learning Meets Trajectory Distribution Matching

iTDM: Reinforcing Diffusion Models by Instantaneous Trajectory Distribution Matching

Yihong Luo

Hong Kong University of Science and Technology

The Hong Kong University of Science and Technology
GenEval2 scaling performance of iTDM vs DGPO, DiffusionNFT, AWM, and GRPO-fast on SD3.5-Medium
GenEval2 scaling on SD3.5-Medium. iTDM reaches the 0.75 milestone in ~150 GPU hours—nearly 3× faster than competing forward diffusion RL methods (DGPO, DiffusionNFT, AWM) and over 8× faster than trajectory-based GRPO-fast—while smoothly scaling to 0.87 without late-stage training collapse.
~3× Faster → 0.87
GenEval2 convergence over DGPO / NFT / AWM, scaling smoothly without collapse
0.63 → 0.97
GenEval under CFG-guided online RL on SD3.5-M (0.98 under unguided policy)
0.59 → 0.96
Visual text rendering (OCR) at CFG = 4.5, breaking the 0.70–0.76 drift bottleneck
Online & Offline
Unified stationary target; surpasses Diffusion-DPO even in pairwise (G = 2) offline RL

Abstract

Forward diffusion reinforcement learning (RL)—enabling deterministic ODE sampling without trajectory backpropagation—has grown increasingly popular for efficiently aligning diffusion models. However, we reveal that existing methods essentially rely on signed reward-weighted regression (RWR), regressing the trainable policy velocity onto rollouts from a behavior distribution. Unbiased baseline subtraction implicitly assumes that the policy velocity equals the behavior marginal velocity—an idealized assumption violated under classifier-free guidance (CFG) rollouts, offline/off-policy updates, and imperfect online self-consistency. This behavior–policy mismatch breaks baseline invariance and injects baseline-induced gradient drift, destabilizing training.

To resolve this issue, we propose Instantaneous Trajectory Distribution Matching (iTDM), taking the infinitesimal limit of Trajectory Distribution Matching toward a time-local reward-guided target via the posterior-score identity to yield a sample-level gradient anchored at the behavior velocity—without learning an additional reward-tilted target score. Tracking this velocity with a lightweight online auxiliary denoiser guarantees exact baseline invariance at the auxiliary optimum, effectively suppressing baseline drift across both online and offline RL.

Extensive experiments on SD3.5-Medium across compositional image generation, visual text rendering, and human preference alignment show that iTDM achieves state-of-the-art in-domain and out-of-domain performance. Notably, on the challenging GenEval2 benchmark, iTDM converges nearly 3× faster than competing methods while scaling smoothly to 0.87 without collapse.

Qualitative Comparisons

Signed RWR pulls the trainable policy toward coarse few-step rollout marginals while drifting under CFG velocity mismatch. By anchoring residuals at the behavior velocity \(v_\phi \approx v_q\) and regularizing solely toward the pretrained reference \(v_{\mathrm{ref}}\), iTDM preserves crisp textures, rich scene context, and accurate typography across both unguided and CFG-guided regimes.

Human Preference Alignment (PickScore, CFG = 1.0)

Click image to enlarge
Qualitative comparison on PickScore with SD3.5-Medium under CFG = 1.0
Qualitative comparisons on human preference alignment (PickScore) with SD3.5-Medium. All models are trained and evaluated under \(\mathrm{CFG}=1.0\). Compared with NFT (23.89), AWM (23.94), and DGPO (23.85), iTDM (24.06) faithfully follows intricate prompt details—such as metallic robot reflections, neon storefront signage, and geometric glass vases—while delivering sharper textures and avoiding blurry few-step artifacts.

Visual Text Rendering: Conditional (CFG = 1.0) vs. CFG-Guided (CFG = 4.5) Online RL

Click image to enlarge
Visual text rendering comparison without CFG vs with CFG on SD3.5-Medium
Unlocking stable CFG-guided RL for visual text rendering. Left (train w/o CFG): Without guidance, baselines overfit text accuracy by collapsing onto plain, context-free white backgrounds. Right (train w/ CFG): With \(\mathrm{CFG}=4.5\), baselines retain scene context but suffer severe velocity-mismatch drift, producing distorted or illegible text (0.70–0.76 OCR). iTDM excels in both regimes, uniting rich photorealistic scene fidelity with sharp, accurate typography (0.96 OCR) under CFG-guided RL.

Why Forward Diffusion RL Drifts — and How iTDM Fixes It

1. Hidden Fragility of Existing Forward Diffusion RL (Signed RWR)

Along the linear flow-matching path \(\mathbf{x}_t = (1-t)\mathbf{x}_0 + t\epsilon\) with conditional velocity \(v(\mathbf{x}_t \mid \mathbf{x}_0) = \epsilon - \mathbf{x}_0\), rollout sampling induces a behavior distribution \(q_0\) with noisy marginal \(q_t\) and marginal velocity \(v_q(\mathbf{x}, t) = \mathbb{E}[v(\mathbf{x}_t \mid \mathbf{x}_0) \mid \mathbf{x}_t = \mathbf{x}]\). Existing forward diffusion RL methods—including DGPO, DiffusionNFT, and AWM—center rewards with a prompt-level baseline \(b(\mathbf{c})\) into signed advantages \(A = R - b(\mathbf{c})\) and optimize a signed reward-weighted regression (RWR) core evaluated at the trainable policy \(v_\theta\):

Proposition 2 · Population Gradient Decomposition of Signed RWR
\[ \nabla_\theta \mathcal{L}_{\mathrm{RWR}}^{A}(\theta) \;=\; \nabla_\theta \mathbb{E}\!\Big[A\,\big\|v(\mathbf{x}_t \mid \mathbf{x}_0) - v_\theta(\mathbf{x}_t, t)\big\|_2^2\Big] \;=\; \underbrace{g_t^A}_{\text{iTDM RL gradient}} \;+\; \underbrace{2\,\mathbb{E}_{q_t}\!\big[m_t\,J_\theta^\top(v_\theta - v_q)\big]}_{\Delta_t^q:\ \text{pull toward rollout } q_t} \;-\; \underbrace{2\,b(\mathbf{c})\,\mathbb{E}_{q_t}\!\big[J_\theta^\top(v_\theta - v_q)\big]}_{\Delta_t^b:\ \text{baseline-induced drift}} \]

Here \(J_\theta = \partial v_\theta(\mathbf{x}_t, t)/\partial \theta\) and \(m_t(\mathbf{x}) = \mathbb{E}[R \mid \mathbf{x}_t = \mathbf{x}]\). Unlike policy gradients in PPO/GRPO, unbiased baseline subtraction in RWR implicitly assumes \(v_\theta = v_q\). Under CFG-guided rollouts, offline/off-policy updates, or imperfect online self-consistency, pervasive mismatch (\(v_\theta \neq v_q\)) triggers two severe side effects:

Side Effect 1 · \(-\Delta_t^b\)

Baseline-Induced Gradient Drift

Subtracting \(b(\mathbf{c}) > 0\) breaks baseline invariance (\(\nabla_\theta \mathcal{L}_{\mathrm{RWR}}^A - \nabla_\theta \mathcal{L}_{\mathrm{RWR}}^R = -\Delta_t^b\)) and actively pushes \(v_\theta\) away from \(v_q\) during gradient descent. Unanchored on-policy RWR collapses rapidly, while heuristic proximity anchors in NFT and AWM stagnate or diverge under CFG-guided and offline rollouts.

Side Effect 2 · \(\Delta_t^q\)

Coarse Rollout-Artifact Fitting

Because \(m_t(\mathbf{x}) \ge 0\), the residual drift \(\Delta_t^q\) pulls \(v_\theta\) toward the behavior marginal \(v_q\). Since online RL uses coarse few-step ODE solvers (~10 steps) for rollout efficiency, \(\Delta_t^q\) forces the policy to fit discretization artifacts—blurring textures and hurting unseen DrawBench quality even at \(\mathrm{CFG}=1.0\).

2. Instantaneous Trajectory Distribution Matching (iTDM)

Instead of forcing policy improvement into signed regression at \(v_\theta\), we apply Trajectory Distribution Matching (TDM) to the local reverse step \(T_\theta(\mathbf{x}) = \mathbf{x} - \delta v_\theta(\mathbf{x}, t)\) against the time-local reward-guided target \(\pi_t^R(\mathbf{x}) \propto q_t(\mathbf{x})\exp(m_t(\mathbf{x}))\), whose score differs from \(s_{q_t}\) purely by the reward-driven score correction \(s_{\pi_t^R}(\mathbf{x}) - s_{q_t}(\mathbf{x}) = \nabla_{\mathbf{x}} m_t(\mathbf{x})\). Taking the step-normalized infinitesimal limit \(\delta \downarrow 0\) and applying the Gaussian posterior-score identity with the tower property yields an exact sample-level RL gradient anchored at \(v_q\)—requiring no reward-tilted score network:

Proposition 1 & Lemma 3 · Sample-Level iTDM Gradient & Exact Baseline Invariance
\[ g_t^A \;:=\; 2\,\mathbb{E}\!\Big[\big(R - b(\mathbf{c})\big)\,J_\theta^\top\big(v_q(\mathbf{x}_t, t) - v(\mathbf{x}_t \mid \mathbf{x}_0)\big)\Big] \;=\; g_t^R \;=\; \frac{2t}{1-t}\,\mathbb{E}_{q_t}\!\Big[J_\theta^\top \nabla_{\mathbf{x}} m_t(\mathbf{x}_t)\Big] \]
Lemma 3 · Drift-Free

Exact Baseline Invariance

Because \(\mathbb{E}[v_q(\mathbf{x}_t, t) - v(\mathbf{x}_t \mid \mathbf{x}_0) \mid \mathbf{x}_t, \mathbf{c}] = 0\) holds identically, subtracting any prompt baseline \(b(\mathbf{c})\) leaves \(g_t^A = g_t^R\) strictly unchanged—even when \(v_\theta \neq v_q\).

Online Auxiliary LoRA

Tracking Behavior Velocity \(v_q\)

A lightweight LoRA adapter \(v_\phi\) minimizes \(\mathcal{L}_{\mathrm{aux}}(\phi) = \mathbb{E}[\|v_\phi(\mathbf{x}_t, t) - v(\mathbf{x}_t \mid \mathbf{x}_0)\|_2^2]\) on re-noised clean rollouts without storing solver trajectories, plugging \(\operatorname{sg}(v_\phi)\) into \(g_t^A\) to eliminate \(-\Delta_t^b\).

Lemma 2 · Unified Optimal Policy

Artifact-Free Reference Anchor

Regularizing toward \(v_{\mathrm{ref}}\) yields unique optimal score \(s_t^\star = s_t^{\mathrm{ref}} + \frac{1}{\beta}\nabla_{\mathbf{x}} m_t\), achieving strict improvement \(\beta\operatorname{KL}(q_t \| \pi_t^+) > 0\) independent of \((q_t, v_\theta)\) to naturally unify online and offline RL.

Unification of Forward Diffusion RL Objectives
Method Residual Anchor Proximity Anchor \(v_{\mathrm{old}}\) Baseline Invariant (\(v_\theta \neq v_q\))
DGPO Policy \(v_\theta\) (group gate) — ✗
DiffusionNFT Policy \(v_\theta\) Rollout \(v_{\theta^-}\) ✗
AWM Policy \(v_\theta\) (IS weight) EMA \(v_{\theta_{\mathrm{EMA}}}\) ✗
iTDM (Ours) Behavior \(v_\phi \approx v_q\) Not needed (\(v_{\mathrm{ref}}\) only) ✓ (at \(v_\phi = v_q\))
Algorithm 1 · iTDM for Forward Diffusion RL ODE Rollout · No Backprop
Input: Policy \(v_\theta\), auxiliary LoRA \(v_\phi\), frozen reference \(v_{\mathrm{ref}}\), group size \(G\), weight \(\beta\).
  1. Sample prompt \(\mathbf{c} \sim \mathcal{D}_c\) and clean ODE rollouts \(\{\mathbf{x}_{0,i}\}_{i=1}^G \sim q_0(\cdot \mid \mathbf{c})\).
  2. Score rewards \(R_i = r(\mathbf{x}_{0,i}, \mathbf{c})\) and compute clipped centered group advantages \(A_i\).
  3. Re-noise endpoints: \(\mathbf{x}_{t,i} = (1-t)\mathbf{x}_{0,i} + t\epsilon_i\) with \(t \sim \mu\), \(\epsilon_i \sim \mathcal{N}(\mathbf{0}, \mathbf{I})\).
  4. Update auxiliary \(\phi\) on \(\|v_\phi(\mathbf{x}_t, t) - v(\mathbf{x}_t \mid \mathbf{x}_0)\|_2^2\).
  5. Update policy \(\theta\) using \(\widehat{g}_t^A = 2\mathbb{E}[A\,J_\theta^\top(\operatorname{sg}(v_\phi) - v(\mathbf{x}_t \mid \mathbf{x}_0))] + \beta\nabla_\theta \|v_\theta - v_{\mathrm{ref}}\|_2^2\).

Quantitative Results & Training Efficiency

We post-train SD3.5-Medium across Compositional Generation (GenEval), Visual Text Rendering (OCR), and Human Preference Alignment (PickScore). To detect reward hacking, every checkpoint is additionally evaluated on seven unseen out-of-domain metrics on DrawBench. Best results are in bold, second best underlined.

Model (CFG = 4.5) In-Domain Task Metric Unseen Image Quality Unseen Alignment & Preference (DrawBench)
GenEval OCR PickScore Aesthetic DeQA CLIPScore HPSv2.1 ImgRwd PickScore UniRwd
SD3.5-M (Pretrained Base) 0.630.5921.72 5.36— 28.5027.900.8522.343.03
Compositional Image Generation (GenEval)
AWM 0.93—— 5.123.43 28.9624.540.9122.143.07
DiffusionNFT 0.89—— 4.922.97 28.7422.620.6421.892.97
DGPO 0.90—— 5.093.17 28.9823.870.7522.052.98
iTDM (Ours) 0.97—— 5.264.12 29.0028.190.9822.493.13
Visual Text Rendering (OCR)
AWM —0.75— 5.283.62 28.6724.770.7322.052.93
DiffusionNFT —0.70— 5.193.67 28.7525.430.6822.102.91
DGPO —0.76— 4.952.56 26.8219.73-0.4520.762.18
iTDM (Ours) —0.96— 5.233.97 28.7727.980.8022.403.09
Human Preference Alignment (PickScore)
AWM ——22.80 6.023.99 27.7329.781.1823.233.27
DiffusionNFT ——22.75 5.963.86 27.5028.721.1423.143.25
DGPO ——22.37 5.653.98 28.1228.871.1022.893.17
iTDM (Ours) ——24.08 6.114.12 28.3532.731.4624.263.52
Model (CFG = 1.0) In-Domain Task Metric Unseen Image Quality Unseen Alignment & Preference (DrawBench)
GenEval OCR PickScore Aesthetic DeQA CLIPScore HPSv2.1 ImgRwd PickScore UniRwd
SD3.5-M (Pretrained Base) 0.240.1219.82 5.13— 23.7020.40-0.5820.512.02
Compositional Image Generation (GenEval)
AWM 0.92—— 4.713.94 27.5021.410.1521.352.62
DiffusionNFT 0.96—— 4.884.05 27.3422.900.3021.512.82
DGPO 0.97—— 5.154.06 27.6424.030.7122.042.96
iTDM (Ours) 0.98—— 5.084.23 27.6924.730.6521.743.04
Visual Text Rendering (OCR)
AWM —0.85— 4.163.25 21.0213.70-1.6919.691.52
DiffusionNFT —0.97— 3.523.52 22.1314.86-1.4919.861.50
DGPO —0.97— 4.192.13 21.3614.16-1.7019.691.53
iTDM (Ours) —0.97— 4.483.88 22.8018.25-1.1520.141.82
Human Preference Alignment (PickScore)
AWM ——23.94 6.453.97 26.5929.991.2923.953.34
DiffusionNFT ——23.89 6.403.81 26.3629.051.2423.863.32
DGPO ——23.85 6.183.60 27.3229.211.2323.543.35
iTDM (Ours) ——24.06 6.224.26 26.7131.851.3324.003.36
Offline Model (Frozen CFG = 4.5 Rollouts) In-Domain Task Metric Unseen Image Quality Unseen Alignment & Preference (DrawBench)
GenEval OCR PickScore Aesthetic DeQA CLIPScore HPSv2.1 ImgRwd PickScore UniRwd
SD3.5-M (Pretrained Base) 0.630.5921.72 5.36— 28.5027.900.8522.343.03
Compositional Image Generation (Pairwise G = 2 & Group-Wise)
Diffusion-DPO (G = 2) 0.69—— 5.414.03 28.7228.550.9722.353.20
iTDM (Ours, G = 2) 0.77—— 5.384.06 29.1128.261.0622.433.18
AWM 0.75—— 5.363.72 29.1027.660.9321.493.14
DiffusionNFT 0.52—— 5.333.76 28.3027.130.7222.003.00
DGPO 0.78—— 5.333.99 29.1128.011.0122.283.21
iTDM (Ours) 0.87—— 5.323.82 28.9327.981.0322.383.23
Visual Text Rendering (Pairwise G = 2 & Group-Wise)
Diffusion-DPO (G = 2) —0.78— 5.233.90 29.4427.990.9122.133.08
iTDM (Ours, G = 2) —0.87— 5.293.95 29.2627.571.0122.233.13
AWM —0.85— 5.343.48 28.9227.640.9021.823.01
DiffusionNFT —0.53— 5.213.52 28.3325.970.6221.742.95
DGPO —0.87— 5.183.33 29.4126.370.9921.902.97
iTDM (Ours) —0.92— 5.223.68 29.2727.690.9522.273.12
Human Preference Alignment (Pairwise G = 2 & Group-Wise)
Diffusion-DPO (G = 2) ——21.87 5.464.06 28.4428.770.9822.513.16
iTDM (Ours, G = 2) ——22.11 5.564.12 28.6730.251.1722.773.25
AWM ——21.71 5.673.73 27.0227.550.8322.203.09
DiffusionNFT ——20.17 5.293.74 28.2326.690.6521.963.02
DGPO ——22.13 5.594.18 28.3630.391.1622.783.27
iTDM (Ours) ——22.26 5.624.15 28.7130.751.2422.943.34

All methods share identical regularization strength toward the frozen pretrained SD3.5-Medium reference and are evaluated with 40-step ODE sampling.

Training Efficiency & Diagnostic Controls

Online RL efficiency with CFG-guided policy (CFG = 4.5)
Online RL efficiency with CFG-guided policy (CFG = 4.5). Removing heuristic proximity anchors causes on-policy RWR (equivalent to unanchored NFT / AWM) to collapse rapidly to zero under baseline-induced drift \(-\Delta_t^b\). Even with anchors, baselines plateau lower or oscillate, whereas iTDM converges substantially faster in wall-clock GPU hours to higher asymptotic rewards without collapse.
Online RL efficiency with conditional policy (CFG = 1.0)
Online RL efficiency without guidance (CFG = 1.0). Even without CFG mismatch, imperfect online self-consistency causes standard-batch AWM, NFT, and on-policy RWR to crash early; doubling the batch size stabilizes AWM/NFT at higher compute cost, yet iTDM still converges faster and more smoothly across all three tasks.
Group-wise offline RL curves and DrawBench OOD radar chart
Group-wise offline RL with frozen SD3.5-M rollouts (CFG = 4.5). Left: Task reward vs. GPU hours—static velocity proxies leave persistent mismatch in offline NFT and AWM, causing collapse or divergence, while iTDM improves monotonically. Right: Seven unseen DrawBench metrics averaged across the three tasks (parentheses show iTDM), confirming superior out-of-domain generalization.
Pairwise offline RL (G = 2) vs Diffusion-DPO curves and DrawBench OOD radar
Pairwise offline RL (G = 2, CFG = 4.5) vs. Diffusion-DPO. Under identical pairwise rollouts, iTDM converges faster and outperforms Diffusion-DPO across all three in-domain tasks (0.77 vs. 0.69 GenEval; 0.87 vs. 0.78 OCR; 22.11 vs. 21.87 PickScore) and across the 3-task average DrawBench radar, while scaling seamlessly to larger groups.

Quick Start

git clone https://github.com/Luo-Yihong/iTDM.git
cd iTDM && pip install -e .

# Single-node (8 GPUs) online RL on SD3.5-M
bash scripts/single_node/sd3_itdm_geneval.sh
bash scripts/single_node/sd3_itdm_ocr.sh
bash scripts/single_node/sd3_itdm_pickscore.sh
# Append --config.sample.guidance_scale=4.5 for CFG RL

BibTeX

@article{luo2026itdm,
  title   = {Reinforcing Diffusion Models by Instantaneous
             Trajectory Distribution Matching},
  author  = {Luo, Yihong},
  year    = {2026},
  url     = {https://github.com/Luo-Yihong/iTDM}
}
Acknowledgement & Contact. Our codebase builds upon TDM-R1, DGPO, and Flow-GRPO, and extends Trajectory Distribution Matching (TDM) to reinforcement post-training. For questions or discussions, please contact Yihong Luo at yluocg@connect.ust.hk.