Contrastive Diffusion Alignment: Learning Structured Latents for Controllable Generation

Ruchi Sandilya, Sumaira Perez, Charles Lynch, Lindsay Victoria, Benjamin Zebley, Derrick Matthew Buchanan, Mahendra T. Bhati, Nolan Williams, Timothy Spellman, Faith M. Gunning, Conor Liston, Logan Grosenick

Abstract / TL;DR Diffusion models are the current state-of-the-art for generative fidelity, yet their latent spaces remain notoriously high-dimensional and unorganized, making precise control and interpretation difficult. Contrastive Diffusion Alignment (ConDA) introduces a "plug-and-play" geometry layer that organizes these messy latent spaces into structured, low-dimensional manifolds. By decoupling the editing of trajectories from the rendering of images, ConDA enables smooth, physically consistent control over complex spatiotemporal dynamics—ranging from fluid flows to neural activity.

The Challenge of Unstructured Latent Spaces

While diffusion models excel at generating high-fidelity images, they suffer from a fundamental "control" problem. The mathematical representations—or latent spaces—where the essence of an image resides do not inherently understand time, physics, or specific semantic labels.

Consequently, attempting to animate a sequence, such as a fluid flowing or a face transitioning into a smile, by interpolating between two points in a standard diffusion latent space often yields poor results. Users frequently encounter "ghosting," blurry transitions, or physically impossible intermediate states. Existing conditioning tools like ControlNet help guide generation but fail to provide a principled mathematical framework to navigate the underlying dynamics of a complex system.

The ConDA Framework: Separating Editing from Rendering

To address this, the authors propose ConDA, a method that treats the pretrained diffusion model as a fixed "synthesis engine" while superimposing a structured "navigation layer." The framework operates in three primary stages:

  1. Inversion: Real-world sequence data (e.g., video frames or neural spikes) are mapped into the high-dimensional diffusion latent space ($Z$) using deterministic solvers like DDIM or the reversible Rex-RK4.
  2. Contrastive Alignment: These latents are then projected into a compact, structured embedding space ($C$) via a supervised contrastive loss (InfoNCE). This step leverages auxiliary variables—such as time, stimulation parameters, or facial action units—to ensure the geometry of $C$ accurately mirrors real-world dynamics.
  3. Nonlinear Traversal and Lifting: Recognizing that linear interpolations often fail for physical systems, ConDA employs nonlinear operators (like Splines or second-order Taylor expansions) to navigate the $C$ space. To translate these low-dimensional "edits" back into high-fidelity images, a neighborhood-preserving k-Nearest Neighbors (kNN) decoder "lifts" the points back to the high-dimensional $Z$ space. The standard diffusion decoder then renders the final output.

This separation is the core innovation: complex mathematical traversals occur in a manageable 3D to 10D space, while the actual rendering leverages the high-fidelity generative power of the original diffusion space.

Key Insights

  • Latent Structure is Already Present: The research suggests that diffusion models already encode dynamics-relevant structures; they are simply entangled. Contrastive learning acts as a mechanism to untangle and align this structure with external, meaningful variables.
  • Linearity is a Trap: Most traditional latent editing assumes linear directions. ConDA demonstrates that for physical systems, higher-order momentum (e.g., Taylor expansions) or splines are strictly necessary to maintain realism.
  • Solver Agnosticism: ConDA is highly versatile, functioning seamlessly with standard DDIM or newer, faster reversible solvers, facilitating easy integration into existing pipelines.

Empirical Validation Across Diverse Domains

The researchers rigorously tested ConDA across five distinct spatiotemporal domains, demonstrating significant improvements over baseline methods:

  • Fluid Dynamics: On 2D Navier-Stokes simulations of vortex shedding, ConDA achieved a remarkable 35.7 PSNR, vastly outperforming linear baselines (28.3 PSNR) which suffered heavily from ghosting artifacts.
  • Neurostimulation (TMS): Using simulated electric fields in human head models, classifiers trained on ConDA’s $C$-space were significantly more accurate at identifying clinical "responders" than those trained on raw diffusion latents. Furthermore, ConDA successfully morphed a non-responder's brain E-field into a responder's pattern via smooth counterfactual editing.
  • Monkey Motor Cortex: When analyzing neural spiking data from macaques performing reaching tasks, ConDA’s low-dimensional embeddings aligned almost perfectly with the animal's actual reach velocity. In contrast, standard dimensionality reduction methods like PCA produced tangled, uninterpretable paths.
  • Facial Expressions & Neural Calcium Imaging: ConDA successfully modeled the dynamics of facial action units (from the DISFA dataset) and two-photon microscopy videos of mouse prefrontal cortex activity, proving its broad applicability.

Limitations and Future Directions

While ConDA represents a significant step forward, the authors note a few limitations. The mapping from the high-dimensional diffusion space to the low-dimensional embedding is inherently "many-to-one," meaning some fine-grained details may be lost during compression. Additionally, the current kNN lifting approach prioritizes local neighborhoods; while excellent for stability, it may struggle with extreme, long-range traversals across the latent space. Finally, the method relies on diffusion inversion, which remains computationally expensive.

Future work will likely focus on replacing the kNN-based lifting mechanism with a fully learned, generative decoder, bridging the structured embedding space and the diffusion latent space even more seamlessly.

Summary updated

BibTeX
@inproceedings{sandilya2026contrastive,
  author = {Ruchi Sandilya and Sumaira Perez and Charles Lynch and Lindsay Victoria and Benjamin Zebley and Derrick Matthew Buchanan and Mahendra T. Bhati and Nolan Williams and Timothy Spellman and FAITH M. GUNNING and Conor Liston and Logan Grosenick},
  title = {{Contrastive Diffusion Alignment: Learning Structured Latents for Controllable Generation}},
  booktitle = {International Conference on Machine Learning},
  year = {2026},
  url = {https://openreview.net/forum?id=o2H3TE1F0g},
}
Figure