Skip to content

Allow configuring the n_processes for parallel inference - #198

Open
ayush9pandey wants to merge 15 commits into
mainfrom
paralle-inference-fixes
Open

ayush9pandey wants to merge 15 commits into
mainfrom
paralle-inference-fixes

Conversation

@ayush9pandey

Copy link
Copy Markdown
Collaborator

This PR adds an optional n_processes argument for parallel MCMC inference.

When parallel=True, users may specify the number of worker processes
created by multiprocessing.Pool:

sampler, inference = py_inference(
    ...,
    parallel=True,
    n_processes=4,
)

If n_processes is omitted or set to None, the pool uses its default
process count. Explicit values must be positive integers.

This PR is based on custom-joint-priors and should be merged after
PR #195 is merged. 

@murrayrm murrayrm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found a few things that I didn't understand. Need to rebase on main to just show the changes for multiprocessing.

Comment thread bioscrape/inference.pyx
multiprocessing is not used.
n_processes : int, optional
Number of worker processes used when `parallel=True`. If None,
`multiprocessing.Pool` uses its default process count. Ignored when

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default process count for default processor count?

Comment thread bioscrape/inference_setup.py Outdated
self.hmax,
self.parallel
self.parallel,
self.custom_joint_prior

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make any changes to the code, worth rebasing on the latest main to get rid of these.

Comment thread tests/test_inference.py
Comment on lines +249 to +250
def test_parallel_inference_uses_requested_process_count(
model_setup, tmp_path, monkeypatch):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably missing something simple here, but what sets the values of the parameters?

Comment thread tests/test_inference.py
nsteps = 1,
init_seed = 1e-4,
parallel = True,
n_processes = 1,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be hardcoded at 1?

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

2 participants