1
$\begingroup$

I am trying to compute the number of circuit layers in a UCC ansatz in Qiskit in order to estimate the circuit running time using CLOPS estimates on IBM quantum devices. Here is what I tried to do:

from qiskit.transpiler import PassManager, StagedPassManager
from qiskit_nature.converters.second_quantization import QubitConverter
from qiskit_nature.second_q.circuit.library.ansatzes import UCC
from qiskit_nature.second_q.drivers import PySCFDriver
from qiskit_nature.second_q.formats.molecule_info import MoleculeInfo
from qiskit_nature.second_q.mappers import ParityMapper

qubit_converter = QubitConverter(ParityMapper(), two_qubit_reduction=True, z2symmetry_reduction='auto')

molecule = MoleculeInfo(["H", "Be", "H"], [(0., 0., -1.3264), (0., 0., 0.), (0., 0., 1.3264)],)
driver = PySCFDriver.from_molecule(molecule, basis="sto3g")
electronic_structure_problem = driver.run()

second_quantized_hamiltonian = electronic_structure_problem.second_q_ops()   
pauli_sum_operator = qubit_converter.convert(second_quantized_hamiltonian[0], num_particles=electronic_structure_problem.num_particles)

num_particles = electronic_structure_problem.num_particles
num_spin_orbitals = electronic_structure_problem.num_spin_orbitals

uccsdt_ansatz = UCC(int(num_spin_orbitals/2), num_particles, excitations="sdt", qubit_converter=qubit_converter)

# more info on pass managers here: https://qiskit.org/documentation/apidoc/transpiler.html
pm = StagedPassManager(stages=["init"])
circuit = pm.run(uccsdt_ansatz)
print(circuit.depth())

However, the above does not work, an exception is thrown ('ListOp' object has no attribute 'to_circuit'). Here is the qiskit version I am using: enter image description here

$\endgroup$

2 Answers 2

1
$\begingroup$

Your QubitConvertor needs importing from second_q location. If you are wanting auto symmetry reduction you need to pass the sector locator from the problem into the convert. This runs and prints a value.

from qiskit.transpiler import PassManager, StagedPassManager
from qiskit_nature.second_q.mappers import QubitConverter
from qiskit_nature.second_q.circuit.library.ansatzes import UCC
from qiskit_nature.second_q.drivers import PySCFDriver
from qiskit_nature.second_q.formats.molecule_info import MoleculeInfo
from qiskit_nature.second_q.mappers import ParityMapper

qubit_converter = QubitConverter(ParityMapper(), two_qubit_reduction=True, z2symmetry_reduction='auto')

molecule = MoleculeInfo(["H", "Be", "H"], [(0., 0., -1.3264), (0., 0., 0.), (0., 0., 1.3264)],)
driver = PySCFDriver.from_molecule(molecule, basis="sto3g")
electronic_structure_problem = driver.run()

second_quantized_hamiltonian = electronic_structure_problem.second_q_ops()
pauli_sum_operator = qubit_converter.convert(second_quantized_hamiltonian[0], num_particles=electronic_structure_problem.num_particles, sector_locator=electronic_structure_problem.symmetry_sector_locator)

num_particles = electronic_structure_problem.num_particles
num_spatial_orbitals = electronic_structure_problem.num_spatial_orbitals

uccsdt_ansatz = UCC(num_spatial_orbitals, num_particles, excitations="sdt", qubit_converter=qubit_converter)

# more info on pass managers here: https://qiskit.org/documentation/apidoc/transpiler.html
pm = StagedPassManager(stages=["init"])
circuit = pm.run(uccsdt_ansatz)
print(circuit.depth())
$\endgroup$
0
$\begingroup$

In the context of CLOPS, circuit depth is calculated differently than the default behavior of QuantumCircuit.depth() method:

  • You have to decompose your circuit into the native gate set of the backend before calculating it, and
  • A 1-qubit gate from the native gate set is included if it has non-zero duration.

You can find the considerations you need to take when calculating depth in appendix of the paper mentioned in your comment.

$\endgroup$
2
  • $\begingroup$ I don't think transpiling against a backend is what need. The notion of Circuit Layers is defined in this paper: arxiv.org/pdf/2110.14108.pdf in the context of defining the quantum volume. Please note the comment in section B on 'Quantum Volume': when a QV circuit is compiled to the native gate set of a particular QPU, the circuit depth of the compiled circuit will typically be much larger than the number of QV layers. What I want to measure is roughly the number of Circuit Layers, meaning the depth of the circuit not yet transpiled but decomposed in one and two qubit gates. $\endgroup$
    – Radu M.
    Mar 12, 2023 at 14:46
  • $\begingroup$ I miss read your question, sorry about that. Answer has been updated. $\endgroup$ Mar 13, 2023 at 4:14

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.