SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2303.17604 · 2023

Token Merging for Fast Stable Diffusion

arXiv · PDF · Open in the Atlas

Code that ran

7 of 7 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, 1 violated it and 0 have no contract verdict; 4 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/2303.17604.json · badge: /api/ran/2303.17604.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
dbolya/tomesd canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
omidiu/ca_tome extension (classifier label)
classifier basis: classifier_2025
5 ran · 0 no recorded run
FunctionStatusWhere it lives
bipartite_soft_matching_random2d Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
omidiu/ca_tome/src/ca_tome/merge.py
code served (permissive licence) · get_code("7c14a90447a2579f")
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 tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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

torch.manual_seed(0)

# Create a small metric tensor [B, N, C]
# B=2 (batch), N=12 (tokens in a 4x3 grid), C=4 (feature dimension)
metric = torch.randn(2, 12, 4)

# Grid dimensions: 4 width, 3 height
w = 4
h = 3

# Strides for selecting destination tokens
sx = 2
sy = 1

# Similarity threshold
similarity_threshold = 0.5

# Cache info dictionary
cache_info = {
    'compute_on': [0, 1, 2],
    'merge': None,
    'unmerge': None
}

# Current inference step
inference_step = 0

# No randomness flag
no_rand = False

# Random generator
generator = torch.Generator()
generator.manual_seed(42)

ARGS = {
    'metric': metric,
    'w': w,
    'h': h,
    'sx': sx,
    'sy': sy,
    'similarity_threshold': similarity_threshold,
    'cache_info': cache_info,
    'inference_step': inference_step,
    'no_rand': no_rand,
    'generator': generator
}
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 tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
bipartite_soft_matching_random2d Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
dbolya/tomesd/tomesd/merge.py
code served (permissive licence) · get_code("50778ef0adbc3581")
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 tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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

torch.manual_seed(0)

# Create a small metric tensor [B, N, C]
# B=2 (batch), N=12 (total tokens), C=4 (channels)
metric = torch.randn(2, 12, 4)

# Image dimensions: 4x3 tokens
w = 4
h = 3

# Strides for partitioning: sx=2, sy=1
sx = 2
sy = 1

# Number of tokens to remove by merging
r = 2

# Disable randomness for deterministic behavior
no_rand = False

# Create a generator for reproducibility
generator = torch.Generator()
generator.manual_seed(42)

ARGS = {
    "metric": metric,
    "w": w,
    "h": h,
    "sx": sx,
    "sy": sy,
    "r": r,
    "no_rand": no_rand,
    "generator": generator,
}
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 tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
do_nothing Ran
ran, honoured the contract we drafted
omidiu/ca_tome/src/ca_tome/merge.py
code served (permissive licence) · get_code("50ce5aa3c4f434e3")
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

torch.manual_seed(0)

# The function do_nothing takes a single parameter x which is a torch.Tensor
# It simply returns x unchanged, so we need to provide a valid tensor

x = torch.randn(2, 4)

ARGS = {
    "x": x
}
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
do_nothing Ran
ran, honoured the contract we drafted
dbolya/tomesd/tomesd/merge.py
code served (permissive licence) · get_code("bd041cf95d856b5d")
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

torch.manual_seed(0)

ARGS = {
    "x": torch.randn(2, 4),
    "mode": None,
}
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
init_generator Ran
ran; our contract draft was wrong, not the code
omidiu/ca_tome/src/ca_tome/utils.py
code served (permissive licence) · get_code("71d0bd8b57e89aba")
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 Generator. 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

torch.manual_seed(0)

# The function takes a device and an optional fallback generator
# device: torch.device - required parameter
# fallback: torch.Generator or None - optional parameter with default None

device = torch.device('cpu')

fallback_generator = torch.Generator(device='cpu')
fallback_generator.set_state(torch.get_rng_state())

ARGS = {
    'device': device,
    'fallback': fallback_generator
}
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 Generator — a Generator output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Generator 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
isinstance_str Ran
ran, violated the contract we drafted
omidiu/ca_tome/src/ca_tome/utils.py
code served (permissive licence) · get_code("fadc1f6d2d7dd9fa")
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
import torch.nn as nn

