{"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/sampa-sharpness-aware-minimization","title":"SAMPa: Sharpness-aware Minimization Parallelized","arxiv_id":"2410.10683","date":"2024-10-14","proceeding":null,"authors":["Wanyun Xie","Thomas Pethick","Volkan Cevher"],"abstract":"Sharpness-aware minimization (SAM) has been shown to improve the generalization of neural networks. However, each SAM update requires \\emph{sequentially} computing two gradients, effectively doubling the per-iteration cost compared to base optimizers like SGD. We propose a simple modification of SAM, termed SAMPa, which allows us to fully parallelize the two gradient computations. SAMPa achieves a twofold speedup of SAM under the assumption that communication costs between devices are negligible. Empirical results show that SAMPa ranks among the most efficient variants of SAM in terms of computational time. Additionally, our method consistently outperforms SAM across both vision and language tasks. Notably, SAMPa theoretically maintains convergence guarantees even for \\emph{fixed} perturbation sizes, which is established through a novel Lyapunov function. We in fact arrive at SAMPa by treating this convergence guarantee as a hard requirement -- an approach we believe is promising for developing SAM-based methods in general. Our code is available at \\url{https://github.com/LIONS-EPFL/SAMPa}.","url_abs":"https://arxiv.org/abs/2410.10683v1","url_pdf":"https://arxiv.org/pdf/2410.10683v1.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":"sampa-sharpness-aware-minimization","repo_url":"https://github.com/lions-epfl/sampa","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}}],"tasks":[],"methods":[{"method_slug":"base","method_name":"BASE"},{"method_slug":"sam","method_name":"SAM"},{"method_slug":"sgd","method_name":"SGD"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"syntology_url":null,"atlas_url":"https://app.syntology.ai/?focus=2410.10683","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2410.10683"}},"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/LIONS-EPFL/SAMPa","reach":{"status":"ok"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/lions-epfl/sampa","reach":{"status":"ok"}}],"summary":{"ran":13,"unverified":2},"by_repo_kind":{"official":{"samples":15,"ran":13,"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":15,"samples":[{"code_sha256_prefix":"dfb395bae3d07d76","entry":"DenseNet121","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"model/densenet.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/model/densenet.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"dfb395bae3d07d76"}},{"code_sha256_prefix":"f295fe3c209ecf78","entry":"DenseNet169","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"model/densenet.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/model/densenet.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f295fe3c209ecf78"}},{"code_sha256_prefix":"6383aee1c940e7a5","entry":"DenseNet201","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"model/densenet.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/model/densenet.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"6383aee1c940e7a5"}},{"code_sha256_prefix":"ac62432dc5134b0d","entry":"make_layers","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"model/vgg.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/model/vgg.py","link_basis":"plan_row","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"ac62432dc5134b0d"}},{"code_sha256_prefix":"a51802083eb2dcec","entry":"perturbation_loss_log","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"model/smooth_cross_entropy.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/model/smooth_cross_entropy.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a51802083eb2dcec"}},{"code_sha256_prefix":"a10d10e7bcf4cb4a","entry":"resnet20","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"model/resnet.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/model/resnet.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"a10d10e7bcf4cb4a"}},{"code_sha256_prefix":"85364deb653f2cf6","entry":"resnet32","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"model/resnet.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/model/resnet.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"85364deb653f2cf6"}},{"code_sha256_prefix":"cd8b7f0a3a1b23f4","entry":"resnet44","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"model/resnet.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/model/resnet.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"cd8b7f0a3a1b23f4"}},{"code_sha256_prefix":"8ba7b4a94a39f790","entry":"smooth_crossentropy","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"model/smooth_cross_entropy.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/model/smooth_cross_entropy.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"8ba7b4a94a39f790"}},{"code_sha256_prefix":"f86df65986410c1d","entry":"smooth_crossentropy","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"utility.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/utility.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"f86df65986410c1d"}},{"code_sha256_prefix":"c1ad6496b7bd2b05","entry":"unflatten","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"utility.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/utility.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"c1ad6496b7bd2b05"}},{"code_sha256_prefix":"d61c738bf16ec3c0","entry":"vgg11","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"model/vgg.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/model/vgg.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"d61c738bf16ec3c0"}},{"code_sha256_prefix":"09c336c3ecb596a3","entry":"vgg11_bn","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"model/vgg.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/model/vgg.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"09c336c3ecb596a3"}},{"code_sha256_prefix":"caf601cac7f2ec8c","entry":"get_dataset","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"get_dataset.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/get_dataset.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"caf601cac7f2ec8c"}},{"code_sha256_prefix":"be5e295a85a5ce89","entry":"perturbation_loss_tanh","repo":"LIONS-EPFL/SAMPa","repo_kind":"official","path":"model/smooth_cross_entropy.py","file_url":"https://github.com/LIONS-EPFL/SAMPa/blob/HEAD/model/smooth_cross_entropy.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"NONE","inline_ok":false,"mcp_get_code":{"code_sha256":"be5e295a85a5ce89"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}