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

Fixing matminer's multiprocessing problem #902

Open
ardunn opened this issue May 26, 2023 · 1 comment
Open

Fixing matminer's multiprocessing problem #902

ardunn opened this issue May 26, 2023 · 1 comment

Comments

@ardunn
Copy link
Contributor

ardunn commented May 26, 2023

Matminer's multiprocessing problem comes from featurizing a few expensive entries in large iterables of entries (generally structures). When a multiprocessing job hangs for a long time, it is usually because the memory needed for some low number of chunks winds up getting thrashed around or stagnating, resulting in the final result never being able to compute.

Proposed solution: replace multiprocessing with Dask bag

Assumptions:

  • The order of samples featurization does not matter, and the result df can be resorted trivially
  • The computation is embarrassingly parallel wrt. samples
  • Keeping the overall df in memory is not the issue, computing the features is the issue.

General overview:

  1. In featurize_many, create a Dask.bag.Bag from chunks (AKA partitions in dask) of the dataframe input samples. Alternatively could be done with a delayed call.
  2. Compute the bag lazily
  3. Reconvert the bag back into dataframe (should be done automatically via generator in featurize_many)

By default, dask uses multiprocessing as the scheduler if no distributed client is defined. So to actually take advantage of this, you need to define a LocalClient or distributed client with a different scheduler. Then you can compute according to whatever is available (including constraints on memory)

I don't think the memory-locking problem from multiprocessing will happen if parallelization is done this way, but we can't be sure until we try it. If it still does happen, it might be worth looking into. At very least, using dask will allow you to use multiple machines to compute features

@ardunn
Copy link
Contributor Author

ardunn commented May 26, 2023

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