SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2105.04779 · ICML · 2021

EL-Attention: Memory Efficient Lossless Attention for Generation

Weizhen Qi, Yeyun Gong, Yu Yan, Jiusheng Chen, Ruofei Zhang, Nan Duan, Nikhil Bhendawade

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 (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 1 violated it and 1 has no contract verdict; 4 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/2105.04779.json · badge: /api/ran/2105.04779.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
microsoft/fastseq canonical (classifier label)
classifier basis: census
6 ran · 0 no recorded run
FunctionStatusWhere it lives
Embedding Ran
ran; our contract draft was wrong, not the code · constructed an object; no result was computed
microsoft/fastseq/fastseq/models/prophetnet_fs/ngram_s2s_model.py
pointer only (licence: MIT); the stored copy get_code serves, from instance-wise-ordered-transformer/iot, is pointer only (licence: NOASSERTION) · get_code("96cbb5e9ca5b6be0")
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 instance-wise-ordered-transformer/iot, and GitHub could not classify the licence of that repository (NOASSERTION). 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.

Linear Ran
ran; our contract draft was wrong, not the code · constructed an object; no result was computed
microsoft/fastseq/fastseq/models/prophetnet_fs/ngram_s2s_model.py
pointer only (licence: MIT); the stored copy get_code serves, from instance-wise-ordered-transformer/iot, is pointer only (licence: NOASSERTION) · get_code("8cd8cb0d1e9e63e4")
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 instance-wise-ordered-transformer/iot, and GitHub could not classify the licence of that repository (NOASSERTION). 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.

encode_line Ran
ran; our contract draft was wrong, not the code
microsoft/fastseq/fastseq_cli/transformers_utils.py
code served (permissive licence) · get_code("314b4accae5bf9b5")
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 dict. 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 transformers import BartTokenizer

torch.manual_seed(0)

# Create a minimal BartTokenizer by building a stand-in that has the required methods
# The function calls tokenizer([line], ...) and checks isinstance(tokenizer, BartTokenizer)
# For a real tokenizer, we need one that actually works, so let's use a real BartTokenizer
# But since we can't download, we'll create a mock that satisfies the interface

class MockBartTokenizer:
    def __init__(self):
        self.model_max_length = 512
    
    def __call__(self, texts, max_length=None, padding=None, truncation=False, return_tensors=None, add_prefix_space=False):
        # Return a dict with 'input_ids' and 'attention_mask' tensors
        batch_size = len(texts)
        seq_len = max_length if max_length else 10
        return {
            'input_ids': torch.randint(0, 1000, (batch_size, seq_len)),
            'attention_mask': torch.ones((batch_size, seq_len), dtype=torch.long)
        }

# Create tokenizer instance
tokenizer = MockBartTokenizer()

# Define parameters
line = "This is a test sentence."
max_length = 16
pad_to_max_length = True
return_tensors = 'pt'

ARGS = {
    'tokenizer': tokenizer,
    'line': line,
    'max_length': max_length,
    'pad_to_max_length': pad_to_max_length,
    'return_tensors': return_tensors
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
label_smoothed_nll_loss Ran
ran on a synthesized input
microsoft/fastseq/fastseq_cli/transformers_utils.py
code served (permissive licence) · get_code("e386d3a24af4d168")
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, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 log probabilities tensor
# Shape: (batch_size=2, vocab_size=4)
# lprobs should be log probabilities, so values between -inf and 0
lprobs = torch.log(torch.softmax(torch.randn(2, 4), dim=-1))

# Create target indices tensor
# Shape: (batch_size=2,) - indices into the vocabulary
# Values should be in range [0, vocab_size) or ignore_index
target = torch.tensor([1, 2], dtype=torch.long)

# Epsilon for label smoothing (typically small, e.g., 0.1)
epsilon = 0.1

# Ignore index for padding tokens
ignore_index = -100

ARGS = {
    "lprobs": lprobs,
    "target": target,
    "epsilon": epsilon,
    "ignore_index": ignore_index,
}
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, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
lmap Ran
ran; our contract draft was wrong, not the code
microsoft/fastseq/fastseq_cli/transformers_utils.py
code served (permissive licence) · get_code("6a66f22f0034f9d3")
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 list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 typing import Callable, Dict, Iterable, List

torch.manual_seed(0)

# Define a simple callable function
def double(x: int) -> int:
    return x * 2

# Define an iterable (list of integers)
numbers = [1, 2, 3, 4, 5]

ARGS = {
    "f": double,
    "x": numbers,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list output has no array shape of its own; none is stated
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
ngram_attention_bias Ran
ran, violated the contract we drafted
microsoft/fastseq/fastseq/models/prophetnet_fs/ngram_multihead_attention.py
code served (permissive licence) · get_code("c2d34f90558f3cf6")
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 (3, 5, 10) 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 numpy as np

torch.manual_seed(0)

ARGS = {
    "length": 5,
    "num_skip": 3,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, 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 (3, 5, 10) — shape (3, 5, 10) 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 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, 5 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 4 the same month, 4 later) and 1 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
Linear 58 other papers
16 dated earlier, 2 the same month, 40 later · 5 only as an assembly brick
1409.0473 (2014-09)
Neural Machine Translation by Jointly Learning to Align and Translate
1706.03762 (2017-06)
Attention Is All You Need
1904.01681 (2019-04)
Augmented Neural ODEs
and 55 more not named here
Embedding 29 other papers
10 dated earlier, 3 the same month, 16 later
1904.01681 (2019-04)
Augmented Neural ODEs
1906.12183 (2019-06)
Neural ODEs as the Deep Limit of ResNets with constant weights
2002.03184 (2020-02)
Time-aware Large Kernel Convolutions
and 26 more not named here
lmap 9 other papers
3 dated earlier, 1 the same month, 5 later
2007.08426 (2020-07)
Investigating Pretrained Language Models for Graph-to-Text Generation
2104.08400 (2021-04)
Structure-Aware Abstractive Conversation Summarization via Discourse and Action Graphs
2104.08691 (2021-04)
The Power of Scale for Parameter-Efficient Prompt Tuning
and 6 more not named here
label_smoothed_nll_loss 7 other papers
3 dated earlier, 1 the same month, 3 later
2007.08426 (2020-07)
Investigating Pretrained Language Models for Graph-to-Text Generation
2104.08400 (2021-04)
Structure-Aware Abstractive Conversation Summarization via Discourse and Action Graphs
2104.08691 (2021-04)
The Power of Scale for Parameter-Efficient Prompt Tuning
and 4 more not named here
encode_line 1 other paper
1 dated earlier
2104.08400 (2021-04)
Structure-Aware Abstractive Conversation Summarization via Discourse and Action Graphs

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

Transformer model with multi-head attention requires caching intermediate results for efficient inference in generation tasks. However, cache brings new memory-related costs and prevents leveraging larger batch size for faster speed. We propose memory-efficient lossless attention (called EL-attention) to address this issue. It avoids heavy operations for building multi-head keys and values, cache for them is not needed. EL-attention constructs an ensemble of attention results by expanding query while keeping key and value shared. It produces the same result as multi-head attention with less GPU memory and faster inference speed. We conduct extensive experiments on Transformer, BART, and GPT-2 for summarization and question generation tasks. The results show EL-attention speeds up existing models by 1.6x to 5.3x without accuracy loss.

For agents

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

get_harvested_code_for_paper("2105.04779")
get_code_for_paper("2105.04779")
have("2105.04779")

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

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

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

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

Connect an agent — have() is free.