Hybrid Optimization for Variational Quantum Linear Solvers

Sebastian Rodríguez
Wolfram Research South America

(RowDefault[, (Spacer1), , (Spacer1), ])  #WolframTechConf

ABSTRACT

This talk introduces Quantum Natural Gradient Descent (QNGD), a technique that improves the efficiency of quantum optimization algorithms. We will explore its use in a novel Variational Quantum Linear Solver for solving linear systems, implemented with the Wolfram Quantum Framework in Wolfram.

Presentation Overview

Natural Gradient Descent

Quantum Natural Gradient Descent (QNGD)

Example and visualizations

Integration into your project

Quantum Linear Solver (QLS)

QLS circuit + QNGD optimization

Natural Gradient Descent

In natural gradient descent, the metric  ℱ(θ) inform us about the geometry of parameter space. To ensure a faster convergence in this space, we use the natural gradient  ((ℱ(θ))^(-1))∇.

Quantum Natural Gradient Descent

In the search for a metric tensor for the quantum state space, we found the Fubini–Study metric tensor (Subscript[F, ij])

Then each optimization step is given by:

(Subscript[θ, t+1])=(Subscript[θ, t])-η ((F(θ))^(-1))∇ℒ(θ)

where

(Subscript[F, ij])=Re((BraKet[(∂_i)ϕ, (∂_j)ϕ]))-(BraKet[(∂_i)ϕ, ϕ])(BraKet[ϕ, (∂_j)ϕ]),(Ket[(∂_i)ϕ(θ)])=(∂_i)(Ket[ϕ(θ)])/∂(Subscript[θ, i])

Cost Function

We will construct our cost function using the fundamental process of the Variational Quantum Eigensolver (VQE) defining the mean energy:

ℒ(θ)=(Bra[ϕ(θ)])H(Ket[ϕ(θ)]) , (Ket[ϕ(θ,,,),,,,])=V(θ,,)(Ket[0])

We can iteratively adjust θ to minimize the average energy or cost.

Load Quantum Framework

Using Wolfram Quantum Framework

PacletInstall["https://wolfr.am/DevWQCF",ForceVersionInstall->True]

<<Wolfram`QuantumFramework`

Load QuantumOptimization

<<Wolfram`QuantumFramework`QuantumOptimization`

Functionalities

?Wolfram`QuantumFramework`QuantumOptimization`*

Single qubit example

Define |ϕ(θ,,,),,,,⟩ QuantumState:

We want to drive the state to the ground state of the Hamiltonian H=(Subscript[σ, x])

(Ket[ϕ])=state["StateVector"];
(Bra[ϕ])=(SuperDagger[state])["StateVector"];

Implement the cost function:

energy[θ1_,θ2_]=(Bra[ϕ]).PauliMatrix[1].(Ket[ϕ])//ComplexExpand//Simplify

Calculate Fubini–Study metric tensor :

metricTensor=FubiniStudyMetricTensor[state];
matrix=FubiniStudyMetricTensor[state,"Matrix"];
%//MatrixForm

Optimization and visualization

Let’s compare the optimization process:

qparameters=QuantumNaturalGradientDescent[
energy,
metricTensor,
"InitialPoint"->{π/12,π/12},
"LearningRate"->0.05
];

parameters=GradientDescent[
energy,
{π/12,π/12},
"LearningRate"->0.05
];

Quantum Natural Gradient Descent optimization reach the ground state “faster”:

ListLinePlot[{energy@@@qparameters,energy@@@parameters},]

There is a degeneracy in |ϕ(θ,,,),,,,⟩  when (Subscript[θ, 1])=0:

state["Formula"]

state[<|θ1->0.|>]["Formula"]

that is translated into a singularity in the natural gradient:

grad=Grad[energy[θ1,θ2],{θ1,θ2}]

grad/.θ1->0

Inverse[matrix].grad/.θ1->0

In the Quantum Natural Gradient Descent, the optimization path doesn’t go through the singularity

ContourPlot[energy[θ1,θ2],]

In the following plots we show the difference between the streams from the Gradient Descent and Quantum Natural Gradient Descent:

