SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2304.06140 · 2023

An Edit Friendly DDPM Noise Space: Inversion and Manipulations

arXiv · PDF · Open in the Atlas

Code that ran

4 of 4 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; 2 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 2 failures of our instrument; 0 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/2304.06140.json · badge: /api/ran/2304.06140.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
inbarhub/ddpm_inversion canonical (classifier label)
classifier basis: classifier_2025
3 ran · 0 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
FunctionStatusWhere it lives
aggregate_attention Ran
ran, honoured the contract we drafted
inbarhub/ddpm_inversion/prompt_to_prompt/ptp_classes.py
code served (permissive licence) · get_code("e151ef7384cb586b")
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 Tensor, ndim 3, dtype family float, shape (8, 8, 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 abc
from typing import List

torch.manual_seed(0)

LOW_RESOURCE = True

class AttentionControl(abc.ABC):

    def step_callback(self, x_t):
        return x_t

    def between_steps(self):
        return

    @property
    def num_uncond_att_layers(self):
        return self.num_att_layers if LOW_RESOURCE else 0

    @abc.abstractmethod
    def forward(self, attn, is_cross: bool, place_in_unet: str):
        raise NotImplementedError

    def __call__(self, attn, is_cross: bool, place_in_unet: str):
        if self.cur_att_layer >= self.num_uncond_att_layers:
            if LOW_RESOURCE:
                attn = self.forward(attn, is_cross, place_in_unet)
            else:
                h = attn.shape[0]
                attn[h // 2:] = self.forward(attn[h // 2:], is_cross, place_in_unet)
        self.cur_att_layer += 1
        if self.cur_att_layer == self.num_att_layers + self.num_uncond_att_layers:
            self.cur_att_layer = 0
            self.cur_step += 1
            self.between_steps()
        return attn

    def reset(self):
        self.cur_step = 0
        self.cur_att_layer = 0

    def __init__(self):
        self.cur_step = 0
        self.num_att_layers = -1
        self.cur_att_layer = 0

class AttentionStore(AttentionControl):

    @staticmethod
    def get_empty_store():
        return {'down_cross': [], 'mid_cross': [], 'up_cross': [], 'down_self': [], 'mid_self': [], 'up_self': []}

    def forward(self, attn, is_cross: bool, place_in_unet: str):
        key = f"{place_in_unet}_{('cross' if is_cross else 'self')}"
        if attn.shape[1] <= 32 ** 2:
            self.step_store[key].append(attn)
        return attn

    def between_steps(self):
        if len(self.attention_store) == 0:
            self.attention_store = self.step_store
        else:
            for key in self.attention_store:
                for i in range(len(self.attention_store[key])):
                    self.attention_store[key][i] += self.step_store[key][i]
        self.step_store = self.get_empty_store()

    def get_average_attention(self):
        average_attention = {key: [item / self.cur_step for item in self.attention_store[key]] for key in self.attention_store}
        return average_attention

    def reset(self):
        super(AttentionStore, self).reset()
        self.step_store = self.get_empty_store()
        self.attention_store = {}

    def __init__(self):
        super(AttentionStore, self).__init__()
        self.step_store = self.get_empty_store()
        self.attention_store = {}

# Create an AttentionStore instance and populate it with test data
attention_store = AttentionStore()
attention_store.num_att_layers = 2
attention_store.cur_step = 2

# Populate attention_store with test attention maps
# Shape: (batch_size, num_pixels, num_heads) where num_pixels = 64 (8x8)
test_attn_down_cross = torch.randn(2, 64, 4)
test_attn_mid_cross = torch.randn(2, 64, 4)
test_attn_up_cross = torch.randn(2, 64, 4)

attention_store.attention_store = {
    'down_cross': [test_attn_down_cross, test_attn_down_cross],
    'mid_cross': [test_attn_mid_cross, test_attn_mid_cross],
    'up_cross': [test_attn_up_cross, test_attn_up_cross],
    'down_self': [],
    'mid_self': [],
    'up_self': []
}

ARGS = {
    'attention_store': attention_store,
    'res': 8,
    'from_where': ['down', 'mid', 'up'],
    'is_cross': True,
    'select': 0,
    'prompts': ['a cat', 'a dog']
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 3, dtype family float, shape (8, 8, 4) — shape (8, 8, 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
get_noise_pred Ran
ran; our contract draft was wrong, not the code
inbarhub/ddpm_inversion/ddm_inversion/ddim_inversion.py
code served (permissive licence) · get_code("8b17adfc032f84aa")
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 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 torch.nn as nn

torch.manual_seed(0)

class MockUNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, latents_input, t, encoder_hidden_states):
        # latents_input shape: (4, 4) - batch of 4 (2 original + 2 from cat)
        # encoder_hidden_states shape: (4, 3)
        # Return dict with 'sample' key containing noise predictions
        batch_size = latents_input.shape[0]
        output = self.linear(latents_input)
        return {'sample': output}

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.unet = MockUNet()

# Create model
model = MockModel()

# Create latent tensor: (2, 4) - batch size 2, latent dim 4
latent = torch.randn(2, 4)

# Create timestep tensor: scalar or (1,)
t = torch.tensor([5])

# Create context (encoder hidden states): (4, 3) - will be used with concatenated latents
# The concatenated latents will have batch 4, so context should match
context = torch.randn(4, 3)

# Classifier-free guidance scale
cfg_scale = 7.5

ARGS = {
    'model': model,
    'latent': latent,
    't': t,
    'context': context,
    'cfg_scale': cfg_scale
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
load_512 Ran
ran, honoured the contract we drafted
this paper's copy was not recorded; identical code first harvested from cuixing100876/instastyle
pointer only; the stored copy get_code serves, from cuixing100876/instastyle, is pointer only (licence: NONE) · get_code("0230471a58926463")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

next_step Ran
ran; our contract draft was wrong, not the code
inbarhub/ddpm_inversion/ddm_inversion/ddim_inversion.py
code served (permissive licence) · get_code("ca2409fb3e38f775")
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 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 numpy as np
from torch import nn

torch.manual_seed(0)

class MockSchedulerConfig:
    def __init__(self):
        self.num_train_timesteps = 1000

class MockScheduler:
    def __init__(self):
        self.config = MockSchedulerConfig()
        self.num_inference_steps = 50
        # alphas_cumprod needs to be indexable with timesteps up to 999
        self.alphas_cumprod = torch.linspace(0.9999, 0.0001, 1000)
        self.final_alpha_cumprod = 0.0001

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.scheduler = MockScheduler()

model = MockModel()
model_output = torch.randn(2, 4)
timestep = 500
sample = torch.randn(2, 4)

ARGS = {
    "model": model,
    "model_output": model_output,
    "timestep": timestep,
    "sample": sample
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, 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

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 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 3 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
load_512 5 other papers
5 later
2305.15581 (2023-05)
Unsupervised Semantic Correspondence Using Stable Diffusion
2305.18729 (2023-05)
Real-World Image Variation by Aligning Diffusion Inversion Chain
2311.15040 (2023-11)
InstaStyle: Inversion Noise of a Stylized Image is Secretly a Style Adviser
and 2 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

Denoising diffusion probabilistic models (DDPMs) employ a sequence of white Gaussian noise samples to generate an image. In analogy with GANs, those noise maps could be considered as the latent code associated with the generated image. However, this native noise space does not possess a convenient structure, and is thus challenging to work with in editing tasks. Here, we propose an alternative latent noise space for DDPM that enables a wide range of editing operations via simple means, and present an inversion method for extracting these edit-friendly noise maps for any given image (real or synthetically generated). As opposed to the native DDPM noise space, the edit-friendly noise maps do not have a standard normal distribution and are not statistically independent across timesteps. However, they allow perfect reconstruction of any desired image, and simple transformations on them translate into meaningful manipulations of the output image (e.g. shifting, color edits). Moreover, in text-conditional models, fixing those noise maps while changing the text prompt, modifies semantics while retaining structure. We illustrate how this property enables text-based editing of real images via the diverse DDPM sampling scheme (in contrast to the popular non-diverse DDIM inversion). We also show how it can be used within existing diffusion-based editing methods to improve their quality and diversity. Webpage: https://inbarhub.github.io/DDPM_inversion

For agents

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

get_harvested_code_for_paper("2304.06140")
get_code_for_paper("2304.06140")
have("2304.06140")

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

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

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

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

Connect an agent — have() is free.