Skip to content

Conversation

@tcbegley
Copy link
Contributor

@tcbegley tcbegley commented Sep 1, 2022

This PR implements a new accountant PRVAccountant based on the paper Numerical Composition of Differential Privacy.

Code inspired heavily by the code that accompanied the paper: https://github.com/microsoft/prv_accountant

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Docs change / refactoring / dependency upgrade

Motivation and Context / Related issue

See #378

How Has This Been Tested (if it applies)

I have tested these changes with the following scripts, but would welcome suggestions on how to test further or write unit tests to cover these changes:

Checklist

I have not yet written docstrings or tests for these changes both as it was slightly unclear to me how best to proceed, but also because I would like to validate the approach taken in this initial implementation before polishing.

  • The documentation is up-to-date with the changes I made.
  • I have read the CONTRIBUTING document and completed the CLA (see CONTRIBUTING).
  • All tests passed, and additional code has been covered with new tests.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 1, 2022
@facebook-github-bot
Copy link
Contributor

@tcbegley has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@romovpa romovpa linked an issue Sep 13, 2022 that may be closed by this pull request
@tcbegley tcbegley marked this pull request as ready for review September 13, 2022 13:48
@romovpa romovpa self-requested a review September 13, 2022 13:50
@romovpa
Copy link
Contributor

romovpa commented Sep 13, 2022

@tcbegley Thank you for contributing to Opacus! Great job!

You asked me a few questions in the chat, here is the top of my mind:

  1. Documentation
    • Mandatory: docstring for PRVAccountant with the reference to the paper, short description of benefits/limitations of this accountant, anything that the user should know before using this accountant
    • Optional: put a concise engineer-faced description of the accounting method that allows to quickly understand how it works without having much context and going into deep details (which can be clarified by reading the paper); I think you may put some of your notes in the docstring
    • Ideal: use this accountant in one of the tutorials (or create a new one); this is another big task though.
  2. Testing
    • We have accountant_test.py that checks for regressions, please add PRVAccountant there.
    • However, the unit tests does not validate the correctness of the theory and the implementation. One known way to do the validation is to run membership inference attacks. We have privacy_lint for this, the new API that allows to easily do that is on the way. If anyone interested, validating accountants and mechanisms with the MI attacks is another good tasks / mini-project. cc @alexandresablayrolles

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Comment on lines +76 to +99
total_compositions = sum(max_self_compositions)

rdp_accountant = RDPAccountant()
for prv, max_self_composition in zip(prvs, max_self_compositions):
rdp_accountant.history.append(
(prv.noise_multiplier, prv.sample_rate, max_self_composition)
)

L_max = rdp_accountant.get_epsilon(delta_error / 4)

for prv, max_self_composition in zip(prvs, max_self_compositions):
rdp_accountant = RDPAccountant()
rdp_accountant.history = [(prv.noise_multiplier, prv.sample_rate, 1)]
L_max = max(
L_max,
rdp_accountant.get_epsilon(delta=delta_error / (8 * total_compositions)),
)

# FIXME: this implementation is adapted from the code accompanying the paper, but
# disagrees subtly with the theory from remark 5.6. It's not immediately clear this
# gives the right guarantees in all cases, though it's fine for eps_error < 1 and
# hence generic cases.
# cf. https://github.com/microsoft/prv_accountant/discussions/34
return max(L_max, eps_error) + 3
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm in two minds about whether to keep this as it is which follows the implementation from microsoft/prv_accountant or to follow the paper more precisely. It's not immediately clear to me that this implementation always satisfies the conditions required in the paper without making an assumption like eps_error < 1.

The changes required are minor and would look something like the following

-    L_max = rdp_accountant.get_epsilon(delta_error / 4)
+    L_max = rdp_accountant.get_epsilon(delta_error / 4) + eps_error
-    return max(L_max, eps_error) + 3
+    return L_max + 2

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@tcbegley has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot
Copy link
Contributor

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@tcbegley tcbegley deleted the prv-accountant branch November 8, 2022 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[New accountant] Numerical composition

3 participants