Search

Search papers and lessons

Privacy Amplification by Subsampling

Level 4 · 11 min read

If a private mechanism only ever sees a random sample of the data, its privacy loss shrinks, roughly in proportion to the sampling rate.

On this page

  • Colour = topic mix
  • Probability
  • Discrete math
  • Calculus
  • Linear algebra
  • Algorithms
  • Security & cryptography
  • ReadReady to readNot yet

TL;DR

Suppose a mechanism is already differentially private, and before it runs we keep each record only with some small probability. The random sample hides each person more than the full data did, so the privacy loss is smaller than the original one. For a sampling rate qq and an original budget ε\varepsilon, the new budget is ln⁡(1+q(eε−1))\ln(1 + q(e^{\varepsilon} - 1)), which is roughly qq times the original cost when qq is small.

Builds on: Differential Privacy, Bernoulli Distribution, Random Sampling · Leads to: Moments Accountant, Differentially Private SGD

Where it's used

Training with private gradients. A common way to train a neural network with differential privacy is to draw a random batch of training examples at each step, compute a clipped gradient on that batch with stochastic gradient descent, and add noise. The batch is a random sample, so each example enters a given step only some of the time. The amplification result is what lets the total privacy cost over many steps stay within a usable budget. The method is described in the DP-SGD paper of Abadi and colleagues, and the DP-SGD lesson shows the training loop.

Releasing statistics from a sample. A statistics office that answers queries on a random subset of households gets privacy for free on top of the mechanism it already uses. The sample itself is a privacy tool: a household that was not drawn cannot affect the answer at all.

Accounting for many steps. Analysts who track the privacy cost of a long training run need to know how much each sampled step costs. Tighter accounting, such as the moments accountant, builds on this result, because each step is a subsampled mechanism.

How it works

Take one record, called rr, and a mechanism MM that is ε\varepsilon-differentially private. Suppose MM is run on a random sample of the data. Each record enters the sample with probability qq, independently of the others. We want to know how much one person's presence can change what an outsider sees.

We use a small setting with round numbers: ε=1\varepsilon = 1 and q=0.5q = 0.5. Each record is kept with probability one half.

  1. Fix everything except one record. Let SS be the sample of the other records, which we hold fixed. The only difference between the two worlds is whether rr is in the sample. Check: this is exactly the neighbouring comparison of Differential Privacy, with rr added or removed.
  2. Name the two outputs. Let p0(x)p_0(x) be the chance that MM releases xx when rr is absent, and p1(x)p_1(x) the chance when rr is present. Because MM is ε\varepsilon-private, p1(x)≤eε p0(x)p_1(x) \le e^{\varepsilon} \, p_0(x), where eεe^{\varepsilon} is the Exponential Function of the budget. Check: with ε=1\varepsilon = 1, p1p_1 is at most 2.7182.718 times p0p_0.
  3. Mix the two cases. By the Law of Total Probability, with probability qq the record is sampled, so the release comes from p1p_1. With probability 1−q1 - q it is not, so the release comes from p0p_0. The chance of releasing xx when rr is a candidate is the mixture (1−q) p0(x)+q p1(x)(1-q)\,p_0(x) + q\,p_1(x). Check: the mixture weights add to 1.
  4. Bound the mixture. Compare the mixture with the world where rr is absent, p0(x)p_0(x). Replace p1(x)p_1(x) by its largest allowed value eεp0(x)e^{\varepsilon} p_0(x). The ratio becomes (1−q)+q eε=1+q(eε−1)(1-q) + q\,e^{\varepsilon} = 1 + q(e^{\varepsilon} - 1). Check: with q=0.5q = 0.5 and ε=1\varepsilon = 1, this is 1+0.5×1.718=1.8591 + 0.5 \times 1.718 = 1.859.
  5. Turn the ratio into a budget. The new budget is the natural Logarithm of that ratio, ε′=ln⁡(1.859)≈0.620\varepsilon' = \ln(1.859) \approx 0.620. Check: 0.6200.620 is less than the original ε=1\varepsilon = 1.
  6. Read the result. Sampling half the records cut the privacy loss from 1 to about 0.62. Sampling fewer records cuts it further, because the mixture puts less weight on the case where rr matters.

The math

Definition: Poisson subsampling

Given a dataset DD and a rate qq with 0<q<10 \lt q \lt 1, the subsampled dataset Sampleq(D)\mathrm{Sample}_q(D) keeps each record of DD independently with probability qq. Each record's inclusion is a Bernoulli trial with success probability qq, so the sample size is a binomial random variable with mean q ∣D∣q\,|D|.

The mechanism M∘SampleqM \circ \mathrm{Sample}_q runs the subsampling first and then MM. Its privacy is the question the walkthrough answers.

Step 1 in symbols: fix the other records

Write the dataset as D=S∪{r}D = S \cup \{r\} and its neighbour as D′=SD' = S. Condition on the sample of the other records, so that the only randomness left is whether rr is kept. The output density of the subsampled mechanism is then

