Skip to main content

Numerical privacy accounting for random allocation and subsampling using PLDs.

Project description

PLD_accounting

PLD_accounting is a Python package for tight differential privacy accounting for random allocation and subsampling using Privacy Loss Distributions (PLDs) as described in: Efficient privacy loss accounting for subsampling and random allocation

Purpose

  • Compute tight upper/lower DP bounds for random allocation.
  • Support both Gaussian mechanisms and explicit PLD realizations.
  • Return dp_accounting PLDs for epsilon/delta queries and composition workflows.

Random Allocation Model

The package accounts for the following sampling pattern:

  • Per epoch: choose k steps out of t uniformly at random.
  • Across training: repeat this for num_epochs epochs.

Parameter Mapping

  • num_steps = t (total candidate steps per epoch)
  • num_selected = k (selected steps per epoch)
  • num_epochs (number of repeated epochs)

Internal composition:

  • floor_steps = floor(num_steps / num_selected)
  • remainder = num_steps - num_selected * floor_steps
  • floor_epochs = (num_selected - remainder) * num_epochs
  • ceil_steps = floor_steps + 1
  • ceil_epochs = remainder * num_epochs
  • We compute 1-out-of-floor_steps then self compose it floor_epochs times, compute 1-out-of-ceil_steps then self compose it ceil_epochs times, and finally compose them with each other

API Overview

Random Allocation APIs

Gaussian path (most common):

  • gaussian_allocation_epsilon_range(delta, sigma, num_steps, num_selected=1, num_epochs=1, epsilon_accuracy=-1.0)
    • Adaptive upper/lower bounds for epsilon.
  • gaussian_allocation_epsilon_configurable(params, config, bound_type=BoundType.DOMINATES)
    • Single epsilon query with explicit discretization/convolution config.
  • gaussian_allocation_delta_configurable(params, config, bound_type=BoundType.DOMINATES)
    • Single delta query with explicit discretization/convolution config.
  • gaussian_allocation_pld(params, config, bound_type=BoundType.DOMINATES)
    • Build a reusable dp_accounting.PrivacyLossDistribution.

Realization path (advanced):

  • general_allocation_pld(num_steps, num_selected, num_epochs, remove_realization, add_realization, config, bound_type=BoundType.DOMINATES)
    • Build PLD from explicit PLDRealization inputs.
  • general_allocation_epsilon(delta, num_steps, num_selected, num_epochs, remove_realization, add_realization, config, bound_type=BoundType.DOMINATES)
    • Epsilon query from explicit realizations.
  • general_allocation_delta(epsilon, num_steps, num_selected, num_epochs, remove_realization, add_realization, config, bound_type=BoundType.DOMINATES)
    • Delta query from explicit realizations.

Common notes:

  • BoundType.DOMINATES gives an upper (pessimistic) bound.
  • BoundType.IS_DOMINATED gives a lower (optimistic) bound.
  • Builders do not accept BoundType.BOTH; build two PLDs if both bounds are needed.

Mechanism PLD Helpers

Factory helpers for building PLDRealization inputs from specific mechanisms:

  • gaussian_distribution(scale, value_discretization, tail_truncation, bound_type=BoundType.DOMINATES)
    • Discretizes the Gaussian mechanism PLD (L2 sensitivity 1) onto a linear grid.
    • Returns a PLDRealization for DOMINATES and a DenseDiscreteDist for IS_DOMINATED.
  • laplace_distribution(scale, value_discretization, tail_truncation, bound_type=BoundType.DOMINATES)
    • Discretizes the Laplace mechanism PLD (L1 sensitivity 1) onto a linear grid.
    • Same return semantics as gaussian_distribution.

For both, scale is the noise standard deviation (Gaussian) or Laplace scale parameter. Pass the result directly as remove_realization and add_realization to the general allocation APIs.

Subsampling APIs

PLD-based subsampling helpers:

  • subsample_pld(pld, sampling_probability)
    • Applies subsampling amplification to a dp_accounting PLD.
  • subsample_pld_realization(base_pld, sampling_prob, direction)
    • Lower-level helper for PLDRealization inputs (REMOVE/ADD direction).

Subsampling helpers use DOMINATES semantics (upper-bound style).

Install

pip install PLD_accounting  # distribution name; then: import PLD_accounting

Where To Start

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pld_accounting-0.4.0.tar.gz (56.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pld_accounting-0.4.0-py3-none-any.whl (58.6 kB view details)

Uploaded Python 3

File details

Details for the file pld_accounting-0.4.0.tar.gz.

File metadata

  • Download URL: pld_accounting-0.4.0.tar.gz
  • Upload date:
  • Size: 56.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for pld_accounting-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e2bc0b65bd38b0777c355fe9bab5d9d078d6d3dc5984f4a2933463360ed1e459
MD5 083c5af28110d1491e100a5d94b262d1
BLAKE2b-256 a894778a9cb3fc2f9a521171afa55f76c915ee62315b5b2e38b3dc012447e8e3

See more details on using hashes here.

File details

Details for the file pld_accounting-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pld_accounting-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 58.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for pld_accounting-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 122be0a5c7c89d05a9de8d6d0aa4bbe3496b4100cae6a82ed5edae82f8584499
MD5 0f39b872a0d58944ea6ba280fc33433f
BLAKE2b-256 87be77ff5bb21f2760db665296086b1555c9447f8b762b5e56ea01f905cafb7b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page