Description
Hello! I'm currently using the adaptive library to depict a phase diagram. I'm attempting to leverage multiple cores on my server by employing multiprocessing. However, I've encountered issues when using the AsyncRunner.
Below is the code snippet that I'm running in a single Python script:
import adaptive
from concurrent.futures import ProcessPoolExecutor
from functools import partial
def sample(xy, data):
# Implementation of time-demanding function
# ...
learner = adaptive.Learner2D(partial(sample, data=data), bounds=((0, 7), (7, 13)))
with ProcessPoolExecutor(max_workers=96) as executor:
runner = adaptive.Runner(learner, executor=executor, npoints_goal=10)
runner.task.print_stack()
It's important to note that the sample function is computationally intensive, taking hours to complete. Each function instance writes to its own identical files, preventing conflicts.
However, executing the code above results in an incomplete run, leaving the stack trace below:
Stack for <Task pending name='Task-1' coro=<AsyncRunner._run() running at /xxx/envs/FFS/lib/python3.10/site-packages/adaptive/runner.py:771>> (most recent call last):
File "/xxx/envs/FFS/lib/python3.10/site-packages/adaptive/runner.py", line 771, in _run
async def _run(self) -> None:
While using the BlockingRunner class works fine, I suspect there might be an efficiency bottleneck in the multiprocessing process.
Could you please help me identify the problem in my script? Additionally, do you think it would be more efficient to use the AsyncRunner in my case?
Thanks a lot for your assistance!