Quantum error mitigation using N-representability of 2-RDM

The 2-RDMs from response theory are not N-representable. That is, the response 2-RDM does not correspond to an actual physical N-electron wave function.

Lanssens et al. presents a new method making these non-N-representable 2-RDMs approximately N-representable in Method For Making 2-Electron Response Reduced Density Matrices Approximately N-representable.

This program is the implementation of the method in this paper and obtains good performance (see below), and serves as a subprogram for Variational Quantum Eigensolver (VQE).

Procedure

See FIG.1 of the paper.

This is implemented in NRepresentabiliy.optimize.

Fix 2-RDM

See from Equation.40 to Equation.43 of the paper.

This is implemented in NRepresentabiliy.fix_two_rdm.

Requirements

See requirements.txt.

This program uses PySCF for calculating energy. Installation of PySCF see here.

P.S. rdm_mapping_functions.py is copied from OpenFermion without any modification. You can install OpenFermion and import the functions in rdm_mapping_functions.py instead. See docs of OpenFermion.

Usage

For using N-representability in your own program, copy NRepresentability.py (and rdm_mapping_functions.py if you do not install OpenFermion) to your program, and refer to error_mitigation.py for the usage. Here are some explanations.

0. Generate ideal and noisy 2-RDM from your ansatz

2-RDM is a 4-dimensional numpy.ndarray.

Let's assume they are stored in ideal_rdm, noisy_rdm.

1. Use NRepresentability to get approximately N-representable 2-RDM

nrep = NRepresentability(
        num_spin_orbital=num_spin_orbitals,
        num_particle=num_particles,
        two_particle_rdm_ideal=ideal_rdm,
        two_particle_rdm_noisy=noisy_rdm
      )
      
nrep.optimize()

# the optimized 2rdm is saved in nrep.two_particle_rdm_optimized

2. Calculate energy using 2-RDM

Calculate energe from 2-RDM and 1-RDM, according to Equation A14 in the Google's famous Hartree Fork paper.

The method of obtaining $ h_{ij} $ and $ V_{ijkl} $ refers to stackexchange.

ideal_energy = get_energy(nrep.two_particle_rdm_ideal, atom, basis, num_particles)
noisy_energy = get_energy(nrep.two_particle_rdm_noisy, atom, basis, num_particles)
optimized_energy = get_energy(nrep.two_particle_rdm_optimized, atom, basis, num_particles)

3. Result

1-qubit and 2-qubit gate error rate:  0.005 0.01
trace of ideal and noisy 2-RDM:  12.00156146577284 13.862
fidelity and norm distance before error mitigation:  22.5801569246888 0.733351165091072
fidelity and norm distance after error mitigation:  21.587536213113708 0.5774721548336637
trace of error-mitigated 2-RDM:  12.000000000000004
converged SCF energy = -1.40975299670212
converged SCF energy = -1.40975299670212
converged SCF energy = -1.40975299670212
Energy calculation with ideal 2-RDM, noisy 2-RDM, and error-mitigated 2-RDM:  -3.701272225045865 -4.2769176286551955 -3.701140476126008

P.S. Since the 2-RDM provided in ./2rdm_array_data is generated from an ansatz which is not optimized, the energy of the noisy 2-RDM is lower than that of ideal one.

As you see, the trace error optimized from 13.862 to 12, while energy optimized from -4.27 to -3.70.

To Do

  1. release the code of generating 2-RDM
  2. embedding this program into some existing quantum error mitigation module

Since (1) might release some of our research idea, so we do not release them at now.