pub struct PerRoundBudget { /* private fields */ }Expand description
Wraps a PrivacyBudget and enforces per-round epsilon/delta caps.
This prevents any single training round from consuming a disproportionate share of the total budget.
Implementations§
Source§impl PerRoundBudget
impl PerRoundBudget
Sourcepub fn new(
epsilon_total: f64,
delta_total: f64,
max_epsilon_per_round: f64,
max_delta_per_round: f64,
) -> Result<Self, BudgetError>
pub fn new( epsilon_total: f64, delta_total: f64, max_epsilon_per_round: f64, max_delta_per_round: f64, ) -> Result<Self, BudgetError>
Create a new per-round budget.
§Errors
Returns BudgetError::InvalidBudget if the underlying PrivacyBudget
construction fails, or if per-round caps are non-positive.
Sourcepub fn budget(&self) -> &PrivacyBudget
pub fn budget(&self) -> &PrivacyBudget
Reference to the underlying total budget.
Sourcepub fn max_epsilon_per_round(&self) -> f64
pub fn max_epsilon_per_round(&self) -> f64
Maximum epsilon allowed per round.
Sourcepub fn max_delta_per_round(&self) -> f64
pub fn max_delta_per_round(&self) -> f64
Maximum delta allowed per round.
Sourcepub fn begin_round(&self) -> Result<RoundGuard, BudgetError>
pub fn begin_round(&self) -> Result<RoundGuard, BudgetError>
Begin a new round.
Checks that the total budget has at least max_epsilon_per_round and
max_delta_per_round remaining before issuing the guard.
§Errors
BudgetError::BudgetExceededif epsilon remaining < per-round cap.BudgetError::DeltaExceededif delta remaining < per-round cap.
Sourcepub fn commit_round(
&self,
_guard: RoundGuard,
epsilon_used: f64,
delta_used: f64,
) -> Result<(), BudgetError>
pub fn commit_round( &self, _guard: RoundGuard, epsilon_used: f64, delta_used: f64, ) -> Result<(), BudgetError>
Commit the round, consuming the actual epsilon_used / delta_used.
§Errors
BudgetError::BudgetExceededifepsilon_used>max_epsilon_per_round.BudgetError::DeltaExceededifdelta_used>max_delta_per_round.- Propagates errors from
PrivacyBudget::consume.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PerRoundBudget
impl RefUnwindSafe for PerRoundBudget
impl Send for PerRoundBudget
impl Sync for PerRoundBudget
impl Unpin for PerRoundBudget
impl UnsafeUnpin for PerRoundBudget
impl UnwindSafe for PerRoundBudget
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more