Skip to content

Ensure size info matches MPI world-1 if not set #7353

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions pennylane/concurrency/executors/external/mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, max_workers: Optional[int] = None, persist: bool = False, **k
# Handle set-up upon object creation only.
from mpi4py import MPI

self._size = max_workers
self._size = max_workers if max_workers else MPI.COMM_WORLD.Get_size() - 1
self._comm = MPI.COMM_WORLD

self._cfg = ExecBackendConfig(
Expand Down Expand Up @@ -84,10 +84,6 @@ def __call__(self, dispatch: str, fn: Callable, *args, **kwargs):
**kwargs,
)

@property
def size(self):
return self._size

def submit(self, fn: Callable, *args, **kwargs):
with self._exec_backend()(max_workers=self.size, use_pkl5=True) as executor:
output_f = executor.submit(fn, *args, **kwargs)
Expand Down Expand Up @@ -194,10 +190,6 @@ def starmap(self, fn: Callable, args: Sequence[tuple], **kwargs):
output_f = executor.starmap(fn, args, chunksize=chunksize, **kwargs)
return list(output_f)

@property
def size(self):
return self._size

def shutdown(self):
"Shutdown the executor backend, if valid."

Expand Down