Qiskit / qiskit-tutorials

A collection of Jupyter notebooks showing how to use the Qiskit SDK
Apache License 2.0
2.31k stars 1.29k forks source link

ignis - process tomography - memory run-away #730

Closed ashsaki closed 5 years ago

ashsaki commented 5 years ago

(The issue still persists if anyone wants to use a larger number of qubit instead of just 1) If I re-create the quantum process tomography tutorial in https://github.com/Qiskit/qiskit-tutorials/blob/master/qiskit/ignis/process_tomography.ipynb with a QuantumRegister() of size greater than 2 (e.g., QuantumRegister(3) or QuantumRegister(5)), the memory runs out (i.e., the program consumes too much RAM and RAM usage keeps increasing with time) quickly and the process (python) gets killed.

With QuantumRegister(1) or QuantumRegister(2) the program runs okay.

FYI, I want to run a process tomography of Hadamard gate on q[4].

ashsaki commented 5 years ago

A way around could be using a single qubit register for ideal unitary preparation and a larger register for the generate quantum process tomography circuit with reduced Hilbert space for a gate on a qubit other than 0. My code snippet: #####################################################

Process tomography of a Hadamard gate

q = QuantumRegister(1) circ = QuantumCircuit(q) circ.h(q[0])

Run circuit on unitary simulator to find ideal unitary

job = qiskit.execute(circ, Aer.get_backend('unitary_simulator')) ideal_unitary = job.result().get_unitary(circ)

convert to Choi-matrix in column-major convention

choi_ideal = outer(ideal_unitary.ravel(order='F')) print("Ideal Unitary Done")

q2 = QuantumRegister(5) circ2 = QuantumCircuit(q2) circ2.h(q2[4])

Generate process tomography circuits (reduced Hilbert space) and run on qasm simulator

qpt_circs = process_tomography_circuits(circ2, [q2[4]]) #####################################################

nonhermitian commented 5 years ago

Can you please post this issue on the Ignis repo: https://github.com/Qiskit/qiskit-ignis