opendp / opendp

The core library of differential privacy algorithms powering the OpenDP Project.
https://opendp.org
MIT License
302 stars 48 forks source link

Error: Potential For Overflow #1699

Closed GKD-stack closed 2 days ago

GKD-stack commented 1 month ago

In the developer environment, I had to cast everything to Int32. With a really large max_partition_length was also really large, it resulted in a potential for overflow error. Working with Int64 might fix it.

OpenDPException: 
  MakeTransformation("potential for overflow when computing function")

During handling of the above exception, another exception occurred:

Run this to reproduce the error

import polars as pl 
import opendp.prelude as dp
dp.enable_features("contrib")

data = {"col1": [0, 2], "col2": [3, 7]}
df = pl.LazyFrame(data, schema={"col1": pl.Int32, "col2": pl.Int32})
context = dp.Context.compositor(
    data=df,
    privacy_unit=dp.unit_of(contributions=36),
    privacy_loss=dp.loss_of(epsilon=1.0),
    split_evenly_over=10,
    margins={
        ("col1", ): dp.Margin(public_info="keys", max_partition_length=60_000_000, max_partition_contributions=4),
    },
)

(context.query().
group_by("col1").
agg(pl.col("col2").dp.sum((1.0,1000.0)))).release().collect()
Shoeboxam commented 1 month ago

They key action-item for this issue is to update the error message to be more descriptive about how to fix the problem. We'll have to raise an error, but the error should point users in a direction to fix it.