GraphicsRow[{StreamPlot[-grad,],StreamPlot[Inverse[matrix].-grad,]},]

Quantum Linear Solver

Problem: Given a matrix m and vector b, find x such that m.x=b

Use a random vector b and a random m matrix:

m=RandomReal[{0,1},{4,4}];
m//MatrixForm

b=RandomReal[{0,1},4]

Testing the QuantumLinearSolve function:

QuantumLinearSolve[m,b]

LinearSolve[m,b]

Quantum Linear Solver: Step–by–step

We load the controlled multiplexer quantum circuit:

circuit=QuantumCircuitOperator[{"ControlledMultiplexer",m,b}];
circuit["Diagram",ImageSize->Large]

ansatz=circuit[[2]];
ψ=circuit[]

Define the cost function as f(ω)=1- |(BraKet[b, ψ(ω),])|(,^( 2)) :

cost[v1_,v2_,v3_,v4_]:=
QuantumDistance[
	QuantumState[b]["Normalize"],
	ψ[v1,v2,v3,v4]["Normalize"],
"Fidelity"];

Calculate Fubini-Study metric:

metric=FubiniStudyMetricTensor[ψ]

Start optimizing!

init=RandomReal[{0,1},4]

optparam=QuantumNaturalGradientDescent[cost,metric,];
param=GradientDescent[cost,init,];

Check the minimization process with the learning curve:

ListLinePlot[{cost@@@optparam,cost@@@param},]

Calculate ψ((Subscript[ω, opt])) and x((Subscript[ω, opt])):

optψ=ψ[Sequence@@Last@optparam]["AmplitudesList"]

optX=ansatz[Sequence@@Last@optparam]["AmplitudesList"]

Calculate the global phase between b and ψ, and denormalize x:

phase=Mean[b/optψ];
optX= phase*optX/Norm[m]

This result match with the LinearSolve output:

LinearSolve[m,b]

Summary

Wolfram Quantum Framework supports the Quantum Natural Gradient Descent method using the Fubini-Study metric tensor.

Using the Fubini-Study metric along with the Quantum Natural Gradient Descent improves the optimization for quantum variational algorithms.

In particular, we used the Quantum Natural Gradient Descent for the optimization of the Quantum Linear Solver.

In this case, using the Fubini–Study metric and the quantum fidelity cost function makes the convergence faster.

{ListLinePlot[{energy@@@qparameters,energy@@@parameters},],,ListLinePlot[{cost@@@optparam,cost@@@param},]}//Row

Thanks!

Sebastián Rodríguez Falcón
srodriguez@wolfram.com

References

“Quantum Optimization Tech Note”. Rodriguez, S. (2024). Wolfram Language Paclet Repository.
https://resources.wolframcloud.com/PacletRepository/resources/Wolfram/QuantumFramework/tutorial/QuantumOptimization.html

“Multiplexer-based variational quantum linear solver​”. Rodriguez, S.​ (2024). Wolfram Community, STAFF PICKS.
​https://community.wolfram.com/groups/-/m/t/3253903

“Natural gradient descent optimization for quantum circuits with Fubini–Study metric tensor​”. Rodriguez, S. (2024). Wolfram Community, STAFF PICKS.
​https://community.wolfram.com/groups/-/m/t/3131997

“Natural gradient works efficiently in learning”. Amari, S. (1998). Natural gradient works efficiently in learning. Neural Computation, 10(2), 251–276.
https://doi.org/10.1162/089976698300017746

“On the natural gradient for variational quantum eigensolver”. Yamamoto, N. (2019). On the natural gradient for variational quantum eigensolver. Cornell University.
https://doi.org/10.48550/arxiv.1909.05074

“Quantum Natural gradient”. Stokes, J., Izaac, J., Killoran, N., & Carleo, G. (2020). Quantum Natural gradient. Quantum, 4, 269.
https://doi.org/10.22331/q-2020-05-25-269

“Variational Quantum Linear Solver”. Bravo-Prieto, C., LaRose, R., Cerezo, M., Subasi, Y., Cincio, L., & Coles, P. J. (2023). Variational Quantum Linear Solver. Quantum, 7, 1188.
https://doi.org/10.22331/q-2023-11-22-1188