SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2107.05407 · ICML · 2021

PonderNet: Learning to Ponder

Deepmind London, Andrea Banino, Charles Blundell, Jan Balaguer

arXiv · PDF · Open in the Atlas

Code that ran

10 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (5 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 5 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/2107.05407.json · badge: /api/ran/2107.05407.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
lucidrains/ponder-transformer community
Papers with Code archive
8 ran · 0 no recorded run
copy not recorded community
not in the paper's declared repositories
1 ran · 0 no recorded run
jankrepl/mildlyoverfitted community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
Attention Ran
ran on a synthesized input · constructed an object; no result was computed
lucidrains/ponder-transformer/ponder_transformer/ponder_transformer.py
code served (permissive licence) · get_code("2bca9856715b9238")
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, Attention: 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
from torch import nn, einsum
from einops import rearrange, repeat

torch.manual_seed(0)

def exists(val):
    return val is not None

class Attention(nn.Module):

    def __init__(self, *, dim, dim_head=64, heads=8, causal=False):
        super().__init__()
        self.heads = heads
        self.causal = causal
        self.scale = dim_head ** (-0.5)
        inner_dim = dim_head * heads
        self.to_qkv = nn.Linear(dim, inner_dim * 3, bias=False)
        self.to_out = nn.Linear(inner_dim, dim)

    def forward(self, x, mask=None):
        n, h, device = (x.shape[1], self.heads, x.device)
        qkv = self.to_qkv(x).chunk(3, dim=-1)
        q, k, v = map(lambda t: rearrange(t, 'b n (h d) -> b h n d', h=h), qkv)
        sim = einsum('b h i d, b h j d -> b h i j', q, k) * self.scale
        mask_value = -torch.finfo(sim.dtype).max
        if exists(mask):
            mask = rearrange(mask, 'b i -> b () i ()') * rearrange(mask, 'b j -> b () () j')
            sim = sim.masked_fill(mask, mask_value)
        if self.causal:
            i, j = sim.shape[-2:]
            causal_mask = torch.ones((i, j), device=device).triu(j - i + 1).bool()
            sim = sim.masked_fill(causal_mask, mask_value)
        attn = sim.softmax(dim=-1)
        out = einsum('b h i j, b h j d -> b h i d', attn, v)
        out = rearrange(out, 'b h n d -> b n (h d)')
        return self.to_out(out)

# Create test input tensor: batch_size=2, seq_len=3, dim=4
x = torch.randn(2, 3, 4)

# Create mask tensor: batch_size=2, seq_len=3
mask = torch.ones(2, 3, dtype=torch.bool)

ARGS = {
    "dim": 4,
    "dim_head": 4,
    "heads": 2,
    "causal": False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Attention — 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 Attention 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
Block Ran
ran on a synthesized input · constructed an object; no result was computed
lucidrains/ponder-transformer/ponder_transformer/ponder_transformer.py
code served (permissive licence) · get_code("b3198dc3cdb01277")
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, Block: 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
from torch import nn

torch.manual_seed(0)

# Define the helper function that's used in the module
def exists(val):
    return val is not None

# Define small versions of the dependencies
def FeedForward(dim, mult=4):
    return nn.Sequential(
        nn.Linear(dim, dim * mult),
        nn.GELU(),
        nn.Linear(dim * mult, dim)
    )

from einops import rearrange, repeat
from einops.layers.torch import Rearrange, Reduce

class Attention(nn.Module):
    def __init__(self, *, dim, dim_head=64, heads=8, causal=False):
        super().__init__()
        self.heads = heads
        self.causal = causal
        self.scale = dim_head ** (-0.5)
        inner_dim = dim_head * heads
        self.to_qkv = nn.Linear(dim, inner_dim * 3, bias=False)
        self.to_out = nn.Linear(inner_dim, dim)

    def forward(self, x, mask=None):
        from torch import einsum
        n, h, device = (x.shape[1], self.heads, x.device)
        qkv = self.to_qkv(x).chunk(3, dim=-1)
        q, k, v = map(lambda t: rearrange(t, 'b n (h d) -> b h n d', h=h), qkv)
        sim = einsum('b h i d, b h j d -> b h i j', q, k) * self.scale
        mask_value = -torch.finfo(sim.dtype).max
        if exists(mask):
            mask = rearrange(mask, 'b i -> b () i ()') * rearrange(mask, 'b j -> b () () j')
            sim = sim.masked_fill(~mask, mask_value)
        if self.causal:
            i, j = sim.shape[-2:]
            causal_mask = torch.ones((i, j), device=device).triu(j - i + 1).bool()
            sim = sim.masked_fill(causal_mask, mask_value)
        attn = sim.softmax(dim=-1)
        out = einsum('b h i j, b h j d -> b h i d', attn, v)
        out = rearrange(out, 'b h n d -> b n (h d)')
        return self.to_out(out)

class PreNorm(nn.Module):
    def __init__(self, dim, fn):
        super().__init__()
        self.fn = fn
        self.norm = nn.LayerNorm(dim)

    def forward(self, x, **kwargs):
        x = self.norm(x)
        return self.fn(x, **kwargs)

# Build arguments for Block
ARGS = {
    'dim': 4,
    'dim_head': 2,
    'heads': 2,
    'causal': False,
    'ff_mult': 4
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Block — 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 Block 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
FeedForward Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from lucidrains/fast-transformer-pytorch
pointer only · get_code("a7b572de5bd1ac1d")
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.

PonderNet Ran
ran on a synthesized input · constructed an object; no result was computed
jankrepl/mildlyoverfitted/github_adventures/pondernet/utils.py
code served (permissive licence) · get_code("45d2dfbfea2e8b32")
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, PonderNet: 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

torch.manual_seed(0)

# Create setup arguments for PonderNet
n_elems = 4
n_hidden = 8
max_steps = 3
allow_halting = False

ARGS = {
    "n_elems": n_elems,
    "n_hidden": n_hidden,
    "max_steps": max_steps,
    "allow_halting": allow_halting,
}
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 PonderNet — 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 PonderNet 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
PonderTransformer Ran
ran on a synthesized input · constructed an object; no result was computed
lucidrains/ponder-transformer/ponder_transformer/ponder_transformer.py
code served (permissive licence) · get_code("711e802f88faf1ac")
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, PonderTransformer: 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

torch.manual_seed(0)

ARGS = {
    'num_tokens': 16,
    'dim': 4,
    'max_seq_len': 8,
    'causal': True,
    'dim_head': 2,
    'heads': 2,
    'ponder_kl_div_loss_weight': 0.01,
    'ponder_lambda_p': 0.2,
    'ponder_epsilon': 0.05,
    'eps': 1e-20,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
einops, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PonderTransformer — 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 PonderTransformer 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
PreNorm Ran
ran on a synthesized input · constructed an object; no result was computed
lucidrains/ponder-transformer/ponder_transformer/ponder_transformer.py
code served (permissive licence) · get_code("49d427be2e3ba462")
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, PreNorm: 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
from torch import nn

torch.manual_seed(0)

# Define a simple function module that will be wrapped by PreNorm
class SimpleFn(nn.Module):
    def __init__(self, dim):
        super().__init__()
        self.linear = nn.Linear(dim, dim)
    
    def forward(self, x, **kwargs):
        return self.linear(x)

# Parameters for PreNorm
dim = 4
fn = SimpleFn(dim)

ARGS = {
    "dim": dim,
    "fn": fn
}
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 PreNorm — 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 PreNorm 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
calc_geometric Ran
ran; our contract draft was wrong, not the code
lucidrains/ponder-transformer/ponder_transformer/ponder_transformer.py
code served (permissive licence) · get_code("e2bf2cc30c9d48b5")
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
import torch.nn.functional as F

torch.manual_seed(0)

# Create a small tensor for testing calc_geometric
# The function expects a tensor with values that will be clipped to [eps, 1.0]
# and used in the exclusive_cumprod and geometric calculations
l = torch.rand(2, 4)  # batch_size=2, dim=4

ARGS = {
    "l": l,
    "dim": -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 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
exclusive_cumprod Ran
ran; our contract draft was wrong, not the code
lucidrains/ponder-transformer/ponder_transformer/ponder_transformer.py
code served (permissive licence) · get_code("b8c7ff709eea4738")
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
import torch.nn.functional as F

torch.manual_seed(0)

# Create a small tensor for testing
# Shape: (2, 4) - batch size 2, dimension 4
t = torch.tensor([
    [0.5, 0.7, 0.9, 0.6],
    [0.8, 0.4, 0.5, 0.7]
], dtype=torch.float32)

ARGS = {
    't': t,
    'dim': -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 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
pad_to Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
lucidrains/ponder-transformer/ponder_transformer/ponder_transformer.py
code served (permissive licence) · get_code("a1234fe3bafdaa8f")
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, 7) 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 a small tensor to pad
# Shape: (2, 4) - batch of 2, feature dim of 4
t = torch.randn(2, 4)

# Define padding tuple: (left, right) for the last dimension
# This will pad the last dimension with 1 element on each side
padding = (1, 2)

# dim parameter - using -1 to pad the last dimension
dim = -1

# value for padding
value = 0.0

ARGS = {
    't': t,
    'padding': padding,
    'dim': dim,
    'value': value
}
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, 7) — shape (2, 7) 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
safe_cumprod Ran
ran; our contract draft was wrong, not the code
lucidrains/ponder-transformer/ponder_transformer/ponder_transformer.py
code served (permissive licence) · get_code("bd7cfde2fcfc3707")
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 safe_cumprod takes:
# - t: a tensor (clipped, then log is taken, then cumsum, then exp)
# - eps: a small float for numerical stability
# - dim: an integer dimension along which to compute cumsum

# Create a small tensor with values in (0, 1] range to avoid log issues
t = torch.rand(2, 4)

ARGS = {
    "t": t,
    "eps": 1e-10,
    "dim": -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 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

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 2 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 8 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
FeedForward
brick of this paper's assembly: helper
1 other paper
1 later
2108.09084 (2021-08)
Fastformer: Additive Attention Can Be All You Need
PreNorm
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2105.08050 (2021-05)
Pay Attention to MLPs

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

In standard neural networks the amount of computation used grows with the size of the inputs, but not with the complexity of the problem being learnt. To overcome this limitation we introduce PonderNet, a new algorithm that learns to adapt the amount of computation based on the complexity of the problem at hand. PonderNet learns end-to-end the number of computational steps to achieve an effective compromise between training prediction accuracy, computational cost and generalization. On a complex synthetic problem, PonderNet dramatically improves performance over previous adaptive computation methods and additionally succeeds at extrapolation tests where traditional neural networks fail. Also, our method matched the current state of the art results on a real world question and answering dataset, but using less compute. Finally, PonderNet reached state of the art results on a complex task designed to test the reasoning capabilities of neural networks.

For agents

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

get_harvested_code_for_paper("2107.05407")
get_code_for_paper("2107.05407")
have("2107.05407")

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

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

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

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

Connect an agent — have() is free.