wikillm

Paper · 2024-07-01 · cs.LG, cs.CV, cs.RO

Diffusion Forcing: Next-token Prediction Meets Full-Sequence Diffusion

Diffusion Forcing trains a causal sequence model where every token has its own independent noise level. Sampling with a per-token noise schedule gives stable long video rollouts, Monte Carlo Guidance over future tokens and flexible-horizon planning. Author-reported: 141.7 average reward on single-task Maze2D (Diffuser* 119.5) and CRPS_sum at or near the best on several time-series datasets.

Diffusion modelsMasked language modelingModel predictive control (MPC)Imitation learningdiffusionsequence-modelingvideo-predictionplanningimitation-learning

arXivPDFCodeMarkdown13 min read

AI-compiled by claude-haiku-5-5 on 2026-10-18, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

In plain words

Usually a model that writes a sequence one step at a time (like a language model predicting the next word) and a model that starts from noise and cleans up a whole sequence at once (like image diffusion) are trained in different ways. This paper trains one model that can do both. Every item in the sequence gets its own amount of noise during training. Some items are almost clean, some are mostly noise, and the model learns to clean up whichever ones it is given.

Because of this, generation can be arranged as a schedule. The near future can be cleaned up before the far future, so the model keeps the far future uncertain. The past can stay clean while new items are generated, which lets sequences like video keep going well past the lengths the model was trained on. The same flexibility lets you steer the sampling toward a goal, for example a robot reaching a point in a maze, and plan with a window that can be short or long.

TL;DR

Diffusion Forcing trains a denoiser in which each token of a sequence has an independent noise level, and it uses a causal recurrent model so each token only sees the past. Sampling follows a per-token noise schedule, which enables stable autoregressive video rollouts, guidance over future tokens, and flexible-horizon planning. The paper reports the best average reward on its Maze2D planning benchmarks against the offline-RL and diffusion-planning baselines it compares to, and competitive time-series forecasting. All numbers are author-reported.

Problem

Next-token prediction models are good at variable-length generation but can diverge when they roll out high-dimensional continuous sequences such as video beyond their training horizon §4.1. Full-sequence diffusion models generate consistent samples and can be guided toward desired trajectories, but they fix the sequence length and must denoise all tokens together, so they cannot take actions or update a plan step by step §2 §3.4. The paper argues both properties are wanted and proposes a single model that has both §1 §3.1.

Method

Notation. A sequence is x_{1:T}. Each token x_t at noise level k_t is written x_t^{k_t}. Level 0 is clean and level K is pure white noise §3.1. The paper uses K = 1000 diffusion steps app. D.

Noising as partial masking §3.1. Next-token training with teacher forcing masks a token and predicts it from the past. Full-sequence diffusion can be read as partial masking of every token at once. Diffusion Forcing combines the two views by giving each token its own partial mask, which is its own noise level.

Recurrent denoiser §3.2. A recurrent network with latent z_t holds a summary of the past. At each step the latent is updated from the previous latent, the noisy token and that token's level, z_t ~ p(z_t | z_{t-1}, x_t^{k_t}, k_t). The paper implements this update as deterministic, so z_t is a belief state rather than a sample. An observation head predicts the clean token from z_t. The paper's training is a standard conditional diffusion loss on the noise epsilon_t, applied to each token and summed over the sequence §3.2.

Training §3.2 alg. training. Sample a clean sequence. Sample every token's noise level independently and uniformly from the K levels. Noise each token at its level. Run the recurrent unit over the sequence and sum a noise-prediction loss over all tokens. The paper's informal theorem says this objective optimises a reweighted evidence lower bound on the log-likelihood of the noised sequences. Under suitable conditions it also bounds the likelihood of every subsequence of noise levels at once §3.2 app. A.

