Training - Quantum simulator- kindly validate and confirm #194
Replies: 2 comments
-
It seems that each process has rank 0, if the example code has been used without modification. This may indicate that an independent 36‑qubit run is being performed on each node. Therefore, it is advisable to ensure that both the enroot and cuquantum-25.06 containers are properly deployed on every host and that MPI ranks have been assigned as expected. It is generally recommended to use SLURM with Pyxis for multi-node runs with Enroot. While it is possible to run Enroot on its own, the setup can be complicated. |
Beta Was this translation helpful? Give feedback.
-
Input 1 :- ============== root@qcommthub1:/home/cuquantum# cat examples/ghz.py # Copyright (c) 2021-2022, NVIDIA CORPORATION & AFFILIATES # # SPDX-License-Identifier: BSD-3-Clause
import argparse import cirq import qsimcirq
parser = argparse.ArgumentParser(description='GHZ circuit') parser.add_argument('--nqubits', type=int, default=3, help='the number of qubits in the circuit') parser.add_argument('--nsamples', type=int, default=3, help='the number of samples to take') parser.add_argument('--ngpus', type=int, default=1, help='the number of GPUs to use')
def create_qsim_options( max_fused_gate_size=2, disable_gpu=False, cpu_threads=1, gpu_mode=(0,), verbosity=0, n_subsvs=-1, use_sampler=None, debug=False ): return qsimcirq.QSimOptions( max_fused_gate_size=max_fused_gate_size, disable_gpu=disable_gpu, cpu_threads=cpu_threads, gpu_mode=gpu_mode, verbosity=verbosity, n_subsvs=n_subsvs, use_sampler=use_sampler, debug=debug )
def qsim_options_from_arguments(ngpus): if ngpus > 1: return create_qsim_options(gpu_mode=ngpus) elif ngpus == 1: return create_qsim_options() elif ngpus == 0: return create_qsim_options(disable_gpu=True, gpu_mode=0, use_sampler=False)
def make_ghz_circuit(nqubits, measure=False): qubits = cirq.LineQubit.range(nqubits) circuit = cirq.Circuit() circuit.append(cirq.H(qubits[0])) circuit.append(cirq.CNOT(qubits[idx], qubits[idx + 1]) for idx in range(nqubits - 1)) if measure: circuit.append(cirq.measure(*qubits)) return circuit
def main(nqubits=28, nrepetitions=10, ngpus=1): measure = True if nrepetitions > 0 else False circuit = make_ghz_circuit(nqubits, measure=measure)
qsim_options = qsim_options_from_arguments(ngpus) simulator = qsimcirq.QSimSimulator(qsim_options=qsim_options) if nrepetitions > 0: results = simulator.run(circuit, repetitions=nrepetitions) else: results = simulator.simulate(circuit) print(results)
if __name__ == '__main__': args = parser.parse_args() main(nqubits=args.nqubits, nrepetitions=args.nsamples, ngpus=args.ngpus) root@qcommthub1:/home/cuquantum#
+++++++++++++++ Single node ============= 32-qbit ============= Run command :- enroot start --rw --mount /enroot/data:/data cuquantum-25.06 python /home/cuquantum/examples/ghz.py --nqubits 32
Output:- q(0),q(1),q(2),q(3),q(4),q(5),q(6),q(7),q(8),q(9),q(10),q(11),q(12),q(13),q(14),q(15),q(16),q(17),q(18),q(19),q(20),q(21),q(22),q(23),q(24),q(25),q(26),q(27),q(28),q(29),q(30),q(31)=111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111, 111
============= 33-qbit ============= Run command :- enroot start --rw --mount /enroot/data:/data cuquantum-25.06 python /home/cuquantum/examples/ghz.py --nqubits 33
Output:- q(0),q(1),q(2),q(3),q(4),q(5),q(6),q(7),q(8),q(9),q(10),q(11),q(12),q(13),q(14),q(15),q(16),q(17),q(18),q(19),q(20),q(21),q(22),q(23),q(24),q(25),q(26),q(27),q(28),q(29),q(30),q(31),q(32)=000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000
============= 34-qbit ============= Run command :- enroot start --rw --mount /enroot/data:/data cuquantum-25.06 python /home/cuquantum/examples/ghz.py --nqubits 34
Output:- CUDA error: out of memory vector_mgpu.h 116
+++++++++++++++ Two node
========== 34-qbit ========= Run command :- mpirun --allow-run-as-root --mca plm_rsh_agent ssh -np 2 -host qcommthub1,qcommthub2 enroot start --rw --mount /enroot/data:/data cuquantum-25.06 python /home/cuquantum/examples/qiskit_ghz.py --nbits 34
Output:- precision: single {'1111111111111111111111111111111111': 525, '0000000000000000000000000000000000': 499} backend: cusvaer_simulator_statevector precision: single {'1111111111111111111111111111111111': 532, '0000000000000000000000000000000000': 492} backend: cusvaer_simulator_statevector
=============== 35qbit =============== Run command :- mpirun --allow-run-as-root --mca plm_rsh_agent ssh -np 2 -host qcommthub1,qcommthub2 enroot start --rw --mount /enroot/data:/data cuquantum-25.06 python /home/cuquantum/examples/qiskit_ghz.py --nbits 35
Output:- precision: single {'11111111111111111111111111111111111': 509, '00000000000000000000000000000000000': 515} backend: cusvaer_simulator_statevector precision: single {'11111111111111111111111111111111111': 491, '00000000000000000000000000000000000': 533} backend: cusvaer_simulator_statevector
================= 36 qbit ================= Run command :- mpirun --allow-run-as-root --mca plm_rsh_agent ssh -np 2 -host qcommthub1,qcommthub2 enroot start --rw --mount /enroot/data:/data cuquantum-25.06 python /home/cuquantum/examples/qiskit_ghz.py --nbits 36
Output:- precision: single {'111111111111111111111111111111111111': 472, '000000000000000000000000000000000000': 552} backend: cusvaer_simulator_statevector precision: single {'000000000000000000000000000000000000': 500, '111111111111111111111111111111111111': 524} backend: cusvaer_simulator_statevector
================ 37 qbit ================ Run command :- mpirun --allow-run-as-root --mca plm_rsh_agent ssh -np 2 -host qcommthub1,qcommthub2 enroot start --rw --mount /enroot/data:/data cuquantum-25.06 python /home/cuquantum/examples/qiskit_ghz.py --nbits 37
Output:- qiskit.providers.basic_provider.exceptions.BasicProviderError: 'the available memory is not enough to accomodate state vector, required=1099511627776 bytes, available=680543059968 bytes'
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As I read and found the run steps on https://catalog.ngc.nvidia.com/orgs/nvidia/containers/cuquantum-appliance this link the execution process is as follows
Single GPU
cd examples && python ghz.py --nqubits 30 will create and simulate a GHZ circuit running on a single GPU. To run on
4 available GPUs
Multiple GPUs (e.g., 4 GPUs)
cd examples && python qiskit_ghz.py --nbits 30 will create and simulate a GHZ circuit. This script will assign one GPU per process. To run on
4 GPUs
We have successfully run a job on a single node (for 32 or 33 qubits)
Single-node output of Ghz.py with 32 qubits
When we tried to run ghz.py on multi-node with 32 qubits, the output was as follows:
I am able to run over the IB network. Please find the results attached (screenshot). Could you kindly validate them?
I used the following command
mpirun --allow-run-as-root --mca plm_rsh_agent ssh -np 2 -host qcommthub1,qcommthub2
enroot start --rw --mount /enroot/data:/data cuquantum-25.06
python /home/cuquantum/examples/qiskit_ghz.py --nbits 36
Beta Was this translation helpful? Give feedback.
All reactions