Skip to main content

entrenar/optim/dp/
mod.rs

1//! Differential Privacy Module (MLOPS-015)
2//!
3//! DP-SGD implementation following Abadi et al. (2016) for privacy-preserving training.
4//!
5//! # Toyota Way: Jidoka (Autonomation)
6//!
7//! Built-in privacy protection stops data leakage. The privacy budget acts as
8//! an Andon system, halting training when privacy guarantees would be violated.
9//!
10//! # Example
11//!
12//! ```ignore
13//! use entrenar::optim::dp::{DpSgdConfig, DpSgd, PrivacyBudget};
14//! use entrenar::optim::SGD;
15//!
16//! let config = DpSgdConfig::new()
17//!     .with_max_grad_norm(1.0)
18//!     .with_noise_multiplier(1.1)
19//!     .with_budget(PrivacyBudget::new(8.0, 1e-5));
20//!
21//! let dp_sgd = DpSgd::new(SGD::new(0.01), config);
22//! ```
23//!
24//! # References
25//!
26//! \[3\] Abadi et al. (2016) - Deep Learning with Differential Privacy
27//! \[4\] Mironov (2017) - Renyi Differential Privacy
28
29pub mod accountant;
30pub mod budget;
31pub mod config;
32pub mod dp_sgd;
33pub mod error;
34pub mod gradient;
35pub mod utils;
36
37#[cfg(test)]
38mod tests;
39
40// Re-exports for API compatibility
41pub use accountant::{compute_rdp_gaussian, rdp_to_dp, RdpAccountant};
42pub use budget::PrivacyBudget;
43pub use config::DpSgdConfig;
44pub use dp_sgd::DpSgd;
45pub use error::{DpError, Result};
46pub use gradient::{add_gaussian_noise, clip_gradient, grad_norm};
47pub use utils::{estimate_noise_multiplier, privacy_cost_per_step};