Pseudocode
# Training step  [§3.2] [alg. training]
# clean_tokens: (T, B, D)
def training_step(clean_tokens):
    # Sample an independent noise level for every token  [§3.2]
    noise_levels = sample_uniform_levels(K, shape=(T, B))  # (T, B)
    # Draw Gaussian noise for every token  [§3.2]
    eps = normal(0, 1, shape=clean_tokens.shape)  # (T, B, D)
    # Forward diffusion, each token at its own level  [§3.2]
    noisy_tokens = forward_diffuse(clean_tokens, noise_levels, eps)
    latent = initial_latent(B)  # z_0  [§3.2]
    loss = 0.0
    for t in range(T):
        # Predict the noise from the previous latent and the noisy token [§3.2]
        eps_hat = observe(latent, noisy_tokens[t], noise_levels[t])
        loss = loss + squared_error(eps[t], eps_hat)
        # Update the latent with the noisy token and its level  [§3.2]
        latent = dynamics(latent, noisy_tokens[t], noise_levels[t])
    return loss

Sampling with a schedule §3.2 alg. sampling. Sampling is defined by a scheduling matrix K with M rows and T columns. Column t is the time step and row m gives the target noise level for that token. Start with every token at level K. Walk down the rows from the top. In each row, step through the tokens from left to right, update each token's latent, and denoise the token to its target level in K. After the last row, every token is clean. The paper uses standard DDIM-style updates at each level §3.2 app. D.

Pseudocode
# Sampling with a noise schedule  [§3.2] [alg. sampling]
# schedule: (M, T) integer grid of noise levels, row 0 is clean
def sample_sequence(schedule, guidance_cost=None):
    # Start every token from pure noise, at level K  [§3.2]
    tokens = normal(0, 1, shape=(T, B, D))  # (T, B, D)
    latent = initial_latent(B)  # z_0  [§3.2]
    for row in range(M - 1, -1, -1):
        for t in range(T):
            # Update the latent using the level from the row above  [§3.2]
            new_latent = dynamics(
                latent, tokens[t], schedule[row + 1, t]
            )
            # Denoise token t to the target level for this row  [§3.2]
            tokens[t] = denoise_step(
                tokens[t], new_latent, schedule[row, t]
            )
            latent = new_latent
        if guidance_cost is not None:
            # Add guidance from the partially denoised trajectory  [§3.3]
            tokens = add_guidance(tokens, guidance_cost)
    return tokens

New sampling capabilities §3.3.

  • Stabilised autoregressive generation. Condition on past tokens that are slightly noisy (a small level 0 < k << K) rather than fully clean. The paper reports this keeps long rollouts stable, and the paper's appendix explains why §3.3 app. B.
  • Zig-zag schedule. Denoise the first token fully, the second partly, the third not at all, and so on. Near tokens are then more certain than far ones §3.3.
  • Long-horizon guidance. Guidance gradients on future tokens propagate back to past tokens, because the model is causal and the past is only partly noised §3.3 app. D.

Planning and decision making §3.4. Tokens are triplets of action, reward and next observation. At each step the model plans a window of future tokens conditioned on the latent of the past, executes the first action, and updates the latent with the new token §3.4. The window can be shortened to act as a policy, or lengthened to plan, without retraining §3.4. Guidance can use dense rewards, rewards over a future window, or a sparse goal term §3.4 app. D.

Monte Carlo Guidance (MCG) §3.4. Instead of guiding with one sampled future, draw several samples of the future tokens and average their guidance gradients. The paper argues this works best with a schedule that keeps far tokens noisier §3.4 app. B. The paper does not give the number of samples used.

Pseudocode
# Monte Carlo Guidance for one token  [§3.4]
# future_samples: list of rollouts of the tokens after t
def monte_carlo_guidance(token_t, future_samples, cost):
    # Guidance gradient for each sampled future  [§3.4]
    grads = [grad_wrt(token_t, cost(f)) for f in future_samples]
    # Average the gradients over the samples  [§3.4]
    return mean(grads)

Hyperparameters

Values are from the paper unless the Where column names the code. "not stated" means neither the paper nor the code (as read here) gives the value.

