Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Support to PLD composition #259 #405

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ricardocarvalhods
Copy link
Contributor

Description

Solving "Advance composition in PipelineDP" #259

The approach I'm using is:

  • Propagates noise_standard_deviation (in the case of NaiveAccountant, it is None throughout)
  • When it reaches apply_laplace_mechanism/apply_gaussian_mechanism, if noise_standard_deviation is NOT None, we use it for noise (ignoring eps/delta)
  • Otherwise (if noise_standard_deviation is None), eps/delta are used to add noise.

Tasks:

  • Add noise_standard_deviation to scalar computations and parameters
  • Ajust tests to pass after changes
  • Create tests for scalar computations with noise_standard_deviation
  • Same as above, just to vector sum computation

Additionally:

  • I've also did some minor changes, like two TODOs in the dp_computations.py and formatting.
  • I see that request_budget receives noise_standard_deviation, do you know why? not sure if it is needed, as noise_standard_deviation is only calculated in compute_budgets.

@ricardocarvalhods ricardocarvalhods marked this pull request as draft February 24, 2023 15:14
Copy link
Collaborator

@dvadym dvadym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It looks good. I left some comments.

Please add tests for apply_laplace/gaussian with std_deviation (no need to add tests for all function count/sum etc), because after the next refactoring they will be removed

@@ -103,50 +104,70 @@ def compute_sigma(eps: float, delta: float, l2_sensitivity: float):
delta: The delta value.
l2_sensitivity: The L2 sensitivity.
"""
# TODO: use named arguments, when argument names are added in PyDP on PR
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this TODO

mechanism = dp_mechanisms.LaplaceMechanism(epsilon=eps,
sensitivity=l1_sensitivity)
if noise_standard_deviation is not None:
mechanism = dp_mechanisms.LaplaceMechanism(epsilon=1 /
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comment that here workaround is used, since we can't set the Laplace parameter directly

mechanism = MechanismSpec(MechanismType.LAPLACE)
print(mechanism.noise_standard_deviation())
mechanism = MechanismSpec(MechanismType.LAPLACE)
self.assertEqual(None, mechanism.noise_standard_deviation)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: self.assertNone(

count_noise_standard_deviation = \
sum_noise_standard_deviation = \
2*dp_params.noise_standard_deviation \
if dp_params.noise_standard_deviation is not None \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: maybe something like that

noise_std = None
if dp_params.noise_standard_deviation is not None:
  noise_std = 2*dp_params.noise_standard_deviation
count_noise_standard_deviation = sum_noise_standard_deviation = noise_std

return mechanism.add_noise(1.0 * value)


def _add_random_noise(
value: float,
eps: float,
delta: float,
noise_standard_deviation: float,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional[float]?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants