{"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-19633","title":"Mamba Modulation: On the Length Generalization of Mamba","arxiv_id":"2509.19633","date":"2025-09-23","proceeding":"NeurIPS","authors":["Peng Lu","Jerry Huang","Qiuhao Zeng","Xinyu Wang","Boxing Chen","Philippe Langlais","Yufei Cui"],"abstract":"The quadratic complexity of the attention mechanism in Transformer models has motivated the development of alternative architectures with sub-quadratic scaling, such as state-space models. Among these, Mamba has emerged as a leading architecture, achieving state-of-the-art results across a range of language modeling tasks. However, Mamba's performance significantly deteriorates when applied to contexts longer than those seen during pre-training, revealing a sharp sensitivity to context length extension. Through detailed analysis, we attribute this limitation to the out-of-distribution behaviour of its state-space dynamics, particularly within the parameterization of the state transition matrix $\\mathbf{A}$. Unlike recent works which attribute this sensitivity to the vanished accumulation of discretization time steps, $\\exp(-\\sum_{t=1}^NΔ_t)$, we establish a connection between state convergence behavior as the input length approaches infinity and the spectrum of the transition matrix $\\mathbf{A}$, offering a well-founded explanation of its role in length extension. Next, to overcome this challenge, we propose an approach that applies spectrum scaling to pre-trained Mamba models to enable robust long-context generalization by selectively modulating the spectrum of $\\mathbf{A}$ matrices in each layer. We show that this can significantly improve performance in settings where simply modulating $Δ_t$ fails, validating our insights and providing avenues for better length generalization of state-space models with structured transition matrices.","url_abs":"https://arxiv.org/abs/2509.19633","url_pdf":"https://arxiv.org/pdf/2509.19633","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=2509.19633","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2509.19633"}},"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/gnepul-ace/mamba_modulation","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran_honours":1,"ran_draft_wrong":2,"ran_violates":1,"unverified":8},"by_repo_kind":{"found_in_text":{"samples":12,"ran":4,"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":"b349b79d9cc2934b","entry":"count_score","repo":"gnepul-ace/mamba_modulation","repo_kind":"found_in_text","path":"Mamba/LongBench/metrics.py","file_url":"https://github.com/gnepul-ace/mamba_modulation/blob/HEAD/Mamba/LongBench/metrics.py","link_basis":"plan_row","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b349b79d9cc2934b"}},{"code_sha256_prefix":"e7e75981cb464788","entry":"normalize_answer","repo":"gnepul-ace/mamba_modulation","repo_kind":"found_in_text","path":"Mamba/LongBench/metrics.py","file_url":"https://github.com/gnepul-ace/mamba_modulation/blob/HEAD/Mamba/LongBench/metrics.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"e7e75981cb464788"}},{"code_sha256_prefix":"8c5c581f9264c810","entry":"normalize_zh_answer","repo":"gnepul-ace/mamba_modulation","repo_kind":"found_in_text","path":"Mamba/LongBench/metrics.py","file_url":"https://github.com/gnepul-ace/mamba_modulation/blob/HEAD/Mamba/LongBench/metrics.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"OUTPUT_MISDECLARED","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"8c5c581f9264c810"}},{"code_sha256_prefix":"4489113b536ca6eb","entry":"post_process","repo":"gnepul-ace/mamba_modulation","repo_kind":"found_in_text","path":"Mamba/LongBench/pred.py","file_url":"https://github.com/gnepul-ace/mamba_modulation/blob/HEAD/Mamba/LongBench/pred.py","link_basis":"plan_row","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4489113b536ca6eb"}},{"code_sha256_prefix":"324506640e971548","entry":"build_chat","repo":"gnepul-ace/mamba_modulation","repo_kind":"found_in_text","path":"Mamba/LongBench/pred.py","file_url":"https://github.com/gnepul-ace/mamba_modulation/blob/HEAD/Mamba/LongBench/pred.py","link_basis":"plan_row","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":"324506640e971548"}},{"code_sha256_prefix":"46f8dfafbbb8c9b2","entry":"calc_grad_norm","repo":"gnepul-ace/mamba_modulation","repo_kind":"found_in_text","path":"Mamba/PasskeyRetrieval/utils.py","file_url":"https://github.com/gnepul-ace/mamba_modulation/blob/HEAD/Mamba/PasskeyRetrieval/utils.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":"46f8dfafbbb8c9b2"}},{"code_sha256_prefix":"91336ac6a4247b60","entry":"calc_mean_entropy","repo":"gnepul-ace/mamba_modulation","repo_kind":"found_in_text","path":"Mamba/PasskeyRetrieval/utils.py","file_url":"https://github.com/gnepul-ace/mamba_modulation/blob/HEAD/Mamba/PasskeyRetrieval/utils.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":"91336ac6a4247b60"}},{"code_sha256_prefix":"b0cb65c5d1c5516c","entry":"function_","repo":"gnepul-ace/mamba_modulation","repo_kind":"found_in_text","path":"Mamba/PasskeyRetrieval/modeling/mamba_module.py","file_url":"https://github.com/gnepul-ace/mamba_modulation/blob/HEAD/Mamba/PasskeyRetrieval/modeling/mamba_module.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":"b0cb65c5d1c5516c"}},{"code_sha256_prefix":"c28f8a171756d1ea","entry":"init_t","repo":"gnepul-ace/mamba_modulation","repo_kind":"found_in_text","path":"Mamba/PasskeyRetrieval/finetune_ssm.py","file_url":"https://github.com/gnepul-ace/mamba_modulation/blob/HEAD/Mamba/PasskeyRetrieval/finetune_ssm.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":"c28f8a171756d1ea"}},{"code_sha256_prefix":"7c9375e7379c1087","entry":"load_config","repo":"gnepul-ace/mamba_modulation","repo_kind":"found_in_text","path":"Mamba/PasskeyRetrieval/utils.py","file_url":"https://github.com/gnepul-ace/mamba_modulation/blob/HEAD/Mamba/PasskeyRetrieval/utils.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":"7c9375e7379c1087"}},{"code_sha256_prefix":"51a46c0ad37271aa","entry":"parse_args","repo":"gnepul-ace/mamba_modulation","repo_kind":"found_in_text","path":"Mamba/LongBench/pred.py","file_url":"https://github.com/gnepul-ace/mamba_modulation/blob/HEAD/Mamba/LongBench/pred.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":"51a46c0ad37271aa"}},{"code_sha256_prefix":"4f66b16871415955","entry":"set_min","repo":"gnepul-ace/mamba_modulation","repo_kind":"found_in_text","path":"Mamba/PasskeyRetrieval/finetune_ssm.py","file_url":"https://github.com/gnepul-ace/mamba_modulation/blob/HEAD/Mamba/PasskeyRetrieval/finetune_ssm.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":"4f66b16871415955"}}]},"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":null}