SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.13301 · 2023

Training Diffusion Models with Reinforcement Learning

arXiv · PDF · Open in the Atlas

Code that ran

4 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 4 have no contract verdict; 0 failures of our instrument; 2 no recorded run), measured 2026-11-22; 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/2305.13301.json · badge: /api/ran/2305.13301.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
kvablack/ddpo-pytorch canonical (classifier label)
classifier basis: census
0 ran · 1 no recorded run
akashsonowal/ddpo-pytorch community (classifier label)
classifier basis not recorded on the link
4 ran · 1 no recorded run
FunctionStatusWhere it lives
aesthetic_model_normalize Ran
ran on a synthesized input
akashsonowal/ddpo-pytorch/ddpo_pytorch/aesthetic_scorer.py
code served (permissive licence) · get_code("839da88e68e0677c")
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 ndarray, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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 numpy as np

# Construct arguments for aesthetic_model_normalize
# The function normalizes an array along a specified axis using L2 norm

# Create a small test array with shape (2, 4) - batch size 2, dimension 4
a = np.array([
    [1.0, 2.0, 3.0, 4.0],
    [5.0, 6.0, 7.0, 8.0]
], dtype=np.float32)

# axis parameter: normalize along the last axis (default -1)
axis = -1

# order parameter: L2 norm (default 2)
order = 2

ARGS = {
    "a": a,
    "axis": axis,
    "order": order
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
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
aesthetic_scoring Ran
ran on a synthesized input
akashsonowal/ddpo-pytorch/ddpo_pytorch/aesthetic_scorer.py
code served (permissive licence) · get_code("b4f4d87568dc7dbf")
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 Tensor, ndim 2, dtype family float, shape (2, 1) as a later run recorded it. 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, ndim and shape 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 numpy as np
import torch
import torch.nn as nn
from PIL import Image
from torchvision import transforms

torch.manual_seed(0)

# Create mock CLIP model
class MockCLIPModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(3, 4)
    
    def encode_image(self, imgs):
        # imgs shape: (batch, 3, H, W)
        # Return embeddings of shape (batch, 4)
        batch_size = imgs.shape[0]
        return self.linear(imgs.mean(dim=[2, 3]))

# Create mock aesthetic model
class MockAestheticModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 1)
    
    def forward(self, x):
        # x shape: (batch, 4)
        # returns: (batch, 1)
        return self.linear(x)

# Create mock preprocess function
def mock_preprocess(img):
    # Convert PIL Image to tensor
    # Returns shape (3, H, W)
    img_array = np.array(img)
    tensor = torch.from_numpy(img_array).permute(2, 0, 1).float() / 255.0
    return tensor

# Create sample images as numpy arrays
batch_size = 2
height = 8
width = 8
channels = 3
imgs = np.random.randint(0, 256, (batch_size, height, width, channels), dtype=np.uint8)

# Define the normalize function
def aesthetic_model_normalize(a, axis=-1, order=2):
    l2 = np.atleast_1d(np.linalg.norm(a, order, axis))
    l2[l2 == 0] = 1
    return a / np.expand_dims(l2, axis)

# Initialize models and functions
clip_model = MockCLIPModel()
aesthetic_model = MockAestheticModel()
preprocess = mock_preprocess

