opendp / opendp

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

alp_queryable freezes #1553

Open mccalluc opened 2 weeks ago

mccalluc commented 2 weeks ago

I'm trying code very similar to test_alp_histogram:

>>> import opendp.prelude as dp
>>> dp.enable_features("contrib")
>>> counter = dp.t.make_count_by(
...     dp.vector_domain(dp.atom_domain(T=str)),
...     dp.symmetric_distance(),
...     MO=dp.L1Distance[int])
>>> alp_queryable = dp.m.make_alp_queryable(
...     *counter,
...     scale=1.,
...     total_limit=24,
...     value_limit=24)

but for me, at that point it freezes and is unresponsive. I've waited a couple minutes.

I'm probably doing something wrong, but freezing is unusual.

mccalluc commented 2 weeks ago

No, shouldn't freeze. Chuck can look into it more, or at least see if it reproduces.

mccalluc commented 1 week ago

Still freezing for me. For context, this is based on test_alp_histogram, except that uses then, and I've confirmed that it works.

>>> import opendp.prelude as dp
>>> dp.enable_features('contrib')
>>> counter = dp.t.make_count_by(
...     dp.vector_domain(dp.atom_domain(T=str)),
...     dp.symmetric_distance(),
...     MO=dp.L1Distance[int])
>>>
>>> alp_meas = counter >> dp.m.then_alp_queryable(
...     scale=1.,
...     total_limit=24,
...     value_limit=24,
... )

Shouldn't make a difference / maybe there's another typo / but even if there is, freezing is not the expected behavior. I'll try to dig into this.

mccalluc commented 1 week ago

This is weird: If I redefine the function, I can hit the breakpoint:

def make_alp_queryable(
    *args, **kwargs
) -> Measurement:
    breakpoint()

but a breakpoint at the top of the function doesn't work. (Although the then_ construct calls it indirectly, and that works.)

I've pushed to github, and we'll see if the freeze is replicated there.

mccalluc commented 1 week ago

Decided we should see if defining __iter__ helps.

Mike says:

Here's a smaller repro that might help: [*counter]. Is it safe to override iter?