py4dstem / py4dstem/py4DSTEM

WPF Parallelization fails

Open
#687 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
279
Forks
177
PR merge metrics
No merged PRs in 30d

Description

There have been reports of the mpire distributed WPF optimization failing with errors like

AttributeError: Can't pickle local object 'WholePatternFit._fit_distributed.<locals>.f

This appears to only affect Windows systems.

I think the fix is to enable dill serialization:
https://github.com/py4dstem/py4DSTEM/blob/113763791edae292060eaf817216eda7d289d352/py4DSTEM/process/wholepatternfit/wpf.py#L748-L753
should be modified to become:

        with WorkerPool(
            n_jobs=num_jobs,
            shared_objects=fit_opts,
            use_dill=True,
        ) as pool:

mpire produces threads differently on Windows vs UNIX and so there can be serialization errors that only show up one one platform when transmitting complicated objects to threads. Unfortunately I do not have a Windows machine to test this on at the moment, so someone else will have to try this and let us know.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in py4DSTEM/process/wholepatternfit/wpf.py at the WorkerPool setup around lines 748-753 and review how the distributed WPF fit is serialized. Apply the proposed serialization setting, then run the distributed WPF optimization on Windows. Done means the fit completes without the reported local-object pickle error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.