{"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/opacus-user-friendly-differential-privacy","title":"Opacus: User-Friendly Differential Privacy Library in PyTorch","arxiv_id":"2109.12298","date":"2021-09-25","proceeding":null,"authors":["Ashkan Yousefpour","Igor Shilov","Alexandre Sablayrolles","Davide Testuggine","Karthik Prasad","Mani Malek","John Nguyen","Sayan Ghosh","Akash Bharadwaj","Jessica Zhao","Graham Cormode","Ilya Mironov"],"abstract":"We introduce Opacus, a free, open-source PyTorch library for training deep learning models with differential privacy (hosted at opacus.ai). Opacus is designed for simplicity, flexibility, and speed. It provides a simple and user-friendly API, and enables machine learning practitioners to make a training pipeline private by adding as little as two lines to their code. It supports a wide variety of layers, including multi-head attention, convolution, LSTM, GRU (and generic RNN), and embedding, right out of the box and provides the means for supporting other user-defined layers. Opacus computes batched per-sample gradients, providing higher efficiency compared to the traditional \"micro batch\" approach. In this paper we present Opacus, detail the principles that drove its implementation and unique features, and benchmark it against other frameworks for training models with differential privacy as well as standard PyTorch.","url_abs":"https://arxiv.org/abs/2109.12298v4","url_pdf":"https://arxiv.org/pdf/2109.12298v4.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":"opacus-user-friendly-differential-privacy","repo_url":"https://github.com/pytorch/opacus","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok","spdx":"Apache-2.0"}},{"paper_slug":"opacus-user-friendly-differential-privacy","repo_url":"https://github.com/alexbie98/dpgan-revisit","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"opacus-user-friendly-differential-privacy","repo_url":"https://github.com/woodyx218/private_vision","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null}],"tasks":[],"methods":[{"method_slug":"gru","method_name":"GRU"}],"datasets_introduced":[],"methods_introduced":[],"results":[],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2109.12298","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2109.12298"}},"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/pytorch/opacus","reach":{"status":"ok","spdx":"Apache-2.0"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/woodyx218/private_vision","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/alexbie98/dpgan-revisit","reach":null}],"summary":{"ran_fixture":1,"ran_honours":2,"unverified":9},"by_repo_kind":{"listed":{"samples":11,"ran":2,"repositories":1},"community":{"samples":1,"ran":1,"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":"dc7c6bd894c3af35","entry":"_compute_eps_cks","repo":"woodyx218/private_vision","repo_kind":"listed","path":"private_vision/privacy_engine.py","file_url":"https://github.com/woodyx218/private_vision/blob/HEAD/private_vision/privacy_engine.py","link_basis":"first_harvest_node","language":"python","status":"ran_fixture","verification_level":1,"contract_check":"RAISES","metamorphic_tier":null,"behaviour_fingerprint":true,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"dc7c6bd894c3af35"}},{"code_sha256_prefix":"0fc5cc5c20c50872","entry":"_get_sigma_with_target_epsilon","repo":"woodyx218/private_vision","repo_kind":"listed","path":"private_vision/privacy_engine.py","file_url":"https://github.com/woodyx218/private_vision/blob/HEAD/private_vision/privacy_engine.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"0fc5cc5c20c50872"}},{"code_sha256_prefix":"dc66a9c5c516e132","entry":"test","repo":"meta-pytorch/opacus","repo_kind":"community","path":"examples/mnist.py","file_url":"https://github.com/meta-pytorch/opacus/blob/HEAD/examples/mnist.py","link_basis":"first_harvest_node","language":"python","status":"ran_honours","verification_level":1,"contract_check":"HONOURS","metamorphic_tier":"well_formed","behaviour_fingerprint":false,"licence":"Apache-2.0","inline_ok":true,"mcp_get_code":{"code_sha256":"dc66a9c5c516e132"}},{"code_sha256_prefix":"52ccc99b2a6cde9c","entry":"PrivacyEngine","repo":"woodyx218/private_vision","repo_kind":"listed","path":"private_vision/privacy_engine.py","file_url":"https://github.com/woodyx218/private_vision/blob/HEAD/private_vision/privacy_engine.py","link_basis":"first_harvest_node","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":"52ccc99b2a6cde9c"}},{"code_sha256_prefix":"975a9efbff2d7c7a","entry":"_eps_from_gdp","repo":"woodyx218/private_vision","repo_kind":"listed","path":"private_vision/privacy_engine.py","file_url":"https://github.com/woodyx218/private_vision/blob/HEAD/private_vision/privacy_engine.py","link_basis":"first_harvest_node","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":"975a9efbff2d7c7a"}},{"code_sha256_prefix":"6a82b741a671c5d4","entry":"_eps_from_glw","repo":"woodyx218/private_vision","repo_kind":"listed","path":"private_vision/privacy_engine.py","file_url":"https://github.com/woodyx218/private_vision/blob/HEAD/private_vision/privacy_engine.py","link_basis":"first_harvest_node","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":"6a82b741a671c5d4"}},{"code_sha256_prefix":"bd9bd46c79d2c238","entry":"_eps_from_rdp","repo":"woodyx218/private_vision","repo_kind":"listed","path":"private_vision/privacy_engine.py","file_url":"https://github.com/woodyx218/private_vision/blob/HEAD/private_vision/privacy_engine.py","link_basis":"first_harvest_node","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":"bd9bd46c79d2c238"}},{"code_sha256_prefix":"68999f7567ff1192","entry":"_eps_from_rdp_cks","repo":"woodyx218/private_vision","repo_kind":"listed","path":"private_vision/privacy_engine.py","file_url":"https://github.com/woodyx218/private_vision/blob/HEAD/private_vision/privacy_engine.py","link_basis":"first_harvest_node","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":"68999f7567ff1192"}},{"code_sha256_prefix":"12bce719b6a3b060","entry":"get_sigma_from_gdp","repo":"woodyx218/private_vision","repo_kind":"listed","path":"private_vision/privacy_engine.py","file_url":"https://github.com/woodyx218/private_vision/blob/HEAD/private_vision/privacy_engine.py","link_basis":"first_harvest_node","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":"12bce719b6a3b060"}},{"code_sha256_prefix":"665dc7e22ef05056","entry":"get_sigma_from_glw","repo":"woodyx218/private_vision","repo_kind":"listed","path":"private_vision/privacy_engine.py","file_url":"https://github.com/woodyx218/private_vision/blob/HEAD/private_vision/privacy_engine.py","link_basis":"first_harvest_node","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":"665dc7e22ef05056"}},{"code_sha256_prefix":"afe0f1fc95083e88","entry":"get_sigma_from_rdp","repo":"woodyx218/private_vision","repo_kind":"listed","path":"private_vision/privacy_engine.py","file_url":"https://github.com/woodyx218/private_vision/blob/HEAD/private_vision/privacy_engine.py","link_basis":"first_harvest_node","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":"afe0f1fc95083e88"}},{"code_sha256_prefix":"080da196349fb3a7","entry":"get_sigma_from_rdp_cks","repo":"woodyx218/private_vision","repo_kind":"listed","path":"private_vision/privacy_engine.py","file_url":"https://github.com/woodyx218/private_vision/blob/HEAD/private_vision/privacy_engine.py","link_basis":"first_harvest_node","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":"080da196349fb3a7"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}