Overview of examples

In addition to the detailed tutorials, InQuanto contains several example scripts showing how various functionality is used. In this file we provide a broad overview of the intention of each example, highlighting the functionality that is demonstrated. Examples using the extensions are found elsewhere.

algorithms/adapt

Examples of ADAPT-VQE.

File

Description

algorithm_iqeb.py

A simulation of H2 in STO-3G using IQEB algorithm.

algorithm_fermionic_adapt.py

A simulation of H2 in STO-3G using the ADAPT algorithm with fermionic helper functions.

algorithm_adapt.py

A simulation of H2 in STO-3G using the ADAPT algorithm.

algorithms/qpe

Examples of quantum phase estimation algorithms.

File

Description

iterative_quantum_phase_estimation.py

A simulation of H2 using the Information Theory QPE algorithm and QPDE protocol.

algorithms/qse

Examples of Quantum Subspace Expansion.

File

Description

algorithm_qse.py

A simulation of H2 in STO-3G using the QSE algorithm

algorithms/time_evolution

Examples of time evolution algorithms.

File

Description

time_evolution_example.py

An exact time evolution simulation using express methods

imtime_evolution_example.py

An exact imaginary time evolution simulation using express methods

vqs_real_example_paper.py

A AlgorithmMcLachlanRealTime time evolution simulation for a small system.

vqs_imag_example.py

A AlgorithmMcLachlanImagTime time evolution simulation

vqs_real_example.py

A AlgorithmMcLachlanRealTime time evolution simulation

vqs_real_example_paper_phased.py

A custom equation of motion VQS time evolution simulation.

algorithms/vqd

Examples of Variational Quantum Deflation.

File

Description

algorithm_vqd.py

Variational Quantum Deflation using computables.

algorithms/vqe

Examples of canonical Variational Quantum Eigensolver usage.

File

Description

algorithm_vqe_uccsd.py

A canonical VQE simulation of H2 in STO-3G using a UCCSD Ansatz.

algorithm_vqe_ups.py

A VQE simulation of H4 in STO-3G using UPS Ansatzes.

algorithm_vqe_unitary_cluster_jastrow.py

Example running VQE for unitary cluster Jastrow ansatz.

algorithm_vqe_hva_hubbard.py

A VQE simulation of a 2x4 Hubbard model using a HVA Ansatz.

algorithm_vqe_shots_minimizers.py

Use of minimizers in shot-based calculations.

algorithm_vqe_varCI.py

A canonical VQE simulation of H2 in STO-3G using a variational configuration interaction Ansatz.

algorithm_vqe_hva_chem.py

A VQE simulation of H2 in STO-3G using a HVA Ansatz.

algorithm_vqe_hea.py

A canonical VQE simulation of H2 in STO-3G using a hardware-efficient Ansatz.

algorithm_vqe_varCI_sparse.py

A canonical VQE simulation of H2 in STO-3G using a variational configuration interaction Ansatz.

ansatzes

Examples demonstrating usage of Ansatz classes.

File

Description

unitary_cluster_jastrow.py

Example demonstrating the use of unitary cluster Jastrow ansatz, both exact and fermionic implementations.

hamiltonian_variational_hubbard.py

Use of HVA Ansatz for the Hubbard model.

multiconfigstate_6qubit.py

Preparation of a 6 qubit linear combination of fermionic occupation states with fixed coefficients.

multiconfigstatesparse_6qubit.py

Preparation of a 6 qubit linear combination of fermionic occupation states with fixed coefficients.

multiconfigstatebox_6qubit.py

Preparation of a 6 qubit linear combination of fermionic occupation states with fixed coefficients.

layered_hea.py

Use of a layered hardware efficient Ansatz.

multiconfigsparse_with_symbols.py

Use of a linear combination of fermionic occupation states as a variational ansatz.

multiconfig_with_symbols.py

Use of a linear combination of fermionic occupation states as a variational ansatz.

fermion_space_ansatze.py

Use of a general Fermionic Ansatz.

multireference_builder.py

Use of reference_circuit_builder to prepare a circuit for a multireference state.

multiconfigstate_4qubit.py

Preparation of a 4 qubit linear combination of fermionic occupation states with fixed coefficients.

multiconfigstatesparse_4qubit.py

Preparation of a 4 qubit linear combination of fermionic occupation states with fixed coefficients.

multiconfigstatebox_4qubit.py

Preparation of a 4 qubit linear combination of fermionic occupation states with fixed coefficients.

computables

Examples demonstrating usage of computables classes.

File

Description

computable_protocol_tutorial.py

Demonstrates the general use of computables and protocols.

bootstrapping_simple.py

Computable level usage of BackendResult resampling classes for bootstrappi

