Papers › Luna: Linear Unified Nested Attention

Luna: Linear Unified Nested Attention

3 Jun 2021NeurIPS 2021 12arXiv:2106.01540archive 2025-07-28

Xuezhe Ma, Xiang Kong, Sinong Wang, Chunting Zhou, Jonathan May, Hao Ma, Luke Zettlemoyer

The quadratic computational and memory complexities of the Transformer's attention mechanism have limited its scalability for modeling long sequences. In this paper, we propose Luna, a linear unified nested attention mechanism that approximates softmax attention with two nested linear attention functions, yielding only linear (as opposed to quadratic) time and space complexity. Specifically, with the first attention function, Luna packs the input sequence into a sequence of fixed length. Then, the packed sequence is unpacked using the second attention function. As compared to a more traditional attention mechanism, Luna introduces an additional sequence with a fixed length as input and an additional corresponding output, which allows Luna to perform attention operation linearly, while also storing adequate contextual information. We perform extensive evaluations on three benchmarks of sequence modeling tasks: long-context sequence modeling, neural machine translation and masked language modeling for large-scale pretraining. Competitive or even better experimental results demonstrate both the effectiveness and efficiency of Luna compared to a variety

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2106.01540")

Code

Syntology Ran 5 of 10 code samples harvested from 2 repositories linked to this paper; 5 have no recorded run. Of those that ran: 5 ran with no contract checked.

By repository: official repository: 7 samples from 1 repository, 4 ran; community (archive-listed): 3 samples from 1 repository, 1 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

XuezheMax/fairseq-apollo officialmentioned in papermentioned on GitHubpytorchMIT report
sooftware/luna-transformer mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

10 samples harvested; 5 ran; 0 honoured the contract we drafted; 5 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

5ran
5unverified

Licence: 5 of the 10 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

distributed_init XuezheMax/fairseq-apollo/fairseq/distributed_utils.py official repository ran MIT recorded; this copy not marked cleared · pointer only · 07969f7041022050 · report
is_master XuezheMax/fairseq-apollo/fairseq/distributed_utils.py official repository ran MIT recorded; this copy not marked cleared · pointer only · 90b79fe15491de83 · report
safe_readline XuezheMax/fairseq-apollo/fairseq/binarizer.py official repository ran MIT recorded; this copy not marked cleared · pointer only · 82bdf940665aeeb4 · report
url_to_filename XuezheMax/fairseq-apollo/fairseq/file_utils.py official repository ran fingerprinted MIT recorded; this copy not marked cleared · pointer only · 9418b43048e4e4ec · report
all_reduce XuezheMax/fairseq-apollo/fairseq/distributed_utils.py official repository unverified MIT recorded; this copy not marked cleared · pointer only · 199e96db5edd0edd · report
filename_to_url XuezheMax/fairseq-apollo/fairseq/file_utils.py official repository unverified MIT (permissive) · b1a033619f614e17 · report
load_archive_file XuezheMax/fairseq-apollo/fairseq/file_utils.py official repository unverified MIT (permissive) · bd3fe80662b28bc7 · report
MultiHeadAttention sooftware/luna-transformer/luna_transformer/attention.py community (archive-listed) ran · metamorphic tier: deterministic fingerprinted MIT (permissive) · 9b0ec916edfd0481 · report
DotProductAttention sooftware/luna-transformer/luna_transformer/attention.py community (archive-listed) unverified MIT (permissive) · f42cf74a0708c772 · report
LinearUnifiedNestedAttention sooftware/luna-transformer/luna_transformer/attention.py community (archive-listed) unverified MIT (permissive) · e29a0daaf387dc67 · report

Tasks

Language ModelingLanguage ModellingMachine TranslationMasked Language ModelingTranslation

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Softmax

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections