Papers › Bridging the Divide: Reconsidering Softmax and Linear Attention

Bridging the Divide: Reconsidering Softmax and Linear Attention

9 Dec 2024arXiv:2412.06590archive 2025-07-28

Dongchen Han, Yifan Pu, Zhuofan Xia, Yizeng Han, Xuran Pan, Xiu Li, Jiwen Lu, Shiji Song, Gao Huang

Widely adopted in modern Vision Transformer designs, Softmax attention can effectively capture long-range visual information; however, it incurs excessive computational cost when dealing with high-resolution inputs. In contrast, linear attention naturally enjoys linear complexity and has great potential to scale up to higher-resolution images. Nonetheless, the unsatisfactory performance of linear attention greatly limits its practical application in various scenarios. In this paper, we take a step forward to close the gap between the linear and Softmax attention with novel theoretical analyses, which demystify the core factors behind the performance deviations. Specifically, we present two key perspectives to understand and alleviate the limitations of linear attention: the injective property and the local modeling ability. Firstly, we prove that linear attention is not injective, which is prone to assign identical attention weights to different query vectors, thus adding to severe semantic confusion since different queries correspond to the same outputs. Secondly, we confirm that effective local modeling is essential for the success of Softmax attention, in which linear attention falls short. The aforementioned two fundamental differences significantly contribute to the disparities between these two attention paradigms, which is demonstrated by our substantial empirical validation in the paper. In addition, more experiment results indicate that linear attention, as long as endowed with these two properties, can outperform Softmax attention across various tasks while maintaining lower computation complexity. Code is available at https://github.com/LeapLabTHU/InLine.

PaperPDFCodeCode Syntology ran

In Syntology View this paper on Syntology, its page in Syntology's graph. That page adds which of its functions are also present in other papers' code Syntology holds, with dates, and its dated run record as JSON and a README badge. It also lists the repositories linked to the paper, the abstract and the calls for agents.

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

For agents, on Syntology's MCP service (how to connect):

Code

