{"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/tropical-attention-neural-algorithmic","title":"Tropical Attention: Neural Algorithmic Reasoning for Combinatorial Algorithms","arxiv_id":"2505.17190","date":"2025-05-22","proceeding":null,"authors":["Baran Hashemi","Kurt Pasque","Chris Teska","Ruriko Yoshida"],"abstract":"Dynamic programming (DP) algorithms for combinatorial optimization problems work with taking maximization, minimization, and classical addition in their recursion algorithms. The associated value functions correspond to convex polyhedra in the max plus semiring. Existing Neural Algorithmic Reasoning models, however, rely on softmax-normalized dot-product attention where the smooth exponential weighting blurs these sharp polyhedral structures and collapses when evaluated on out-of-distribution (OOD) settings. We introduce Tropical attention, a novel attention function that operates natively in the max-plus semiring of tropical geometry. We prove that Tropical attention can approximate tropical circuits of DP-type combinatorial algorithms. We then propose that using Tropical transformers enhances empirical OOD performance in both length generalization and value generalization, on algorithmic reasoning tasks, surpassing softmax baselines while remaining stable under adversarial attacks. We also present adversarial-attack generalization as a third axis for Neural Algorithmic Reasoning benchmarking. Our results demonstrate that Tropical attention restores the sharp, scale-invariant reasoning absent from softmax.","url_abs":"https://arxiv.org/abs/2505.17190v1","url_pdf":"https://arxiv.org/pdf/2505.17190v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[],"tasks":[{"task_slug":"adversarial-attack","task_name":"Adversarial Attack"},{"task_slug":"benchmarking","task_name":"Benchmarking"},{"task_slug":"combinatorial-optimization","task_name":"Combinatorial Optimization"},{"task_slug":"mathematical-reasoning","task_name":"Mathematical Reasoning"},{"task_slug":"out-of-distribution-generalization","task_name":"Out-of-Distribution Generalization"}],"methods":[{"method_slug":"attention","method_name":"Attention"},{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2505.17190","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2505.17190"}},"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":[{"provenance":"deterministic:regex_extraction","url":"https://github.com/Baran-phys/Tropical-Attention","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"unverified":9},"by_repo_kind":{"found_in_text":{"samples":9,"ran":0,"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":"f443dbe93defa3cf","entry":"adaptive_temperature_softmax","repo":"Baran-phys/Tropical-Attention","repo_kind":"found_in_text","path":"models.py","file_url":"https://github.com/Baran-phys/Tropical-Attention/blob/HEAD/models.py","link_basis":"harvester_set","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":"f443dbe93defa3cf"}},{"code_sha256_prefix":"17f649fefaa3c71e","entry":"convert_value","repo":"Baran-phys/Tropical-Attention","repo_kind":"found_in_text","path":"experiment.py","file_url":"https://github.com/Baran-phys/Tropical-Attention/blob/HEAD/experiment.py","link_basis":"harvester_set","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":"17f649fefaa3c71e"}},{"code_sha256_prefix":"88d2790b0768be11","entry":"max_subset_mask","repo":"Baran-phys/Tropical-Attention","repo_kind":"found_in_text","path":"dataloaders.py","file_url":"https://github.com/Baran-phys/Tropical-Attention/blob/HEAD/dataloaders.py","link_basis":"harvester_set","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":"88d2790b0768be11"}},{"code_sha256_prefix":"4849f6753bf0ec67","entry":"maxplus_matmul","repo":"Baran-phys/Tropical-Attention","repo_kind":"found_in_text","path":"tropical_gemm_backend.py","file_url":"https://github.com/Baran-phys/Tropical-Attention/blob/HEAD/tropical_gemm_backend.py","link_basis":"harvester_set","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":"4849f6753bf0ec67"}},{"code_sha256_prefix":"f01f2aa40c7f61ac","entry":"set_max_subset_sum","repo":"Baran-phys/Tropical-Attention","repo_kind":"found_in_text","path":"dataloaders.py","file_url":"https://github.com/Baran-phys/Tropical-Attention/blob/HEAD/dataloaders.py","link_basis":"harvester_set","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":"f01f2aa40c7f61ac"}},{"code_sha256_prefix":"aff0ad1b655e8b76","entry":"set_subset_sum_decision","repo":"Baran-phys/Tropical-Attention","repo_kind":"found_in_text","path":"dataloaders.py","file_url":"https://github.com/Baran-phys/Tropical-Attention/blob/HEAD/dataloaders.py","link_basis":"harvester_set","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":"aff0ad1b655e8b76"}},{"code_sha256_prefix":"d5e0a54421d6976c","entry":"smooth_max","repo":"Baran-phys/Tropical-Attention","repo_kind":"found_in_text","path":"models.py","file_url":"https://github.com/Baran-phys/Tropical-Attention/blob/HEAD/models.py","link_basis":"harvester_set","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":"d5e0a54421d6976c"}},{"code_sha256_prefix":"1b2a20f459140576","entry":"smooth_min","repo":"Baran-phys/Tropical-Attention","repo_kind":"found_in_text","path":"models.py","file_url":"https://github.com/Baran-phys/Tropical-Attention/blob/HEAD/models.py","link_basis":"harvester_set","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":"1b2a20f459140576"}},{"code_sha256_prefix":"adfa93deef389005","entry":"torch_maxplus_matmul","repo":"Baran-phys/Tropical-Attention","repo_kind":"found_in_text","path":"tropical_gemm_backend.py","file_url":"https://github.com/Baran-phys/Tropical-Attention/blob/HEAD/tropical_gemm_backend.py","link_basis":"harvester_set","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":"adfa93deef389005"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}