SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2412.16748 · NeurIPS · 2024

Solving Inverse Problems via Diffusion Optimal Control

Henry Li, Marcus Pereira

arXiv · PDF · Open in the Atlas

Code that ran

3 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 1 failure of our instrument; 2 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2412.16748.json · badge: /api/ran/2412.16748.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
lihenryhfl/diffusion_optimal_control canonical (classifier label)
classifier basis: classifier_2025
3 ran · 2 no recorded run
FunctionStatusWhere it lives
DDP Ran
ran on a synthesized input · constructed an object; no result was computed
lihenryhfl/diffusion_optimal_control/optimizers/mfddp.py
code served (permissive licence) · get_code("1c5e1bfb04b70e0c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, DDP: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

class SimpleEnv:
    """Minimal environment class for DDP."""
    def __init__(self):
        self.state_dim = 4
        self.control_dim = 3
        self.num_steps = 5
        self.timesteps = list(range(self.num_steps))
    
    def running_control_cost(self, t, x, u):
        """Returns running control cost."""
        return torch.sum(u ** 2, dim=1)
    
    def terminal_cost(self, state):
        """Returns terminal cost."""
        return torch.sum(state ** 2, dim=1)
    
    def dynamics(self, t, state, action):
        """Simple linear dynamics: x_{t+1} = x_t + u_t."""
        return state + action
    
    def get_jacobian(self, t, state, action):
        """Returns Jacobian of dynamics w.r.t. state and action."""
        batch_size = state.shape[0]
        # dx/dx = Identity
        jac_state = torch.eye(self.state_dim).unsqueeze(0).repeat(batch_size, 1, 1)
        # dx/du = Identity-like (state_dim x control_dim)
        jac_action = torch.eye(self.state_dim, self.control_dim).unsqueeze(0).repeat(batch_size, 1, 1)
        return jac_state, jac_action
    
    def get_hessian(self, t, state, action):
        """Returns Hessian of cost w.r.t. state and action."""
        batch_size = state.shape[0]
        # Hessian of terminal cost w.r.t. state
        hess_state = 2.0 * torch.eye(self.state_dim).unsqueeze(0).repeat(batch_size, 1, 1)
        # Hessian of control cost w.r.t. action
        hess_action = 2.0 * torch.eye(self.control_dim).unsqueeze(0).repeat(batch_size, 1, 1)
        return hess_state, hess_action

env = SimpleEnv()

ARGS = {
    'env': env,
    'k_jacobian': 0,
    'k_hessian': 0,
    'lr_mode': 'k',
    'rrf_iters': 2,
    'eps': 0.001,
    'success_multiplier': 1.0,
    'failure_multiplier': 10.0,
    'min_eps': 1e-08,
    'chunk_size': 8,
    'verbose': 1,
    'print_every': 10,
    'use_running_state_cost': False,
    'lr_identity': False,
    'seed': None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DDP — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a DDP output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
MFDDP Ran
ran on a synthesized input · constructed an object; no result was computed
lihenryhfl/diffusion_optimal_control/optimizers/mfddp.py
code served (permissive licence) · get_code("3fa10fb6aafd5454")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, MFDDP: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

class SimpleEnv:
    """Minimal environment class satisfying DDP's interface."""
    
    def __init__(self):
        self.num_steps = 5
        self.state_dim = 4
        self.control_dim = 3
        self.timesteps = list(range(self.num_steps))
    
    def running_control_cost(self, t, x, u):
        """Returns control cost as a tensor."""
        # x shape: (batch, state_dim), u shape: (batch, control_dim)
        return torch.sum(u ** 2, dim=1, keepdim=True)
    
    def terminal_cost(self, x):
        """Returns terminal cost as a tensor."""
        # x shape: (batch, state_dim)
        return torch.sum(x ** 2, dim=1, keepdim=True)
    
    def dynamics(self, t, x, u):
        """Simple linear dynamics returning next state."""
        # x shape: (batch, state_dim), u shape: (batch, control_dim)
        batch_size = x.shape[0]
        # Next state is a linear combination of current state and control
        next_x = x + 0.1 * torch.randn(batch_size, self.state_dim)
        return next_x
    
    def rollout(self, init_state, actions):
        """Rollout trajectory given initial state and actions."""
        states = [init_state]
        x = init_state.clone()
        for t, u in enumerate(actions):
            x = self.dynamics(t, x, u)
            states.append(x)
        return torch.stack(states)

# Create environment
env = SimpleEnv()

# Create initial state
init_state = torch.randn(2, env.state_dim)

# Create initial actions
actions = torch.randn(env.num_steps - 1, 2, env.control_dim)

ARGS = {
    'env': env,
    'k_jacobian': 2,
    'k_hessian': 2,
    'lr_mode': 'k',
    'rrf_iters': 2,
    'eps': 0.001,
    'success_multiplier': 1.0,
    'failure_multiplier': 10.0,
    'min_eps': 1e-08,
    'chunk_size': 8,
    'verbose': 1,
    'print_every': 10,
    'use_running_state_cost': False,
    'lr_identity': False,
    'seed': None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type MFDDP — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MFDDP output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
register_sampler Ran
ran; our contract draft was wrong, not the code
lihenryhfl/diffusion_optimal_control/utils/gaussian_diffusion.py
code served (permissive licence) · get_code("fd57d8e6b5de11d3")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from functools import partial

torch.manual_seed(0)

# The register_sampler function takes one parameter: name (str)
# It returns a wrapper function that takes a cls parameter
# The wrapper checks if name exists in __SAMPLER__ dict, raises NameError if it does,
# then registers the class and returns it

# To test this function, we need to:
# 1. Provide a valid name string
# 2. Provide a class to decorate

class DummySampler:
    """A minimal sampler class for testing the decorator"""
    pass

ARGS = {
    "name": "test_sampler"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
matplotlib, numpy, torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
create_sampler Not yet run
unverified (harvested, no recorded run)
lihenryhfl/diffusion_optimal_control/utils/gaussian_diffusion.py
code served (permissive licence) · get_code("294fde7d083cb8c9")
How it ran

no invocation recorded.

get_sampler Not yet run
unverified (harvested, no recorded run)
lihenryhfl/diffusion_optimal_control/utils/gaussian_diffusion.py
code served (permissive licence) · get_code("3c731f22d73494cc")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 3 later) and 2 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
register_sampler 11 other papers
10 dated earlier, 1 later · 1 only as an assembly brick
2309.00287 (2023-09)
Fast Diffusion EM: a diffusion model for blind inverse problems with application to deconvolution
2402.03201 (2024-02)
Guidance with Spherical Gaussian Constraint for Conditional Diffusion
2402.16907 (2024-02)
Diffusion Posterior Proximal Sampling for Image Restoration
and 8 more not named here
get_sampler 9 other papers
8 dated earlier, 1 later
2309.00287 (2023-09)
Fast Diffusion EM: a diffusion model for blind inverse problems with application to deconvolution
2402.03201 (2024-02)
Guidance with Spherical Gaussian Constraint for Conditional Diffusion
2402.16907 (2024-02)
Diffusion Posterior Proximal Sampling for Image Restoration
and 6 more not named here
create_sampler 6 other papers
5 dated earlier, 1 later
2309.00287 (2023-09)
Fast Diffusion EM: a diffusion model for blind inverse problems with application to deconvolution
2402.16907 (2024-02)
Diffusion Posterior Proximal Sampling for Image Restoration
2403.11407 (2024-03)
Divide-and-Conquer Posterior Sampling for Denoising Diffusion Priors
and 3 more not named here

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Existing approaches to diffusion-based inverse problem solvers frame the signal recovery task as a probabilistic sampling episode, where the solution is drawn from the desired posterior distribution. This framework suffers from several critical drawbacks, including the intractability of the conditional likelihood function, strict dependence on the score network approximation, and poor x 0 prediction quality. We demonstrate that these limitations can be sidestepped by reframing the generative process as a discrete optimal control episode. We derive a diffusion-based optimal controller inspired by the iterative Linear Quadratic Regulator (iLQR) algorithm. This framework is fully general and able to handle any differentiable forward measurement operator, including super-resolution, inpainting, Gaussian deblurring, nonlinear deblurring, and even highly nonlinear neural classifiers. Furthermore, we show that the idealized posterior sampling equation can be recovered as a special case of our algorithm. We then evaluate our method against a selection of neural inverse problem solvers, and establish a new baseline in image reconstruction with inverse problems 1 .

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2412.16748")
get_code_for_paper("2412.16748")
have("2412.16748")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2412.16748.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2412.16748.svg)](https://syntology.ai/paper/2412.16748)

Connect an agent — have() is free.