SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2202.06258 · 2022

Flowformer: Linearizing Transformers with Conservation Flows

arXiv · PDF · Open in the Atlas

Code that ran

6 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; 1 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 3 failures of our instrument; 0 no recorded run), measured 2026-11-21; 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/2202.06258.json · badge: /api/ran/2202.06258.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
thuml/Flowformer canonical (classifier label)
classifier basis not recorded on the link
6 ran · 0 no recorded run
FunctionStatusWhere it lives
batch_index_select Ran
ran; our contract draft was wrong, not the code
thuml/Flowformer/Flowformer_CV/utils.py
code served (permissive licence) · get_code("908619be92da9903")
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, 2, 3) 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)

# Test case 1: 3D tensor
x_3d = torch.randn(2, 4, 3)  # B=2, N=4, C=3
idx_3d = torch.tensor([[0, 2], [1, 3]])  # B=2, N_new=2

# Test case 2: 2D tensor
x_2d = torch.randn(2, 4)  # B=2, N=4
idx_2d = torch.tensor([[0, 2], [1, 3]])  # B=2, N_new=2

# Use the 3D case for ARGS
ARGS = {
    "x": x_3d,
    "idx": idx_3d,
}
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, 2, 3) — shape (2, 2, 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
build_dataset Ran
ran on a synthesized input
thuml/Flowformer/Flowformer_CV/datasets.py
code served (permissive licence) · get_code("09d8970cc61c5886")
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. 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 os
import tempfile
import shutil
from pathlib import Path
import torch
import numpy as np
from torchvision import datasets, transforms
from PIL import Image

torch.manual_seed(0)

# Create a temporary directory structure with minimal ImageFolder data
temp_dir = tempfile.mkdtemp()
train_dir = os.path.join(temp_dir, 'train')
val_dir = os.path.join(temp_dir, 'val')

os.makedirs(train_dir, exist_ok=True)
os.makedirs(val_dir, exist_ok=True)

# Create a few dummy classes with minimal images
for split_dir in [train_dir, val_dir]:
    for class_idx in range(2):
        class_dir = os.path.join(split_dir, f'class_{class_idx}')
        os.makedirs(class_dir, exist_ok=True)
        
        # Create 2 dummy images per class
        for img_idx in range(2):
            img_array = np.random.randint(0, 256, (32, 32, 3), dtype=np.uint8)
            img = Image.fromarray(img_array)
            img_path = os.path.join(class_dir, f'img_{img_idx}.jpg')
            img.save(img_path)

# Create args object
class Args:
    def __init__(self):
        self.data_path = temp_dir
        self.input_size = 224
        self.color_jitter = 0.4
        self.aa = 'rand-m9-mstd0.5'
        self.train_interpolation = 'bicubic'
        self.reprob = 0.25
        self.remode = 'pixel'
        self.recount = 1
        self.arch = 'resnet50'

args = Args()

ARGS = {
    'is_train': True,
    'args': args,
    'infer_no_resize': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, timm, torch, torchvision — 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
build_transform Ran
ran on a synthesized input
thuml/Flowformer/Flowformer_CV/datasets.py
code served (permissive licence) · get_code("984b0cb17eae025e")
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 Compose. 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 torchvision import transforms

torch.manual_seed(0)

class Args:
    def __init__(self):
        self.arch = 'resnet50'
        self.input_size = 224
        self.color_jitter = 0.4
        self.aa = 'rand-m9-mstd0.5'
        self.train_interpolation = 'bicubic'
        self.reprob = 0.25
        self.remode = 'pixel'
        self.recount = 2

ARGS = {
    'is_train': True,
    'args': Args(),
    'infer_no_resize': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, timm, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Compose — a Compose output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Compose 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
get_lr Ran
ran, honoured the contract we drafted
thuml/Flowformer/Flowformer_RL/utils.py
pointer only (licence: MIT); the stored copy get_code serves, from yjzhang96/UTI-VFI, is pointer only (licence: NONE) · get_code("7337f1f5ff01dcd0")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from yjzhang96/UTI-VFI, 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.

get_pos_encoder Ran
ran; our contract draft was wrong, not the code
thuml/Flowformer/Flowformer_TimeSeries/models/Flowformer.py
code served (permissive licence) · get_code("48ee0364b1d8b847")
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 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
import math

torch.manual_seed(0)

ARGS = {
    'pos_encoding': 'fixed'
}
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 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
make_dir Ran
ran; our contract draft was wrong, not the code
thuml/Flowformer/Flowformer_RL/utils.py
pointer only (licence: MIT); the stored copy get_code serves, from silihuang-ai/idt, is pointer only (licence: NONE) · get_code("42958997018c3581")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from silihuang-ai/idt, 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.

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, 4 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 0 the same month, 4 later) and 2 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_lr 25 other papers
14 dated earlier, 11 later · 2 only as an assembly brick
1605.07148 (2016-05)
Backprop KF: Learning Discriminative Deterministic State Estimators
1606.00915 (2016-06)
DeepLab: Semantic Image Segmentation with Deep Convolutional Nets, Atrous Convolution, and Fully Connected CRFs
1904.01355 (2019-04)
FCOS: Fully Convolutional One-Stage Object Detection
and 22 more not named here
batch_index_select 10 other papers
1 dated earlier, 9 later · 1 only as an assembly brick
2106.02034 (2021-06)
DynamicViT: Efficient Vision Transformers with Dynamic Token Sparsification
aaai_25860 (2023 (year only))
CF-ViT: A General Coarse-to-Fine Method for Vision Transformer
2304.10716 (2023-04)
Joint Token Pruning and Squeezing Towards More Aggressive Compression of Vision Transformers
and 7 more not named here
make_dir 8 other papers
3 dated earlier, 5 later
1910.01741 (2019-10)
Improving Sample Efficiency in Model-Free Reinforcement Learning from Images
2004.04136 (2020-04)
CURL: Contrastive Unsupervised Representations for Reinforcement Learning
2010.09163 (2020-10)
D2RL: Deep Dense Architectures in Reinforcement Learning
and 5 more not named here
get_pos_encoder 2 other papers
1 dated earlier, 1 later
2010.02803 (2020-10)
A Transformer-based Framework for Multivariate Time Series Representation Learning
2410.17918 (2024-10)
Addressing Asynchronicity in Clinical Multimodal Fusion via Individualized Chest X-ray Generation

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-21.

Repositories linked to this paper

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

Abstract

Transformers based on the attention mechanism have achieved impressive success in various areas. However, the attention mechanism has a quadratic complexity, significantly impeding Transformers from dealing with numerous tokens and scaling up to bigger models. Previous methods mainly utilize the similarity decomposition and the associativity of matrix multiplication to devise linear-time attention mechanisms. They avoid degeneration of attention to a trivial distribution by reintroducing inductive biases such as the locality, thereby at the expense of model generality and expressiveness. In this paper, we linearize Transformers free from specific inductive biases based on the flow network theory. We cast attention as the information flow aggregated from the sources (values) to the sinks (results) through the learned flow capacities (attentions). Within this framework, we apply the property of flow conservation into attention and propose the Flow-Attention mechanism of linear complexity. By respectively conserving the incoming flow of sinks for source competition and the outgoing flow of sources for sink allocation, Flow-Attention inherently generates informative attentions without using specific inductive biases. Empowered by the Flow-Attention, Flowformer yields strong performance in linear time for wide areas, including long sequence, time series, vision, natural language, and reinforcement learning. The code and settings are available at this repository: https://github.com/thuml/Flowformer.

For agents

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

get_harvested_code_for_paper("2202.06258")
get_code_for_paper("2202.06258")
have("2202.06258")

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

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

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

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

Connect an agent — have() is free.