Skip to content

Parallelization of DEMetropolis sampling fails due to a kwarg assert #3555

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

Closed
michaelosthege opened this issue Jul 19, 2019 · 0 comments
Closed
Assignees

Comments

@michaelosthege
Copy link
Member

If you have questions about a specific use case, or you are not sure whether this is a bug or not, please post it to our discourse channel: https://discourse.pymc.io

DEMetropolis sampling can't be parallelized due to kwarg checking in the sampling method

Additional kwargs are assumed to be used by the steppers. The parallelize kwargs however is not. It is used by the functions that initiate sampling.

import pymc3
with pymc3.Model() as pmodel:
    n = pymc3.Normal('n', 0, 1)
    trace = pymc3.sample(step=pymc3.DEMetropolis(), chains=6, parallelize=True)
Traceback (most recent call last):
  File "...\site-packages\pymc3\sampling.py", line 406, in sample
    step = assign_step_methods(model, step, step_kwargs=kwargs)
  File "...\site-packages\pymc3\sampling.py", line 155, in assign_step_methods
    return instantiate_steppers(model, steps, selected_steps, step_kwargs)
  File "...\site-packages\pymc3\sampling.py", line 81, in instantiate_steppers
    raise ValueError('Unused step method arguments: %s' % unused_args)
ValueError: Unused step method arguments: {'parallelize'}

Versions

Done with recent pip install, but the code on master still has the bug.

Solution

Add the parallelize kwarg explicitly to the signature of the sample method. But also discuss how it should be called to avoid confusion. (It only applies to the parallelization of population samplers.)

Also, the test in https://github.com/pymc-devs/pymc3/blob/90093d9d2b6aa5c38424abd6097bd5bb0191d904/pymc3/tests/test_step.py#L918 should be duplicated to also test with parallelization enabled.

@michaelosthege michaelosthege self-assigned this Jul 19, 2019
michaelosthege added a commit to michaelosthege/pymc that referenced this issue Jul 21, 2019
michaelosthege added a commit to michaelosthege/pymc that referenced this issue Jul 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant