Active space or orbit of Pennylean and Qiskit

Dear Community,

I’m currently working on mapping a Qiskit program to PennyLane, but I’m facing some challenges when it comes to selecting the active space.

First, I found a sample PennyLane program on ADAPT-VQE that I’d like to use as a reference:

import pennylane as qml
from pennylane import qchem
from pennylane import numpy as np

symbols = ["Li", "H"]
geometry = np.array([[0., 0., 0], [0., 0., 2.8]])
H, qubits = qchem.molecular_hamiltonian(
    symbols,
    geometry,
    charge=0,
    mult=1,
    basis='sto-3g',
    method='pyscf',
    active_electrons=2,
    active_orbitals=5
)

active_electrons = 2
singles, doubles = qchem.excitations(active_electrons, qubits)
print(f"Total number of excitations = {len(singles) + len(doubles)}")

electrons = 4
orbitals = 6
core, active = qchem.active_space(electrons, orbitals, active_electrons=a_electrons, active_orbitals=a_orbitals)
print("List of core orbitals: {:}".format(core))
print("List of active orbitals: {:}".format(active))
print("Number of qubits: {:}".format(2 * len(active)))

Result:

List of core orbitals: [0]
List of active orbitals: [1, 2, 3, 4, 5]
Number of qubits: 10

In this PennyLane program, they set active_orbitals=5. When I change it to active_orbitals=3, the result is:

List of core orbitals: [0]
List of active orbitals: [1, 2, 3]
Number of qubits: 6

Now, here’s my Qiskit program. Please note that the generate_hamiltonian function doesn’t directly relate to my issue, but I’ve included it for context:

molecule = 'LiH'
d = 2.8
spin = 0
charge = 0
use_cas = False

if molecule == "LiH":
    atoms = f'H .0, .0, .0; Li .0, .0, {d}'
    occupied_indices = [0]
    active_indices = [1, 2, 5]
    n_elec = 2

molecular_hamiltonian, qubit_hamiltonian = generate_hamiltonian(molecule, atoms, occupied_indices, active_indices, n_elec, spin, charge, use_cas)

We have found that using [1, 2, 5] is better than [1, 2, 3] for approaching the ground state energy.

Now, my question is how can I translate the occupied_indices=[0] and active_indices=[1,2,5] from Qiskit to PennyLane?

Also, I’m interested in using the ADAPT-VQE method as described ADAPT. How can I input the quantum circuits I obtain using this method into Qiskit, as I want to apply Qiskit’s noise model?

I understand that it is possible to increase the noise model by qiskit_aer the backend, but it is simply too slow. And I have a significant part of my subsequent processing is written in Qiskit.

Thank you for your help!

Hey @Qiming_Ding! Welcome to the forum :sunglasses:

I’ll have to get back to you on this. My initial thought is that the active space indices aren’t changeable, so wanting them to be [1, 2, 5] instead of [1, 2, 3] isn’t doable. But, I’ll double check with one of our qchem experts here :slight_smile:. Sit tight!

Hey @Qiming_Ding, I got a quick response back. Correct me if I’m misinterpreting your original question, but PennyLane doesn’t let you change the active orbital index labels in the way that I mentioned in my previous comment. You can only change the number of active orbitals.

If this is a feature that you’d like us to implement, I suggest that you make a Feature Request to our github repository for the paper trail :smile:.

Hope this helps!

1 Like

Hi @isaacdevlugt ,
Thank you for your reply, your understanding of my question is correct. Unfortunately, Pennylane is not free to change the settings of the active space just yet, although I do see in qiskit that using [1, 2, 5] is better than [1, 2, 3] for approaching the ground state energy. I hope to experience such a feature in future releases.

1 Like

Thanks @Qiming_Ding! Don’t hesitate to make a feature request :grin: appreciate the feedback!