pmix(x)=(1−q) p0(x)+q p1(x),p_{\text{mix}}(x) = (1 - q)\, p_0(x) + q\, p_1(x),

where p0p_0 is the density of M(S)M(S) and p1p_1 the density of M(S∪{r})M(S \cup \{r\}). This is the mixture from Step 3 of the walkthrough.

Step 2 in symbols: use the privacy of the base mechanism

Because SS and S∪{r}S \cup \{r\} are neighbours, the definition of Differential Privacy gives

p1(x)≤eε p0(x)for every output x.p_1(x) \le e^{\varepsilon} \, p_0(x) \quad \text{for every output } x.

This is the only place the original guarantee is used.

Step 3 in symbols: the density ratio

Divide the mixture by p0(x)p_0(x) and apply the bound from Step 2:

pmix(x)p0(x)=(1−q)+qp1(x)p0(x)≤(1−q)+q eε=1+q(eε−1).\frac{p_{\text{mix}}(x)}{p_0(x)} = (1 - q) + q \frac{p_1(x)}{p_0(x)} \le (1 - q) + q\, e^{\varepsilon} = 1 + q\left(e^{\varepsilon} - 1\right).

This is the direction the walkthrough uses. The bound on the reverse ratio p0(x)/pmix(x)p_0(x) / p_{\text{mix}}(x) needs a separate argument, which this lesson does not give; the Balle and colleagues paper in the sources proves the two-sided bound. The one-sided ratio is what the definition needs for the walkthrough's comparison.

Step 4 in symbols: the new budget

Setting ε′=ln⁡ ⁣(1+q(eε−1))\varepsilon' = \ln\!\big(1 + q(e^{\varepsilon} - 1)\big) turns the ratio bound into the form eε′e^{\varepsilon'}. For small qq, using eε−1≈εe^{\varepsilon} - 1 \approx \varepsilon for small ε\varepsilon is not enough; the exact expression is the one to use. The key property is that ε′\varepsilon' grows with qq, so a smaller sampling rate gives a smaller budget.

Step 5 in symbols: the approximate version

For the approximate guarantee with an extra failure probability δ\delta, the same result gives δ′=q δ\delta' = q\,\delta, so the failure probability is also scaled by qq. This is the form used with the Gaussian Mechanism. The derivation of the δ\delta part needs more care than the ε\varepsilon part shown here, so this lesson states it without proof; the Balle and colleagues paper in the sources gives the full argument.

Worked examples

Example
Example 1: one output, one record

Take ε=1\varepsilon = 1 and q=0.5q = 0.5. Suppose for one output xx the base mechanism gives p0(x)=0.2p_0(x) = 0.2 and the largest allowed p1(x)=0.2 e≈0.5436p_1(x) = 0.2\,e \approx 0.5436.

  1. The mixture under the subsampled mechanism is (1−0.5)(0.2)+0.5(0.5436)=0.1+0.2718=0.3718(1 - 0.5)(0.2) + 0.5(0.5436) = 0.1 + 0.2718 = 0.3718.
  2. Divide by p0(x)=0.2p_0(x) = 0.2: the ratio is 0.3718/0.2=1.8590.3718 / 0.2 = 1.859.
  3. The bound from Step 4 is 1+0.5(e−1)=1+0.5×1.718=1.8591 + 0.5(e - 1) = 1 + 0.5 \times 1.718 = 1.859. The two agree.
  4. Take the logarithm: ln⁡(1.859)≈0.620\ln(1.859) \approx 0.620.

Interpretation: for this output, sampling halved the chance ratio from e1≈2.72e^{1} \approx 2.72 to 1.8591.859, which is a privacy budget of about 0.62 instead of 1.

Example
Example 2: a standard sampling rate

Take ε=1\varepsilon = 1 and q=0.01q = 0.01, so each record is kept with probability 1 in 100.

  1. Compute e1−1=1.718e^{1} - 1 = 1.718.
  2. Multiply by qq: 0.01×1.718=0.017180.01 \times 1.718 = 0.01718.
  3. Add 1: 1.017181.01718.
  4. Take the logarithm: ln⁡(1.01718)≈0.0170\ln(1.01718) \approx 0.0170.
  5. Compare with the original budget: 1/0.0170≈591 / 0.0170 \approx 59, so the new budget is about 59 times smaller.

Interpretation: when only 1 record in 100 is used, almost all of the privacy loss disappears. The budget is roughly q(eε−1)q(e^{\varepsilon} - 1), which is why small sampling rates are so useful.

Example
Example 3: one training step on a realistic dataset

