{"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/transformers-are-ssms-generalized-models-and","title":"Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality","arxiv_id":"2405.21060","date":"2024-05-31","proceeding":null,"authors":["Tri Dao","Albert Gu"],"abstract":"While Transformers have been the main architecture behind deep learning's success in language modeling, state-space models (SSMs) such as Mamba have recently been shown to match or outperform Transformers at small to medium scale. We show that these families of models are actually quite closely related, and develop a rich framework of theoretical connections between SSMs and variants of attention, connected through various decompositions of a well-studied class of structured semiseparable matrices. Our state space duality (SSD) framework allows us to design a new architecture (Mamba-2) whose core layer is an a refinement of Mamba's selective SSM that is 2-8X faster, while continuing to be competitive with Transformers on language modeling.","url_abs":"https://arxiv.org/abs/2405.21060v1","url_pdf":"https://arxiv.org/pdf/2405.21060v1.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":[{"paper_slug":"transformers-are-ssms-generalized-models-and","repo_url":"https://github.com/state-spaces/mamba","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"transformers-are-ssms-generalized-models-and","repo_url":"https://github.com/lions-epfl/lion","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"transformers-are-ssms-generalized-models-and","repo_url":"https://github.com/radarFudan/mamba","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"transformers-are-ssms-generalized-models-and","repo_url":"https://github.com/rorschach1989/transformer-for-gmm","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"transformers-are-ssms-generalized-models-and","repo_url":"https://github.com/tommyip/mamba2-minimal","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}}],"tasks":[{"task_slug":"language-modeling","task_name":"Language Modeling"},{"task_slug":"language-modelling","task_name":"Language Modelling"},{"task_slug":"mamba","task_name":"Mamba"},{"task_slug":"state-space-models","task_name":"State Space Models"}],"methods":[],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2405.21060","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2405.21060"}},"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/state-spaces/mamba","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/rorschach1989/transformer-for-gmm","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/tommyip/mamba2-minimal","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/lions-epfl/lion","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/radarFudan/mamba","reach":{"status":"ok","spdx":"Apache-2.0"}}],"summary":{"ran_draft_wrong":3,"ran":3,"unverified":7},"by_repo_kind":{"official":{"samples":1,"ran":1,"repositories":1},"listed":{"samples":11,"ran":4,"repositories":3}},"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":1,"samples":[{"code_sha256_prefix":"5c853f3f04ddb483","entry":"heavy_tail_activation","repo":"state-spaces/mamba","repo_kind":"official","path":"mamba_ssm/modules/mamba3.py","file_url":"https://github.com/state-spaces/mamba/blob/HEAD/mamba_ssm/modules/mamba3.py","link_basis":"first_harvest_node","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"5c853f3f04ddb483"}},{"code_sha256_prefix":"ef936c81f5d4c41c","entry":"segsum","repo":"radarFudan/mamba","repo_kind":"listed","path":"mamba_ssm/modules/ssd_minimal.py","file_url":"https://github.com/radarFudan/mamba/blob/HEAD/mamba_ssm/modules/ssd_minimal.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"ef936c81f5d4c41c"}},{"code_sha256_prefix":"f641b66c642a2908","entry":"segsum_unstable","repo":"radarFudan/mamba","repo_kind":"listed","path":"mamba_ssm/modules/ssd_minimal.py","file_url":"https://github.com/radarFudan/mamba/blob/HEAD/mamba_ssm/modules/ssd_minimal.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f641b66c642a2908"}},{"code_sha256_prefix":"ba7b868fec181b57","entry":"selective_scan_ref","repo":null,"repo_kind":null,"path":null,"file_url":null,"link_basis":"identical_code_first_harvested_elsewhere","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":null,"inline_ok":false,"mcp_get_code":{"code_sha256":"ba7b868fec181b57"}},{"code_sha256_prefix":"8558535d4b8ed416","entry":"silu","repo":"tommyip/mamba2-minimal","repo_kind":"listed","path":"mamba2.py","file_url":"https://github.com/tommyip/mamba2-minimal/blob/HEAD/mamba2.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"8558535d4b8ed416"}},{"code_sha256_prefix":"f5c3ef656ef76878","entry":"ssd_minimal_discrete","repo":"radarFudan/mamba","repo_kind":"listed","path":"mamba_ssm/modules/ssd_minimal.py","file_url":"https://github.com/radarFudan/mamba/blob/HEAD/mamba_ssm/modules/ssd_minimal.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"f5c3ef656ef76878"}},{"code_sha256_prefix":"0f2196b3902caf16","entry":"all_gather_raw","repo":"radarFudan/mamba","repo_kind":"listed","path":"mamba_ssm/distributed/distributed_utils.py","file_url":"https://github.com/radarFudan/mamba/blob/HEAD/mamba_ssm/distributed/distributed_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"0f2196b3902caf16"}},{"code_sha256_prefix":"a06d70b09eb46b60","entry":"all_reduce_raw","repo":"radarFudan/mamba","repo_kind":"listed","path":"mamba_ssm/distributed/distributed_utils.py","file_url":"https://github.com/radarFudan/mamba/blob/HEAD/mamba_ssm/distributed/distributed_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"a06d70b09eb46b60"}},{"code_sha256_prefix":"389b08cfb8b3130b","entry":"concat_task_sample","repo":"rorschach1989/transformer-for-gmm","repo_kind":"listed","path":"tgmm/task.py","file_url":"https://github.com/rorschach1989/transformer-for-gmm/blob/HEAD/tgmm/task.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":"389b08cfb8b3130b"}},{"code_sha256_prefix":"f23bd7f5b8889fa3","entry":"concat_task_sample_hf","repo":"rorschach1989/transformer-for-gmm","repo_kind":"listed","path":"tgmm/task.py","file_url":"https://github.com/rorschach1989/transformer-for-gmm/blob/HEAD/tgmm/task.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":"f23bd7f5b8889fa3"}},{"code_sha256_prefix":"32968cc3a1d4a2e0","entry":"concat_task_sample_instruct","repo":"rorschach1989/transformer-for-gmm","repo_kind":"listed","path":"tgmm/task.py","file_url":"https://github.com/rorschach1989/transformer-for-gmm/blob/HEAD/tgmm/task.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":"32968cc3a1d4a2e0"}},{"code_sha256_prefix":"2ef6cf3e9fce8a55","entry":"gen_name_from_cfg","repo":"rorschach1989/transformer-for-gmm","repo_kind":"listed","path":"tgmm/utils/configuration.py","file_url":"https://github.com/rorschach1989/transformer-for-gmm/blob/HEAD/tgmm/utils/configuration.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":"2ef6cf3e9fce8a55"}},{"code_sha256_prefix":"2d002bb9a87211b8","entry":"reduce_scatter_raw","repo":"radarFudan/mamba","repo_kind":"listed","path":"mamba_ssm/distributed/distributed_utils.py","file_url":"https://github.com/radarFudan/mamba/blob/HEAD/mamba_ssm/distributed/distributed_utils.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"2d002bb9a87211b8"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}