{"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-2511-05832","title":"Hilbert-Guided Sparse Local Attention","arxiv_id":"2511.05832","date":"2025-11-08","proceeding":"ICLR","authors":["Yunge Li","Lanyu Xu"],"abstract":"The quadratic compute and memory costs of global self-attention severely limit its use in high-resolution images. Local attention reduces complexity by restricting attention to neighborhoods. Block-sparse kernels can further improve the efficiency of local attention, but conventional local attention patterns often fail to deliver significant speedups because tokens within a window are not contiguous in the 1D sequence. This work proposes a novel method for constructing windows and neighborhoods based on the Hilbert curve. Image tokens are first reordered along a Hilbert curve, and windows and neighborhoods are then formed on the reordered 1D sequence. From a block-sparse perspective, this strategy significantly increases block sparsity and can be combined with existing block-sparse kernels to improve the efficiency of 2D local attention. Experiments show that the proposed Hilbert Window Attention and Hilbert Slide Attention can accelerate window attention and slide attention by about $4\\times$ and $18\\times$, respectively. To assess practicality, the strategy is instantiated as the Hilbert Window Transformer and the Hilbert Neighborhood Transformer, both of which achieve end-to-end speedups with minimal accuracy loss. Overall, combining Hilbert-guided local attention with block-sparse kernels offers a general and practical approach to enhancing the efficiency of 2D local attention for images.","url_abs":"https://arxiv.org/abs/2511.05832","url_pdf":"https://arxiv.org/pdf/2511.05832","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":{"syntology_url":"https://syntology.ai/paper/2511.05832","atlas_url":"https://app.syntology.ai/?focus=2511.05832","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2511.05832"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-25T09:33:49+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/Yunge6666/Hilbert-Local-Attention","reach":null}],"summary":{"ran":2,"ran_honours":2,"ran_fixture":4,"unverified":2},"by_repo_kind":{"found_in_text":{"samples":10,"ran":8,"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":"0cd8d046c5019b75","entry":"GilbertPathCache","repo":"Yunge6666/Hilbert-Local-Attention","repo_kind":"found_in_text","path":"hwt.py","file_url":"https://github.com/Yunge6666/Hilbert-Local-Attention/blob/HEAD/hwt.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0cd8d046c5019b75"}},{"code_sha256_prefix":"2132f2ba5f5ca484","entry":"WindowAttention","repo":"Yunge6666/Hilbert-Local-Attention","repo_kind":"found_in_text","path":"hwt.py","file_url":"https://github.com/Yunge6666/Hilbert-Local-Attention/blob/HEAD/hwt.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2132f2ba5f5ca484"}},{"code_sha256_prefix":"970fcca41b5bcf82","entry":"gilbert2d","repo":"Yunge6666/Hilbert-Local-Attention","repo_kind":"found_in_text","path":"hwt.py","file_url":"https://github.com/Yunge6666/Hilbert-Local-Attention/blob/HEAD/hwt.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"970fcca41b5bcf82"}},{"code_sha256_prefix":"fae6570c89b0b0a7","entry":"gilbert_shift_forward","repo":"Yunge6666/Hilbert-Local-Attention","repo_kind":"found_in_text","path":"hwt.py","file_url":"https://github.com/Yunge6666/Hilbert-Local-Attention/blob/HEAD/hwt.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"fae6570c89b0b0a7"}},{"code_sha256_prefix":"8f27c3af24bbc8f9","entry":"gilbert_shift_reverse","repo":"Yunge6666/Hilbert-Local-Attention","repo_kind":"found_in_text","path":"hwt.py","file_url":"https://github.com/Yunge6666/Hilbert-Local-Attention/blob/HEAD/hwt.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8f27c3af24bbc8f9"}},{"code_sha256_prefix":"41ad57b96f86bf0c","entry":"gilbert_tensor_to_windows","repo":"Yunge6666/Hilbert-Local-Attention","repo_kind":"found_in_text","path":"hwt.py","file_url":"https://github.com/Yunge6666/Hilbert-Local-Attention/blob/HEAD/hwt.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"41ad57b96f86bf0c"}},{"code_sha256_prefix":"f8ddeb4e57c75167","entry":"gilbert_windows_to_tensor","repo":"Yunge6666/Hilbert-Local-Attention","repo_kind":"found_in_text","path":"hwt.py","file_url":"https://github.com/Yunge6666/Hilbert-Local-Attention/blob/HEAD/hwt.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f8ddeb4e57c75167"}},{"code_sha256_prefix":"441e92cd07dd8324","entry":"sgn","repo":"Yunge6666/Hilbert-Local-Attention","repo_kind":"found_in_text","path":"hwt.py","file_url":"https://github.com/Yunge6666/Hilbert-Local-Attention/blob/HEAD/hwt.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"441e92cd07dd8324"}},{"code_sha256_prefix":"5b0fbf3070f2cc49","entry":"SwinTransformerBlock","repo":"Yunge6666/Hilbert-Local-Attention","repo_kind":"found_in_text","path":"hwt.py","file_url":"https://github.com/Yunge6666/Hilbert-Local-Attention/blob/HEAD/hwt.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"5b0fbf3070f2cc49"}},{"code_sha256_prefix":"bd1ee63e84e6b28c","entry":"generate2d","repo":"Yunge6666/Hilbert-Local-Attention","repo_kind":"found_in_text","path":"hwt.py","file_url":"https://github.com/Yunge6666/Hilbert-Local-Attention/blob/HEAD/hwt.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"bd1ee63e84e6b28c"}}]},"arxiv_metadata":{"licence":"arXiv metadata, CC0 1.0 (https://info.arxiv.org/help/license)","fields":["title","abstract","authors","date"],"primary_category":"cs.CV","source":"arxiv_api"},"syntology_extracted_results":null}