Hello! If applicable, put your complete code example down below. Make sure that your code:
- is 100% self-contained — someone can copy-paste exactly what is here and run it to
reproduce the behaviour you are observing - includes comments
from mpi4py import MPI
import pennylane as qml
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
dev = qml.device('lightning.gpu', wires=8, mpi=True)
@qml.qnode(dev)
def circuit_mpi():
qml.PauliX(wires=[0])
return qml.state()
local_state_vector = circuit_mpi()
#rank 0 will collect the local state vector
state_vector = comm.gather(local_state_vector, root=0)
if rank == 0:
print(state_vector)
If you want help with diagnosing an error, please put the full error message below:
> nvidia-smi --list-gpus | wc -l
4
srun -n 4 python testmpi2.py
Traceback (most recent call last):
File "/global/u1/p/prmantha/PilotQuantumBenchmarks/dist_mem_pennylane_mpi/testmpi2.py", line 5, in <module>
Traceback (most recent call last):
File "/global/u1/p/prmantha/PilotQuantumBenchmarks/dist_mem_pennylane_mpi/testmpi2.py", line 5, in <module>
Traceback (most recent call last):
File "/global/u1/p/prmantha/PilotQuantumBenchmarks/dist_mem_pennylane_mpi/testmpi2.py", line 5, in <module>
Traceback (most recent call last):
File "/global/u1/p/prmantha/PilotQuantumBenchmarks/dist_mem_pennylane_mpi/testmpi2.py", line 5, in <module>
dev = qml.device('lightning.gpu', wires=8, mpi=True)
dev = qml.device('lightning.gpu', wires=8, mpi=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/global/homes/p/prmantha/.local/lib/python3.11/site-packages/pennylane/__init__.py", line 370, in device
dev = qml.device('lightning.gpu', wires=8, mpi=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/global/homes/p/prmantha/.local/lib/python3.11/site-packages/pennylane/__init__.py", line 370, in device
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/global/homes/p/prmantha/.local/lib/python3.11/site-packages/pennylane/__init__.py", line 370, in device
dev = qml.device('lightning.gpu', wires=8, mpi=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/global/homes/p/prmantha/.local/lib/python3.11/site-packages/pennylane/__init__.py", line 370, in device
dev = plugin_device_class(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/global/homes/p/prmantha/.local/lib/python3.11/site-packages/pennylane_lightning_gpu/lightning_gpu.py", line 266, in __init__
dev = plugin_device_class(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/global/homes/p/prmantha/.local/lib/python3.11/site-packages/pennylane_lightning_gpu/lightning_gpu.py", line 266, in __init__
dev = plugin_device_class(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/global/homes/p/prmantha/.local/lib/python3.11/site-packages/pennylane_lightning_gpu/lightning_gpu.py", line 266, in __init__
dev = plugin_device_class(*args, **options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/global/homes/p/prmantha/.local/lib/python3.11/site-packages/pennylane_lightning_gpu/lightning_gpu.py", line 266, in __init__
self._mpi_init_helper(self.num_wires)
File "/global/homes/p/prmantha/.local/lib/python3.11/site-packages/pennylane_lightning_gpu/lightning_gpu.py", line 308, in _mpi_init_helper
self._mpi_init_helper(self.num_wires)
File "/global/homes/p/prmantha/.local/lib/python3.11/site-packages/pennylane_lightning_gpu/lightning_gpu.py", line 308, in _mpi_init_helper
self._mpi_init_helper(self.num_wires)
File "/global/homes/p/prmantha/.local/lib/python3.11/site-packages/pennylane_lightning_gpu/lightning_gpu.py", line 308, in _mpi_init_helper
self._mpi_init_helper(self.num_wires)
File "/global/homes/p/prmantha/.local/lib/python3.11/site-packages/pennylane_lightning_gpu/lightning_gpu.py", line 308, in _mpi_init_helper
raise ValueError(
ValueError: Number of devices should be larger than or equal to the number of processes on each node.
raise ValueError(
ValueError: Number of devices should be larger than or equal to the number of processes on each node.
raise ValueError(
ValueError: Number of devices should be larger than or equal to the number of processes on each node.
raise ValueError(
ValueError: Number of devices should be larger than or equal to the number of processes on each node.
srun: error: nid200325: tasks 1-2: Exited with exit code 1
srun: Terminating StepId=20928774.12
slurmstepd: error: *** STEP 20928774.12 ON nid200325 CANCELLED AT 2024-01-28T09:11:54 ***
srun: error: nid200325: tasks 0,3: Exited with exit code 1
And, finally, make sure to include the versions of your packages. Specifically, show us the output of qml.about()
.
Name: PennyLane
Version: 0.32.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/PennyLaneAI/pennylane
Author:
Author-email:
License: Apache License 2.0
Location: /global/homes/p/prmantha/.local/lib/python3.11/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml, typing-extensions
Required-by: PennyLane-Lightning, PennyLane-Lightning-GPU
Platform info: Linux-5.14.21-150400.24.81_12.0.87-cray_shasta_c-x86_64-with-glibc2.31
Python version: 3.11.7
Numpy version: 1.23.5
Scipy version: 1.12.0
Installed devices:
- default.gaussian (PennyLane-0.32.0)
- default.mixed (PennyLane-0.32.0)
- default.qubit (PennyLane-0.32.0)
- default.qubit.autograd (PennyLane-0.32.0)
- default.qubit.jax (PennyLane-0.32.0)
- default.qubit.tf (PennyLane-0.32.0)
- default.qubit.torch (PennyLane-0.32.0)
- default.qutrit (PennyLane-0.32.0)
- null.qubit (PennyLane-0.32.0)
- lightning.qubit (PennyLane-Lightning-0.32.0)
- lightning.gpu (PennyLane-Lightning-GPU-0.32.0)