google / google/differential-privacy
RFC: dp accounting should use rust as its backend
- Dominant language
- Go
- Stars
- 3.4k
- Forks
- 434
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 9
Description
I am proposing an optional, high-performance backend for `dp-accounting` that resolves the computation bottleneck in RDP accounting.
By offloading the exact RDP math (Poisson Subsampled Gaussian) to a vectorized Rust extension, I achieved a **40x-45x speedup** on standard workloads while maintaining floating-point accuracy ($10^{-12}$
### Proposed Solution
I have developed `dp-accelerator`, a drop-in Rust replacement that:
1. Implements the **exact** `_compute_log_a_frac` logic from Google's `dp_accounting` using `statrs`.
2. Vectorizes computation across all $\alpha$ orders.
3. Exposes a safe Python interface via `PyO3`.
This package is already published on [PyPI](https://pypi.org/project/dp-accelerator/) (`pip install dp-accelerator`) and uses Apache 2.0.
### Benchmarks (Intel Mac i5 8th gen)
| Config | Steps | Python (ms) | Rust (ms) | Speedup |
|--------|-------|-------------|-----------|---------|
| MNIST | 1k | 36.5 | 0.86 | **42x** |
| ImageNet | 90k | 30.0 | 0.69 | **43x** |
| Batch (10 checks) | 1k-60k | 333.4 | 8.8 | **37x** |
### Integration Plan
I have a working branch where this is implemented as a **soft dependency**:
- `dp-accounting` does **not** need to compile Rust.
- If `dp-accelerator` is installed, `analysis.py` detects it and routes the computation to the fast path.
- If not installed, it falls back to the existing Python implementation with an alert kind of warning to suggest using the `dp-accelarator` package for faster
I have prepared a technical report (submitted to techrxiv) detailed in the repo: https://github.com/AxiomaticLabs/dp-accelerator
Would the team be open to a PR integrating this optional backend?
Contributor guide
Assessment
This issue has not been assessed yet.