{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/arxiv-2604-23798","title":"ELSA: Exact Linear-Scan Attention for Fast and Memory-Light Vision Transformers","arxiv_id":"2604.23798","date":"2026-04-26","proceeding":null,"authors":["Chih-Chung Hsu","Xin-Di Ma","Wo-Ting Liao","Chia-Ming Lee"],"abstract":"Existing attention accelerators often trade exact softmax semantics, depend on fused Tensor Core kernels, or incur sequential depth that limits FP32 throughput on long sequences. We present \\textbf{ELSA}, an algorithmic reformulation of online softmax attention that (i)~preserves exact softmax semantics in real arithmetic with a \\emph{provable} $\\mathcal{O}(u\\log n)$ FP32 relative error bound; (ii)~casts the online softmax update as a prefix scan over an associative monoid $(m,S,W)$, yielding $O(n)$ extra memory and $O(\\log n)$ parallel depth; and (iii)~is Tensor-Core independent, implemented in Triton and CUDA C++, and deployable as a \\emph{drop-in replacement} requiring no retraining or weight modification. Unlike FlashAttention-2/3, which rely on HMMA/GMMA Tensor Core instructions and provide no compatible FP32 path, ELSA operates identically on A100s and resource-constrained edge devices such as Jetson TX2 -- making it the only hardware-agnostic exact-attention kernel that reduces parallel depth to $O(\\log n)$ at full precision. On A100 FP32 benchmarks (1K--16K tokens), ELSA delivers $1.3$--$3.5\\times$ speedup over memory-efficient SDPA and $1.97$--$2.27\\times$ on BERT; on Jetson TX2, ELSA achieves $1.5$--$1.6\\times$ over Math (64--900 tokens), with $17.8$--$20.2\\%$ throughput gains under LLaMA-13B offloading at $\\ge$32K. In FP16, ELSA approaches hardware-fused baselines at long sequences while retaining full FP32 capability, offering a unified kernel for high-precision inference across platforms. Our code and implementation are available at https://github.com/ming053l/ELSA.","url_abs":"https://arxiv.org/abs/2604.23798","url_pdf":"https://arxiv.org/pdf/2604.23798","source":{"archive":null,"snapshot":"2025-07-28","note":"not in the Papers with Code archive (frozen at the snapshot)","row_kind":"graph","title_abstract_authors_date":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)"},"code_links":[],"tasks":[],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2604.23798","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2604.23798"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"mentioned_in_github":null,"is_official":null,"provenance":"deterministic:regex_extraction","mentioned_in_paper":null,"url":"https://github.com/Dao-AILab/flash-attention","reach":{"status":"ok","spdx":"BSD-3-Clause"}}],"summary":{"ran":13,"ran_fixture":1,"ran_honours":2,"unverified":2},"by_repo_kind":{"found_in_text":{"samples":18,"ran":16,"repositories":1}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"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"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"5ec949977c334f87","entry":"apply_rotary_emb_torch","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"flash_attn/layers/rotary.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/flash_attn/layers/rotary.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"5ec949977c334f87"}},{"code_sha256_prefix":"4afe00a5853d633f","entry":"attention_pytorch","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"flash_attn/cute/benchmark_flash_attention_fp8.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/flash_attn/cute/benchmark_flash_attention_fp8.py","link_basis":"plan_row","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"4afe00a5853d633f"}},{"code_sha256_prefix":"942ce4d7b0714c0a","entry":"attention_pytorch","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"benchmarks/benchmark_flash_attention.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/benchmarks/benchmark_flash_attention.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"942ce4d7b0714c0a"}},{"code_sha256_prefix":"cc628b160e090ba1","entry":"convert_blockmask","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"flash_attn/flash_blocksparse_attn_interface.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/flash_attn/flash_blocksparse_attn_interface.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"cc628b160e090ba1"}},{"code_sha256_prefix":"f29cb637db3ec374","entry":"efficiency","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"flash_attn/cute/benchmark_flash_attention_fp8.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/flash_attn/cute/benchmark_flash_attention_fp8.py","link_basis":"plan_row","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"f29cb637db3ec374"}},{"code_sha256_prefix":"b5de75d142329f03","entry":"efficiency","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"benchmarks/benchmark_flash_attention.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/benchmarks/benchmark_flash_attention.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"b5de75d142329f03"}},{"code_sha256_prefix":"7541ce9614862680","entry":"flash_attn_qkvpacked_func","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"flash_attn/flash_attn_interface.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/flash_attn/flash_attn_interface.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"7541ce9614862680"}},{"code_sha256_prefix":"e73bdfbda28da341","entry":"flops","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"flash_attn/cute/benchmark_flash_attention_fp8.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/flash_attn/cute/benchmark_flash_attention_fp8.py","link_basis":"plan_row","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"e73bdfbda28da341"}},{"code_sha256_prefix":"8d5fb28ca2f46eb8","entry":"flops","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"benchmarks/benchmark_flash_attention.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/benchmarks/benchmark_flash_attention.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"8d5fb28ca2f46eb8"}},{"code_sha256_prefix":"1586b639a5abd0b0","entry":"init_to_zero","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"flash_attn/flash_attn_triton.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/flash_attn/flash_attn_triton.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"1586b639a5abd0b0"}},{"code_sha256_prefix":"19ad2ccd82e378c1","entry":"maybe_contiguous","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"flash_attn/flash_attn_interface.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/flash_attn/flash_attn_interface.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"19ad2ccd82e378c1"}},{"code_sha256_prefix":"a8cf6124094beaab","entry":"pad_input","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"flash_attn/bert_padding.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/flash_attn/bert_padding.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"a8cf6124094beaab"}},{"code_sha256_prefix":"163292f43a3c861b","entry":"rotate_half","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"flash_attn/layers/rotary.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/flash_attn/layers/rotary.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"163292f43a3c861b"}},{"code_sha256_prefix":"a0595f1c95cacf06","entry":"round_multiple","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"flash_attn/flash_attn_interface.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/flash_attn/flash_attn_interface.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"a0595f1c95cacf06"}},{"code_sha256_prefix":"d84093c20a0ed8fd","entry":"unpad_input","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"flash_attn/bert_padding.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/flash_attn/bert_padding.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"d84093c20a0ed8fd"}},{"code_sha256_prefix":"62394c842aafb022","entry":"unpad_input_for_concatenated_sequences","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"flash_attn/bert_padding.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/flash_attn/bert_padding.py","link_basis":"harvester_set","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"62394c842aafb022"}},{"code_sha256_prefix":"a9519adef33152bb","entry":"convert_to_cudnn_type","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"hopper/benchmark_flash_attention_fp8.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/hopper/benchmark_flash_attention_fp8.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"a9519adef33152bb"}},{"code_sha256_prefix":"58ebcd8dbefa010d","entry":"cudnn_spda_setup","repo":"Dao-AILab/flash-attention","repo_kind":"found_in_text","path":"hopper/benchmark_flash_attention_fp8.py","file_url":"https://github.com/Dao-AILab/flash-attention/blob/HEAD/hopper/benchmark_flash_attention_fp8.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"58ebcd8dbefa010d"}}]},"arxiv_metadata":{"licence":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)","fields":["title","abstract","authors","date"],"primary_category":"cs.LG","source":"arxiv_2026.jsonl"},"syntology_extracted_results":null}