-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix bug with pickling PointFunc #7858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -425,3 +425,20 @@ def test_sampling_state(step_method, model_fn): | |||
assert equal_sampling_states(final_state1, final_state2) | |||
assert equal_dataclass_values(sample1, sample2) | |||
assert equal_dataclass_values(stat1, stat2) | |||
|
|||
|
|||
def test_binary_gibbs_with_spawn(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this specific to binary gibbs? That's the only one using PointFunc?
We should test spawning a PointFunc instead or this test won't be a regression test if binary gibbs changes to not using PointFunc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no idea why it's these functions. model.compile_xxx returns a PointFunc, so everyone uses them, but only these 3 samplers trigger the error (I tried most of them)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most samplers build their own function on raveled inputs and don't use the wrapper PointFunc for performance
b060d01
to
55db526
Compare
assert "shape=(?,)" in captured.out | ||
|
||
|
||
def test_pickle_point_func(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to be sure this failed before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
FAILED [100%]
tests/test_pytensorf.py:769 (test_pickle_point_func)
def test_pickle_point_func():
"""
Regression test for https://github.com/pymc-devs/pymc/issues/7857
"""
import cloudpickle
x, y = pt.vectors("x", "y")
outs = x * 2 + y**2
f = compile([x, y], outs)
point_f = PointFunc(f)
point_f_pickled = cloudpickle.dumps(point_f)
> point_f_unpickled = cloudpickle.loads(point_f_pickled)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test_pytensorf.py:782:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../pymc/pytensorf.py:573: in __getattr__
return getattr(self.f, item)
^^^^^^
../pymc/pytensorf.py:573: in __getattr__
return getattr(self.f, item)
^^^^^^
../pymc/pytensorf.py:573: in __getattr__
return getattr(self.f, item)
^^^^^^
E RecursionError: maximum recursion depth exceeded
!!! Recursion detected (same locals & position)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7858 +/- ##
==========================================
+ Coverage 92.92% 92.98% +0.06%
==========================================
Files 107 108 +1
Lines 18299 18328 +29
==========================================
+ Hits 17004 17043 +39
+ Misses 1295 1285 -10
🚀 New features to boost your workflow:
|
Description
Fixes a bug when unpickling certain step samplers (BinaryMetropolis, BinaryGibbsMetropolis, and CategoricalGibbsMetropolis) when mp_ctx is spawn or forkserver
Related Issue
mp_ctx=spawn
orforkserver
#7857Checklist
Type of change