{"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/cautious-optimizers-improving-training-with","title":"Cautious Optimizers: Improving Training with One Line of Code","arxiv_id":"2411.16085","date":"2024-11-25","proceeding":null,"authors":["Kaizhao Liang","Lizhang Chen","Bo Liu","Qiang Liu"],"abstract":"AdamW has been the default optimizer for transformer pretraining. For many years, our community searched for faster and more stable optimizers with only constrained positive outcomes. In this work, we propose a single-line modification in Pytorch to any momentum-based optimizer, which we rename cautious optimizer, e.g. C-AdamW and C-Lion. Our theoretical result shows that this modification preserves Adam's Hamiltonian function and it does not break the convergence guarantee under the Lyapunov analysis. In addition, a whole new family of optimizers is revealed by our theoretical insight. Among them, we pick the simplest one for empirical experiments, showing not only speed-up on Llama and MAE pretraining up to $1.47$ times, but also better results in LLM post-training tasks. Code is available at https://github.com/kyleliang919/C-Optim.","url_abs":"https://arxiv.org/abs/2411.16085v3","url_pdf":"https://arxiv.org/pdf/2411.16085v3.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":"cautious-optimizers-improving-training-with","repo_url":"https://github.com/kyleliang919/c-optim","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"cautious-optimizers-improving-training-with","repo_url":"https://github.com/huggingface/pytorch-image-models","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"cautious-optimizers-improving-training-with","repo_url":"https://github.com/zhaoolee/garss","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[],"methods":[{"method_slug":"llama","method_name":"LLaMA"},{"method_slug":"mae","method_name":"MAE"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2411.16085","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2411.16085"}},"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/huggingface/pytorch-image-models","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/kyleliang919/c-optim","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/zhaoolee/garss","reach":{"status":"ok"}}],"summary":{"ran_fixture":1,"ran_violates":1,"ran_draft_wrong":3,"ran":1,"unverified":6},"by_repo_kind":{"official":{"samples":12,"ran":6,"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":"f725bc2d76076485","entry":"apply_rotary_pos_emb","repo":"kyleliang919/c-optim","repo_kind":"official","path":"peft_pretraining/modeling_llama.py","file_url":"https://github.com/kyleliang919/c-optim/blob/HEAD/peft_pretraining/modeling_llama.py","link_basis":"harvester_set","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":"invariant","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f725bc2d76076485"}},{"code_sha256_prefix":"aa5486a3650902d8","entry":"exists","repo":"kyleliang919/c-optim","repo_kind":"official","path":"c_lion.py","file_url":"https://github.com/kyleliang919/c-optim/blob/HEAD/c_lion.py","link_basis":"harvester_set","language":"python","status":"ran_violates","verification_level":1,"contract_check":"VIOLATES","metamorphic_tier":"deterministic","behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"aa5486a3650902d8"}},{"code_sha256_prefix":"cb1f2229e6a594f7","entry":"muon_update","repo":"kyleliang919/c-optim","repo_kind":"official","path":"c_muon.py","file_url":"https://github.com/kyleliang919/c-optim/blob/HEAD/c_muon.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"cb1f2229e6a594f7"}},{"code_sha256_prefix":"c87588f218c6b548","entry":"pad_batch","repo":"kyleliang919/c-optim","repo_kind":"official","path":"opt_utils.py","file_url":"https://github.com/kyleliang919/c-optim/blob/HEAD/opt_utils.py","link_basis":"plan_row","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":"c87588f218c6b548"}},{"code_sha256_prefix":"b99eea6376d1e212","entry":"rotate_half","repo":"kyleliang919/c-optim","repo_kind":"official","path":"peft_pretraining/modeling_llama.py","file_url":"https://github.com/kyleliang919/c-optim/blob/HEAD/peft_pretraining/modeling_llama.py","link_basis":"harvester_set","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":"invariant","behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"b99eea6376d1e212"}},{"code_sha256_prefix":"88b19bfaad9384f8","entry":"zeropower_via_newtonschulz5","repo":"kyleliang919/c-optim","repo_kind":"official","path":"c_muon.py","file_url":"https://github.com/kyleliang919/c-optim/blob/HEAD/c_muon.py","link_basis":"plan_row","language":"python","status":"ran_draft_wrong","verification_level":1,"contract_check":"MISDECLARED","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"88b19bfaad9384f8"}},{"code_sha256_prefix":"9a4937c269491b61","entry":"adam_update","repo":"kyleliang919/c-optim","repo_kind":"official","path":"c_muon.py","file_url":"https://github.com/kyleliang919/c-optim/blob/HEAD/c_muon.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":"9a4937c269491b61"}},{"code_sha256_prefix":"b144323a9c6e08cd","entry":"backward","repo":"kyleliang919/c-optim","repo_kind":"official","path":"nanogpt_speedrun.py","file_url":"https://github.com/kyleliang919/c-optim/blob/HEAD/nanogpt_speedrun.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":"b144323a9c6e08cd"}},{"code_sha256_prefix":"646a0d2ae6a22b76","entry":"get_model_and_dataloader","repo":"kyleliang919/c-optim","repo_kind":"official","path":"moonlight_toy_train.py","file_url":"https://github.com/kyleliang919/c-optim/blob/HEAD/moonlight_toy_train.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":"646a0d2ae6a22b76"}},{"code_sha256_prefix":"2a9e445529f71938","entry":"mm_backward_op","repo":"kyleliang919/c-optim","repo_kind":"official","path":"nanogpt_speedrun.py","file_url":"https://github.com/kyleliang919/c-optim/blob/HEAD/nanogpt_speedrun.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":"2a9e445529f71938"}},{"code_sha256_prefix":"05ddce9e4507d60a","entry":"mm_op","repo":"kyleliang919/c-optim","repo_kind":"official","path":"nanogpt_speedrun.py","file_url":"https://github.com/kyleliang919/c-optim/blob/HEAD/nanogpt_speedrun.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":"05ddce9e4507d60a"}},{"code_sha256_prefix":"c6cbb0406b3d2e05","entry":"zeropower_via_newtonschulz5","repo":"kyleliang919/c-optim","repo_kind":"official","path":"muon.py","file_url":"https://github.com/kyleliang919/c-optim/blob/HEAD/muon.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":"c6cbb0406b3d2e05"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}