Bravyi_kitaev vs jordan_wigner - molecular Hamiltonian

Mapping bravyi_kitaev vs jordan_wigner - molecular Hamiltonian

I run the code from the following tutorial:

without any changes, except for setting the mapping explicitly to bravyi_kitaev instead of the default one which I assume is jordan_wigner.

After this minor change I get at the end of the VQE result that is numerically not accurate.

The same happens (change to bravyi_kitaev does not allow to reproduce correct numerical results) when I run the code from the Usage Details section from this link:

Is it an internal pennylane issue or is it just that bravyi kitaev for some reason performs worse for chemistry VQE than jordan wigner?

Hi @mbaczyk, welcome to the forum and thank you for posting this question here!

I’m not being able to reproduce your problem. I ran the Adaptive circuits for quantum chemistry — PennyLane demo with mapping='bravyi_kitaev' in the computation of the molecular hamiltonian and I get the same result (E = -7.88223735) as when I specify mapping="jordan_wigner" or when I don’t specify any mapping.

Could you please post the output of qml.about()? import pennylane as qml; qml.about()

If you’re already using the latest PennyLane version then I would recommend that you post the exact line(s) of code that you changed because the problem may be there.

Hi @CatalinaAlbornoz, thank you for your prompt response and warm welcome!

I was working with the Pennylane version 0.22.2 and with that version for the Adaptive circuits tutorial I was getting an error that “output seems to be independent of input” while calculating gradients of circuits. The update to the latest version has solved the issue.

However, I think some problem still exists. Right now I am running bravyi_kitaev transformation in the openfermion library and then I am importing the observable to pennylane. In that case I am still getting an error that output seems to be independent of the input. The following lines are the details how I create my Hamiltonian, then I run the code from Adaptive circuits tutorial for the optimization.

system = '
basis = 'sto-3g'
multiplicity = 1
charge = 0
active_indices = [1, 2, 3, 4, 5]
occupied_indices = [0]
active_orbitals = 2 * len(active_indices)
active_electrons = 2

geometry = openfermion.chem.geometry_from_file('')

molecule = MolecularData(geometry=geometry,

fermionic_H = get_fermion_operator(

Hamiltonian = bravyi_kitaev(fermionic_H)

Hamiltonian = qchem.import_operator(Hamiltonian, format="openfermion")

Hi @mbaczyk, could you please share your full code, including your system? It will make it easier to reproduce your error.

Also, if you want to use an xyz file you can use our read_structure function, without needing to do so many things using openfermion. This may help you prevent errors. Here’s an example on how to use this function:

symbols, coordinates = qml.qchem.read_structure('')
print(symbols, coordinates)