Kernel for ctrl-VQE

Run ctrl-VQE methods by instantiating cvqe.kernel.control() class, takes cvqe.pulse() and cvqe.transmon() as positional arguments.

The following methods are implemented in CtrlQ:

Pulse optimization

Perform ctrl-VQE variational pulse optimization with cvqe.kernel.control.optimize() method. The objective function is the molecular energy. Square and gaussian pulse shapes are currently supported. Efficient analytical gradients are also implemented for the pulse parameters.

Measure energy

Get the molecular energy from the state prepared with control pulses using cvqe.kernel.control.energy(). Supply the optimal pulse shape using cvqe.pulse():

mypulse = cvqe.pulse(shape='square',duration=10.0)
mypulse.amp = [[-0.02,-0.03],[0.02,0.03]] # assumed two-qubits
mypulse.tseq = [[5.0],[5.0]] # two windows
mypulse.freq = [30.0,30.1]

myctrl = cvqe.control(mypulse, myham) # check Transmon Hamiltonian for myham
energy, leak = myctrl.energy()

Get the initial energy (Hartree Fock) using cvqe.kernel.control.HF()

Adaptive parameterization

With adaptive parameterization, grow the number of pulse parameters to optimize with ctrl-VQE. Starting from twindow time segment sqaure pulse, adaptively increase the number of pulse windows one at a time. This scheme ultimately avoids over parameterization and determines the neccesary number of pulse windows.

Perform the adaptive pulse update using cvqe.kernel.control.adapt(). Works only with square pulses with time segments aka windows. Usually start with one pulse window and grow the number of windows.

class ctrlq.cvqe.kernel.control(pulse_, ham, solver='ode', nstep=500, iprint=5)

Control class: kernel for ctrl-VQE

Parameters:
  • pulse (cvqe.pulse) – Pulse
  • ham (cvqe.ham) – Transmon Hamiltonian
  • solver (str) – Solver for time evolution. Supported, ‘ode’, ‘trotter’. Defaults to ‘ode’.
  • nstep (int) – Time step. Defaults to 500.
HF()

Get Hartree Fock energy.

adapt(gradient='analytical', maxiter=200, shape='square', normalize=True, maxls=20, maxwindow=20, twindow=False, random=True, exactE=0, thres=0.0001)

control class method: Perform ctrl-VQE pulse optimization by adaptively increasing the number of pulse parameterization one at a time to determine an optimal number for a target accuracy. Only supported for ‘square’ pulse shape.

Parameters:
  • gradient (str) – Method for computing the gradients in the optimization. ‘numerical’ for numerical gradients for all pulse parameters. ‘analytical’ for an analytical gradients for the amplitudes and numerical gradients for the frequencies. Defaults to ‘analytical’.
  • maxwindow (int) – Maximum number of pulse window (time segments) allowed. Defaults to 20.
  • exactE (float) – Provide exact energy to print the error in each adaptive step. Set iprint to < 2 if not provided.
  • thres (float) – Convergence threshold to terminate adaptive update. thres is the difference to the energy from a previous adaptive step. Defaults to 0.0001.
  • random (bool) – Whether to use random slicing of square pulse or use the duration where gradients are maximum on each halves. Defaults to True.
energy(normalize=True, twindow=True, flattop=False, exactV=[], shape='square')
Parameters:
  • normalize (bool) – Whether to normalize the expectation value. Defaults to True.
  • twindow (bool) – Turn on/off piecewise function. Deaults to True.
  • shape (str) – Shape of control pulse. ‘square’ and ‘gaussian’ forms are supported. Defaults to ‘square’
  • exactV (list) – Supply the exact state to print out overlap (optional).
optimize(method='l-bfgs-b', maxiter=100, maxls=20, gtol=1e-09, ftol=1e-09, exactE=0.0, normalize=False, gradient='numerical', shape='square', optiter=True, pulse_return=False)

Variational pulse optimization: Perform ctrl-VQE pulse optimization using the expectation value of the molecular hamiltonian supplied in ham class.

Parameters:
  • method (str) – Numerical optimization method. Only supports ‘l-bfgs-b’.
  • normalize (bool) – Whether to normalize the expectation value. Defaults to False.
  • maxiter (int) – Maximum number of iteration for optimization. Defaults to 100.
  • maxls (int) – Set the maximum number of line searches in each optimization step (l-bfgs-b line search). Defaults to 20.
  • gradient (str) – Method for computing the gradients in the optimization. ‘numerical’ for numerical gradients for all pulse parameters. ‘analytical’ for an analytical gradients for the amplitudes and numerical gradients for the frequencies. Defaults to ‘numerical’.
  • optiter (bool) – If set False, energy and gradients for the initial step can be returned. Defaults to True.
  • gtol (float) – Exposes gtol of l-bfgs-b’s in scipy. Defaults to 1e-9.
  • ftol (float) – Exposes ftol of l-bfgs-b’s in scipy. Defaults to 1e-9.
  • shape (str) – Shape of control pulse. ‘square’ and ‘gaussian’ forms are supported. Defaults to ‘square’
  • pulse_return (bool) – Returns the pulse object if set True. Defaults to False.