cutqc2.library.VQE package

Submodules

cutqc2.library.VQE.uccsd_ansatz module

Teague Tomesh - 3/25/2019

Implementation of the UCCSD ansatz for use in the VQE algorithm.

Based on the description given in Whitfield et al. (https://arxiv.org/abs/1001.3855?context=physics.chem-ph)

Adapted from a Scaffold implementation by Pranav Gokhale] (https://github.com/epiqc/ScaffCC)

NOTE: Qiskit orders their circuits increasing from top -> bottom

0 — 1 — 2 —

Both Whitfield et al. and Barkoutsos et al. order increasing from bottom -> top

p 3 — q 2 — r 1 — s 0 —

Not a problem. Qubit index is what matters. Set reverse_bits = True when drawing Qiskit circuit.

class cutqc2.library.VQE.uccsd_ansatz.UCCSD(width, parameters='random', seed=None, barriers=False, regname=None)[source]

Bases: object

Class to implement the UCCSD ansatz as described in Whitfield et al. (https://arxiv.org/abs/1001.3855?context=physics.chem-ph)

A UCCSD circuit can be generated for a given instance of the UCCSD class by calling the gen_circuit() method.

width

number of qubits

Type:

int

parameters

choice of parameters [random, seeded]

Type:

str

seed

a number to seed the number generator with

Type:

int

barriers

should barriers be included in the generated circuit

Type:

bool

regname

optional string to name the quantum and classical registers. This allows for the easy concatenation of multiple QuantumCircuits.

Type:

str

qr

Qiskit QuantumRegister holding all of the quantum bits

Type:

QuantumRegister

circ

Qiskit QuantumCircuit that represents the uccsd circuit

Type:

QuantumCircuit

CNOTLadder(controlStartIndex, controlStopIndex)[source]

Applies a ladder of CNOTs, as in the dashed-CNOT notation at bottom of Table A1 of Whitfield et al 2010

Qubit indices increase from bottom to top

DoubleExcitationOperator(theta, p, q, r, s)[source]

Prerequisite: p > q > r > s

M_d(i, p, q, r, s, dagger=False)[source]

See Double Excitation Operator circuit in Table A1 of Whitfield et al 2010

Y in Table A1 of Whitfield et al 2010 really means Rx(-pi/2)

SingleExcitationOperator(theta, p, q)[source]

Prerequisite: p > q See Single Excitation Operator circuit in Table A1 of Whitfield et al 2010

gen_circuit()[source]

Create a circuit implementing the UCCSD ansatz

Given the number of qubits and parameters, construct the ansatz as given in Whitfield et al.

Returns:

QuantumCircuit object of size nq with no ClassicalRegister and no measurements

Return type:

QuantumCircuit

Module contents