{"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-2509-10918","title":"ToMA: Token Merge with Attention for Diffusion Models","arxiv_id":"2509.10918","date":"2025-09-13","proceeding":"ICML","authors":["Wenbo Lu","Shaoyi Zheng","Yuxuan Xia","Shengjie Wang"],"abstract":"Diffusion models excel in high-fidelity image generation but face scalability limits due to transformers' quadratic attention complexity. Plug-and-play token reduction methods like ToMeSD and ToFu reduce FLOPs by merging redundant tokens in generated images but rely on GPU-inefficient operations (e.g., sorting, scattered writes), introducing overheads that negate theoretical speedups when paired with optimized attention implementations (e.g., FlashAttention). To bridge this gap, we propose Token Merge with Attention (ToMA), an off-the-shelf method that redesigns token reduction for GPU-aligned efficiency, with three key contributions: 1) a reformulation of token merge as a submodular optimization problem to select diverse tokens; 2) merge/unmerge as an attention-like linear transformation via GPU-friendly matrix operations; and 3) exploiting latent locality and sequential redundancy (pattern reuse) to minimize overhead. ToMA reduces SDXL/Flux generation latency by 24%/23%, respectively (with DINO $Δ< 0.07$), outperforming prior methods. This work bridges the gap between theoretical and practical efficiency for transformers in diffusion. Code available at https://github.com/WenboLuu/ToMA.","url_abs":"https://arxiv.org/abs/2509.10918","url_pdf":"https://arxiv.org/pdf/2509.10918","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":null,"atlas_url":"https://app.syntology.ai/?focus=2509.10918","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2509.10918"}},"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/WenboLuu/ToMA","reach":null}],"summary":{"ran_fixture":7,"ran_draft_wrong":2,"ran_honours":1,"ran_violates":1,"unverified":7},"by_repo_kind":{"found_in_text":{"samples":18,"ran":11,"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":18,"samples":[{"code_sha256_prefix":"208e2100acfde26e","entry":"apply_rotary_emb","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"208e2100acfde26e"}},{"code_sha256_prefix":"5ade63ed6618f3fe","entry":"batched_facility_location","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"5ade63ed6618f3fe"}},{"code_sha256_prefix":"f4a7eae675fa67d1","entry":"create_flux_transformer_block","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f4a7eae675fa67d1"}},{"code_sha256_prefix":"3dc9b1a39943f29e","entry":"do_nothing","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3dc9b1a39943f29e"}},{"code_sha256_prefix":"9b9fc96a1092e8b4","entry":"fold_with_indices","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"9b9fc96a1092e8b4"}},{"code_sha256_prefix":"4d43c39d84b84472","entry":"isinstance_str","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4d43c39d84b84472"}},{"code_sha256_prefix":"4445496141dac5db","entry":"local_tile_wise_facility","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"4445496141dac5db"}},{"code_sha256_prefix":"115cd04d3861aed1","entry":"remove_patch","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"115cd04d3861aed1"}},{"code_sha256_prefix":"8dbb589ce2ef2ed8","entry":"stripe_attention_merge","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8dbb589ce2ef2ed8"}},{"code_sha256_prefix":"f0906818176c5c3d","entry":"tile_attention_merge","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f0906818176c5c3d"}},{"code_sha256_prefix":"6316efeb5120f8b6","entry":"unfold_with_indices","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6316efeb5120f8b6"}},{"code_sha256_prefix":"67c075726d5f41eb","entry":"AttnProcessor","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"67c075726d5f41eb"}},{"code_sha256_prefix":"78499dabb8628941","entry":"FluxGlobalAttentionProcessor","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"78499dabb8628941"}},{"code_sha256_prefix":"3d87583091d93955","entry":"apply_patch","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3d87583091d93955"}},{"code_sha256_prefix":"f28cd4b5d2f5c515","entry":"compute_merge","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f28cd4b5d2f5c515"}},{"code_sha256_prefix":"3803c1243a084543","entry":"create_flux_single_transformer_block","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"3803c1243a084543"}},{"code_sha256_prefix":"d021703ca179bf9f","entry":"merge_helper","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d021703ca179bf9f"}},{"code_sha256_prefix":"796fdd38c185e58e","entry":"stripe_wise_facility","repo":"WenboLuu/ToMA","repo_kind":"found_in_text","path":"toma/patch.py","file_url":"https://github.com/WenboLuu/ToMA/blob/HEAD/toma/patch.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"796fdd38c185e58e"}}]},"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_api"},"syntology_extracted_results":{"kind":"leaderboard_placements","source":"Syntology's leaderboard-shaped extractor over the paper's own arXiv-HTML tables: a model pointed at a cell, the number was read from that cell and checked against the board's metric, dataset, split and scale, and an independent check accepted the entry; not reviewed by the paper's authors or the archive's editors","extractor_model":"global.anthropic.claude-sonnet-4-5-20250929-v1:0","verifier_model":null,"prompt_sha":"fa63d4bb9d755694","coverage":{"sentence":"Syntology has checked 6,795 of the 9,581 papers on this site that are newer than the archive; results from the others appear after they are checked.","papers_newer_than_archive":9581,"papers_checked":6795},"entries":[],"not_placed":{"boards":0,"rejected_by_independent_check":0,"refused_by_a_rule":0,"check_did_not_answer":0,"proposed_without_a_cell":0,"declined_by_site":0}}}