SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2307.04895 · ICLR · 2023

Learning to Solve Constraint Satisfaction Problems with Recurrent Transformer

Joohyung Lee, Zhun Yang, Adam Ishay

arXiv · PDF · Open in the Atlas

Code that ran

6 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 3 failures of our instrument; 1 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/2307.04895.json · badge: /api/ran/2307.04895.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
azreasoners/recurrent_transformer canonical (classifier label)
classifier basis: classifier_2025
5 ran · 1 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
FunctionStatusWhere it lives
CausalSelfAttention Ran
ran on a synthesized input · constructed an object; no result was computed
azreasoners/recurrent_transformer/mingpt/model.py
code served (permissive licence) · get_code("db4f6eb0540de0f8")
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 an instance of its own class, CausalSelfAttention: the run constructed the object and did not call it, so no result was computed. 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)

class Config:
    def __init__(self):
        self.n_embd = 4
        self.n_head = 2
        self.block_size = 3
        self.attn_pdrop = 0.1
        self.resid_pdrop = 0.1
        self.causal_mask = True

config = Config()

ARGS = {
    'config': config
}
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 CausalSelfAttention — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a CausalSelfAttention 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
Disc Ran
ran on a synthesized input · constructed an object; no result was computed
azreasoners/recurrent_transformer/mingpt/model.py
code served (permissive licence) · get_code("6134c9ccb641ad62")
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 an instance of its own class, Disc: the run constructed the object and did not call it, so no result was computed. 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

torch.manual_seed(0)

# The Disc class is a custom autograd Function that takes a single tensor x
# The forward method expects x to be a tensor with values in [0,1]
# The backward method expects grad_output to be a tensor of the same shape

# Create a small tensor with values in [0,1] to serve as input
x = torch.rand(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 Disc — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Disc 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
GPT Ran
ran on a synthesized input · constructed an object; no result was computed
azreasoners/recurrent_transformer/mingpt/model.py
code served (permissive licence) · get_code("02f8ad27ca4c2227")
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 an instance of its own class, GPT: the run constructed the object and did not call it, so no result was computed. 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)

class MockTokenEmbedding(nn.Module):
    def __init__(self, config):
        super().__init__()
        self.emb = nn.Embedding(config.vocab_size, config.n_embd)
    
    def forward(self, x):
        return self.emb(x)

class Config:
    def __init__(self):
        self.n_embd = 4
        self.n_head = 2
        self.block_size = 8
        self.n_layer = 2
        self.vocab_size = 16
        self.num_classes = 10
        self.attn_pdrop = 0.1
        self.resid_pdrop = 0.1
        self.embd_pdrop = 0.1
        self.tok_emb = None
        self.losses = ['sudoku_c1']
        self.all_layers = True
        self.n_recur = 1
        self.hyper = {}
        self.C = 0.01
        self.f = lambda x: x
        self.create_v = False
        self.causal_mask = True

config = Config()

ARGS = {
    'config': config
}
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 GPT — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GPT 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
bp Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from azreasoners/cl-ste
pointer only · get_code("7e41f71a107809d1")
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.

reg_att_sudoku_c1 Ran
ran; our contract draft was wrong, not the code
azreasoners/recurrent_transformer/mingpt/model.py
code served (permissive licence) · get_code("f2e9cc2d9abc8708")
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 as nn

torch.manual_seed(0)

# Initialize A_adj as a global tensor (as defined in the function)
A_adj = torch.zeros([81, 81], dtype=torch.int32)
# Set some values to make the computation meaningful
A_adj[0, 0] = 1
A_adj[1, 1] = 1

# Define the Disc class and related functions exactly as in the function
class Disc(torch.autograd.Function):

    @staticmethod
    def forward(ctx, x):
        return bp(x)

    @staticmethod
    def backward(ctx, grad_output):
        return grad_output

def bp(x):
    """ binarization function bp(x) = 1 if x >= 0.5; bp(x) = 0 if x < 0.5

    @param x: a real number in [0,1] denoting a probability
    """
    return torch.clamp(torch.sign(x - 0.5) + 1, max=1)

def reg_cardinality(x, num):
    """
    @param x: a tensor of shape (m, n), denoting the probabilities
              of n possible values of m random variables
    @param num: an integer denoting the expected number 1s in each row of x
    """
    return (B(x).sum(dim=-1) - num).pow(2).mean()

B = Disc.apply

def reg_att_sudoku_c1(x):
    """
    @param x: a tensor of shape (n_layer * n_recur * batch_size * num_heads, 81, 81)
              denoting the probabilities in the attention matrices
    """
    test = (x * A_adj.unsqueeze(0).to(x.device)).sum(dim=-1, keepdim=True)
    return reg_cardinality(test, 1)

# Create a small valid input tensor
# Shape: (n_layer * n_recur * batch_size * num_heads, 81, 81)
# Using small batch: (2, 81, 81) where 2 = n_layer * n_recur * batch_size * num_heads
x = torch.rand(2, 81, 81, dtype=torch.float32)

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 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
reg_cardinality Ran
ran; our contract draft was wrong, not the code
azreasoners/recurrent_transformer/mingpt/model.py
code served (permissive licence) · get_code("9766fa16fd393d68")
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 a tensor of shape (m, n) with probabilities in [0, 1]
# m=2 (batch size), n=4 (number of possible values)
x = torch.rand(2, 4)

# num: expected number of 1s in each row
num = 2

ARGS = {
    "x": x,
    "num": num
}
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
Block Not yet run
unverified (harvested, no recorded run)
azreasoners/recurrent_transformer/mingpt/model.py
code served (permissive licence) · get_code("d5a04fb7481be04b")
How it ran

no invocation recorded.

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, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 1 the same month, 0 later) and 6 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
bp
brick of this paper's assembly: helper
1 other paper
1 the same month
2307.04347 (2023-07)
Injecting Logical Constraints into Neural Networks via Straight-Through Estimators

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

Constraint satisfaction problems (CSPs) are about finding values of variables that satisfy the given constraints. We show that Transformer extended with recurrence is a viable approach to learning to solve CSPs in an end-to-end manner, having clear advantages over state-of-the-art methods such as Graph Neural Networks, SATNet, and some neuro-symbolic models. With the ability of Transformer to handle visual input, the proposed Recurrent Transformer can straightforwardly be applied to visual constraint reasoning problems while successfully addressing the symbol grounding problem. We also show how to leverage deductive knowledge of discrete constraints in the Transformer's inductive learning to achieve sampleefficient learning and semi-supervised learning for CSPs.

For agents

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

get_harvested_code_for_paper("2307.04895")
get_code_for_paper("2307.04895")
have("2307.04895")

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

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

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

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

Connect an agent — have() is free.