QOKit icon indicating copy to clipboard operation
QOKit copied to clipboard

MPI segfaulting

Open abid1214 opened this issue 6 months ago • 0 comments

When I try using the 'gpumpi' simulator for running qaoa, I segfault when using more than 1 node.

Specifically, I run

mpiexec -n 2 python benchmark.py

where benchmark.py has the lines

f = get_qaoa_maxcut_objective(N, p, G, simulator='gpumpi')
f(theta)

when calling f(theta), it eventually calls furx_all in qokit/fur/mpi_nbcuda/fur.py. I get a segfault when running this, and specifically in the following line:

from ..lazy_import import MPI
from ..nbcuda.fur import furx_all as furx_local


def furx_all(x, theta: float, n_local_qubits: int, n_all_qubits: int, comm):
    assert n_local_qubits <= n_all_qubits
    assert n_all_qubits <= 2 * n_local_qubits, "n_all_qubits > 2*n_local_qubits is not yet implemented"

    for i in range(n_local_qubits):
        furx_local(x, theta, i)

    if n_all_qubits > n_local_qubits:
        comm.Alltoall(MPI.IN_PLACE, x)  #  <- SEGFAULTS AT THIS LINE ------ #
        for i in range(2 * n_local_qubits - n_all_qubits, n_local_qubits):
            furx_local(x, theta, i)
        comm.Alltoall(MPI.IN_PLACE, x)

I've attached benchmark.py to replicate this issue. The branch I'm working on is fix-mpi

benchmark.py.txt

abid1214 avatar Aug 02 '24 15:08 abid1214