NameValueWhereNotes
diffusion steps K1000app. D df_base.yaml
sampling DDIM steps, video100app. D
sampling DDIM steps, non-video50app. D df_base.yaml
noise schedule, videosigmoidapp. D
noise schedule, maze planninglinearapp. D df_planning.yaml
noise schedule, all otherscosineapp. D df_base.yaml
prediction target, videov-parameterisationapp. D
prediction target, planning and imitationx_0app. D df_planning.yamlPaper's loss in §3.2 is written on the noise; see Paper vs code
prediction target, time seriesv-parameterisationapp. D
fused SNR reweightingon for video, off elsewhereapp. Dmin-SNR is the base reweighting §D.1
frame stack, DMLab4app. D
frame stack, Minecraft8app. D
frame stack, maze planning10app. D df_planning.yaml
latent channels, DMLab / Minecraft16 / 32app. D
parameters, DMLab / Minecraft / maze24M / 36M / 4.33Mapp. D
learning ratenot statedapp. Dcode: 8e-5 for video exp_video.yaml, 5e-4 for planning exp_planning.yaml
optimisernot statedcode: betas [0.9, 0.999] df_base.yaml
weight decaynot statedcode: 1e-4 df_base.yaml
warm-upnot statedcode: 10000 steps df_base.yaml
video training50K steps, batch 8 x 16, 8 A100, fp16app. Dconverges around 40K steps
maze and compositional batch2048app. D
visual imitation batch32app. D
time series batch, early stopping32, patience 6 epochsapp. E app. D100 batches per epoch
time series architecture1 MLP and 4 GRUsapp. D
guidance scalenot statedcode: 2.0 for planning df_planning.yaml
stabilisation level knot stated§3.3code: 10 for planning df_planning.yaml
MCG sample countnot stated§3.4
RNN width and depthnot stated§3.2
time series quantile levels19 quantiles from 100 sampled trajectoriesapp. F

Results

All author-reported.

Planning, D4RL Maze2D and multi-goal Multi2D §4.2. Average episode reward. Diffuser* is run with the hand-crafted PD controller the paper uses for it. "Diffuser w/ diffused action" executes the actions the diffusion model generates. The paper notes that the reward metric may favour slow plans that stay near the goal app. D, so compare these numbers with care.

EnvironmentMPPICQLIQLDiffuser*Diffuser w/ diffused actionOurs wo/ MCGOurs
Maze2D U-Maze33.25.747.4113.9 ± 3.16.3 ± 2.1110.1 ± 3.9116.7 ± 2.0
Maze2D Medium10.25.034.9121.5 ± 2.713.5 ± 2.3136.1 ± 10.2149.4 ± 7.5
Maze2D Large5.112.558.6123.0 ± 6.46.3 ± 2.1142.8 ± 5.6159.0 ± 2.7
Maze2D single-task average16.27.747.0119.58.7129.67141.7
Multi2D U-Maze41.2-24.8128.9 ± 1.832.8 ± 1.7107.7 ± 4.9119.1 ± 4.0
Multi2D Medium15.4-12.1127.2 ± 3.422.0 ± 2.7145.6 ± 6.5152.3 ± 9.9
Multi2D Large8.0-13.9132.1 ± 5.86.9 ± 1.7129.8 ± 1.5167.1 ± 2.7
Multi-task average21.5-16.9129.420.6127.7146.2

Source: the planning table in §4.2 (typeset inside a figure environment in the source; its number in the compiled paper was not checked). The paper says Diffusion Forcing outperforms Diffuser and all baselines on all six environments §4.2.

Video §4.1. Qualitative only, with no table of metrics in the main text. The paper reports that its rollouts stay stable up to 1000 frames, far beyond the training horizon, while teacher-forcing and full-sequence baselines diverge §4.1 (video figure in the source; numbering not checked).

