yuxiangw / autodp

autodp: A flexible and easy-to-use package for differential privacy
Apache License 2.0
260 stars 52 forks source link

Composing different mechanism with different sensitivies #35

Closed SaitejaUtpala closed 1 year ago

SaitejaUtpala commented 2 years ago

@yuxiangw Great talk at MIT!. I have a question regarding composing difference mechanisms with different rounds and with different sensitivities. Assume that am we are composing in following way

Then to get epsilon for delta = 1e-6, this is right way to pass parameter configs right

class TestMech(Mechanism):
    def __init__(self, params, name="TestMech"):
        Mechanism.__init__(self)
        subsample = AmplificationBySampling(PoissonSampling=False)
        mech1 = GaussianMechanism(sigma=params["sigma1"] )
        mech2 = GaussianMechanism(sigma=params["sigma2"] )
        mech2.neighboring = "replace_one"
        submech2 = subsample(mech2, params["prob"], improved_bound_flag=True)
        compose = Composition()
        mech = compose([mech1, submech2], [params["T1"] , params["T2"]])
        rdp_total = mech.RenyiDP
        self.propagate_updates(rdp_total, type_of_update="RDP")
params = {}
params["sigma1"] = sigma1/(L1)  # This is correct right ?
params["sigma2"] = sigma2/(L2)  # This is correct right ?
params["T1"] = T1
params["T2"] = T2
mech = TestMech(params)
mech.get_approxDP(delta=1e-6)

My main question is about scaling of sigma parameters params["sigma1"] = sigma1/(L1) and params["sigma2"] = sigma2/(L2), as far as I can understand this seems necessary right? Thanks!

yuxiangw commented 2 years ago

Yes, the scaling parameters are correct. mechanism_zoo.GaussianMechanism takes sigma as the noise as if the sensitivity is 1.
Instead of

    rdp_total = mech.RenyiDP
  self.propagate_updates(rdp_total, type_of_update="RDP")

I usually just use the following instead:

self.set_all_representation(mech)

which is equivalent to your code in this case but is slightly more general.

btw, you will have to add params["prob"] for the code to work I think.

SaitejaUtpala commented 2 years ago

@yuxiangw. Thanks! one more question if we want to pick best leanring rate (by picking best training error achieved) privately. Is there any reference ?

yuxiangw commented 2 years ago

Sorry I just saw this. I would Papernot and Steinke https://arxiv.org/abs/2110.03620 is the SOTA on hyperparameter tuning with DP. (and RDP). A student of mine has an implementation but I don't know her timeline of merging it into autodp.

SaitejaUtpala commented 2 years ago

@yuxiangw Thanks for the pointer!. Will take a look. Is there a way to cite this library ? I don't see any paper associated with the library.

yuxiangw commented 1 year ago

You should cite the work that proposes the specific method you used. autodp is here to help with privacy accounting and to put everything together. the first version of autodp was a release as part of this paper from AISTATS'19 and then at the Journal of Privacy and Confidentiality https://arxiv.org/abs/1808.00087.

I also typically just cite the repo itself.

@misc{autodp, author = {autodp}, title = {AutoDP: Automating Differential Privacy Computation}, year = {2021}, url = {https://github.com/yuxiangw/autodp}, }