Syntology 22 code samples harvested from 1 repository linked to this paper: 17 ran (of which 0 constructed an object rather than computing a result; 7 with no instrument failure: 1 honoured, 1 violated, 5 with no contract checked; 10 where Syntology's instrument failed) · 5 unverified. Where Syntology's instrument failed: 7 where our contract draft was wrong; 3 where the contract check could not run; failures of Syntology's instrument, not of the code.

By repository: official repository: 22 samples from 1 repository, 17 ran (7 with no instrument failure; 10 where Syntology's instrument failed). The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

Levels written between 2026-09-22 and 2026-09-25 (UTC): the dates Syntology's graph wrote each sample's verification level, not when the code executed. 2 of the 17 samples that ran have no recorded date.

leaplabthu/inline officialmentioned in papermentioned on GitHubpytorchSyntology: 22 samples, 17 ran (10 instrument-failed) · 5 unverified 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

22 samples harvested: 17 ran (of which 0 constructed an object rather than computing a result; 7 with no instrument failure: 1 honoured, 1 violated, 5 with no contract checked; 10 where Syntology's instrument failed) · 5 unverified. “Where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Syntology's record for this page last changed ; when this build read Syntology's graph is in the build record. That date is not when the samples ran.

1ran · honoured contract
1ran · violated contract
7ran · our draft was wrong
3ran; the contract check could not run
5ran
5unverified

Licence: 22 of the 22 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 leaplabthu/inline. “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. A line beginning “fixture:” under a sample that ran gives the arguments Syntology's fixture called the sample with, each as name:type/rank/element kind (? where none was recorded), and the type of what the fixture's run returned, exactly as the harness recorded them; the arguments and the returned type were recorded by two separate runs of the same fixture. No output value is shown, and a returned type says nothing about whether the output was right. “Level recorded” gives the UTC date when Syntology's graph wrote the sample's verification level, not when the code executed; where the level was written before Syntology's graph kept that date, the row says “level recorded, date not recorded”. For 1 sample that ran, the graph records a signature this page does not show: an argument's recorded type or element kind is a printout of an object in Syntology's harness (such as a mock object, a class or a pandas printout), not the type of an input, so it does not describe the call's shape. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself. “Our draft was wrong” and “the contract check could not run” are failures of Syntology's instrument, not of the code: the sample ran on Syntology's synthesized input, and then the drafted contract did not describe it, or the check itself raised an error (RAISES), lacked a dependency (DEP_MISSING) or ran out of time (TIMEOUT); hover the label for which. A metamorphic tier, where shown, is evidence of the output's shape, not that the sample implements the method.

Each sample ends with its code_sha256. A sample's code_sha256 is Syntology's identity for that exact code. It is printed in full (16 hexadecimal characters for every sample in this build), and get_code(code_sha256="…") takes it exactly as printed. An agent calls it on Syntology's MCP service (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 are grouped by repository: a repository marked official first, then by how directly the repository is tied to the paper, then in the archive's order; never by how many ran. 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 six 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; the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar); this paper's copy was not located, so its licence is not recorded; or this paper's copy is cleared, but the stored copy of the same code that Syntology serves is not. 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.

A function or class name links to its page when the name occurs in the harvested code of at least 5 papers; the name is a string, not an identity. A census tag appears when Syntology's census ran implementations with that name on one shared input per bucket: it gives how many were compared, from how many papers, and how many distinct outputs they produced, and names this sample's bucket when this sample was one of them.

leaplabthu/inline official repository 22 samples, 17 ran (10 instrument-failed) · 5 unverified
window_partition in 377 papers
census: 13 implementations from 17 papers, 5 distinct outputs across 3 buckets, one shared input per bucket
models/inline_swin.py ran; the contract check could not run (RAISES) · metamorphic tier: invariant fingerprinted no licence file found · pointer only · 144d10b49baeb8a6 · report fixture: signature x:Tensor/4/float, window_size:int/0/int · returned Tensor · level recorded, date not recorded
auto_resume_helper in 27 papers utils.py ran · our draft was wrong no licence file found · pointer only · 0c32459bef92ff8c · report fixture: signature output_dir:str/0/str · returned str · level recorded 2026-09-25
build_model in 469 papers models/build.py ran · our draft was wrong no licence file found · pointer only · aad933b3b81ff1a5 · report fixture: returned InLineSwin · level recorded 2026-09-25
build_optimizer in 83 papers optimizer.py ran no licence file found · pointer only · fcf2d41dd445a70b · report fixture: signature config:Config/0/?, model:callable/0/? · returned AdamW · level recorded 2026-09-25
build_scheduler in 56 papers lr_scheduler.py ran · our draft was wrong no licence file found · pointer only · 07e8b4b487c0abb6 · report fixture: signature config:SimpleNamespace/0/?, optimizer:SGD/0/?, n_iter_per_epoch:int/0/int · returned LinearLRScheduler · level recorded 2026-09-25
check_keywords_in_name in 32 papers optimizer.py ran · violated contract no licence file found · pointer only · b0a5beb34716d5a6 · report fixture: signature name:str/0/str, keywords:tuple/1/str · returned bool · level recorded 2026-09-25
checkpoint_filter_fn in 80 papers models/inline_deit.py ran · our draft was wrong no licence file found · pointer only · 5dac11fdc41c896b · report fixture: signature state_dict:dict/0/?, model:callable/0/? · returned dict · level recorded 2026-09-25
create_logger in 172 papers logger.py ran no licence file found · pointer only · 82e52feafbf040bb · report fixture: signature output_dir:str/0/str, dist_rank:int/0/int, name:str/0/str · returned Logger · level recorded 2026-09-25
exp_kernel models/inline_swin.py ran fingerprinted no licence file found · pointer only · 99a5631eaaa3bf92 · report fixture: signature x:Tensor/2/float, t:float/0/float · returned Tensor · level recorded 2026-09-25
get_grad_norm in 45 papers utils.py ran · honoured contract no licence file found · pointer only · eec1e7cba51d5e8e · report fixture: signature parameters:list/1/Tensor, norm_type:int/0/int · returned float · level recorded 2026-09-22
img2windows in 15 papers models/inline_cswin.py ran; the contract check could not run (RAISES) · metamorphic tier: invariant no licence file found · pointer only · 39b18f062e0cc6d9 · report fixture: signature img:Tensor/4/float, H_sp:int/0/int, W_sp:int/0/int · returned Tensor · level recorded 2026-09-22
inline_pvt_medium models/inline_pvt.py ran · our draft was wrong no licence file found · pointer only · 08374cb9905d8cf6 · report fixture: signature x:Tensor/4/float, backbone:callable/0/?, neck:callable/0/?, head:callable/0/?, config:DummyConfig/0/? · returned PyramidVisionTransformer · level recorded 2026-09-25
load_checkpoint in 277 papers utils.py ran no licence file found · pointer only · 7e0715dc48712749 · report fixture: returned float · level recorded 2026-09-25
resize_pos_embed in 102 papers models/inline_deit.py ran; the contract check could not run (RAISES) no licence file found · pointer only · 1dbef2d4da4ee10f · report fixture: signature posemb:Tensor/3/float, posemb_new:Tensor/3/float, num_tokens:int/0/int, gs_new:tuple/1/int · returned Tensor · level recorded 2026-09-25
set_weight_decay_and_lr in 5 papers optimizer.py ran no licence file found · pointer only · 104af48a94364f24 · report fixture: signature model:callable/0/?, skip_list:tuple/1/str, skip_keywords:tuple/1/str, lower_lr_kvs:dict/0/?, base_lr:float/0/float · returned list · level recorded 2026-09-25
window_reverse in 296 papers models/inline_swin.py ran · our draft was wrong no licence file found · pointer only · 61bf152e6a42a184 · report fixture: signature windows:Tensor/4/float, window_size:int/0/int, H:int/0/int, W:int/0/int · returned Tensor · level recorded, date not recorded
windows2img in 15 papers models/inline_cswin.py ran · our draft was wrong no licence file found · pointer only · ab01fbfe58c75b08 · report fixture: signature img_splits_hw:Tensor/4/float, H_sp:int/0/int, W_sp:int/0/int, H:int/0/int, W:int/0/int · returned Tensor · level recorded 2026-09-22
get_config in 203 papers config.py unverified no licence file found · pointer only · 20681a9065c0a731 · report
inline_cswin_tiny models/inline_cswin.py unverified no licence file found · pointer only · 66116ff15364aa78 · report
inline_pvt_small models/inline_pvt.py unverified no licence file found · pointer only · ad181339ef9d5474 · report
inline_pvt_tiny models/inline_pvt.py unverified no licence file found · pointer only · 65a492aded74a41e · report
load_checkpoint in 277 papers utils_ema.py unverified no licence file found · pointer only · 26a01685ebc8f358 · report

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Absolute Position EncodingsAdamAttentionBPEDense ConnectionsDropoutLabel SmoothingLayer NormalizationLinear LayerMulti-Head AttentionPosition-Wise Feed-Forward LayerResidual ConnectionSoftmaxTransformerVision Transformer

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