Skip to content

Conversation

@arrjon
Copy link
Member

@arrjon arrjon commented Sep 4, 2025

I added support for parallel sampling in SequentialSimulator using joblib. This allows simulations to be executed across multiple cores without introducing joblib as a hard global dependency (it is only imported locally inside the parallel method).

Do we want to support parallel execution natively in BayesFlow?

@arrjon arrjon self-assigned this Sep 4, 2025
@codecov
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

❌ Patch coverage is 10.52632% with 34 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
bayesflow/simulators/sequential_simulator.py 10.52% 34 Missing ⚠️
Files with missing lines Coverage Δ
bayesflow/simulators/sequential_simulator.py 46.03% <10.52%> (-53.97%) ⬇️

@stefanradev93
Copy link
Contributor

Do we want to support parallel execution natively in BayesFlow?

I would be very much up for it. Can you post a small time benchmark for a model of choice?

@arrjon
Copy link
Member Author

arrjon commented Sep 9, 2025

For the SIR model in our examples, 32.000 simulations are done in 1.8s in parallel using 10 cores or 4.6s sequentially. For very fast simulators, using parallelization will be slower than sequential simulations. However, if simulations are performed on a computing cluster, it might be nice for users to have parallelization already ready to use for more expensive simulators.

@stefanradev93
Copy link
Contributor

Thanks! I would be up for merging this PR with joblib as a non-core dependency for now (as is) and perhaps add it as a core dependency when we parallelize all sims. What do you think @paul-buerkner?

@paul-buerkner
Copy link
Contributor

Agreed. I think it's nice to have it and doesn't hurt as long as it's a non-core dependency.

@arrjon arrjon merged commit d349e63 into dev Sep 10, 2025
8 of 9 checks passed
@arrjon arrjon deleted the parallel_simulator branch September 10, 2025 08:41
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.

4 participants