SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2412.06590 · NeurIPS · 2024

Bridging the Divide: Reconsidering Softmax and Linear Attention

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

arXiv · PDF · Open in the Atlas

Code that ran

We lifted 22 functions out of this paper's own repositories and ran 5 of them in a sandbox. "Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results.

RepositoryRoleRan
leaplabthu/inline canonical 5 of 22
FunctionStatusWhere it lives
window_partition Ran leaplabthu/inline/models/inline_swin.py
pointer only (licence: NONE) · get_code("144d10b49baeb8a6")
get_grad_norm Ran leaplabthu/inline/utils.py
pointer only (licence: NONE) · get_code("eec1e7cba51d5e8e")
img2windows Ran leaplabthu/inline/models/inline_cswin.py
pointer only (licence: NONE) · get_code("39b18f062e0cc6d9")
window_reverse Ran leaplabthu/inline/models/inline_swin.py
pointer only (licence: NONE) · get_code("61bf152e6a42a184")
windows2img Ran leaplabthu/inline/models/inline_cswin.py
pointer only (licence: NONE) · get_code("ab01fbfe58c75b08")
auto_resume_helper Not yet run leaplabthu/inline/utils.py
pointer only (licence: NONE) · get_code("0c32459bef92ff8c")
build_model Not yet run leaplabthu/inline/models/build.py
pointer only (licence: NONE) · get_code("aad933b3b81ff1a5")
build_optimizer Not yet run leaplabthu/inline/optimizer.py
pointer only (licence: NONE) · get_code("fcf2d41dd445a70b")
build_scheduler Not yet run leaplabthu/inline/lr_scheduler.py
pointer only (licence: NONE) · get_code("07e8b4b487c0abb6")
check_keywords_in_name Not yet run leaplabthu/inline/optimizer.py
pointer only (licence: NONE) · get_code("b0a5beb34716d5a6")
checkpoint_filter_fn Not yet run leaplabthu/inline/models/inline_deit.py
pointer only (licence: NONE) · get_code("5dac11fdc41c896b")
create_logger Not yet run leaplabthu/inline/logger.py
pointer only (licence: NONE) · get_code("82e52feafbf040bb")
exp_kernel Not yet run leaplabthu/inline/models/inline_swin.py
pointer only (licence: NONE) · get_code("99a5631eaaa3bf92")
get_config Not yet run leaplabthu/inline/config.py
pointer only (licence: NONE) · get_code("20681a9065c0a731")
inline_cswin_tiny Not yet run leaplabthu/inline/models/inline_cswin.py
pointer only (licence: NONE) · get_code("66116ff15364aa78")
inline_pvt_medium Not yet run leaplabthu/inline/models/inline_pvt.py
pointer only (licence: NONE) · get_code("08374cb9905d8cf6")
inline_pvt_small Not yet run leaplabthu/inline/models/inline_pvt.py
pointer only (licence: NONE) · get_code("ad181339ef9d5474")
inline_pvt_tiny Not yet run leaplabthu/inline/models/inline_pvt.py
pointer only (licence: NONE) · get_code("65a492aded74a41e")
load_checkpoint Not yet run leaplabthu/inline/utils.py
pointer only (licence: NONE) · get_code("7e0715dc48712749")
load_checkpoint Not yet run leaplabthu/inline/utils_ema.py
pointer only (licence: NONE) · get_code("26a01685ebc8f358")
resize_pos_embed Not yet run leaplabthu/inline/models/inline_deit.py
pointer only (licence: NONE) · get_code("1dbef2d4da4ee10f")
set_weight_decay_and_lr Not yet run leaplabthu/inline/optimizer.py
pointer only (licence: NONE) · get_code("104af48a94364f24")

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

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.

For agents

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

get_harvested_code_for_paper("2412.06590")
get_code_for_paper("2412.06590")
have("2412.06590")

Connect an agent — have() is free.