หน้านี้ยังไม่ได้รับการแปล คุณกำลังดูเวอร์ชันต้นฉบับภาษาอังกฤษ
SQD for energy estimation of a chemistry Hamiltonian
In this lesson, we will apply SQD to estimate the ground state energy of a molecule.
In particular, we will discuss the following topics using the -step Qiskit pattern approach:
- Step 1: Map problem to quantum circuits and operators
- Setup the molecular Hamiltonian for .
- Explain the chemistry-inspired and hardware-friendly local unitary cluster Jastrow (LUCJ) [1]
- Step 2: Optimize for target hardware
- Optimize gate counts and layout of the ansatz for hardware execution
- Step 3: Execute on target hardware
- Run the optimized circuit on a real QPU to generate samples of the subspace.
- Step 4: Post-process results
- Introduce the self-consistent configuration recovery loop [2]
- Post-process the full set of bitstring samples, using prior knowledge of particle number and the average orbital occupancy calculated on the most recent iteration.
- Probabilistically create batches of subsamples from recovered bitstrings.
- Project and diagonalize the molecular Hamiltonian over each sampled subspace.
- Save the minimum ground state energy found across all batches and update the avg orbital occupancy.
- Introduce the self-consistent configuration recovery loop [2]
We will use several software packages throughout the lesson.
PySCFto define the molecule and setup the Hamiltonian.ffsimpackage to construct the LUCJ ansatz.Qiskitfor transpiling the ansatz for hardware execution.Qiskit IBM Runtimeto execute the circuit on a QPU and collect samples.Qiskit addon SQDconfiguration recovery and ground state energy estimation using subspace projection and matrix diagonalization.
1. Map problem to quantum circuits and operators
Molecular Hamiltonian
A molecular Hamiltonian takes the generic form:
/ are the fermionic creation/annihilation operators associated to the -th basis set element and the spin . and are the one- and two-body electronic integrals. Using pySCF, we will define the molecule and compute the one- and two-body integrals of the Hamiltonian for basis set 6-31g.
# Added by doQumentation — required packages for this notebook
!pip install -q ffsim matplotlib numpy pyscf qiskit qiskit-addon-sqd qiskit-ibm-runtime
import warnings
import pyscf
import pyscf.cc
import pyscf.mcscf
warnings.filterwarnings("ignore")
# Specify molecule properties
open_shell = False
spin_sq = 0
# Build N2 molecule
mol = pyscf.gto.Mole()
mol.build(
atom=[["N", (0, 0, 0)], ["N", (1.0, 0, 0)]], # Two N atoms 1 angstrom apart
basis="6-31g",
symmetry="Dooh",
)
# Define active space
n_frozen = 2
active_space = range(n_frozen, mol.nao_nr())
# Get molecular integrals
scf = pyscf.scf.RHF(mol).run()
num_orbitals = len(active_space)
n_electrons = int(sum(scf.mo_occ[active_space]))
num_elec_a = (n_electrons + mol.spin) // 2
num_elec_b = (n_electrons - mol.spin) // 2
cas = pyscf.mcscf.CASCI(scf, num_orbitals, (num_elec_a, num_elec_b))
mo = cas.sort_mo(active_space, base=0)
hcore, nuclear_repulsion_energy = cas.get_h1cas(mo) # hcore: one-body integrals
eri = pyscf.ao2mo.restore(1, cas.get_h2cas(mo), num_orbitals) # eri: two-body integrals
# Compute exact energy for comparison
exact_energy = cas.run().e_tot
converged SCF energy = -108.835236570774
CASCI E = -109.046671778080 E(CI) = -32.8155692383188 S^2 = 0.0000000
In this lesson, we will use Jordan-Wigner (JW) transformation to map a fermionic wavefunction to a qubit wavefunction so that it can be prepared using a quantum circuit. The JW transformation maps the Fock space of fermions in M spatial orbitals onto the Hilbert space of 2M qubits, that is, a spatial orbital is split into two spin orbitals, one associated with a spin up () electron and another with spin down (). A spin orbital can be occupied or unoccupied. Usually, when we refer to number of orbitals, we will be using number of spatial orbitals. The number of spin orbitals will be double. In quantum circuits, we will represent each spin orbital with one qubit. Thus, a set of qubits will represent spin-up or -orbitals, and another set will represent spin-down or -orbitals. For example, molecule for 6-31g basis set has spatial orbitals (that is, + = spin orbitals). Thus, we will need a -qubit quantum circuit (we may need extra ancilla qubits as discussed later). The qubits are measured in computational basis to generate bitstrings, which represent electronic configurations or (Slater) determinants. Throughout this lesson, we will use the terms bitstrings, configurations, and determinants interchangeably. The bitstrings tell us electron occupancy in spin orbitals: a in a bit position means the corresponding spin orbital is occupied, while a means the spin orbital is empty. As electronic structure problems are particle preserving, only a fixed number of spin orbitals must be occupied. The molecule has spin-up () and spin-down () electrons. Thus, any bitstring representing the and orbitals must have five each for molecule.
1.1 Quantum circuit for sample generation: The LUCJ ansatz
In this lesson, we will use the local unitary coupled cluster Jastrow (LUCJ) \[1\] ansatz for quantum state preparation and subsequent sampling. First, we will explain different building blocks of the full UCJ ansatz and the approximations made in the local version of it. Next, by using ffsim package, we will construct the LUCJ ansatz and optimize it using Qiskit transpiler for hardware execution.
The UCJ ansatz has the following form (for a product of layers or repetitions of the UCJ operator.)
where, is a reference state, typically taken as the Hartree-Fock (HF) state. As the Hartree-Fock state is defined as having the lowest numbered orbitals occupied, the HF state preparation will involve applying X gates to set qubits corresponding to occupied orbitals to one. For example, the HF state preparation block for 4 spatial orbitals and 2 up- and 2 down-spin may look like the following:
A single repetition of the UCJ operator consists of a diagonal Coulomb evolution () sandwiched by orbital rotations ( and ).
Orbital rotation blocks work on a single spin species ( (up-spin)/ (down-spin)). For each electron species, orbital rotation consists of a layer of single-qubit gates followed by a sequence of 2-qubit Given's rotation gates ( gates).
The 2-qubit gates act on adjacent spin-orbitals (nearest neighbor qubits), and therefore, are implementable on IBM® QPUs without the need for SWAP gates.
The , also known as the diagonal Coulomb operator, consists of three blocks. Two of them work on same spin sectors (