Spatial Reasoning with Denoising Models

Christopher Wewer, Bartlomiej Pogodzinski, Bernt Schiele, Jan Eric Lenssen

TL;DR

Researchers have developed Spatial Reasoning Models (SRMs), a framework enabling diffusion models to solve complex logical tasks by generating data sequentially rather than all at once. By training the model to estimate its own uncertainty, it can "decide" the best order to fill in missing information, boosting accuracy on hard tasks like MNIST Sudoku from near 0% to over 50%.

The Challenge of Spatial Reasoning in Generative Models

Standard generative models, such as those powering Stable Diffusion or DALL-E, excel at capturing textures and general aesthetics but frequently stumble on hard logical constraints. This limitation manifests as hallucinations: an image might superficially resemble a valid Sudoku board but contain duplicate numbers in a single row or column.

Standard DDPM struggling with logical constraints, leading to hallucinations and incomplete generation.

The root of this issue lies in "parallel denoising," where every pixel or patch is generated simultaneously. While computationally efficient, this approach prevents the model from executing the step-by-step reasoning necessary for complex dependencies. If a model cannot establish what occupies cell A, it cannot logically deduce the contents of cell B. This research bridges the gap between high-dimensional continuous generation (like images) and discrete logical reasoning.

Introducing Spatial Reasoning Models (SRMs)

To address these shortcomings, the authors introduce Spatial Reasoning Models (SRMs). Unlike standard Diffusion Models (DDPMs) that apply a single noise level $t$ across an entire image, SRMs utilize individual noise levels ($t_i$) for different variables, such as distinct image patches.

Key technical innovations of the SRM framework include:

  • Sequentialization Strategies: The framework flexibly operates across various modes, ranging from fully parallel to fully autoregressive (processing one patch at a time), as well as intermediate "overlapping" approaches.
  • Uniform $\bar{t}$ Training: Standard training samples noise levels independently, often resulting in a "Bates distribution" where most patches are half-noisy. The authors propose a two-step sampling strategy ensuring the model is robustly trained for all stages of generation, from a completely empty grid to a nearly finished state.
  • Uncertainty-Guided Ordering: The model features an additional head trained to predict its own noise-prediction error (heteroscedastic uncertainty). During inference, the SRM evaluates all empty cells, identifies the one it is most "certain" about, and resolves it first. This mimics the human approach to solving puzzles.

Benchmarks and Key Results

To quantify spatial reasoning capabilities, the authors introduced three novel benchmarks:

  1. MNIST Sudoku: A 9x9 grid of MNIST digits requiring the model to satisfy complex row, column, and block constraints (an NP-hard problem).
  2. Even Pixels: A global constraint task demanding the generation of an image with an exactly equal number of pixels for two different colors.
  3. Counting Polygons/Stars FFHQ: A complexity task where the model must generate specific shapes with exact vertex counts over complex human face backgrounds.
A successfully solved MNIST Sudoku grid generated by the SRM framework.

The results on the MNIST Sudoku (Hard) benchmark strongly validate the SRM approach:

  • Standard Diffusion (Parallel): Achieved a mere 0.8% accuracy.
  • SRM (Predicted Order): Reached 51.6% accuracy using the exact same architecture, driven entirely by the change in sampling strategy.
  • LLM Comparison: Text-based versions of these puzzles were tested on GPT-4o and Phi-4. Despite their reasoning capabilities, LLMs performed poorly (GPT-4o reached only ~1.1% on hard cases), underscoring that spatial reasoning remains a distinct and formidable challenge.

Similarly, on the Even Pixels task, the SRM with predicted ordering achieved 51.8% accuracy, doubling the 25% baseline of standard diffusion.

Insights, Limitations, and Future Directions

The most striking insight from this work is that the denoising network can successfully act as its own compass by predicting uncertainty. When solving Sudoku, the model naturally assigns the lowest uncertainty to cells logically determined by existing clues. The paper proves that while any generation order works in theory, a "greedy" order (resolving the most certain parts first) drastically reduces hallucinations compared to random or raster-scan orders. Parallelism, it turns out, is the enemy of logic in highly constrained tasks.

Despite a massive 50x performance improvement, the models are not yet perfect solvers for NP-hard tasks. The authors acknowledge several limitations:

  • Computational Cost: Sequential generation requires more passes through the neural network, making it inherently slower than parallel generation.
  • Lack of Backtracking: The current model moves forward greedily. Implementing a "backtracking" mechanism to undo mistaken steps could yield further performance gains.
  • Scaling: The current framework focuses on patch-based reasoning. Scaling this approach to pixel-perfect reasoning in massive, high-resolution world models remains an open challenge for future research.

Summary updated

BibTeX
@inproceedings{wewer2025spatial,
  author = {Christopher Wewer and Bartlomiej Pogodzinski and Bernt Schiele and Jan Eric Lenssen},
  title = {{Spatial Reasoning with Denoising Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=dWuN4jCQo3},
}
Figure