Robotics §4.4. Franka robot, apple-and-orange swap task with a memory requirement. Diffusion Forcing reaches 80% success. A diffusion policy without memory fails §4.4. With visual distractions or a fully occluded camera, success falls to 76% for Diffusion Forcing and 48% for a next-frame diffusion baseline §4.4.

Compositional generation §4.3 app. E. Qualitative: switching between full memory and short MPC-style plans recovers either the cross-shaped or the V-shaped trajectory distribution §4.3.

Time series, CRPS_sum, lower is better §4.5 app. E. Mean and standard deviation over five seeds for the paper's method.

MethodExchangeSolarElectricityTrafficTaxiWikipedia
VES0.005 ± 0.0000.900 ± 0.0030.880 ± 0.0040.350 ± 0.002--
VAR0.005 ± 0.0000.830 ± 0.0060.039 ± 0.0010.290 ± 0.001--
VAR-Lasso0.012 ± 0.0000.510 ± 0.0060.025 ± 0.0000.150 ± 0.002-3.100 ± 0.004
GARCH0.023 ± 0.0000.880 ± 0.0020.190 ± 0.0010.370 ± 0.001--
DeepAR-0.336 ± 0.0140.023 ± 0.0010.055 ± 0.003-0.127 ± 0.042
LSTM-Copula0.007 ± 0.0000.319 ± 0.0110.064 ± 0.0080.103 ± 0.0060.326 ± 0.0070.241 ± 0.033
GP-Copula0.007 ± 0.0000.337 ± 0.0240.025 ± 0.0020.078 ± 0.0020.208 ± 0.1830.086 ± 0.004
KVAE0.014 ± 0.0020.340 ± 0.0250.051 ± 0.0190.100 ± 0.005-0.095 ± 0.012
NKF-0.320 ± 0.0200.016 ± 0.0010.100 ± 0.002-0.071 ± 0.002
Transformer-MAF0.005 ± 0.0030.301 ± 0.0140.021 ± 0.0000.056 ± 0.0010.179 ± 0.0020.063 ± 0.003
TimeGrad0.006 ± 0.0010.287 ± 0.0200.021 ± 0.0010.044 ± 0.0060.114 ± 0.0200.049 ± 0.002
ScoreGrad sub-VP SDE0.006 ± 0.0010.256 ± 0.0150.019 ± 0.0010.041 ± 0.0040.101 ± 0.0040.043 ± 0.002
Diffusion Forcing0.003 ± 0.0010.289 ± 0.0020.023 ± 0.0010.040 ± 0.0040.075 ± 0.0020.085 ± 0.007

The paper says Diffusion Forcing is overall tied with ScoreGrad, and places fourth on Wikipedia §4.5. Dataset details are in app. F.

Paper vs code

The official repository is buoyancy99/diffusion-forcing, linked from the project page. Its main branch is a reimplementation with temporal attention (its README calls it the latest version). The README says the RNN code the paper used is on a separate paper branch. I could not read that branch, so the citations below are to main at code_commit. Statements about the RNN implementation are unverified.

  • Paper says the planning objective is written on the noise epsilon in the training loss §3.2. The planning config sets objective: pred_x0 df_planning.yaml, and the loss is an MSE on the clean signal weighted by clipped SNR diffusion.py. Appendix D says planning uses x_0 prediction app. D, so the appendix and the code agree but the main text's equation does not match them.
  • Paper says the noise levels are sampled uniformly from [K] §3.2. The code samples integers in [0, timesteps) df_base.py. Frames that are masked out are set to the top level timesteps - 1 df_base.py.
  • Paper does not describe a special first-frame noise rule. The planning code draws the first frame's level from the lower quarter of the range with probability 0.5 df_planning.py.
  • Paper uses a recurrent backbone for the dynamics and a residual MLP for non-video data app. D. The main planning config uses a transformer with 12 layers, width 128 and 4 heads df_planning.yaml.
  • Paper's sampling uses the schedule matrix K §3.2. The code's pyramid schedule builds a matrix with sampling_timesteps + (horizon - 1) * uncertainty_scale + 1 rows, so the number of rows depends on the horizon df_base.py.
  • Paper uses the reweighting from min-SNR for the base loss app. D. The code's default use_snr is False df_base.yaml, with fused SNR selectable by config df_base.yaml. The paper states fused SNR is used for video only app. D.
  • Paper says DDIM sampling with 50 steps for non-video app. D. The base config uses ddim_sampling_eta: 1.0 df_base.yaml, while the planning config uses 0.0 df_planning.yaml. The paper does not state eta.
  • Sampling line 8 of the algorithm, as the paper describes it, can either recompute the posterior latent or reuse the sampled one. Appendix D says the authors reuse it, to halve compute and to get the stabilisation behaviour app. D. I did not check which option the main sampler takes.