A training set has 60,000 examples, and each step uses a random batch of 256 of them. Treat one step as a mechanism that would cost ε=1\varepsilon = 1 on the full data, and use the batch as the sample.

  1. The sampling rate is q=256/60,000≈0.004267q = 256 / 60{,}000 \approx 0.004267.
  2. Compute q(e1−1)=0.004267×1.718≈0.007331q(e^{1} - 1) = 0.004267 \times 1.718 \approx 0.007331.
  3. Add 1 and take the logarithm: ln⁡(1.007331)≈0.00730\ln(1.007331) \approx 0.00730.
  4. Compare with the unsampled step: 0.007300.00730 is about one hundred and thirty-seven times smaller than 11.
  5. Check: the batch holds about 0.4 per cent of the data, and the cost per step falls by about the same proportion, as the rough formula predicts.

Interpretation: a single step is cheap, so a long training run that takes many steps accumulates cost much more slowly than the number of steps would suggest. Tracking that accumulation exactly is the job of the accounting method in Moments Accountant.

Try it: with q=0.01q = 0.01 and ε=2\varepsilon = 2, what is the new budget ε′\varepsilon'? Answer: e2≈7.389e^{2} \approx 7.389, so 1+0.01×6.389=1.063891 + 0.01 \times 6.389 = 1.06389, and ln⁡(1.06389)≈0.0619\ln(1.06389) \approx 0.0619.

Common mistakes and tradeoffs

It is tempting to think sampling is a separate privacy guarantee that can be added on its own. In fact it only amplifies a mechanism that is already private. If the base mechanism has no guarantee, a random sample does not create one, because a sample of a leaking answer still leaks.

It is tempting to think a smaller sample always means better privacy at no cost. In fact the smaller sample also means less data reaches the mechanism, so the answer or model is less accurate. The privacy gain and the accuracy loss have to be weighed together, which is why training systems tune the batch size.

It is tempting to think the amplified budget is simply qq times the original. In fact the exact expression is ln⁡(1+q(eε−1))\ln(1 + q(e^{\varepsilon} - 1)). The simple product is a good estimate for small qq and small ε\varepsilon, but it is not the bound to quote.

Subsampling works best when the sampling is genuinely random and independent of the data. A fixed rule such as "take every tenth row" does not have this guarantee, because an attacker who knows the rule knows which records were used. It also depends on the adjacency notion. The result above assumes each record is included independently; sampling without replacement at a fixed size needs a different analysis.

Use this amplification when the training or query procedure already samples at random, as minibatch training does. Do not use it as a substitute for a mechanism with a guarantee. Alternatives include computing the privacy cost with a tighter accountant, or reducing the number of steps, though both have their own costs.

History

Sampling is an old way of limiting what an answer reveals, but its formal privacy effect was analysed only once differential privacy gave a precise guarantee to measure against. Borja Balle, Gilles Barthe and Marco Gaboardi, in 2018, gave tight analyses of subsampling using couplings and divergences.

It became central in machine learning when Abadi and colleagues trained deep networks with differentially private stochastic gradient descent in 2016. Their training loop samples a batch at every step, so each step benefits from subsampling.

Recap

  • Keeping each record with probability qq before a private mechanism runs lowers the privacy loss.
  • The mixture argument gives the new budget ε′=ln⁡(1+q(eε−1))\varepsilon' = \ln(1 + q(e^{\varepsilon} - 1)), roughly q(eε−1)q(e^{\varepsilon} - 1) for small qq.
  • The result needs independent random sampling, and it amplifies an existing guarantee rather than creating one.
  • Read next: Moments Accountant for tight accounting over many sampled steps, and Differentially Private SGD for the training loop that uses it.

Check yourself

QuestionRecall: why does a random sample reduce the privacy loss of a mechanism that is already differentially private?Show answer
Because a record is only sometimes used. The released answer is a mixture of the case where the record is present and the case where it is absent, and the mixture is less distinguishable than the case where the record is always present. The sampling weight qq dilutes the difference.
QuestionComputation: take ε=1\varepsilon = 1 and q=0.1q = 0.1. What is ε′=ln⁡(1+q(eε−1))\varepsilon' = \ln(1 + q(e^{\varepsilon} - 1)), to two decimal places?Show answer
e1−1=1.718e^{1} - 1 = 1.718, so 1+0.1×1.718=1.17181 + 0.1 \times 1.718 = 1.1718. Then ln⁡(1.1718)≈0.16\ln(1.1718) \approx 0.16.
QuestionWhy: why does a fixed rule such as 'use every tenth row' not give the same guarantee as random subsampling?Show answer
The guarantee relies on each record being included at random and independently of the others, so that the mixture argument applies. With a fixed rule, anyone who knows the rule knows exactly which records were used, so the chance that a record was included is not hidden, and the amplification argument does not hold.
QuestionApplied: a team trains a model with a fixed budget per step, and they halve the batch size. Does the per-step privacy cost go up or down, and why?Show answer
It goes down. Halving the batch size halves the sampling rate qq, and the amplified budget ln⁡(1+q(eε−1))\ln(1 + q(e^{\varepsilon} - 1)) falls with qq. The team should also expect the model to be less accurate per step, so the trade-off has to be weighed.

Sources