SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2306.06874 · NeurIPS · 2023

VillanDiffusion: A Unified Backdoor Attack Framework for Diffusion Models

Sheng-Yen Chou, Tsung-Yi Ho

arXiv · PDF · Open in the Atlas

Code that ran

9 of 14 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; 3 honoured the contract we drafted, 2 violated it and 0 have no contract verdict; 4 failures of our instrument; 5 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/2306.06874.json · badge: /api/ran/2306.06874.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
IBM/villandiffusion canonical (classifier label)
classifier basis not recorded on the link
8 ran · 5 no recorded run
IBM/VillanDiffusion canonical (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
Upsample Ran
ran; our contract draft was wrong, not the code
IBM/villandiffusion/model.py
code served (permissive licence) · get_code("8bee9b7a4832d4a1")
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 ConvTranspose2d. 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

torch.manual_seed(0)

# The function Upsample takes a single parameter 'dim' which is used as:
# - First argument to nn.ConvTranspose2d (in_channels)
# - Second argument to nn.ConvTranspose2d (out_channels)
# So dim should be an integer representing the number of channels

dim = 4

ARGS = {
    "dim": dim
}
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 ConvTranspose2d — a ConvTranspose2d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ConvTranspose2d 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
action_generator Ran
ran; our contract draft was wrong, not the code
IBM/villandiffusion/config.py
code served (permissive licence) · get_code("7eef736dc758d990")
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 str. 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 numpy as np

torch.manual_seed(0)

# The function action_generator takes a boolean parameter and returns a string
# based on its value. It's a simple function with no complex object requirements.

ARGS = {
    'default_action': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
cosine_beta_schedule Ran
ran, honoured the contract we drafted
IBM/villandiffusion/loss.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from vanzll/FA-OPD, is pointer only (licence: NONE) · get_code("f3a9cdb81c13d825")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from vanzll/FA-OPD, and GitHub detected no licence in that repository when it was checked. 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.

default Ran
ran, violated the contract we drafted
IBM/villandiffusion/model.py
code served (permissive licence) · get_code("fbf9ec7be545688e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned str. 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 numpy as np
from inspect import isfunction

torch.manual_seed(0)

# Test case 1: val exists (not None), d is a regular value
val_case1 = 42
d_case1 = 100

# Test case 2: val is None, d is a regular value
val_case2 = None
d_case2 = "default_string"

# Test case 3: val is None, d is a function
val_case3 = None
def d_case3():
    return [1, 2, 3]

# Test case 4: val exists, d is a function (function should not be called)
val_case4 = torch.tensor([1.0, 2.0, 3.0])
def d_case4():
    return torch.tensor([4.0, 5.0, 6.0])

# We'll use case 2 for the main ARGS
ARGS = {
    'val': None,
    'd': "default_value"
}
Setup block drafted by
a language model, Claude Sonnet 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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
exists Ran
ran, violated the contract we drafted
IBM/villandiffusion/model.py
code served (permissive licence) · get_code("608e364a9d2376a3")
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 bool, ndim 0, dtype family float, shape () 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

def exists(x):
    return x is not None

ARGS = {
    "x": torch.tensor([1, 2, 3, 4])
}
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 bool, ndim 0, dtype family float, shape () — shape () 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
linear_beta_schedule Ran
ran, honoured the contract we drafted
IBM/villandiffusion/loss.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from iit-pavis/diffassemble, is pointer only (licence: NONE) · get_code("37a36e71b86103ce")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from iit-pavis/diffassemble, and GitHub detected no licence in that repository when it was checked. 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.

quadratic_beta_schedule Ran
ran, honoured the contract we drafted
IBM/villandiffusion/loss.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from ntkien1904/dmns, is pointer only (licence: NONE) · get_code("496165266c2eceff")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from ntkien1904/dmns, and GitHub detected no licence in that repository when it was checked. 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.

read_json Ran
ran; our contract draft was wrong, not the code
IBM/VillanDiffusion/VillanDiffusion.py
code served (permissive licence) · get_code("410e560ea7b3decb")
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 dict. 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 argparse
import os
import json
import tempfile

# Create a temporary directory to serve as checkpoint directory
temp_dir = tempfile.mkdtemp()

# Create a sample JSON file in the temp directory
sample_data = {"key": "value", "number": 42}
json_file_path = os.path.join(temp_dir, "config.json")
with open(json_file_path, 'w') as f:
    json.dump(sample_data, f)

# Create the args namespace with the checkpoint directory
args = argparse.Namespace(ckpt=temp_dir)

ARGS = {
    "args": args,
    "file": "config.json"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
yield_default Ran
ran; our contract draft was wrong, not the code
IBM/villandiffusion/arg_parser.py
code served (permissive licence) · get_code("5a5ee8bd0dc9da41")
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 DummyClass. 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.

from dataclasses import dataclass, asdict, is_dataclass
from typing import Dict, List, Union, Tuple

@dataclass
class TestConfig:
    learning_rate: float = 0.001
    batch_size: int = 32
    num_epochs: int = 10
    model_name: str = "test_model"

@dataclass
class DummyClass:
    pass

def yield_default(config: Union[dataclass, dict], return_dict: bool=False) -> dataclass:
    config_dict: dict = {}
    res_dataclass: dataclass = DummyClass()
    if is_dataclass(config):
        config_dict = asdict(config)
    for key, val in config_dict.items():
        setattr(res_dataclass, key, val)
    if return_dict:
        return asdict(res_dataclass)
    return res_dataclass

# Test case 1: passing a dataclass with return_dict=False
test_config = TestConfig(learning_rate=0.01, batch_size=64, num_epochs=5, model_name="bert")

ARGS = {
    "config": test_config,
    "return_dict": False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DummyClass — a DummyClass output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DummyClass 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
calculate_activation_statistics Not yet run
unverified (harvested, no recorded run)
IBM/villandiffusion/fid_score.py
code served (permissive licence) · get_code("a17aa1b06ec919e8")
How it ran

no invocation recorded.

calculate_frechet_distance Not yet run
unverified (harvested, no recorded run)
IBM/villandiffusion/fid_score.py
code served (permissive licence) · get_code("0def50a351111624")
How it ran

no invocation recorded. this sample carries JSON test cases instead of a setup block; get_reference_implementation serves them with the level they back.

download_img Not yet run
unverified (harvested, no recorded run)
IBM/villandiffusion/caption_dataset.py
code served (permissive licence) · get_code("be5b84142037dc3b")
How it ran

no invocation recorded.

get_activations Not yet run
unverified (harvested, no recorded run)
IBM/villandiffusion/fid_score.py
code served (permissive licence) · get_code("9f5980b8530c7409")
How it ran

no invocation recorded.

import_model_class_from_model_name_or_path Not yet run
unverified (harvested, no recorded run)
IBM/villandiffusion/caption_sim.py
code served (permissive licence) · get_code("2f00b39db5a81466")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 14 are also present in other papers whose code we hold (7 with at least one paper dated earlier, 4 the same month, 14 later) and 0 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
default 207 other papers
60 dated earlier, 4 the same month, 141 later, 2 same year, order not determinable · 41 only as an assembly brick
1711.11585 (2017-11)
High-Resolution Image Synthesis and Semantic Manipulation with Conditional GANs
2006.11239 (2020-06)
Denoising Diffusion Probabilistic Models
2010.08162 (2020-10)
SidechainNet: An All-Atom Protein Structure Dataset for Machine Learning
and 204 more not named here
exists 144 other papers
41 dated earlier, 6 the same month, 96 later, 1 same year, order not determinable · 40 only as an assembly brick
1611.07004 (2016-11)
Image-to-Image Translation with Conditional Adversarial Networks
1711.11585 (2017-11)
High-Resolution Image Synthesis and Semantic Manipulation with Conditional GANs
2006.11239 (2020-06)
Denoising Diffusion Probabilistic Models
and 141 more not named here
calculate_frechet_distance 74 other papers
39 dated earlier, 2 the same month, 32 later, 1 same year, order not determinable
1610.09585 (2016-10)
Conditional Image Synthesis With Auxiliary Classifier GANs
1706.08500 (2017-06)
GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium
1807.11458 (2018-07)
To learn image super-resolution, use a GAN to learn how to do image degradation first
and 71 more not named here
import_model_class_from_model_name_or_path 24 other papers
1 dated earlier, 1 the same month, 22 later
2212.04489 (2022-12)
SINE: SINgle Image Editing with Text-to-Image Diffusion Models
2306.07280 (2023-06)
Controlling Text-to-Image Diffusion by Orthogonal Finetuning
2310.04687 (2023-10)
Targeted Attack Improves Protection against Unauthorized Diffusion Customization
and 21 more not named here
calculate_activation_statistics 10 other papers
1 dated earlier, 8 later, 1 same year, order not determinable
Chou_How_to_Backdoor_Diffusion_Models_CVPR_2023_paper (2023 (year only))
How to Backdoor Diffusion Models?
2305.08192 (2023-05)
Diffusion Models for Imperceptible and Transferable Adversarial Attack
2312.12030 (2023-12)
Towards Accurate Guided Diffusion Sampling through Symplectic Adjoint Method
and 7 more not named here
cosine_beta_schedule 9 other papers
9 later
2307.11494 (2023-07)
Predict, Refine, Synthesize: Self-Guiding Diffusion Models for Probabilistic Time Series Forecasting
2309.01745 (2023-09)
Benchmarking Autoregressive Conditional Diffusion Models for Turbulent Flow Simulation
2310.20487 (2023-10)
Large Language Model Can Interpret Latent Space of Sequential Recommender
and 6 more not named here
get_activations 6 other papers
5 later, 1 same year, order not determinable
Chou_How_to_Backdoor_Diffusion_Models_CVPR_2023_paper (2023 (year only))
How to Backdoor Diffusion Models?
2312.12030 (2023-12)
Towards Accurate Guided Diffusion Sampling through Symplectic Adjoint Method
aaai_28602 (2024 (year only))
Reducing Spatial Fitting Error in Distillation of Denoising Diffusion Models
and 3 more not named here
linear_beta_schedule 6 other papers
1 dated earlier, 5 later · 1 only as an assembly brick
2303.17839 (2023-03)
Learning Procedure-aware Video Representation from Instructional Videos and Their Narrations
2402.19302 (2024-02)
DiffAssemble: A Unified Graph-Diffusion Model for 2D and 3D Reassembly
2403.17259 (2024-03)
Diffusion-based Negative Sampling on Graphs for Link Prediction
and 3 more not named here
Upsample 3 other papers
1 dated earlier, 2 later
2006.11239 (2020-06)
Denoising Diffusion Probabilistic Models
2406.08473 (2024-06)
Strategies for Pretraining Neural Operators
quadratic_beta_schedule 2 other papers
2 later
2403.17259 (2024-03)
Diffusion-based Negative Sampling on Graphs for Link Prediction
read_json 2 other papers
1 later, 1 same year, order not determinable
Chou_How_to_Backdoor_Diffusion_Models_CVPR_2023_paper (2023 (year only))
How to Backdoor Diffusion Models?
action_generator 1 other paper
1 later
Han_UIBDiffusion_Universal_Imperceptible_Backdoor_Attack_for_Diffusion_Models_CVPR_2025_paper (2025 (year only))
UIBDiffusion: Universal Imperceptible Backdoor Attack for Diffusion Models
download_img 1 other paper
1 later
Han_UIBDiffusion_Universal_Imperceptible_Backdoor_Attack_for_Diffusion_Models_CVPR_2025_paper (2025 (year only))
UIBDiffusion: Universal Imperceptible Backdoor Attack for Diffusion Models
yield_default 1 other paper
1 later
Han_UIBDiffusion_Universal_Imperceptible_Backdoor_Attack_for_Diffusion_Models_CVPR_2025_paper (2025 (year only))
UIBDiffusion: Universal Imperceptible Backdoor Attack for Diffusion Models

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

Diffusion Models (DMs) are state-of-the-art generative models that learn a reversible corruption process from iterative noise addition and denoising. They are the backbone of many generative AI applications, such as text-to-image conditional generation. However, recent studies have shown that basic unconditional DMs (e.g., DDPM [16] and DDIM [52]) are vulnerable to backdoor injection, a type of output manipulation attack triggered by a maliciously embedded pattern at model input. This paper presents a unified backdoor attack framework (VillanDiffusion) to expand the current scope of backdoor analysis for DMs. Our framework covers mainstream unconditional and conditional DMs (denoising-based and score-based) and various training-free samplers for holistic evaluations. Experiments show that our unified framework facilitates the backdoor analysis of different DM configurations and provides new insights into caption-based backdoor attacks on DMs.

For agents

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

get_harvested_code_for_paper("2306.06874")
get_code_for_paper("2306.06874")
have("2306.06874")

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

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

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

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

Connect an agent — have() is free.