I have two questions on UCCSD in qiskit, please see the code below.

import numpy as np
from qiskit.chemistry.components.variational_forms import UCCSD
from qiskit.chemistry.drivers import PySCFDriver, UnitsType
from qiskit.chemistry import FermionicOperator
from qiskit.aqua import QuantumInstance
def get_qubit_op( atom , basis , map_type ):
    driver = PySCFDriver(atom=atom, unit=UnitsType.ANGSTROM, 
                         charge=0, spin=0, basis=basis)
    molecule = driver.run()
    repulsion_energy = molecule.nuclear_repulsion_energy
    num_particles = molecule.num_alpha + molecule.num_beta
    num_spin_orbitals = molecule.num_orbitals * 2
    ferOp = FermionicOperator(h1=molecule.one_body_integrals, h2=molecule.two_body_integrals)
    qubitOp = ferOp.mapping(map_type=map_type, threshold=0.00000001)
#     qubitOp = Z2Symmetries.two_qubit_reduction(qubitOp, num_particles)
    shift = repulsion_energy
    return qubitOp, num_particles, num_spin_orbitals, shift
atom='H .0 .0 .0; H .0 .0 0.74'
qubitOp, num_particles, num_spin_orbitals, shift = get_qubit_op( atom , basis = 'sto3g' , map_type = 'parity' )
num_qubits = qubitOp.num_qubits
print( 'num_qubits = ' , num_qubits ) 
from qiskit.chemistry.components.initial_states import HartreeFock    
init_state = HartreeFock( num_spin_orbitals , num_particles , 'parity' , two_qubit_reduction=False )
# setup the variational form for VQE
from qiskit.chemistry.components.variational_forms import UCCSD
var_form_vqe = UCCSD(
        qubit_mapping='parity' , 
        two_qubit_reduction = False
print( 'var_form_vqe.num_parameters = ' , var_form_vqe.num_parameters )
var_form_vqe.construct_circuit([1,1,1]).draw() # Give some random para

The outputs are (without the plot of the circuit)

num_qubits =  4
var_form_vqe.num_parameters =  3

My questions are

Why there are only 3 free parameters in UCCSD? Since I have 4 spin-orbs, I should expect there are at least 4^4 free parameters from the double excitation operators?

2. Is there a way to see which operators are involved in UCCSD? I plot out the circuit, but there are “Evolution^1” block involved. If I use “decompose().“, it shows all the 1 and 2 qubit operations? Would it be possible to show something in between, by which I mean for example adding barrier for the decomposed circuit, or showing which fermionic excitation operators are involved? Many thanks!


1 Answer 1


Since UCCSD is a particle- and spin-conserving variational form, the number of parameters does not only depend on the number of spin orbitals but also their "nature". What I mean by that is that you also need to consider these conservation rules which leads to the following scenario in your case:

H2 has 2 electrons in 2 molecular orbitals, which correspond to 4 spin orbitals (and, thus, 4 qubits since you do not apply any reductions, here). Taking into account the spin-conservation you have the following possible single excitations:

0 -> 1
2 -> 3

where I use Qiskit's notation in which spin orbitals are ordered block-wise (i.e. first all alpha orbitals, then all beta ones). If the spin was not conserved, then you would also see excitations such as 0 -> 3 and 1 -> 2.

The double excitations are a little bit simpler in this case because there is only one possibility regardless:

0, 1 -> 2, 3

However, if the example was more complex, the same reasoning would apply here, too.

Regarding your second question: if you would like to see the excitation lists as I have written them above you can take a look at the single_excitations and double_excitations attributes of the UCCSD class. I am not aware of any "partial" decompose() functionality which could otherwise provide that you describe above.

  • $\begingroup$ Thank you mrossinek. I will try what you suggested for the second point. Regarding your comment "UCCSD is a particle- and spin-conserving variational form", I am curious how we ensure a quantum circuit preserve particle numbers? $\endgroup$
    – fagd
    Sep 28, 2020 at 7:33
  • $\begingroup$ Also you mentioned "Qiskit's notation in which spin orbitals are ordered block-wise", if you are familiar with how qiskit label the spin-orbitals, would you mind to help me on another question of mine? Many thanks! quantumcomputing.stackexchange.com/questions/13803/… $\endgroup$
    – fagd
    Sep 28, 2020 at 7:35
  • $\begingroup$ After second thought, I think my confusion is due to the fact that I would like to use UCCSD with VQEAdapt. Since I can trigger the adaptive behavior of UCCSD with “manage_hopping_operators”, and define my own pool of excitations from VQEAdapt. If there is an operator in the pool violate the particle number conservation, what will happen for the UCCSD? $\endgroup$
    – fagd
    Sep 28, 2020 at 18:12
  • $\begingroup$ The particle-conservation is essentially hard-coded into the quantum circuit. I.e. we ensure that the number of 1s in the eigenstate remains constant (unless errors occur). I can take a look at the other question you linked later. $\endgroup$
    – mrossinek
    Sep 29, 2020 at 6:22
  • $\begingroup$ As per your other comment regarding AdaptVQE: I honestly haven't tried a scenario where I add a non-particle conserving operator into the excitation pool. Although I originally added that code to Qiskit during the Qiskit Camp 2019 I barely ever used it at all. $\endgroup$
    – mrossinek
    Sep 29, 2020 at 6:24

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.