bootstrapping_computable.py

Computable level usage of BackendResult resampling classes for bootstrapping of H2 energy (STO-3G).

bootstrapping_vs_uvalue.py

Comparing error bars obtained from bootstrapping (using BackendResultsBootstrap) and linear error propagation.

computables/atomic

Examples demonstrating usage of atomic computable classes.

File

Description

expval_noisy_backend.py

Computable expression example (ExpectationValue)

using_protocol_list.py

An example using protocol list for finite differences

expval_symbolic.py

Use of symbolic protocol for expectation value.

expval_pauli.py

Protocol observable averaging to calculate expectation values.

computable_overlap_squared.py

Computable expression example (OverlapSquared)

derivatives_methods.py

An example showing how to use evaluate gradients

finite_difference.py

An example showing how to use evaluate gradients and compare against finite differences

computable_h2_symbolic_derivatives.py

Use of computables classes for STO-3G H2 expectation value and gradients with symbolic protocol.

computable_h2.py

Use of computables classes for STO-3G H2 expectation value measurement.

computables/composite

Examples demonstrating usage of composite computable classes.

File

Description

hubbard_spin_correlation.py

A basic Hubbard model example using the spin correlation computable.

overlap_matrix.py

Simple overlap matrix calculation.

nonorthogonal_matrices.py

Basic CI calculation with NonOrthogonal computable.

qcm4_computable.py

Estimating energy using QCM4 computable.

qse_matrices.py

An example running QSE using computables

computables/composite/gf

Examples demonstrating usage of Green’s function computable classes.

File

Description

krylov_2.py

Use of KrylovSubspaceComputable to get Green’s function element from shot-based protocol from 1st Lanczos vector.

krylov_0.py

Example of evaluating LanczosCoefficientsComputable to get elements of tridiagonal matrix.

gf_measurenorm_element_shots_2.py

Computation (shots for Lanczos, shots for ground state) one element of GF of Hubbard dimer.

krylov_1.py

Example of evaluating LanczosMatrixComputable to get tridiagonal matrix for given dimension of Krylov space.

gf_measurenorm_matrix_mbgf_circuits.py

Generation of the circuits required for the full GF matrix of the Hubbard dimer.

gf_measurenorm_element_shots_1.py

Computation (shots for Lanczos, statevector for ground state) one element of GF of Hubbard dimer.

gf_measurenorm_matrix_mbgf_spectral.py

Computation of the full GF matrix of the Hubbard dimer, and plot the spectral function A(omega).

krylov_-1.py

Example of building your own Lanczos routine, then comparing it to KrylovSubspaceComputable.

krylov_4.py

Example of evaluating LanczosMatrixComputable with sandwiched moments from shot-based protocol.

gf_measurenorm_matrix_mbgf_spectral_shots.py

Computation of the full GF matrix of the Hubbard dimer with shots, and plot the spectral function A(omega).

gf_measurenorm_element.py

Noiseless statevector computation of one element of GF of Hubbard dimer by sandwiching Hamiltonian moments.

gf_measurenorm_matrix_mbgf.py

Computation (noiseless statevector) the full GF matrix of the Hubbard dimer at a single frequency.

krylov_3.py

Example of evaluating KrylovSubspaceComputable with sandwiched moments from shot-based protocol.

computables/composite/rdm

Examples demonstrating usage of reduced density matrix computable classes.

File

Description

rdm_nevpt2.py

Test of NEVPT2 using RDMs from

rdm_computable.py

An example for constructing an RDM using computables

computables/primitive

Examples demonstrating usage of primitive computable classes.

File

Description

basic_primitives.py

An example showing how to use quantum computables.

core

Examples demonstrating usage of logging and debugging functionality.

File

Description

context_printing.py

Using context for logging standard outputs

embeddings

Examples of usage of embedding methods.

File

Description

dmet_one_h2x3_express_hf.py

One-shot DMET calculations on hydrogen rings.

dmet_one_h2x3_express_vqe.py

One-shot DMET calculations on hydrogen rings

dmet_full_h2x3_express_hf.py

Full DMET calculations on hydrogen rings.

impurity_dmet_h2x3_express_vqe.py

An example impurity DMET simulation of a 3-dihydrogen ring using the express module.

express

Examples of usage of the built-in example molecular data in InQuanto.

File

Description

get_started_express.py

Basic code snippets to use express, operators and states.

hubbard_driver_example.py

1D and 2D Hubbard driver example

h5_operations.py

Built-in example molecular data.

hugr

Examples demonstrating usage of Selene.

File

Description

projective_measurements_hugr.py

Example using a simple ProjectiveMeasurements protocol.

mappings