No discrepancies were found in the planning and base diffusion settings that both the paper and the code state (noise schedule, frame stack, diffusion steps and sampling steps all match).

Pitfalls

  • Noise level range. Paper says k_t is drawn from [K]. Code draws from [0, timesteps) and treats the top level as pure noise. An implementer must decide whether level 0 is included, and whether the top level is used for training or only for masking.
  • Unstated values an implementer must choose: learning rate, optimiser, weight decay, warm-up, RNN width and depth, guidance scale, the stabilisation level k, and the MCG sample count. The paper gives none of them, and the values the code uses for some of these are listed in the table above.
  • Stabilisation level. The paper uses "slightly noisy" tokens with 0 < k << K but gives no number §3.3. The planning code uses 10 out of 1000 df_planning.yaml. Treat this as a guess, not a paper value.
  • Copy versus resample when the level stays the same. Paper says the corner case where a token keeps its level can either copy the old value or resample. The authors prefer resampling, and use it for MCG. For k=0 and k=K, copying is equivalent in practice app. D.
  • Sampling cost. Denoising runs over every row of the schedule, and each row runs the recurrent update for every token. A long horizon with a pyramid schedule gives many rows df_base.py. The paper's compute claims are about training only app. D.
  • Reward metric. The paper warns that episode reward on Maze2D can reward a slow agent that stays near the goal, and it suggests time-to-goal as an alternative app. D. Do not compare reward numbers with other work without checking the metric.
  • Guidance on the maze. The maze reward is the sum over time steps of the distance to the goal, so any step can count as the final step app. D. The agent tends to leave the goal, because the training data never stays there app. D.
  • Time-series metric. CRPS_sum is computed by summing over features and estimating quantiles from 100 sampled trajectories app. F. A different number of samples or quantiles gives different numbers.
  • Scale. Video experiments use a 36M-parameter model, trained on 10% of the dataset for compute reasons app. D app. F. The paper does not study scaling beyond these sizes §5.

Lineage

  • Builds on: masked modelling and teacher forcing §3.1; denoising diffusion (DDPM and DDIM) §2 §3.2 app. D; Bayesian filtering §2.
  • Compared against: TimeGrad, Transformer-MAF, ScoreGrad, and other time-series models §4.5; Diffuser for planning §4.2; teacher-forced next-frame diffusion and full-sequence diffusion for video §4.1; diffusion policy for robot imitation §4.4.
  • Related work the paper names: AR-Diffusion and Rolling Diffusion, which also use per-token noise, but with noise levels tied to token position app. C.
  • Superseded by: not known from this wiki's content. The project's own README points to a follow-up repository, Diffusion Forcing v2 (kwsong0113/diffusion-forcing-transformer).

Source and license

Adapted from “Diffusion Forcing: Next-token Prediction Meets Full-Sequence Diffusion” by Boyuan Chen, Diego Marti Monso, Yilun Du, Max Simchowitz, Russ Tedrake, Vincent Sitzmann (arXiv:2407.01392), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/buoyancy99/diffusion-forcing at commit 475e0bcab875 (MIT). Any quoted code is shown under that license.