Skip to content

Refactor discrete_mechanisms to Select-Measure-Estimate base class#89

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
cl/944103007
Open

Refactor discrete_mechanisms to Select-Measure-Estimate base class#89
copybara-service[bot] wants to merge 1 commit into
mainfrom
cl/944103007

Conversation

@copybara-service

Copy link
Copy Markdown

Refactor discrete_mechanisms to Select-Measure-Estimate base class

Introduce a DiscreteMechanism base class in base.py that implements the
Select-Measure-Estimate paradigm from McKenna et al. (2021). Each step of
the pipeline is a separate overridable method, enabling code reuse across
mechanisms that differ primarily in the select step.

New abstractions:

  • DiscreteMechanism: Base dataclass with configure() for budget setup.
    __call__ owns the fixed pre/post scaffolding (measure one-way, compress,
    generate, package result); _run is the overridable middle where the
    estimation strategy lives. One-shot mechanisms override only _select;
    adaptive mechanisms override _run.
  • GaussianMarginalMeasurement: A DPMechanism that encapsulates
    Gaussian noise addition to marginal queries with proper dp_event.
  • _one_way_cliques hook: Subclasses can restrict which one-way
    marginals are measured (AIM/AIM-GDP use workload-specific columns).

Mechanism migrations:

  • Independent: one_way_budget_fraction=1.0, _select -> [], delegates dp_event
  • Direct: one_way_budget_fraction=0.0, _select -> prespecified queries
  • MST: _select delegates to existing exponential mechanism helper
  • AIM: Overrides _run for the adaptive annealed loop, reuses building blocks
  • AIM-GDP: Same _run pattern as AIM but in GDP budget space
  • SWIFT: Overrides _select, _precompile, _measure, _estimate, _generate
    for per-clique budget allocation and junction tree precompilation

@copybara-service copybara-service Bot force-pushed the cl/944103007 branch 4 times, most recently from 8d25fe3 to f42e2e7 Compare July 12, 2026 10:41
Introduce a `DiscreteMechanism` base class in base.py that implements the
Select-Measure-Estimate paradigm from McKenna et al. (2021). Each step of
the pipeline is a separate overridable method, enabling code reuse across
mechanisms that differ primarily in the *select* step.

New abstractions:
- `DiscreteMechanism`: Base dataclass with `configure()` for budget setup.
  `__call__` owns the fixed pre/post scaffolding (measure one-way, compress,
  generate, package result); `_run` is the overridable middle where the
  estimation strategy lives. One-shot mechanisms override only `_select`;
  adaptive mechanisms override `_run`.
- `GaussianMarginalMeasurement`: A `DPMechanism` that encapsulates
  Gaussian noise addition to marginal queries with proper `dp_event`.
- `_one_way_cliques` hook: Subclasses can restrict which one-way
  marginals are measured (AIM/AIM-GDP use workload-specific columns).

Mechanism migrations:
- Independent: one_way_budget_fraction=1.0, _select -> [], delegates dp_event
- Direct: one_way_budget_fraction=0.0, _select -> prespecified queries
- MST: _select delegates to existing exponential mechanism helper
- AIM: Overrides _run for the adaptive annealed loop, reuses building blocks
- AIM-GDP: Same _run pattern as AIM but in GDP budget space
- SWIFT: Overrides _select, _precompile, _measure, _estimate, _generate
  for per-clique budget allocation and junction tree precompilation

PiperOrigin-RevId: 944103007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants