SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2506.10036 · NeurIPS · 2025

Token Perturbation Guidance for Diffusion Models

Seyedmorteza Sadat, Javad Rajabi, Soroush Mehraban, Babak Taati

arXiv · PDF · Open in the Atlas

Code that ran

3 of 3 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 0 have no contract verdict; 3 failures of our instrument; 0 no recorded run), measured 2026-11-24; 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/2506.10036.json · badge: /api/ran/2506.10036.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
taatiteam/token-perturbation-guidance canonical (classifier label)
classifier basis: classifier_2025
2 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
make_tpg_block Ran
ran; our contract draft was wrong, not the code
taatiteam/token-perturbation-guidance/pipeline_sdxl_tpg.py
code served (permissive licence) · get_code("896ad2d655f710b2")
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 type. 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)

# Create a minimal base transformer block that implements the forward method
class MinimalTransformerBlock(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, hidden_states, attention_mask=None, encoder_hidden_states=None, 
                encoder_attention_mask=None, timestep=None, cross_attention_kwargs=None, 
                class_labels=None):
        # Minimal implementation that processes hidden_states
        return self.linear(hidden_states)

ARGS = {
    "block_class": MinimalTransformerBlock,
    "do_cfg": True,
}
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 type — a type output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a type 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
rescale_noise_cfg Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from gnobitab/InstaFlow
pointer only · get_code("bea2d776a332f2b0")
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.

retrieve_timesteps Ran
ran; our contract draft was wrong, not the code
taatiteam/token-perturbation-guidance/pipeline_sdxl_tpg.py
code served (permissive licence) · get_code("5817cdfd5ceed6f4")
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 tuple. 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 inspect
from typing import List, Optional, Union

torch.manual_seed(0)

# Create a minimal scheduler mock that satisfies the function's requirements
class MockScheduler:
    def __init__(self):
        self.timesteps = torch.tensor([999, 799, 599, 399, 199], dtype=torch.long)
    
    def set_timesteps(self, num_inference_steps: Optional[int] = None, device: Optional[Union[str, torch.device]] = None, timesteps: Optional[List[int]] = None, **kwargs):
        """Mock set_timesteps that handles both custom timesteps and num_inference_steps"""
        if timesteps is not None:
            # Custom timesteps case
            self.timesteps = torch.tensor(timesteps, dtype=torch.long)
            if device is not None:
                self.timesteps = self.timesteps.to(device)
        else:
            # Standard case with num_inference_steps
            if num_inference_steps is not None:
                # Generate timesteps based on num_inference_steps
                self.timesteps = torch.linspace(999, 0, num_inference_steps, dtype=torch.long)
            if device is not None:
                self.timesteps = self.timesteps.to(device)

# Create scheduler instance
scheduler = MockScheduler()

# Define ARGS dictionary with all parameters
ARGS = {
    "scheduler": scheduler,
    "num_inference_steps": 5,
    "device": None,
    "timesteps": None,
}
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 tuple — a tuple output has no array shape of its own; none is 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

Also present in other papers' code

Of 3 samples lifted from this paper's linked repositories, 3 carry a function identity and 0 do not. Of the 3 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 2 later) and 1 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
rescale_noise_cfg 62 other papers
54 dated earlier, 7 later, 1 same year, order not determinable
2206.02779 (2022-06)
Blended Latent Diffusion
2304.06720 (2023-04)
Expressive Text-to-Image Generation with Rich Text
2309.06380 (2023-09)
InstaFlow: One Step is Enough for High-Quality Diffusion-Based Text-to-Image Generation
and 59 more not named here
retrieve_timesteps 21 other papers
19 dated earlier, 2 later
2310.06313 (2023-10)
Advancing Pose-Guided Image Synthesis with Progressive Conditional Diffusion Models
2401.11708 (2024-01)
Mastering Text-to-Image Diffusion: Recaptioning, Planning, and Generating with Multimodal LLMs
2403.06976 (2024-03)
BrushNet: A Plug-and-Play Image Inpainting Model with Decomposed Dual-Branch Diffusion
and 18 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-24.

Repositories linked to this paper

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

Abstract

Classifier-free guidance (CFG) has become an essential component of modern diffusion models to enhance both generation quality and alignment with input conditions. However, CFG requires specific training procedures and is limited to conditional generation. To address these limitations, we propose Token Perturbation Guidance (TPG), a novel method that applies perturbation matrices directly to intermediate token representations within the diffusion network. TPG employs a norm-preserving shuffling operation to provide effective and stable guidance signals that improve generation quality without architectural changes. As a result, TPG is training-free and agnostic to input conditions, making it readily applicable to both conditional and unconditional generation. We further analyze the guidance term provided by TPG and show that its effect on sampling more closely resembles CFG compared to existing training-free guidance techniques. Extensive experiments on SDXL and Stable Diffusion 2.1 show that TPG achieves nearly a 2× improvement in FID for unconditional generation over the SDXL baseline, while closely matching CFG in prompt alignment. These results establish TPG as a general, condition-agnostic guidance method that brings CFG-like benefits to a broader class of diffusion models. The code is available at

For agents

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

get_harvested_code_for_paper("2506.10036")
get_code_for_paper("2506.10036")
have("2506.10036")

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

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

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

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

Connect an agent — have() is free.