In depth: vqeeCalculator

vqeeCalculator is a command-line executable for accessing Qristal’s MPI-enabled Variational Quantum Eigensolver (VQE) functionality.

Compiling

cd $QRISTAL_INSTALL_DIR/examples/cpp/vqeeCalculator
mkdir build
cd build
cmake .. -DENABLE_MPI=ON
make

Limitations

  • Noise model: none

JSON input and output

Instead of supplying command line options, vqeeCalculator reads a JSON file (and output results to another JSON file) when called with these options:

mpiexec -n 2 vqeeCalculator --fromJson=$json_input_file --jsonID=0 --outputJson=$json_output_file

Input

The fields that are recognized in $json_input_file are shown below:

Key

Example value

Details

nQubits

"nQubits": 5

Number of physical qubits

nShots

"nShots": 128

Number of circuit execution shots

pauli

"pauli":
"5.907 -
2.1433 X0X1 -
2.1433 Y0Y1 +
.21829 Z0 -
6.125 Z1"

Qubit Hamiltonian expressed as
a weighted sum of Pauli terms

geometry

"geometry":
"H 0.0 0.0 0.0;
H 0.0 0.0 0.7408481486"

Alternative to specifying pauli:
atoms in X-Y-Z co-ordinates.
Unit is angstroms

ansatz

"ansatz": "ASWAP"

Predefined quantum circuit conditioned
by parameter thetas

nElectrons

"nElectrons": 2

Number of particles in the ansatz

circuit

See this link for information

Alternative to specifying ansatz and nElectrons

thetas

"thetas": [-0.2,0.14,1.01]

Initial values for ansatz parameters.
A value is needed for each
parameter in the ansatz.

acceleratorName

"acceleratorName": "qpp"

Backend for executing quantum circuits

maxIters

"maxIters": 100

Maximum iteration count
for the classical optimizer

algorithm

"algorithm": "nelder-mead"

Selects the algorithm used for optimization

extraOptions

"extraOptions": "{<key1>: <value1>, <key2>: <value2>, ...}"

Extra options specific
to the optimization
algorithm set in
algorithm.

More details on the
key-value pairs relevant to each
algorithm are at this link.

isDeterministic

"isDeterministic": true

When set to false,
expectations are calculated
from samples (nShots in size)

When
"acceleratorName": "qpp"
and
"isDeterministic": true,
expectations are calculated directly
using linear algebra.

enableVis

"enableVis": true

Enable convergence trace
visualisation

showTheta

"showTheta": true

Enable the display of
theta elements in the
convergence trace visualisation

tolerance

"tolerance": 1.0e-5

Function tolerance
(used as a termination criterion
in the classical optimizer)

nThreads

"nThreads": 2

Number of OpenMP
threads to use

Example JSON input file

[
    {
        "nQubits": 5,
        "acceleratorName": "qpp",
        "pauli": "0.00021123007138713814  +-0.0004797898199899509 X1 Z2 X3 +-0.0004797898199899509 Y1 Z2 Y3 +-0.0008504196943407897 Z1 +-0.0004797898199899509 X2 Z3 X4 +-0.0004797898199899509 Y2 Z3 Y4 +-0.0008504196943407897 Z2 +-0.0009971065473443474 Z3 +-0.0009971065473443474 Z4",
        "ansatz": "ASWAP",
        "nElectrons": 2,
        "maxIters": 1,
        "tolerance": 1e-05,
        "nShots": 1,
        "isDeterministic": true,
        "thetas": [
            0.19282382007161974,
            0.2635945440300202,
            -0.04929291223947813,
            0.04121265889451157,
            0.16609364599654375,
            0.2502175895079587,
            0.0488588580664832,
            1.6109279933369605,
            2.921249087681776
        ]
    }
]

Output

The fields that are output in $json_output_file are shown below:

Key

Details

energy

The optimum (min.) energy at
the end of VQE optimization routine

iterations

Number of iterations reached
before termination of the optimization routine

pauli

The Hamiltonian expressed as
a weighted sum of Pauli terms

theta

The value of the ansatz parameters
that produces the corresponding
optimum (min.) energy

vis

Energy and ansatz parameter
trace visualization

walltime_ms

The execution wall time, in ms

Example output JSON file

{
    "energy": -6.722747367844044e-05,
    "iterations": 1,
    "pauli": "0.00021123007138713814  +-0.0004797898199899509 X1 Z2 X3 +-0.0004797898199899509 Y1 Z2 Y3 +-0.0008504196943407897 Z1 +-0.0004797898199899509 X2 Z3 X4 +-0.0004797898199899509 Y2 Z3 Y4 +-0.0008504196943407897 Z2 +-0.0009971065473443474 Z3 +-0.0009971065473443474 Z4",
    "theta": [
        0.19282382007161974,
        0.2635945440300202,
        -0.04929291223947813,
        0.04121265889451157,
        0.16609364599654375,
        0.2502175895079587,
        0.0488588580664832,
        1.6109279933369605,
        2.921249087681776
    ],
    "walltime_ms": 30.81
}