Examples of fermion-qubit mapping functionality.

File

Description

mapping_paraparticular.py

Use and comparison of the paraparticle mapping from fermions to qubits

mapping_bk.py

Use of the Bravyi-Kitaev mapping from fermions to qubits.

mapping_jw.py

Use of the Jordan-Wigner mapping from fermions to qubits.

minimizers

Examples of classical minimizers in InQuanto.

File

Description

integrators.py

Symbolic evaluation and comparing integrator methods.

minimizers.py

Use of minimizers.

operators

Examples of functionality of operator and state classes.

File

Description

double_factorization_h3.py

Simple shot-based energy calculation using a double factorized, unrestricted-spin hamiltonian.

fermion_state.py

Creation of FermionState objects and demonstration of some functionality.

double_factorization_h2.py

Simple shot-based energy calculation using a double factorized hamiltonian.

qubit_operator.py

Construction of QubitOperator and demonstration of some functionality.

fermion_operator.py

Examples of some FermionOperator methods.

qubit_state.py

Construction of QubitState and demonstration of some functionality.

double_factorization_lih_sv.py

Statevector calculations of energy with a double factorized hamiltonian.

orbital_optimizer.py

Orbital optimization using Pipek-Mezey as an example.

orbital_transformer.py

Orbital transformation methods.

chemistry_integral_operators.py

Creation of ChemistryRestrictedIntegralOperator (CRIO) and conversion to FermionOperator.

protocols

Examples demonstrating usage of protocol classes.

File

Description

hadamard_direct_df_grad_expr.py

Use of Hadamard test derivative for STO-3G H2 expectation value measurement in direct and indirect mode.

hadamard_df_grad_expr.py

Use of Hadamard test derivative for STO-3G H2 expectation value measurement.

feature_projective_measurements.py

Example using a simple ProjectiveMeasurements protocol.

feature_partition_strategy.py

Partition measurement reduction strategies for PauliAveraging protocol.

expval_pmsv.py

Example using PMSV error mitigation to calculate expectation values.

expval_spam_mitres_h2.py

Running SPAM error mitigation via Qermit MitRes on measurement of expectation value for H2.

bootstrapping_expval.py

Low level usage of BackendResult resampling classes, like Bootstrapping.

feature_hadamard_circuit_kernel.py

Use HadamardTest with a chemistry ansatz and a circuit kernel.

factorized_overlap.py

Calculating complex overlaps with the FactorizedOverlap protocols and comparing to HadamardTestOverlap.

expval_spam.py

Running PauliAveraging with inquanto’s noise mitigation.

feature_credits_cost.py

Protocol observable averaging to calculate expectation values.

pauli_hadamard_protocols.py

Usage of the PauliAveraging and HadamardTest protocols.

expval_mitigation_methods+qermit.py

Running protocols via Qermit’s MitRes and MitEx and inquanto’s noise mitigation.

overlap_squared_protocols.py

Compare different shot based protocols for calculating an overlap squared.

hadamard_df_grad_hea.py

Use of Hadamard test derivative for STO-3G H2 expectation value measurement with a hardware-efficient ansatz.

feature_observable_averaging.py

Protocol observable averaging to calculate expectation values.

qermit_spam_zne.py

Running protocols via Qermit’s MitRes and MitEx.

hadamard_test_overlap.py

Calculating complex overlaps with the HadamardTestOverlap protocol.

protocols/phase_estimation

Examples demonstrating usage of the quantum phase estimation protocols.

File

Description

hadamard_test_iqpe_statevector.py

Demonstration of the generation of IPEA unitaries for statevector simulation.

hadamard_test_iqpe_quantinuum.py

Demonstration of the generation of IPEA circuits with the specialized Quantinuum protocols.

sin-state_qpe_2x2_matrix.py

Demonstration of the generation and use of sin-state phase estimation circuits, and plotting of results.

hadamard_test_iqpe.py

Demonstration of the generation of IPEA circuits, and their use for Hadamard test sampling.

spaces

Examples of space classes for generating operators and states.

File

Description

qubit_spaces.py

Use of QubitSpace object to generate qubit operators.

parafermion_space.py

Use of ParaFermionSpace objects to generate parafermionic states and operators.

fermion_spaces.py

Use of FermionSpace objects to generate fermionic states and operators, including point group symmetry.

symmetry

Examples of symmetry classes and functionality.

File

Description

qubit_tapering.py

Qubit tapering - operators and Ansatzae.

point_group.py

Use of PointGroup class containing point group symmetry information.

qubit_symmetry_operators.py

Finding qubit Z2 symmetry operators.

fermionic_symmetry_operators.py

Finding fermionic Z2 symmetry operators.