SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2405.13046 · ICML · 2024

LeaPformer: Enabling Linear Transformers for Autoregressive and Simultaneous Tasks via Learned Proportions

Sanghyun Hong, Lizhong Chen, Victor Agostinelli

arXiv · PDF · Open in the Atlas

Code that ran

2 of 4 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 0 have no contract verdict; 2 failures of our instrument; 2 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/2405.13046.json · badge: /api/ran/2405.13046.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
osu-starlab/leapformer canonical (classifier label)
classifier basis: classifier_2025
2 ran · 2 no recorded run
FunctionStatusWhere it lives
leapformer_attn_train Ran
ran; our contract draft was wrong, not the code
osu-starlab/leapformer/fairseq-leapformer/fairseq/modules/leapformer_attention.py
code served (permissive licence) · get_code("360cfe9d6cecd5d1")
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 torch
import torch.nn as nn
import torch.nn.functional as F
from torch import Tensor

torch.manual_seed(0)

# Parameters
batch_size = 2
num_heads = 2
embed_dim = 4
seq_len_q = 3
seq_len_k = 5
head_dim = embed_dim // num_heads

# Build q, k, v tensors
# q: (batch_size * num_heads, seq_len_q, head_dim)
q = torch.randn(batch_size * num_heads, seq_len_q, head_dim)
# k: (batch_size * num_heads, seq_len_k, head_dim)
k = torch.randn(batch_size * num_heads, seq_len_k, head_dim)
# v: (batch_size * num_heads, seq_len_k, head_dim)
v = torch.randn(batch_size * num_heads, seq_len_k, head_dim)

# Build q_LeaP and k_LeaP modules
# These need to output denominators, same shape as input after relu(q/k)
class DenominatorModule(nn.Module):
    def __init__(self, in_dim):
        super().__init__()
        self.linear = nn.Linear(in_dim, in_dim)
    
    def forward(self, x):
        # Output denominators with same shape as input
        return self.linear(x)

q_LeaP = DenominatorModule(head_dim)
k_LeaP = DenominatorModule(head_dim)

# Build dropout module
dropout_module = nn.Dropout(p=0.1)

# Build out_proj module
# Input: (seq_len, batch_size, embed_dim)
# Output: (seq_len, batch_size, embed_dim)
out_proj = nn.Linear(embed_dim, embed_dim)

# Optional: key_padding_mask (batch_size, seq_len_k)
key_padding_mask = torch.zeros(batch_size, seq_len_k, dtype=torch.bool)

# Optional: attn_mask (batch_size * num_heads, seq_len_q, seq_len_k)
attn_mask = None

ARGS = {
    'q': q,
    'k': k,
    'v': v,
    'num_heads': num_heads,
    'embed_dim': embed_dim,
    'q_LeaP': q_LeaP,
    'k_LeaP': k_LeaP,
    'dropout_module': dropout_module,
    'out_proj': out_proj,
    'key_padding_mask': key_padding_mask,
    'attn_mask': attn_mask,
    'need_weights': True,
    'need_head_weights': False,
    'linearized_train': False,
}
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 — 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
suffix_rundir Ran
ran; our contract draft was wrong, not the code
osu-starlab/leapformer/fairseq-leapformer/examples/MMPT/mmpt/utils/load_config.py
code served (permissive licence) · get_code("5d8e94d8a66cea96")
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 str. 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

# Create a temporary directory structure for testing
temp_dir = tempfile.mkdtemp()
save_dir = os.path.join(temp_dir, "runs")
os.makedirs(save_dir, exist_ok=True)

# Create some existing run directories to test the suffix logic
os.makedirs(os.path.join(save_dir, "experiment_0"), exist_ok=True)
os.makedirs(os.path.join(save_dir, "experiment_1"), exist_ok=True)
os.makedirs(os.path.join(save_dir, "experiment_2"), exist_ok=True)

# Also create a directory that doesn't match the pattern
os.makedirs(os.path.join(save_dir, "other_stuff"), exist_ok=True)

run_dir = "experiment"

ARGS = {
    "save_dir": save_dir,
    "run_dir": run_dir,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
omegaconf — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
load_config Not yet run
unverified (harvested, no recorded run)
osu-starlab/leapformer/fairseq-leapformer/examples/MMPT/mmpt/utils/load_config.py
code served (permissive licence) · get_code("d13d24d01f8ac68b")
How it ran

no invocation recorded.

recursive_config Not yet run
unverified (harvested, no recorded run)
osu-starlab/leapformer/fairseq-leapformer/examples/MMPT/mmpt/utils/load_config.py
code served (permissive licence) · get_code("ad1f00f2b92a3b27")
How it ran

no invocation recorded.

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 4 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.

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

A promising approach to preserving model performance in linearized transformers is to employ position-based re-weighting functions. However, state-of-the-art re-weighting functions rely heavily on target sequence lengths, making it difficult or impossible to apply them to autoregressive and simultaneous tasks, where the target and sometimes even the input sequence length are unknown. To address this issue, we propose Learned Proportions (LeaP) and LeaPformers 2 . Our contribution is built on two major components. First, we generalize the dependence on explicit positional representations and sequence lengths into dependence on sequence proportions for re-weighting. Second, we replace static positional representations with dynamic proportions derived via a compact module, enabling more flexible attention concentration patterns. We evaluate LeaPformer against eight representative efficient transformers on the Long-Range Arena benchmark, showing that LeaPformer achieves the best quality-throughput trade-off, as well as LeaPformer to Wikitext-103 autoregressive language modeling and simultaneous speech-to-text translation for two language pairs, achieving competitive results.

For agents

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

get_harvested_code_for_paper("2405.13046")
get_code_for_paper("2405.13046")
have("2405.13046")

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

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

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

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

Connect an agent — have() is free.