common.title

Docs
Quantum Circuit
TYTAN CLOUD

QUANTUM GAMING


Desktop RAG

Overview
Terms of service

Privacy policy

Contact
Research

Sign in
Sign up
common.title

How to adapt the IBM Qiskit application developed so far for NVIDIA cuQuantum

Yuichiro Minato

2023/07/24 02:37

Using NVIDIA cuQuantum allows you to easily accelerate the applications you have created so far with IBM's Qiskit. There are two ways to do this, and I would like to go through them one by one. It's very easy, so anyone with a GPU can easily run it using cuQuantum and IBM's Qiskit. There may be some difficulties with installation, so I look forward to improvements in this area. Let's take a look.

The method differs a little for each, so I'll explain them. The former is purely an extension of what we've done so far, while the latter is a completely new simulator with a completely different usage. If you're not familiar, please use the former.

cuStateVec

This is a state vector simulator for quantum computers, which has been accelerated with a GPU. Therefore, many quantum computer applications can be accelerated without significant changes using this method. As it only involves changing the backend on which the application runs, and not major changes to the application itself, many people utilize this method.

As long as cuQuantum, qiskit, and qiskit-aer-gpu are correctly installed, you can run it using only the qiskit library without having to load anything on the cuQuantum side.

import numpy as np
from qiskit import QuantumCircuit
from qiskit_aer import AerSimulator

#parepare circuit
circ = QuantumCircuit(2)

#apply gate
circ.h(0)
circ.cx(0, 1)
circ.measure_all()

#check the circuit
circ.draw()

#execute with CPU
sim_cpu = AerSimulator(method='statevector', device='CPU')

The above method uses traditional CPUs.

%%time
result_cpu = sim_cpu.run(circ).result()
result_cpu.get_counts()

CPU times: user 3.27 ms, sys: 0 ns, total: 3.27 ms
Wall time: 2.91 ms
[2]:{'11': 520, '00': 504}

In case you are using a GPU, all you have to do is set the device to GPU and cuStateVec_enable to True.

#change backend to cuStateVec
sim_gpu = AerSimulator(method='statevector', device="GPU", cuStateVec_enable=True)

%%time
result_gpu = sim_gpu.run(circ).result()
result_gpu.get_counts()

CPU times: user 546 ms, sys: 237 ms, total: 782 ms
Wall time: 776 ms
[4]:{'00': 499, '11': 525}

For smaller problems, the overhead of the GPU may make it slower, but for larger problems, it will be accelerated.

cuTensorNet

This method is a bit different. First, you convert the Qiskit circuit for cuTensorNet, and then compute that quantum circuit with cuTensorNet. Applications created with Qiskit can be easily converted, so if you can convert them, you can calculate as is. I don't think you can calculate very deep circuits. Since you need to load and convert the entire circuit, you will need knowledge of tensor networks.

from cuquantum import CircuitToEinsum, contract
from qiskit import QuantumCircuit, QuantumRegister
from qiskit.quantum_info import Statevector

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
converter = CircuitToEinsum(qc)
expr, operands = converter.amplitude('00')
amp = contract(expr, *operands)
print(amp)
qc.draw()

(0.7071067811865475+0j)

How did you find it? It was easy to compute, wasn't it? Let's continue to make full use of the GPU for quantum computing in the future.

© 2025, blueqat Inc. All rights reserved