Closed Solosneros closed 7 months ago
@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
@Solosneros has updated the pull request. You must reimport the pull request before landing.
@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
This pull request has been merged in pytorch/opacus@ad084da9e46b22d6bc341958855a04c00ffb9b1f.
Types of changes
Motivation and Context / Related issue
Hi,
this PR fixes https://github.com/pytorch/opacus/issues/601 and https://github.com/pytorch/opacus/issues/604.
It will introduce the same fix as in https://github.com/microsoft/prv_accountant/pull/38. Lukas (author of prv accountant, @wulu473) said that
In general, adding any additional points is safe and won't affect the robustness negatively.
The cause of these errors seems to be the grid for computing the
mean()
function of thePrivacyRandomVariableTruncated
class. The grid (points
variable) used to compute the mean is constant apart from the lowest (self.t_min
) and highest point (self.t_max
).This PR determines the grid (
points
variable) based on the lowest and highest point. More information is below.Best
Observation
I debugged the code and arrived at some point at the
mean()
function of thePrivacyRandomVariableTruncated
class. The grid (points
variable) used to compute the mean is constant apart from the lowest (self.t_min
) and highest point (self.t_max
). See the line of code here. It looks like this[self.tmin, -0.1, -0.01, -0.001, -0.0001, -1e-05, 1e-05, 0.0001, 0.001, 0.01, 0.1, self.tmax]
.It seems that the
tmin
andtmax
are of the order of[-12,12]
for the examples that I posted above and even up to[-48,48]
for the example that @jeandut posted in the https://github.com/pytorch/opacus/issues/604 issue whereas they are more like[-7,7]
for the readme example for DP-SGD.We suspect that the integration breaks down when the gridspacing between between
tmin
/tmax
get's too large.Proposed solution
Determine the points grid based on
tmin
andtmax
but determines the start and end of the logspace based ontmin
andtmax
.Before: (https://github.com/pytorch/opacus/blob/95df0904ae5d2b3aaa26b708e5067e9271624036/opacus/accountants/analysis/prv/prvs.py#L99-L106)
After:
How Has This Been Tested (if it applies)
I ran the examples from the issues https://github.com/pytorch/opacus/issues/601 and https://github.com/pytorch/opacus/issues/604 and they don't break anymore.
Checklist
Not able to run all tests locally and unsure if new tests should be added.