Deliverables (all verified in this environment):
All checks pass and the markdown is fully self-contained (extracting its code blocks into a clean directory and running them gives 57/57). Here is the diagnosis and solution.
Deliverables (all verified in this environment):
| File | Purpose |
|---|---|
~/SOLUTION.md |
Full self-contained write-up (embeds the complete, runnable code) |
~/rdp_accountant.py |
The accountant (dependency-free; numpy/mpmath optional) |
~/test_rdp_accountant.py |
57-check verification suite → 57 passed, 0 failed |
Reproduce: python3 test_rdp_accountant.py
The naive approach fails in four independent ways:
exp(k(k−1)/(2σ²)). With σ=0.5, k=20 the exponent is 760 > log(DBL_MAX)≈709, so a direct sum(exp(...)) overflows to inf for ordinary parameters. If the overflow is clamped, the reported δ is too small.q=m/n the without-replacement RDP is strictly larger. Substituting Poisson under-states δ by 36×–239× on a concrete replace-one run — a guarantee that claims far more privacy than exists.ε(α) itself need not upper-bound the truth. One must interpolate the convex log-moment g(α) = (α−1)ε(α) = log E[L^α], whose chord lies above the curve.log_sum_exp — no overflow.g(α) = (α−1)ε(α) across steps (valid for adaptive composition).g (convex) between queried Rényi orders, then convert
δ = min_α exp((α−1)(ε_α−ε))·(α−1)^(α−1)/α^α.σ≤0, bad ranges, invalid amplification/adjacency, dependent batching, non-finite RDP.Key pieces (full source in rdp_accountant.py / SOLUTION.md):
def poisson_subsampled_gaussian_rdp(alpha, q, sigma): # log-space
log_terms = [ (lgamma(a+1)-lgamma(k+1)-lgamma(a-k+1))
+ (a-k)*log1p(-q) + k*log(q)
+ k*(k-1)/(2*sigma**2) for k in range(a+1) ]
return log_sum_exp(log_terms) / (alpha - 1)
def fixed_size_subsampled_gaussian_rdp(alpha, q, sigma): # WOR, alpha int
return fixed_size_subsampled_gaussian_rdp_int(q, sigma, int(alpha)) / (alpha-1)
# ... forward differences of exp(cgf) in log space (W-B-K Theorem 27)
def renyi_to_delta(alpha, rdp_alpha, epsilon): # log-space closed form
log_delta = (alpha-1)*(rdp_alpha-epsilon) + (alpha-1)*log(alpha-1) - alpha*log(alpha)
return min(1.0, exp(log_delta)) if log_delta < 0 else 1.0
Usage:
acc = RDPAccountant()
acc.add_step(GaussianMechanism(sigma=1.1, sampling="poisson", sample_rate=0.01), times=1000)
acc.add_step(GaussianMechanism(sigma=1.5, sampling="fixed_size", batch_size=256,
dataset_size=50000, adjacency="replace_one"), times=200)
print(acc.sound, acc.get_delta(2.0), acc.get_epsilon(1e-5))
dp-accounting to 3.6e-16 (Poisson) and 4.4e-16 (WOR); composed ε matches (Poisson 1.711770091 vs 1.711770166; WOR identical to printed precision).mpmath quadrature.sound=False, message names the failed assumption; naive RDP overflows while log-space yields 124.9567.Full root-cause discussion, the complete 764-line module, the 394-line test suite, and all captured outputs are in ~/SOLUTION.md.
# Evidence - Problem class: python-20261009-subsampled-rdp-accountant-tight-composition - Model: openrouter/deepseek/deepseek-v4.1-flash - Solved: 2026-10-10T04:37:51.800Z - Verification: solution produced by pi in sandbox; see signatures.json
{"description": "Build a privacy accountant for a training run composed of heterogeneous Poisson- and fixed-size subsampled Gaussian mechanisms, including adaptive choices whose parameters are revealed only after each step. Compute a numerically stable upper bound on total delta at a requested epsilon using Renyi orders and interpolation, and identify when floating-point error or an invalid amplification assumption makes the reported guarantee unsound.", "environment": "python3", "language": "python", "model": "openrouter/deepseek/deepseek-v4.1-flash", "problem_class": "python-20261009-subsampled-rdp-accountant-tight-composition", "provider": "openrouter", "solved_at": "2026-10-10T04:37:51.800Z", "version": "3.11"}