Skip to content

Commit

Permalink
Add *kwargs to get_epsilon
Browse files Browse the repository at this point in the history
Summary: Add **kwargs as argument to the get_epsilon() function in accountants. It allows for building custom PrivacyEngines that take in additional arguments.

Differential Revision: D67514874
  • Loading branch information
iden-kalemaj authored and facebook-github-bot committed Dec 20, 2024
1 parent ed1bd0b commit 6497d82
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion opacus/accountants/gdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def step(self, *, noise_multiplier: float, sample_rate: float):
else:
self.history = [(noise_multiplier, sample_rate, 1)]

def get_epsilon(self, delta: float, poisson: bool = True) -> float:
def get_epsilon(self, delta: float, poisson: bool = True, **kwargs) -> float:
"""
Return privacy budget (epsilon) expended so far.
Expand Down
7 changes: 6 additions & 1 deletion opacus/accountants/prv.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ def step(self, *, noise_multiplier: float, sample_rate: float):
self.history.append((noise_multiplier, sample_rate, 1))

def get_epsilon(
self, delta: float, *, eps_error: float = 0.01, delta_error: float = None
self,
delta: float,
*,
eps_error: float = 0.01,
delta_error: float = None,
**kwargs,
) -> float:
"""
Return privacy budget (epsilon) expended so far.
Expand Down
5 changes: 4 additions & 1 deletion opacus/accountants/rdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def get_privacy_spent(
return float(eps), float(best_alpha)

def get_epsilon(
self, delta: float, alphas: Optional[List[Union[float, int]]] = None
self,
delta: float,
alphas: Optional[List[Union[float, int]]] = None,
**kwargs,
):
"""
Return privacy budget (epsilon) expended so far.
Expand Down

0 comments on commit 6497d82

Please sign in to comment.