google / objax

Apache License 2.0
769 stars 77 forks source link

Implementing 2 phases DP-SGD #178

Closed lberrada closed 3 years ago

lberrada commented 3 years ago

This PR implements a two-phase algorithm for per-sample gradient clipping with the goal of improving memory efficiency for the training of private deep models. The two steps are: (1) accumulate the norms of the gradient per sample and (2) use those norm values to perform a weighted backward pass that is equivalent to per-sample clipping. The user can choose whether to use this new algorithm or the currently implemented one through a boolean argument.

The unit-tests have been adapted to check results for both algorithms.

Let me know if this fits well!

google-cla[bot] commented 3 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

google-cla[bot] commented 3 years ago

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

lberrada commented 3 years ago

Hi, sorry for the late reply, I was on vacation.

I have tried to address all comments, let me know if this is fine or if there is anything else to change.

NB: I have squashed all commits into a single one.

lberrada commented 3 years ago

@shs037 thanks for the review! It now looks like a test is failing in a part of the code that is independent of this PR? Let me know if there is something that I can do on my end

shs037 commented 3 years ago

Sorry we're trying to fix it and will let you know asap.

aterzis-google commented 3 years ago

@lberrada please sync with master and this will solve the problem with failing tests

lberrada commented 3 years ago

Done, thanks!