ARGS = {
    "imgs": imgs,
    "preprocess": preprocess,
    "clip_model": clip_model,
    "aesthetic_model_normalize": aesthetic_model_normalize,
    "aesthetic_model": aesthetic_model
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 1) — shape (2, 1) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
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
calculate_log_probs Ran
ran on a synthesized input
akashsonowal/ddpo-pytorch/ddpo_pytorch/utils.py
code served (permissive licence) · get_code("99b4cfbc8f8c70db")
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 Tensor, ndim 2, dtype family float, shape (2, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape 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 math

torch.manual_seed(0)

# Create small tensors for the function parameters
# prev_sample: tensor of previous samples, shape (2, 4)
prev_sample = torch.randn(2, 4)

# prev_sample_mean: mean of previous samples, shape (2, 4)
prev_sample_mean = torch.randn(2, 4)

# std_dev_t: standard deviation at time t, shape (2, 4)
std_dev_t = torch.randn(2, 4).abs() + 0.1  # Ensure positive values

ARGS = {
    "prev_sample": prev_sample,
    "prev_sample_mean": prev_sample_mean,
    "std_dev_t": std_dev_t,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
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
decoding_fn Ran
ran on a synthesized input
akashsonowal/ddpo-pytorch/ddpo_pytorch/utils.py
code served (permissive licence) · get_code("ae64c699ad5628ca")
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 ndarray, ndim 4, dtype family int, shape (2, 8, 8, 3) as a later run recorded it. 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, ndim and shape 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

torch.manual_seed(0)

# Create a minimal VAE decoder module
class MinimalVAEDecoder(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 768)
    
    def decode(self, latents):
        # Mock decode: take latents and output in BCHW format
        # Input: (batch, latent_dim)
        # Output: should be (batch, 3, H, W) for images
        batch_size = latents.shape[0]
        # Create a mock output tensor of shape (batch, 3, 8, 8)
        output = torch.randn(batch_size, 3, 8, 8)
        return MockDecoderOutput(output)

class MockDecoderOutput:
    def __init__(self, sample):
        self.sample = sample

# Create a minimal pipe with VAE
class MinimalPipe:
    def __init__(self):
        self.vae = MinimalVAE()

class MinimalVAE:
    def __init__(self):
        self.decoder = MinimalVAEDecoder()
    
    def decode(self, latents):
        return self.decoder.decode(latents)

# Create test arguments
latents = torch.randn(2, 4)  # batch_size=2, latent_dim=4
pipe = MinimalPipe()

ARGS = {
    "latents": latents,
    "pipe": pipe,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 4, dtype family int, shape (2, 8, 8, 3) — shape (2, 8, 8, 3) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
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
get_config Not yet run
unverified (harvested, no recorded run)
kvablack/ddpo-pytorch/config/dgx.py
code served (permissive licence) · get_code("b6e22297f43ef430")
How it ran

no invocation recorded.

load_aesthetic_model_weights Not yet run
unverified (harvested, no recorded run)
akashsonowal/ddpo-pytorch/ddpo_pytorch/aesthetic_scorer.py
code served (permissive licence) · get_code("ec9dd7a0999c059f")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 later) and 5 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
get_config 6 other papers
6 later
2310.10639 (2023-10)
Zero-Shot Robotic Manipulation with Pretrained Image-Editing Diffusion Models
2402.08552 (2024-02)
Confronting Reward Overoptimization for Diffusion Models: A Perspective of Inductive and Primacy Biases
2411.11727 (2024-11)
Aligning Few-Step Diffusion Models with Dense Reward Difference Learning
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-22.

Repositories linked to this paper

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

Abstract

Diffusion models are a class of flexible generative models trained with an approximation to the log-likelihood objective. However, most use cases of diffusion models are not concerned with likelihoods, but instead with downstream objectives such as human-perceived image quality or drug effectiveness. In this paper, we investigate reinforcement learning methods for directly optimizing diffusion models for such objectives. We describe how posing denoising as a multi-step decision-making problem enables a class of policy gradient algorithms, which we refer to as denoising diffusion policy optimization (DDPO), that are more effective than alternative reward-weighted likelihood approaches. Empirically, DDPO is able to adapt text-to-image diffusion models to objectives that are difficult to express via prompting, such as image compressibility, and those derived from human feedback, such as aesthetic quality. Finally, we show that DDPO can improve prompt-image alignment using feedback from a vision-language model without the need for additional data collection or human annotation. The project's website can be found at http://rl-diffusion.github.io .

For agents

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

get_harvested_code_for_paper("2305.13301")
get_code_for_paper("2305.13301")
have("2305.13301")

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

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

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

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

Connect an agent — have() is free.