SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2110.04627 · ICLR · 2022

Vector-quantized Image Modeling with Improved VQGAN

Han Zhang, Jiahui Yu, Yonghui Wu, Ruoming Pang, Xin Li, James Qin, Jing Koh, Alexander Ku, Yuanzhong Xu, Jason Baldridge

arXiv · PDF · Open in the Atlas

Code that ran

9 of 9 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 4 have no contract verdict; 5 failures of our instrument; 0 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/2110.04627.json · badge: /api/ran/2110.04627.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
thuangb/enhancing-transformers community (classifier label)
classifier basis not recorded on the link
6 ran · 0 no recorded run
CuddleSabe/VQGAN community (classifier label)
classifier basis not recorded on the link
3 ran · 0 no recorded run
FunctionStatusWhere it lives
conv2d Ran
ran; our contract draft was wrong, not the code
thuangb/enhancing-transformers/enhancing/losses/op/conv2d_gradfix.py
code served (permissive licence) · get_code("76042afc43214587")
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 4, dtype family float, shape (2, 5, 2, 2) as a later run recorded it. 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, 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.functional as F

torch.manual_seed(0)

# Create input tensor: batch_size=2, channels=3, height=4, width=4
input_tensor = torch.randn(2, 3, 4, 4, requires_grad=True)

# Create weight tensor: out_channels=5, in_channels=3, kernel_h=3, kernel_w=3
weight_tensor = torch.randn(5, 3, 3, 3, requires_grad=True)

# Create bias tensor: out_channels=5
bias_tensor = torch.randn(5, requires_grad=True)

ARGS = {
    'input': input_tensor,
    'weight': weight_tensor,
    'bias': bias_tensor,
    'stride': 1,
    'padding': 0,
    'dilation': 1,
    'groups': 1,
}
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 4, dtype family float, shape (2, 5, 2, 2) — shape (2, 5, 2, 2) 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
conv_transpose2d Ran
ran; our contract draft was wrong, not the code
thuangb/enhancing-transformers/enhancing/losses/op/conv2d_gradfix.py
code served (permissive licence) · get_code("5f98b4db51504bf7")
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 4, dtype family float, shape (2, 5, 6, 6) as a later run recorded it. 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, 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.functional as F

torch.manual_seed(0)

# Create a small input tensor: (batch=2, channels=3, height=4, width=4)
input_tensor = torch.randn(2, 3, 4, 4, requires_grad=True)

# Create weight tensor for transpose convolution
# For conv_transpose2d: weight shape is (in_channels, out_channels/groups, kH, kW)
# We use in_channels=3, out_channels=5, kernel=3x3
weight_tensor = torch.randn(3, 5, 3, 3, requires_grad=True)

# Create bias tensor: (out_channels,)
bias_tensor = torch.randn(5, requires_grad=True)

ARGS = {
    'input': input_tensor,
    'weight': weight_tensor,
    'bias': bias_tensor,
    'stride': 1,
    'padding': 0,
    'output_padding': 0,
    'groups': 1,
    'dilation': 1,
}
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 4, dtype family float, shape (2, 5, 6, 6) — shape (2, 5, 6, 6) 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
could_use_op Ran
ran on a synthesized input
thuangb/enhancing-transformers/enhancing/losses/op/conv2d_gradfix.py
code served (permissive licence) · get_code("ce977f8c2571b94b")
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 bool, ndim 0, dtype family float, shape () as a later run recorded it. 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, 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 small tensor on CPU
# The function checks input.device.type and input attributes
input_tensor = torch.randn(2, 4, 8, 8)

ARGS = {
    'input': input_tensor
}
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 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
default_conv Ran
ran; our contract draft was wrong, not the code
CuddleSabe/VQGAN/VQGAN/archs/common.py
code served (permissive licence) · get_code("8b0e794d4d8f9b13")
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 Conv2d. 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)

ARGS = {
    'in_channels': 3,
    'out_channels': 5,
    'kernel_size': 3,
    'bias': True
}
Setup block drafted by
a language model, Claude Sonnet 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 Conv2d — a Conv2d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conv2d 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_position_from_periods Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
CuddleSabe/VQGAN/VQGAN/models/lr_scheduler.py
pointer only (licence: MIT); the stored copy get_code serves, from AlifAshrafee/Restoring-Without-Forgetting, is pointer only (licence: NONE) · get_code("cd569444547de84f")
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 AlifAshrafee/Restoring-Without-Forgetting, 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.

hinge_d_loss Ran
ran on a synthesized input
thuangb/enhancing-transformers/enhancing/losses/layers.py
code served (permissive licence) · get_code("e3931d2003beff13")
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 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.functional as F

torch.manual_seed(0)

# Create small float tensors for logits
logits_fake = torch.randn(2, 4, dtype=torch.float32)
logits_real = torch.randn(2, 4, dtype=torch.float32)

ARGS = {
    "logits_fake": logits_fake,
    "logits_real": logits_real,
}
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 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
least_square_d_loss Ran
ran on a synthesized input
thuangb/enhancing-transformers/enhancing/losses/layers.py
code served (permissive licence) · get_code("50984532271d504f")
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 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

torch.manual_seed(0)

# Create small fake logits tensor (batch_size=2, logits_dim=4)
logits_fake = torch.randn(2, 4, dtype=torch.float32)