torch.manual_seed(0)

# Create a simple object with a class hierarchy
class CustomModule(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Create an instance
custom_obj = CustomModule()

# Test with the class name that exists in the MRO
cls_name_to_find = "CustomModule"

ARGS = {
    "x": custom_obj,
    "cls_name": cls_name_to_find
}
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
mps_gather_workaround Ran
ran; our contract draft was wrong, not the code
omidiu/ca_tome/src/ca_tome/merge.py
code served (permissive licence) · get_code("16eb26a585c085e1")
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 3, dtype family float, shape (2, 3, 1) 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

torch.manual_seed(0)

# Create test tensors for the function
# input: tensor to gather from
# dim: dimension along which to gather
# index: indices to gather

# Case 1: input with shape[-1] == 1 (the workaround case)
input_tensor = torch.randn(2, 4, 1)
dim = 1
index = torch.randint(0, 4, (2, 3, 1))

ARGS = {
    "input": input_tensor,
    "dim": dim,
    "index": index
}
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 3, dtype family float, shape (2, 3, 1) — shape (2, 3, 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

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 7 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 6 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
isinstance_str 10 other papers
10 later
2307.10373 (2023-07)
TokenFlow: Consistent Diffusion Features for Consistent Video Editing
2312.02212 (2023-12)
Portrait Diffusion: Training-free Face Stylization with Chain-of-Painting
2312.10656 (2023-12)
VidToMe: Video Token Merging for Zero-Shot Video Editing
and 7 more not named here
do_nothing 7 other papers
1 dated earlier, 6 later · 2 only as an assembly brick
2210.09461 (2022-10)
Token Merging: Your ViT But Faster
2312.10656 (2023-12)
VidToMe: Video Token Merging for Zero-Shot Video Editing
2403.14622 (2024-03)
Language Repository for Long Video Understanding
and 4 more not named here
mps_gather_workaround 7 other papers
1 dated earlier, 6 later · 2 only as an assembly brick
2210.09461 (2022-10)
Token Merging: Your ViT But Faster
2312.10656 (2023-12)
VidToMe: Video Token Merging for Zero-Shot Video Editing
2403.14622 (2024-03)
Language Repository for Long Video Understanding
and 4 more not named here
init_generator 4 other papers
4 later
2312.10656 (2023-12)
VidToMe: Video Token Merging for Zero-Shot Video Editing
2403.14622 (2024-03)
Language Repository for Long Video Understanding
2025.findings-acl.294 (2025 (year only))
Language Repository for Long Video Understanding
and 1 more not named here
bipartite_soft_matching_random2d 1 other paper
1 later
2501.00946 (2025-01)
Cached Adaptive Token Merging: Dynamic Token Reduction and Redundant Computation Elimination in Diffusion Model
bipartite_soft_matching_random2d 1 other paper
1 dated earlier
2210.09461 (2022-10)
Token Merging: Your ViT But Faster
do_nothing 1 other paper
1 later
2501.00946 (2025-01)
Cached Adaptive Token Merging: Dynamic Token Reduction and Redundant Computation Elimination in Diffusion Model

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

The landscape of image generation has been forever changed by open vocabulary diffusion models. However, at their core these models use transformers, which makes generation slow. Better implementations to increase the throughput of these transformers have emerged, but they still evaluate the entire model. In this paper, we instead speed up diffusion models by exploiting natural redundancy in generated images by merging redundant tokens. After making some diffusion-specific improvements to Token Merging (ToMe), our ToMe for Stable Diffusion can reduce the number of tokens in an existing Stable Diffusion model by up to 60% while still producing high quality images without any extra training. In the process, we speed up image generation by up to 2x and reduce memory consumption by up to 5.6x. Furthermore, this speed-up stacks with efficient implementations such as xFormers, minimally impacting quality while being up to 5.4x faster for large images. Code is available at https://github.com/dbolya/tomesd.

For agents

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

get_harvested_code_for_paper("2303.17604")
get_code_for_paper("2303.17604")
have("2303.17604")

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

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

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

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

Connect an agent — have() is free.