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 repositories, every harvested function with whether it ran, its licence and the call to fetch it.

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="2412.06590")

Code

Syntology Ran 5 of 22 code samples harvested from 1 repository linked to this paper; 17 have no recorded run. Of those that ran: 1 ran · honoured contract; 2 ran · our draft was wrong; 2 ran · fixture could not drive it.

By repository: official repository: 22 samples from 1 repository, 5 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

leaplabthu/inline officialmentioned in papermentioned 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

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

1ran · honoured contract
2ran · our draft was wrong
2ran · fixture could not drive it
17unverified

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. “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.

window_partition leaplabthu/inline/models/inline_swin.py official repository ran · fixture could not drive it fingerprinted no licence file found · pointer only · 144d10b49baeb8a6 · report
get_grad_norm leaplabthu/inline/utils.py official repository ran · honoured contract no licence file found · pointer only · eec1e7cba51d5e8e · report
img2windows leaplabthu/inline/models/inline_cswin.py official repository ran · fixture could not drive it no licence file found · pointer only · 39b18f062e0cc6d9 · report
window_reverse leaplabthu/inline/models/inline_swin.py official repository ran · our draft was wrong no licence file found · pointer only · 61bf152e6a42a184 · report
windows2img leaplabthu/inline/models/inline_cswin.py official repository ran · our draft was wrong no licence file found · pointer only · ab01fbfe58c75b08 · report
auto_resume_helper leaplabthu/inline/utils.py official repository unverified no licence file found · pointer only · 0c32459bef92ff8c · report
build_model leaplabthu/inline/models/build.py official repository unverified no licence file found · pointer only · aad933b3b81ff1a5 · report
build_optimizer leaplabthu/inline/optimizer.py official repository unverified no licence file found · pointer only · fcf2d41dd445a70b · report
build_scheduler leaplabthu/inline/lr_scheduler.py official repository unverified no licence file found · pointer only · 07e8b4b487c0abb6 · report
check_keywords_in_name leaplabthu/inline/optimizer.py official repository unverified no licence file found · pointer only · b0a5beb34716d5a6 · report
checkpoint_filter_fn leaplabthu/inline/models/inline_deit.py official repository unverified no licence file found · pointer only · 5dac11fdc41c896b · report
create_logger leaplabthu/inline/logger.py official repository unverified no licence file found · pointer only · 82e52feafbf040bb · report
exp_kernel leaplabthu/inline/models/inline_swin.py official repository unverified no licence file found · pointer only · 99a5631eaaa3bf92 · report
get_config leaplabthu/inline/config.py official repository unverified no licence file found · pointer only · 20681a9065c0a731 · report
inline_cswin_tiny leaplabthu/inline/models/inline_cswin.py official repository unverified no licence file found · pointer only · 66116ff15364aa78 · report
inline_pvt_medium leaplabthu/inline/models/inline_pvt.py official repository unverified no licence file found · pointer only · 08374cb9905d8cf6 · report
inline_pvt_small leaplabthu/inline/models/inline_pvt.py official repository unverified no licence file found · pointer only · ad181339ef9d5474 · report
inline_pvt_tiny leaplabthu/inline/models/inline_pvt.py official repository unverified no licence file found · pointer only · 65a492aded74a41e · report
load_checkpoint leaplabthu/inline/utils.py official repository unverified no licence file found · pointer only · 7e0715dc48712749 · report
load_checkpoint leaplabthu/inline/utils_ema.py official repository unverified no licence file found · pointer only · 26a01685ebc8f358 · report
resize_pos_embed leaplabthu/inline/models/inline_deit.py official repository unverified no licence file found · pointer only · 1dbef2d4da4ee10f · report
set_weight_decay_and_lr leaplabthu/inline/optimizer.py official repository unverified no licence file found · pointer only · 104af48a94364f24 · 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