# Create small real logits tensor (batch_size=2, logits_dim=4)
logits_real = torch.randn(2, 4, dtype=torch.float32)

ARGS = {
    "logits_fake": logits_fake,
    "logits_real": logits_real,
}
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 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
master_only Ran
ran; our contract draft was wrong, not the code
CuddleSabe/VQGAN/VQGAN/utils/dist_util.py
pointer only (licence: MIT); the stored copy get_code serves, from xpixelgroup/seal, is pointer only (licence: NONE) · get_code("f6b0e1eb5b7df3e3")
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 xpixelgroup/seal, 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.

vanilla_d_loss Ran
ran on a synthesized input
thuangb/enhancing-transformers/enhancing/losses/layers.py
code served (permissive licence) · get_code("1c3cd7aa5e8128bd")
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 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.functional as F

torch.manual_seed(0)

# Create small fake logits tensor (batch_size=2)
logits_fake = torch.randn(2, 4, dtype=torch.float32)

# Create small real logits tensor (batch_size=2)
logits_real = torch.randn(2, 4, dtype=torch.float32)

ARGS = {
    "logits_fake": logits_fake,
    "logits_real": logits_real,
}
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 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

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 9 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 9 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_conv 57 other papers
12 dated earlier, 45 later · 2 only as an assembly brick
1707.02921 (2017-07)
Enhanced Deep Residual Networks for Single Image Super-Resolution
1803.02735 (2018-03)
Deep Back-Projection Networks For Super-Resolution
1803.04626 (2018-03)
Maintaining Natural Image Statistics with the Contextual Loss
and 54 more not named here
get_position_from_periods 55 other papers
55 later
136790177 (2022 (year only))
Frequency and Spatial Dual Guidance for Image Dehazing
2204.04676 (2022-04)
Simple Baselines for Image Restoration
2205.05996 (2022-05)
Blueprint Separable Residual Network for Efficient Image Super-Resolution
and 52 more not named here
master_only 9 other papers
1 dated earlier, 8 later
2105.12085 (2021-05)
DSANet: Dynamic Segment Aggregation Network for Video-Level Representation Learning
2303.06373 (2023-03)
Recursive Generalization Transformer for Image Super-Resolution
and 6 more not named here
conv2d 3 other papers
3 later
2112.11641 (2021-12)
JoJoGAN: One Shot Face Stylization
2203.14954 (2022-03)
GIRAFFE HD: A High-Resolution 3D-aware Generative Model
2304.03119 (2023-04)
Zero-shot Generative Model Adaptation via Image-specific Prompt Learning
conv_transpose2d 3 other papers
3 later
2112.11641 (2021-12)
JoJoGAN: One Shot Face Stylization
2203.14954 (2022-03)
GIRAFFE HD: A High-Resolution 3D-aware Generative Model
2304.03119 (2023-04)
Zero-shot Generative Model Adaptation via Image-specific Prompt Learning
could_use_op 2 other papers
2 later
2203.14954 (2022-03)
GIRAFFE HD: A High-Resolution 3D-aware Generative Model
2304.03119 (2023-04)
Zero-shot Generative Model Adaptation via Image-specific Prompt Learning
hinge_d_loss 1 other paper
1 later
2305.02541 (2023-05)
Catch Missing Details: Image Reconstruction with Frequency Augmented Variational Autoencoder
least_square_d_loss 1 other paper
1 later
2305.02541 (2023-05)
Catch Missing Details: Image Reconstruction with Frequency Augmented Variational Autoencoder
vanilla_d_loss 1 other paper
1 later
2305.02541 (2023-05)
Catch Missing Details: Image Reconstruction with Frequency Augmented Variational Autoencoder

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

Pretraining language models with next-token prediction on massive text corpora has delivered phenomenal zero-shot, few-shot, transfer learning and multi-tasking capabilities on both generative and discriminative language tasks. Motivated by this success, we explore a Vector-quantized Image Modeling (VIM) approach that involves pretraining a Transformer to predict rasterized image tokens autoregressively. The discrete image tokens are encoded from a learned Vision-Transformerbased VQGAN (ViT-VQGAN). We first propose multiple improvements over vanilla VQGAN from architecture to codebook learning, yielding better efficiency and reconstruction fidelity. The improved ViT-VQGAN further improves vectorquantized image modeling tasks, including unconditional, class-conditioned image generation and unsupervised representation learning. When trained on Im-ageNet at 256 × 256 resolution, we achieve Inception Score (IS) of 175.1 and Fréchet Inception Distance (FID) of 4.17, a dramatic improvement over the vanilla VQGAN, which obtains 70.6 and 17.04 for IS and FID, respectively. Based on ViT-VQGAN and unsupervised pretraining, we further evaluate the pretrained Transformer by averaging intermediate features, similar to Image GPT (iGPT). This ImageNet-pretrained VIM-L significantly beats iGPT-L on linear-probe accuracy from 60.3% to 73.2% for a similar model size. VIM-L also outperforms iGPT-XL which is trained with extra web image data and larger model size.

For agents

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

get_harvested_code_for_paper("2110.04627")
get_code_for_paper("2110.04627")
have("2110.04627")

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

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

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

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

Connect an agent — have() is free.