Skip to content
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

Multiple inits files incorrectly processed when running multiple chains in one executable #687

Closed
WardBrian opened this issue Aug 25, 2023 · 1 comment · Fixed by #688
Closed

Comments

@WardBrian
Copy link
Member

Summary:

Make two inits files, inits1.json and inits2.json. They can both just contain {}.
Run

import os
from cmdstanpy import CmdStanModel, cmdstan_path
bernoulli_dir = os.path.join(cmdstan_path(), 'examples', 'bernoulli')
stan_file = os.path.join(bernoulli_dir, 'bernoulli.stan')
model = CmdStanModel(stan_file=stan_file)
data = {"N": 10, "y": [0, 1, 0, 0, 0, 0, 0, 0, 0, 1]}
model.sample(data=data, chains=2, inits=['inits1.json', 'inits2.json'], output_dir='.', force_one_process_per_chain=False)

Open the resulting output files, both will have used inits1.json

To make this even more obvious, you can make inits2.json contain something that would fail to initialize, like {'theta':4.0}

Additional Information:

This is related to #362 and #685

@WardBrian
Copy link
Member Author

Oh, the correct behavior is worth noting:

You need a base filename, like init.json, which can be used to "infer" the filenames per chain, which look like init_1.json, init_2.json

This isn't too hard to make work, but getting it to collaborate with the historical multiprocessing approach is belabored.

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 a pull request may close this issue.

1 participant