Skip to content

User Guide

This guide explains each component of Opake's DP training pipeline: what it does, how the API works, and the practical decisions you need to make. For hands-on practice, see the Tutorials. For complete function signatures, see the API Reference.

Install with pip install opake (plus opake[...] extras).

End-to-end pipelines

Pick the track that matches your problem:

  • DP-SGD end-to-end — independent Gaussian noise at every step, with per-step privacy composition. This is the standard DP training recipe. Imports from opake.dpsgd.*.
  • DP-FTRL end-to-end — correlated noise across the whole training run via matrix factorization. Imports from opake.dpftrl.*.

Both pipelines share the same primitives (clipping, noise, sampling, optimizer, accounting). The topic pages below are stack-agnostic concept references; each end-to-end guide picks the right pieces and combines them.

Topics

Foundations

Core pipeline

  • Per-Example Gradient Clipping — clipped_grad, auto_clipped_grad, adaptive_clipped_grad (DP-SGD-only), microbatching, per-group clipping.
  • Noise Addition — gaussian_noise (DP-SGD) and mf_gaussian_noise with strategy factories (DP-FTRL).
  • Privacy Accounting — Composable DpProcess objects, privacy metrics, calibration, the Accountant helper.
  • Sampling & Microbatching — Poisson, truncated Poisson, cyclic / b-min-sep / balls-in-bins / sequential samplers.

Integration

Mechanism reference

Reference

  • Known Limitations — Flash Attention, DDP-only, in-place operations, other constraints.