1
$\begingroup$

I am trying to compute some unitary matrix for some big circuit on GPU using qiskit-aer, specifically a 11 qubits circuit with the following error:

Simulation failed and returned the following error message:
ERROR:  [Experiment 0] ChunkContainer::StoreUintParams size = 4107/266 iChunk = 0 : cudaErrorInvalidValue

I do not understand what the issue is or how to fix it, the same kind of circuit works with 10 qubits and I should not be short on memory as I am running the experiment on a 32gb V100

Here the code to reproduce the issue

import time
from qiskit import QuantumCircuit, transpile
from qiskit_aer import AerSimulator
from qiskit.quantum_info import random_unitary

seed = 42

def create_random_unitary(num_qubits, seed=None):
    return random_unitary(2 ** num_qubits, seed=seed)

num_qubits = 11

circuit = QuantumCircuit(num_qubits)

gate1_qubits = list(range(0, num_qubits))

# Gate 2 spans the second set of qubits
gate2_qubits = list(range(0, num_qubits))

left_unitary = create_random_unitary(len(gate1_qubits), seed)
right_unitary = create_random_unitary(len(gate2_qubits), seed)

circuit.unitary(left_unitary, gate1_qubits)
circuit.unitary(right_unitary, gate2_qubits)

# save a fig of the circuit in pics folder
circuit.draw(output='mpl', filename=f'pics/{num_qubits}.png')

simulator = AerSimulator(method='unitary', device='GPU')

circuit.save_unitary()
# transpiled_circuit = transpile(circuit, simulator) ## doesn't matter

start_time = time.time()

job = simulator.run(circuit)
result = job.result()
unitary_matrix = result.get_unitary(circuit)

end_time = time.time()

execution_time_ms = (end_time - start_time) * 1000

print(execution_time_ms)
$\endgroup$
2
  • $\begingroup$ Can you add some code to reproduce the issue? $\endgroup$
    – luciano
    Commented 2 days ago
  • $\begingroup$ @luciano added the code to reproduce the issue $\endgroup$ Commented 2 days ago

1 Answer 1

1
$\begingroup$

I'm assuming you're trying to benchmark your GPUs performance but if you're not then removing device='GPU' printed 20046.831846237183 on my local machine and on the qbraid server which should resolve your issue.

Remember that your circuit matrix blows up exponentially so a 2^10 size matrix might have been fine but 2^11 for 11 qubits is double the size this might be too big for your GPU which is suggested by the error message.

New contributor
broncosaurus is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
3
  • $\begingroup$ Yes, I am trying to benchmark my gpu performances. Also there is no reason to believe that 11 qubits are too many for the architecture, as I was able to run the same simulation on 10 qubits on a 8Gb GPU, therefore 32Gb should be enough for just one qubit more; moreover the error message for being out of memory is slightly different $\endgroup$ Commented 2 days ago
  • $\begingroup$ What GPU do you have? Currently only NVIDIA GPUs have support according to this qiskit.github.io/qiskit-aer/tutorials/1_aersimulator.html $\endgroup$ Commented 2 days ago
  • $\begingroup$ As stated in the question, I am using an NVIDIA Tesla V100 $\endgroup$ Commented 2 days ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.