{"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/linearizing-large-language-models","title":"Linearizing Large Language Models","arxiv_id":"2405.06640","date":"2024-05-10","proceeding":null,"authors":["Jean Mercat","Igor Vasiljevic","Sedrick Keh","Kushal Arora","Achal Dave","Adrien Gaidon","Thomas Kollar"],"abstract":"Linear transformers have emerged as a subquadratic-time alternative to softmax attention and have garnered significant interest due to their fixed-size recurrent state that lowers inference cost. However, their original formulation suffers from poor scaling and underperforms compute-matched transformers. Recent linear models such as RWKV and Mamba have attempted to address these shortcomings by proposing novel time-mixing and gating architectures, but pre-training large language models requires significant data and compute investments. Thus, the search for subquadratic architectures is limited by the availability of compute and quality pre-training datasets. As a cost-effective alternative to pre-training linear transformers, we propose Scalable UPtraining for Recurrent Attention (SUPRA). We present a method to uptrain existing large pre-trained transformers into Recurrent Neural Networks (RNNs) with a modest compute budget. This allows us to leverage the strong pre-training data and performance of existing transformer LLMs, while requiring 5% of the training cost. We find that our linearization technique leads to competitive performance on standard benchmarks, but we identify persistent in-context learning and long-context modeling shortfalls for even the largest linear models. Our code and models can be found at https://github.com/TRI-ML/linear_open_lm.","url_abs":"https://arxiv.org/abs/2405.06640v1","url_pdf":"https://arxiv.org/pdf/2405.06640v1.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":"linearizing-large-language-models","repo_url":"https://github.com/tri-ml/linear_open_lm","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}}],"tasks":[{"task_slug":"in-context-learning","task_name":"In-Context Learning"},{"task_slug":"mamba","task_name":"Mamba"}],"methods":[{"method_slug":"softmax","method_name":"Softmax"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2405.06640","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2405.06640"}},"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":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/tri-ml/linear_open_lm","reach":{"status":"ok","spdx":"MIT"}}],"summary":{"ran":12,"ran_violates":3,"unverified":3},"by_repo_kind":{"official":{"samples":18,"ran":15,"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":"11254c5664bf9e38","entry":"check_replacement_type","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/params.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/params.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"11254c5664bf9e38"}},{"code_sha256_prefix":"21f8a6ae2cd2f6b2","entry":"combine_average_meters","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/meters.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/meters.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":"21f8a6ae2cd2f6b2"}},{"code_sha256_prefix":"37990e880b7555d5","entry":"combine_ci_meters","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/meters.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/meters.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":"37990e880b7555d5"}},{"code_sha256_prefix":"df90feaeceb948d1","entry":"get_norm_class","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/norms.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/norms.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":"df90feaeceb948d1"}},{"code_sha256_prefix":"03aee31b8bbd541f","entry":"get_rectangular_causal_mask","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/attention.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/attention.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":"03aee31b8bbd541f"}},{"code_sha256_prefix":"234d4be90599afa0","entry":"get_slopes_power_of_2","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/model.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/model.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":"234d4be90599afa0"}},{"code_sha256_prefix":"7c29b374198bddcd","entry":"is_global_master","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/distributed.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/distributed.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"7c29b374198bddcd"}},{"code_sha256_prefix":"0377e309e95cfc3e","entry":"is_local_master","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/distributed.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/distributed.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0377e309e95cfc3e"}},{"code_sha256_prefix":"b092791002b40e8a","entry":"is_master","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/distributed.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/distributed.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b092791002b40e8a"}},{"code_sha256_prefix":"703ae0b4a799d756","entry":"maybe_load_config","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/params.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/params.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":"703ae0b4a799d756"}},{"code_sha256_prefix":"e347aa4278492da6","entry":"no_slope_tensor","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/model.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/model.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":"e347aa4278492da6"}},{"code_sha256_prefix":"913e58b6265fae28","entry":"preprocess_json","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/data.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/data.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"913e58b6265fae28"}},{"code_sha256_prefix":"fc518c7f20985201","entry":"preprocess_txt","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/data.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/data.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":"fc518c7f20985201"}},{"code_sha256_prefix":"cc40644322b3f4f3","entry":"proc_token","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/data.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/data.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cc40644322b3f4f3"}},{"code_sha256_prefix":"632965ea87f107bf","entry":"torch_attn","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/attention.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/attention.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":"632965ea87f107bf"}},{"code_sha256_prefix":"c8826eee91bf0f73","entry":"remote_sync","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/file_utils.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/file_utils.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":"c8826eee91bf0f73"}},{"code_sha256_prefix":"5ef1e6fce93e5928","entry":"remote_sync_fsspec","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/file_utils.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/file_utils.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":"5ef1e6fce93e5928"}},{"code_sha256_prefix":"0cf5fb2e3a3a9114","entry":"remote_sync_s3","repo":"tri-ml/linear_open_lm","repo_kind":"official","path":"open_lm/file_utils.py","file_url":"https://github.com/tri-ml/linear_open_lm/blob/HEAD/open_lm/file_utils.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":"0cf5fb2e3a3a9114"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}