Parametric programs
Qadence base Parameter
type is a subtype of sympy.Symbol
. There are three kinds of parameter subtypes used:
Fixed Parameter : A constant with a fixed, non-trainable value (e.g. \(\dfrac{\pi}{2}\) ).
Variational Parameter : A trainable parameter which can be optimized.
Feature Parameter : A non-trainable parameter which can be used to encode classical data into a quantum state.
Fixed Parameters
To pass a fixed parameter to a gate (or any parametrizable block), one can simply use either Python numeric types or wrapped in
a torch.Tensor
.
from qadence import RX , run , PI
# Let's use a torch type.
block = RX ( 0 , PI )
wf = run ( block )
# Let's pass a simple float.
block = RX ( 0 , 1. )
wf = run ( block )
w f = tens or( [[ 6.1232e-17+0. j , 0.0000e+00-1. j ]] )
w f = tens or( [[ 0.8776+0.0000 j , 0.0000-0.4794 j ]] )
Variational Parameters
To parametrize a block by an angle theta
, either a Python string
or an instance of VariationalParameter
can be passed instead of a numeric type to the gate constructor:
from qadence import RX , run , VariationalParameter
block = RX ( 0 , "theta" )
# This is equivalent to:
block = RX ( 0 , VariationalParameter ( "theta" ))
wf = run ( block )
w f = tens or( [[ 0.9882+0.0000 j , 0.0000-0.1531 j ]] )
In the first case in the above example, theta
is automatically inferred as a VariationalParameter
(i.e. trainable). It is initialized to a random value for the purposes of execution. In the context of a QuantumModel
, there is no need to pass a value for theta
to the run
method since it is stored within the underlying model parameter dictionary.
Feature Parameters
FeatureParameter
types (i.e. inputs), always need to be provided with a value or a batch of values as a dictionary:
from torch import tensor
from qadence import RX , run , FeatureParameter
block = RX ( 0 , FeatureParameter ( "phi" ))
wf = run ( block , values = { "phi" : tensor ([ 1. , 2. ])})
w f = tens or( [[ 0.8776+0.0000 j , 0.0000-0.4794 j ],
[ 0.5403+0.0000 j , 0.0000-0.8415 j ]] )
Now, run
returns a batch of states, one for every provided angle which coincides with the value of the particular FeatureParameter
.
Multiparameter Expressions
However, an angle can itself be an expression Parameter
types of any kind.
As such, any sympy expression expr: sympy.Basic
consisting of a combination of free symbols (i.e. sympy
types) and Qadence Parameter
can
be passed to a block, including trigonometric functions.
from torch import tensor
from qadence import RX , Parameter , run , FeatureParameter
from sympy import sin
theta , phi = Parameter ( "theta" ), FeatureParameter ( "phi" )
block = RX ( 0 , sin ( theta + phi ))
# Remember, to run the block, only FeatureParameter values have to be provided:
values = { "phi" : tensor ([ 1.0 , 2.0 ])}
wf = run ( block , values = values )
w f = tens or( [[ 0.8785+0.0000 j , 0.0000-0.4778 j ],
[ 0.9538+0.0000 j , 0.0000-0.3006 j ]] )
Parameters Redundancy
Parameters are uniquely defined by their name and redundancy is allowed in composite blocks to
assign the same value to different blocks.
import torch
from qadence import RX , RY , run , chain , kron
block = chain (
kron ( RX ( 0 , "phi" ), RY ( 1 , "theta" )),
kron ( RX ( 0 , "phi" ), RY ( 1 , "theta" )),
)
wf = run ( block ) # Same random initialization for all instances of phi and theta.
w f = tens or( [[ 0.5500+0.0000 j , 0.5257+0.0000 j , 0.0000-0.4691 j , 0.0000-0.4484 j ]] )
Parametrized Circuits
Now, let's have a look at the construction of a variational ansatz which composes FeatureParameter
and VariationalParameter
types:
import sympy
from qadence import RX , RY , RZ , CNOT , Z , run , chain , kron , FeatureParameter , VariationalParameter
phi = FeatureParameter ( "phi" )
theta = VariationalParameter ( "theta" )
block = chain (
kron (
RX ( 0 , phi / theta ),
RY ( 1 , theta * 2 ),
RZ ( 2 , sympy . cos ( phi )),
),
kron (
RX ( 0 , phi ),
RY ( 1 , theta ),
RZ ( 2 , phi ),
),
kron (
RX ( 0 , phi ),
RY ( 1 , theta ),
RZ ( 2 , phi ),
),
kron (
RX ( 0 , phi + theta ),
RY ( 1 , theta ** 2 ),
RZ ( 2 , sympy . cos ( phi )),
),
chain ( CNOT ( 0 , 1 ), CNOT ( 1 , 2 ))
)
block . tag = "Rotations"
obs = 2 * kron ( * map ( Z , range ( 3 )))
block = chain ( block , obs )
%3
cluster_81dc7221722a4460a75c7e522bf9eb3d
[* 2]
cluster_f878e9a8370d4e22adee94c17ca7a2cc
Rotations
cde255f99dfe45f7818b055f2ccaac43
0
1a48214d76f744178db3cb87ae6304a9
RX(phi/theta)
cde255f99dfe45f7818b055f2ccaac43--1a48214d76f744178db3cb87ae6304a9
596e5fc5a7114b0c8f531d6680c4954c
1
8d068210d0594aac992e2818ae9ff125
RX(phi)
1a48214d76f744178db3cb87ae6304a9--8d068210d0594aac992e2818ae9ff125
29d7c622505943efab4547e2062c1477
RX(phi)
8d068210d0594aac992e2818ae9ff125--29d7c622505943efab4547e2062c1477
0b78b02d0eda40128c38464ef8c34d2f
RX(phi + theta)
29d7c622505943efab4547e2062c1477--0b78b02d0eda40128c38464ef8c34d2f
f3b0f92f53a24e579018dca6d2004ef8
0b78b02d0eda40128c38464ef8c34d2f--f3b0f92f53a24e579018dca6d2004ef8
999e2da6675345f48bead0e20a9e7ecf
f3b0f92f53a24e579018dca6d2004ef8--999e2da6675345f48bead0e20a9e7ecf
a8ef52e4b01644d0801243571640fa2a
Z
999e2da6675345f48bead0e20a9e7ecf--a8ef52e4b01644d0801243571640fa2a
7b12a7418f944434a3a7b3623de547cf
a8ef52e4b01644d0801243571640fa2a--7b12a7418f944434a3a7b3623de547cf
bd5383402eb54adf9f911d4d8727307b
80f90190f6ef4cf3a2ca9a677e1f27dc
RY(2*theta)
596e5fc5a7114b0c8f531d6680c4954c--80f90190f6ef4cf3a2ca9a677e1f27dc
e844b8b6e42848a1bc317457589ee118
2
d5adc1cb18aa4d518a96bfe08a581360
RY(theta)
80f90190f6ef4cf3a2ca9a677e1f27dc--d5adc1cb18aa4d518a96bfe08a581360
f764807f7eb34cadb405cbba7b6ad5a2
RY(theta)
d5adc1cb18aa4d518a96bfe08a581360--f764807f7eb34cadb405cbba7b6ad5a2
295e447475a24b0c9cf5e9b29bf28b60
RY(theta**2)
f764807f7eb34cadb405cbba7b6ad5a2--295e447475a24b0c9cf5e9b29bf28b60
e5dd6138cef8408f92e86bbf5faa0853
X
295e447475a24b0c9cf5e9b29bf28b60--e5dd6138cef8408f92e86bbf5faa0853
e5dd6138cef8408f92e86bbf5faa0853--f3b0f92f53a24e579018dca6d2004ef8
213328d0ad3d4bdfb64dab494295e684
e5dd6138cef8408f92e86bbf5faa0853--213328d0ad3d4bdfb64dab494295e684
db1a5b8671bb4cd7a7fb5c7e65676bf4
Z
213328d0ad3d4bdfb64dab494295e684--db1a5b8671bb4cd7a7fb5c7e65676bf4
db1a5b8671bb4cd7a7fb5c7e65676bf4--bd5383402eb54adf9f911d4d8727307b
54eef3f12b9b47899033077b1c444481
39d757f1749d4527bccdc9d956a0f40c
RZ(cos(phi))
e844b8b6e42848a1bc317457589ee118--39d757f1749d4527bccdc9d956a0f40c
c4838936e3614b7892a280f44cebb34f
RZ(phi)
39d757f1749d4527bccdc9d956a0f40c--c4838936e3614b7892a280f44cebb34f
f4b7c7560eb245baa9e1a41e424f580c
RZ(phi)
c4838936e3614b7892a280f44cebb34f--f4b7c7560eb245baa9e1a41e424f580c
b6f2f801dd5a408fabfb50c34a3ddd2f
RZ(cos(phi))
f4b7c7560eb245baa9e1a41e424f580c--b6f2f801dd5a408fabfb50c34a3ddd2f
12a9177f746d455a8df5e92fa0e3c7f8
b6f2f801dd5a408fabfb50c34a3ddd2f--12a9177f746d455a8df5e92fa0e3c7f8
10117d35642647dbbca421c789bd4d76
X
12a9177f746d455a8df5e92fa0e3c7f8--10117d35642647dbbca421c789bd4d76
10117d35642647dbbca421c789bd4d76--213328d0ad3d4bdfb64dab494295e684
1c18e9d590744c3a8dd829bcc1b6c77f
Z
10117d35642647dbbca421c789bd4d76--1c18e9d590744c3a8dd829bcc1b6c77f
1c18e9d590744c3a8dd829bcc1b6c77f--54eef3f12b9b47899033077b1c444481
Please note the different colors for the parametrization with different types. The default palette assigns light blue for VariationalParameter
, light green for FeatureParameter
and shaded red for observables.
Parametrized QuantumModels
As a quick reminder: FeatureParameter
are used for data input and data encoding into a quantum state.
VariationalParameter
are trainable parameters in a variational ansatz. When used within a QuantumModel
, an abstract quantum circuit is made differentiable with respect to both variational and feature
parameters which are uniquely identified by their name.
from qadence import FeatureParameter , Parameter , VariationalParameter
# Feature parameters are non-trainable parameters.
# Their primary use is input data encoding.
fp = FeatureParameter ( "x" )
assert fp == Parameter ( "x" , trainable = False )
# Variational parameters are trainable parameters.
# Their primary use is for optimization.
vp = VariationalParameter ( "y" )
assert vp == Parameter ( "y" , trainable = True )
Let's construct a parametric quantum circuit.
from qadence import QuantumCircuit , RX , RY , chain , kron
theta = VariationalParameter ( "theta" )
phi = FeatureParameter ( "phi" )
block = chain (
kron ( RX ( 0 , theta ), RY ( 1 , theta )),
kron ( RX ( 0 , phi ), RY ( 1 , phi )),
)
circuit = QuantumCircuit ( 2 , block )
unique_params = circuit . unique_parameters
u n ique_params = [ t he ta , phi ]
In the circuit above, four parameters are defined but only two unique names. Therefore, there will be only one
variational parameter to be optimized.
The QuantumModel
class also provides convenience methods to manipulate parameters.
from qadence import QuantumModel , BackendName , DiffMode
model = QuantumModel ( circuit , backend = BackendName . PYQTORCH , diff_mode = DiffMode . AD )
num_vparams = model . num_vparams # get the number of variational parameters
vparams_values = model . vparams
nu m_vparams = 1
vparams_values = OrderedDic t ( [ (' t he ta ' , tens or( [ 0.2054 ] )) ] )
Only provide feature parameter values to the quantum model
In order to run
the variational circuit only feature parameter values have to be provided.
Variational parameters are stored in the model itself. If multiple feature parameters are present,
values must be provided in batches of same length.
import torch
values = { "phi" : torch . rand ( 3 )} # theta does not appear here
wf = model . run ( values )
w f = tens or( [[ 0.9677+0.0000 j , 0.1768+0.0000 j , 0.0000-0.1768 j , 0.0000-0.0323 j ],
[ 0.9856+0.0000 j , 0.1193+0.0000 j , 0.0000-0.1193 j , 0.0000-0.0144 j ],
[ 0.8356+0.0000 j , 0.3706+0.0000 j , 0.0000-0.3706 j , 0.0000-0.1644 j ]],
grad_ fn =<TBackward 0 >)
Standard constructors
The unique parameter identification is relevant when using built-in Qadence block
constructors in the qadence.constructors
module such as feature maps and hardware
efficient ansatze (HEA).
from qadence import QuantumCircuit , hea
n_qubits = 4
depth = 2
hea1 = hea ( n_qubits = n_qubits , depth = depth )
circuit = QuantumCircuit ( n_qubits , hea1 )
num_unique_parameters = circuit . num_unique_parameters
U n ique parame ters wi t h a si n gle HEA : 24
%3
d16c84c33efe4dbd881ded07b32ec277
0
10bce040a4d342bc8f5cfdd0830d005a
RX(theta₀)
d16c84c33efe4dbd881ded07b32ec277--10bce040a4d342bc8f5cfdd0830d005a
1dabfb0efb754927a6bc1b758c421589
1
660625b8ce6e4a219443e2325418749c
RY(theta₄)
10bce040a4d342bc8f5cfdd0830d005a--660625b8ce6e4a219443e2325418749c
7949b9a3d4554870bb93bc34c39756eb
RX(theta₈)
660625b8ce6e4a219443e2325418749c--7949b9a3d4554870bb93bc34c39756eb
867029a335f0415eb0847bbc89cdaacd
7949b9a3d4554870bb93bc34c39756eb--867029a335f0415eb0847bbc89cdaacd
0cf3695773bf4707980d7842f96c6333
867029a335f0415eb0847bbc89cdaacd--0cf3695773bf4707980d7842f96c6333
cbc5b36079bb4933aad925984a6bddf4
RX(theta₁₂)
0cf3695773bf4707980d7842f96c6333--cbc5b36079bb4933aad925984a6bddf4
55716b3145f1408fa5e5bcf879799c69
RY(theta₁₆)
cbc5b36079bb4933aad925984a6bddf4--55716b3145f1408fa5e5bcf879799c69
05a201773b9042cc8db2fa9b896aed4f
RX(theta₂₀)
55716b3145f1408fa5e5bcf879799c69--05a201773b9042cc8db2fa9b896aed4f
cb43cc2f6e01432cb6ff8e1f7ac2ae35
05a201773b9042cc8db2fa9b896aed4f--cb43cc2f6e01432cb6ff8e1f7ac2ae35
38efcfd3f14b4d4ba5d92b1b90d1a5ee
cb43cc2f6e01432cb6ff8e1f7ac2ae35--38efcfd3f14b4d4ba5d92b1b90d1a5ee
bec80bee671a4fb08824ee8d50cf13f1
38efcfd3f14b4d4ba5d92b1b90d1a5ee--bec80bee671a4fb08824ee8d50cf13f1
50810dc841e845dcb78abbdcc80320f6
e23e26f980164b1f865ae58d58263b1f
RX(theta₁)
1dabfb0efb754927a6bc1b758c421589--e23e26f980164b1f865ae58d58263b1f
9124b9e8b8524962b8c53c99060b0285
2
3c66a7a16d354bd4ab17619c9304224f
RY(theta₅)
e23e26f980164b1f865ae58d58263b1f--3c66a7a16d354bd4ab17619c9304224f
70f46c301b244cd59e2dd042e2d8ec35
RX(theta₉)
3c66a7a16d354bd4ab17619c9304224f--70f46c301b244cd59e2dd042e2d8ec35
77a735b8bdbf4e3394aaf81d574461a3
X
70f46c301b244cd59e2dd042e2d8ec35--77a735b8bdbf4e3394aaf81d574461a3
77a735b8bdbf4e3394aaf81d574461a3--867029a335f0415eb0847bbc89cdaacd
15b963078106455da0524ba6b6eb707c
77a735b8bdbf4e3394aaf81d574461a3--15b963078106455da0524ba6b6eb707c
872ed5707c65426a9c0a6cc1893f929e
RX(theta₁₃)
15b963078106455da0524ba6b6eb707c--872ed5707c65426a9c0a6cc1893f929e
78f3b8752cfb4e12a2844b84f44f7413
RY(theta₁₇)
872ed5707c65426a9c0a6cc1893f929e--78f3b8752cfb4e12a2844b84f44f7413
cce7f76fbd554e8294ba4af7f79810aa
RX(theta₂₁)
78f3b8752cfb4e12a2844b84f44f7413--cce7f76fbd554e8294ba4af7f79810aa
916cf60f364c4e8dac09eec893b8bd64
X
cce7f76fbd554e8294ba4af7f79810aa--916cf60f364c4e8dac09eec893b8bd64
916cf60f364c4e8dac09eec893b8bd64--cb43cc2f6e01432cb6ff8e1f7ac2ae35
ea26396e285e47129312a2694388440f
916cf60f364c4e8dac09eec893b8bd64--ea26396e285e47129312a2694388440f
ea26396e285e47129312a2694388440f--50810dc841e845dcb78abbdcc80320f6
9d2835d000cb4cee883261a654a67c3a
9f14daa65eca4b2086663d52c7ba17ae
RX(theta₂)
9124b9e8b8524962b8c53c99060b0285--9f14daa65eca4b2086663d52c7ba17ae
7881abfec0164f56a026c84a8d8df6f7
3
f56f461c289f4e3f83a8cd55f405c290
RY(theta₆)
9f14daa65eca4b2086663d52c7ba17ae--f56f461c289f4e3f83a8cd55f405c290
684b06e2fd534185a1c7afb1b2a5b46c
RX(theta₁₀)
f56f461c289f4e3f83a8cd55f405c290--684b06e2fd534185a1c7afb1b2a5b46c
9a1b3c1398ab4b3c947c39556a4c8305
684b06e2fd534185a1c7afb1b2a5b46c--9a1b3c1398ab4b3c947c39556a4c8305
03c622a103684f0fbf882fcbc742e6c2
X
9a1b3c1398ab4b3c947c39556a4c8305--03c622a103684f0fbf882fcbc742e6c2
03c622a103684f0fbf882fcbc742e6c2--15b963078106455da0524ba6b6eb707c
7c588e83a2c14058890adeb115f32a99
RX(theta₁₄)
03c622a103684f0fbf882fcbc742e6c2--7c588e83a2c14058890adeb115f32a99
e74b67c724514e1d91eaf86ade949188
RY(theta₁₈)
7c588e83a2c14058890adeb115f32a99--e74b67c724514e1d91eaf86ade949188
44eefb477c114dd4b452fa447e33e8fc
RX(theta₂₂)
e74b67c724514e1d91eaf86ade949188--44eefb477c114dd4b452fa447e33e8fc
e85793ddd0774021ae8cb2ba276c7380
44eefb477c114dd4b452fa447e33e8fc--e85793ddd0774021ae8cb2ba276c7380
4c763d578954401fa2ec532142b9355d
X
e85793ddd0774021ae8cb2ba276c7380--4c763d578954401fa2ec532142b9355d
4c763d578954401fa2ec532142b9355d--ea26396e285e47129312a2694388440f
4c763d578954401fa2ec532142b9355d--9d2835d000cb4cee883261a654a67c3a
fc6d68c340ba4a05819c2a96e0e07b60
1ee025e2c2c045a396ff0f91769ca144
RX(theta₃)
7881abfec0164f56a026c84a8d8df6f7--1ee025e2c2c045a396ff0f91769ca144
ae0df8d6aeaa4b3db6d57876b24249d9
RY(theta₇)
1ee025e2c2c045a396ff0f91769ca144--ae0df8d6aeaa4b3db6d57876b24249d9
8e72378d79af4951967d64bab9cf8302
RX(theta₁₁)
ae0df8d6aeaa4b3db6d57876b24249d9--8e72378d79af4951967d64bab9cf8302
fa979dc2858144a6bebf1b2913fe9ff0
X
8e72378d79af4951967d64bab9cf8302--fa979dc2858144a6bebf1b2913fe9ff0
fa979dc2858144a6bebf1b2913fe9ff0--9a1b3c1398ab4b3c947c39556a4c8305
06810a9caf0840caa2b20fa0a8b7bc36
fa979dc2858144a6bebf1b2913fe9ff0--06810a9caf0840caa2b20fa0a8b7bc36
0353f505a4664ccf9aba31dc2a9bfae0
RX(theta₁₅)
06810a9caf0840caa2b20fa0a8b7bc36--0353f505a4664ccf9aba31dc2a9bfae0
6e54527cc473443189a0e883c58daf2a
RY(theta₁₉)
0353f505a4664ccf9aba31dc2a9bfae0--6e54527cc473443189a0e883c58daf2a
875d5e4ea5d34cc6b1047e84787203dd
RX(theta₂₃)
6e54527cc473443189a0e883c58daf2a--875d5e4ea5d34cc6b1047e84787203dd
d2c932005dc54427ad39fd5cae6f0e40
X
875d5e4ea5d34cc6b1047e84787203dd--d2c932005dc54427ad39fd5cae6f0e40
d2c932005dc54427ad39fd5cae6f0e40--e85793ddd0774021ae8cb2ba276c7380
1dad8439ae29469787fc16968293471e
d2c932005dc54427ad39fd5cae6f0e40--1dad8439ae29469787fc16968293471e
1dad8439ae29469787fc16968293471e--fc6d68c340ba4a05819c2a96e0e07b60
A new circuit can be created by adding another identical HEA. As expected, the number of unique parameters
is the same.
hea2 = hea ( n_qubits = n_qubits , depth = depth )
circuit = QuantumCircuit ( n_qubits , hea1 , hea2 )
num_unique_params_two_heas = circuit . num_unique_parameters
U n ique parame ters wi t h t wo s ta cked HEAs : 24
%3
cluster_9d5be485247b4cc3811ca0dbac174112
HEA
cluster_b19183dd56ca474c8b7aa8a1d9a0ce18
HEA
40655cec94ab4ce8a8d0d28199584703
0
3cf10b93c6b144cd97cce2cfc3a571f8
RX(theta₀)
40655cec94ab4ce8a8d0d28199584703--3cf10b93c6b144cd97cce2cfc3a571f8
b5c087c77a95487f8d57f22bfaa7d60d
1
f1cf25dc62054a7eb4f514704c4977e8
RY(theta₄)
3cf10b93c6b144cd97cce2cfc3a571f8--f1cf25dc62054a7eb4f514704c4977e8
fd2d881c10ab42e1819f1d401b8aa34a
RX(theta₈)
f1cf25dc62054a7eb4f514704c4977e8--fd2d881c10ab42e1819f1d401b8aa34a
e7f212875180478c9b4d67455abe92cc
fd2d881c10ab42e1819f1d401b8aa34a--e7f212875180478c9b4d67455abe92cc
5b26de7e790349d3921456ee67a8fc06
e7f212875180478c9b4d67455abe92cc--5b26de7e790349d3921456ee67a8fc06
1bf27141498344119e6db4a0b93026ef
RX(theta₁₂)
5b26de7e790349d3921456ee67a8fc06--1bf27141498344119e6db4a0b93026ef
901af0614d5d49d49c5bf5e7f531677a
RY(theta₁₆)
1bf27141498344119e6db4a0b93026ef--901af0614d5d49d49c5bf5e7f531677a
959308c977604040b172c87c8f17a6f4
RX(theta₂₀)
901af0614d5d49d49c5bf5e7f531677a--959308c977604040b172c87c8f17a6f4
7c384307bfb4467e87b677c432fe579a
959308c977604040b172c87c8f17a6f4--7c384307bfb4467e87b677c432fe579a
dcf3a78f76274a3385d0c87b1faac08c
7c384307bfb4467e87b677c432fe579a--dcf3a78f76274a3385d0c87b1faac08c
f70df7a8094b4b449aff3d9386ca22f8
RX(theta₀)
dcf3a78f76274a3385d0c87b1faac08c--f70df7a8094b4b449aff3d9386ca22f8
4fe7447e42ba4a67ac3f2e0842b5c3de
RY(theta₄)
f70df7a8094b4b449aff3d9386ca22f8--4fe7447e42ba4a67ac3f2e0842b5c3de
1b6843b6cc7147d7a1e9be5a33b2cfa7
RX(theta₈)
4fe7447e42ba4a67ac3f2e0842b5c3de--1b6843b6cc7147d7a1e9be5a33b2cfa7
41dfbc9966cc44f0b292e6addc9580d2
1b6843b6cc7147d7a1e9be5a33b2cfa7--41dfbc9966cc44f0b292e6addc9580d2
9a209e0c0d2d4a88b747ad399b55ef0a
41dfbc9966cc44f0b292e6addc9580d2--9a209e0c0d2d4a88b747ad399b55ef0a
106e8b8b431a472abad3d71cd32f4b30
RX(theta₁₂)
9a209e0c0d2d4a88b747ad399b55ef0a--106e8b8b431a472abad3d71cd32f4b30
cf4e11b19a064f16b4b1bd5759379a9b
RY(theta₁₆)
106e8b8b431a472abad3d71cd32f4b30--cf4e11b19a064f16b4b1bd5759379a9b
acbecfe323f045eb9a421534ccd0c375
RX(theta₂₀)
cf4e11b19a064f16b4b1bd5759379a9b--acbecfe323f045eb9a421534ccd0c375
35ecd83779ac4d7f9b9fdcc082aee2e0
acbecfe323f045eb9a421534ccd0c375--35ecd83779ac4d7f9b9fdcc082aee2e0
ad899d94fcbe4f31a1201f83b20bbf4a
35ecd83779ac4d7f9b9fdcc082aee2e0--ad899d94fcbe4f31a1201f83b20bbf4a
12f6bfab8b4b484d9fd6c661538f8a04
ad899d94fcbe4f31a1201f83b20bbf4a--12f6bfab8b4b484d9fd6c661538f8a04
59b4fcfb92ef409098f37e068eb1f56e
0cfde6bd74ad43d78251bfc6bc251f6d
RX(theta₁)
b5c087c77a95487f8d57f22bfaa7d60d--0cfde6bd74ad43d78251bfc6bc251f6d
ebb363b8e7b741be99e96be92875a813
2
41efa23853a74a5c8da89628d121249e
RY(theta₅)
0cfde6bd74ad43d78251bfc6bc251f6d--41efa23853a74a5c8da89628d121249e
fa07e1dcddbb420aaf5800b5f4be5529
RX(theta₉)
41efa23853a74a5c8da89628d121249e--fa07e1dcddbb420aaf5800b5f4be5529
d3280de4b2ea4088b7911982a8e57a7a
X
fa07e1dcddbb420aaf5800b5f4be5529--d3280de4b2ea4088b7911982a8e57a7a
d3280de4b2ea4088b7911982a8e57a7a--e7f212875180478c9b4d67455abe92cc
e60bf3b6666849a3aa1eff0fd247dd1b
d3280de4b2ea4088b7911982a8e57a7a--e60bf3b6666849a3aa1eff0fd247dd1b
93de5b2f03464878907170e0ded929f6
RX(theta₁₃)
e60bf3b6666849a3aa1eff0fd247dd1b--93de5b2f03464878907170e0ded929f6
ca819af737dd446da8b9d488b88333ec
RY(theta₁₇)
93de5b2f03464878907170e0ded929f6--ca819af737dd446da8b9d488b88333ec
bcc92e72d95d42519dbc60254e96574a
RX(theta₂₁)
ca819af737dd446da8b9d488b88333ec--bcc92e72d95d42519dbc60254e96574a
d9d489a98f9340f4b44f595a3595a27d
X
bcc92e72d95d42519dbc60254e96574a--d9d489a98f9340f4b44f595a3595a27d
d9d489a98f9340f4b44f595a3595a27d--7c384307bfb4467e87b677c432fe579a
85dc2c5871384a179d4b886bb7e41702
d9d489a98f9340f4b44f595a3595a27d--85dc2c5871384a179d4b886bb7e41702
11c7d56b3563460994b1c2c987d07858
RX(theta₁)
85dc2c5871384a179d4b886bb7e41702--11c7d56b3563460994b1c2c987d07858
dc27d3d41dd5463e82db3ad6cb613aa6
RY(theta₅)
11c7d56b3563460994b1c2c987d07858--dc27d3d41dd5463e82db3ad6cb613aa6
36739fabc2ac4ca2a71b52224b2c8db1
RX(theta₉)
dc27d3d41dd5463e82db3ad6cb613aa6--36739fabc2ac4ca2a71b52224b2c8db1
ad13cfcd24e54030ade80f8670a121d4
X
36739fabc2ac4ca2a71b52224b2c8db1--ad13cfcd24e54030ade80f8670a121d4
ad13cfcd24e54030ade80f8670a121d4--41dfbc9966cc44f0b292e6addc9580d2
0aa229b7c4f546eabd37b8040a4dcb5f
ad13cfcd24e54030ade80f8670a121d4--0aa229b7c4f546eabd37b8040a4dcb5f
f68563a2110a4ce4845565215e1a9d84
RX(theta₁₃)
0aa229b7c4f546eabd37b8040a4dcb5f--f68563a2110a4ce4845565215e1a9d84
aaeaf84447a54340852f2a9fd550d550
RY(theta₁₇)
f68563a2110a4ce4845565215e1a9d84--aaeaf84447a54340852f2a9fd550d550
1319839000cb4ba9bedc60f0570a2483
RX(theta₂₁)
aaeaf84447a54340852f2a9fd550d550--1319839000cb4ba9bedc60f0570a2483
c9c448797789459ea8f81bd78bcc07e5
X
1319839000cb4ba9bedc60f0570a2483--c9c448797789459ea8f81bd78bcc07e5
c9c448797789459ea8f81bd78bcc07e5--35ecd83779ac4d7f9b9fdcc082aee2e0
b83842b1ffe648499b7d34e89b5e207b
c9c448797789459ea8f81bd78bcc07e5--b83842b1ffe648499b7d34e89b5e207b
b83842b1ffe648499b7d34e89b5e207b--59b4fcfb92ef409098f37e068eb1f56e
71799526c7a8459981e0f2b1ecd20c36
7b8eb494f4d54a209251222e7456f472
RX(theta₂)
ebb363b8e7b741be99e96be92875a813--7b8eb494f4d54a209251222e7456f472
bd784622cc534915afd84939011f0200
3
c17eff08cde649a59fde4273ddce1351
RY(theta₆)
7b8eb494f4d54a209251222e7456f472--c17eff08cde649a59fde4273ddce1351
242b69a3542e48c29b867ade45f68504
RX(theta₁₀)
c17eff08cde649a59fde4273ddce1351--242b69a3542e48c29b867ade45f68504
b7e5f22c53494d47b554cfd329f47e4d
242b69a3542e48c29b867ade45f68504--b7e5f22c53494d47b554cfd329f47e4d
54e5ef8d36ed4d30998b8937c36b71c2
X
b7e5f22c53494d47b554cfd329f47e4d--54e5ef8d36ed4d30998b8937c36b71c2
54e5ef8d36ed4d30998b8937c36b71c2--e60bf3b6666849a3aa1eff0fd247dd1b
5cb4c899cdaa47e4ae18ebc0880dc2e0
RX(theta₁₄)
54e5ef8d36ed4d30998b8937c36b71c2--5cb4c899cdaa47e4ae18ebc0880dc2e0
ef3cde80bcd844259ed2f206cadaa5fa
RY(theta₁₈)
5cb4c899cdaa47e4ae18ebc0880dc2e0--ef3cde80bcd844259ed2f206cadaa5fa
394460716ed540f1ae5c5181e2e84b73
RX(theta₂₂)
ef3cde80bcd844259ed2f206cadaa5fa--394460716ed540f1ae5c5181e2e84b73
e59f11b2d0564abcb681b67a0104e9e8
394460716ed540f1ae5c5181e2e84b73--e59f11b2d0564abcb681b67a0104e9e8
ebf705fc1e0d4d5ca1a4e0f69698a544
X
e59f11b2d0564abcb681b67a0104e9e8--ebf705fc1e0d4d5ca1a4e0f69698a544
ebf705fc1e0d4d5ca1a4e0f69698a544--85dc2c5871384a179d4b886bb7e41702
637f32cc52cb49e491fe2fbf7e59c9d1
RX(theta₂)
ebf705fc1e0d4d5ca1a4e0f69698a544--637f32cc52cb49e491fe2fbf7e59c9d1
e31b0367d2934ce0aa2c9fcd608e542b
RY(theta₆)
637f32cc52cb49e491fe2fbf7e59c9d1--e31b0367d2934ce0aa2c9fcd608e542b
1a91999c2c9748fc85bbeeeb6f558069
RX(theta₁₀)
e31b0367d2934ce0aa2c9fcd608e542b--1a91999c2c9748fc85bbeeeb6f558069
0873f2e54270465cbf3d25e596ae4f46
1a91999c2c9748fc85bbeeeb6f558069--0873f2e54270465cbf3d25e596ae4f46
4b5894841624478091f7363dac53f883
X
0873f2e54270465cbf3d25e596ae4f46--4b5894841624478091f7363dac53f883
4b5894841624478091f7363dac53f883--0aa229b7c4f546eabd37b8040a4dcb5f
8661514738cb4f6b8ef13b800d5c6d41
RX(theta₁₄)
4b5894841624478091f7363dac53f883--8661514738cb4f6b8ef13b800d5c6d41
d1d4be91444c4f1d8e78d2ea6867ad27
RY(theta₁₈)
8661514738cb4f6b8ef13b800d5c6d41--d1d4be91444c4f1d8e78d2ea6867ad27
2f8e37ce4633455d9cd22df4848c0fd5
RX(theta₂₂)
d1d4be91444c4f1d8e78d2ea6867ad27--2f8e37ce4633455d9cd22df4848c0fd5
1fbe207f184c4370975be696928230db
2f8e37ce4633455d9cd22df4848c0fd5--1fbe207f184c4370975be696928230db
1a77b0f3e1614199a2fc8dc81cc6abec
X
1fbe207f184c4370975be696928230db--1a77b0f3e1614199a2fc8dc81cc6abec
1a77b0f3e1614199a2fc8dc81cc6abec--b83842b1ffe648499b7d34e89b5e207b
1a77b0f3e1614199a2fc8dc81cc6abec--71799526c7a8459981e0f2b1ecd20c36
de8cfdd9fbc0471da32adf826c7fa9f7
50515a623d0f45f49553fa52697b21cc
RX(theta₃)
bd784622cc534915afd84939011f0200--50515a623d0f45f49553fa52697b21cc
d755b28c8c4e4f9d8e988808fc153a35
RY(theta₇)
50515a623d0f45f49553fa52697b21cc--d755b28c8c4e4f9d8e988808fc153a35
fb3f60615cb446a29af2af0ac445f2bf
RX(theta₁₁)
d755b28c8c4e4f9d8e988808fc153a35--fb3f60615cb446a29af2af0ac445f2bf
6a180be146a340649e2283a402b59307
X
fb3f60615cb446a29af2af0ac445f2bf--6a180be146a340649e2283a402b59307
6a180be146a340649e2283a402b59307--b7e5f22c53494d47b554cfd329f47e4d
1e94b73c33614bd2b72e2d71c16be3b4
6a180be146a340649e2283a402b59307--1e94b73c33614bd2b72e2d71c16be3b4
334be36a1b4e49e8b03622612d404b1f
RX(theta₁₅)
1e94b73c33614bd2b72e2d71c16be3b4--334be36a1b4e49e8b03622612d404b1f
70ba2601c9184866a6af19c3cbf527e8
RY(theta₁₉)
334be36a1b4e49e8b03622612d404b1f--70ba2601c9184866a6af19c3cbf527e8
583ac3b298ae4686b64b6971383428d6
RX(theta₂₃)
70ba2601c9184866a6af19c3cbf527e8--583ac3b298ae4686b64b6971383428d6
f13d6a324a3246e3a90ff21b01f07a7d
X
583ac3b298ae4686b64b6971383428d6--f13d6a324a3246e3a90ff21b01f07a7d
f13d6a324a3246e3a90ff21b01f07a7d--e59f11b2d0564abcb681b67a0104e9e8
bdf6c6526bcd41dea64edce6e6b2b634
f13d6a324a3246e3a90ff21b01f07a7d--bdf6c6526bcd41dea64edce6e6b2b634
4c0f306328b94569b70674866c80454f
RX(theta₃)
bdf6c6526bcd41dea64edce6e6b2b634--4c0f306328b94569b70674866c80454f
06251b8a7a304aeabe2ce6dbcb4d3480
RY(theta₇)
4c0f306328b94569b70674866c80454f--06251b8a7a304aeabe2ce6dbcb4d3480
3dacd98a88d84623833fd45ff0c19a80
RX(theta₁₁)
06251b8a7a304aeabe2ce6dbcb4d3480--3dacd98a88d84623833fd45ff0c19a80
d893c7c5a6ed4069ad1116b137b62650
X
3dacd98a88d84623833fd45ff0c19a80--d893c7c5a6ed4069ad1116b137b62650
d893c7c5a6ed4069ad1116b137b62650--0873f2e54270465cbf3d25e596ae4f46
4e66acb243334c98a05c30d38c6c4e5d
d893c7c5a6ed4069ad1116b137b62650--4e66acb243334c98a05c30d38c6c4e5d
a7b8701f0d11431992dbe9760e91fa43
RX(theta₁₅)
4e66acb243334c98a05c30d38c6c4e5d--a7b8701f0d11431992dbe9760e91fa43
827a150735f2400ba2a64e961cf4c3d9
RY(theta₁₉)
a7b8701f0d11431992dbe9760e91fa43--827a150735f2400ba2a64e961cf4c3d9
abc53dd2780d4675a3151ea30632e17e
RX(theta₂₃)
827a150735f2400ba2a64e961cf4c3d9--abc53dd2780d4675a3151ea30632e17e
3429df8bb71542f1b8a37a90f37abd7f
X
abc53dd2780d4675a3151ea30632e17e--3429df8bb71542f1b8a37a90f37abd7f
3429df8bb71542f1b8a37a90f37abd7f--1fbe207f184c4370975be696928230db
22df1359dc1944c9bb72b0afc749ff71
3429df8bb71542f1b8a37a90f37abd7f--22df1359dc1944c9bb72b0afc749ff71
22df1359dc1944c9bb72b0afc749ff71--de8cfdd9fbc0471da32adf826c7fa9f7
Avoid non-unique names by prefixing
A parameter prefix for each HEA can be passed as follows:
hea1 = hea ( n_qubits = n_qubits , depth = depth , param_prefix = "p1" )
hea2 = hea ( n_qubits = n_qubits , depth = depth , param_prefix = "p2" )
circuit = QuantumCircuit ( n_qubits , hea1 , hea2 )
n_params_two_heas = circuit . num_unique_parameters
U n ique parame ters wi t h t wo s ta cked HEAs : 48
%3
cluster_6909ad5bec944ca89ab327c53ba4ca84
HEA
cluster_104c104188be4986ab62f588e128dc76
HEA
80368b35db3742288861e6a5cff71c03
0
0fd16ecce3854a878ce78c8ab390fd32
RX(p1₀)
80368b35db3742288861e6a5cff71c03--0fd16ecce3854a878ce78c8ab390fd32
bfcf7ee9008f4d739fc184d67b2d924c
1
9794d0c330464f4393a229ad8d8c8fd7
RY(p1₄)
0fd16ecce3854a878ce78c8ab390fd32--9794d0c330464f4393a229ad8d8c8fd7
dd49849238784036a056f6bf4e4d79a2
RX(p1₈)
9794d0c330464f4393a229ad8d8c8fd7--dd49849238784036a056f6bf4e4d79a2
bf278718ceab44b7bf83024a7a6439b7
dd49849238784036a056f6bf4e4d79a2--bf278718ceab44b7bf83024a7a6439b7
6c452496745e42c9bacc4c3e012eb96f
bf278718ceab44b7bf83024a7a6439b7--6c452496745e42c9bacc4c3e012eb96f
bab5e61264c44b02ad1425be367ce6f3
RX(p1₁₂)
6c452496745e42c9bacc4c3e012eb96f--bab5e61264c44b02ad1425be367ce6f3
068d895a2d6c4cdf9887e4434f9d327e
RY(p1₁₆)
bab5e61264c44b02ad1425be367ce6f3--068d895a2d6c4cdf9887e4434f9d327e
a1f4a0a34e54418ba281214c5d8c4193
RX(p1₂₀)
068d895a2d6c4cdf9887e4434f9d327e--a1f4a0a34e54418ba281214c5d8c4193
65a474e2305d4373b470c49b8f7c7eb1
a1f4a0a34e54418ba281214c5d8c4193--65a474e2305d4373b470c49b8f7c7eb1
c639f35d6e564aa3a6e0a3692a4dff62
65a474e2305d4373b470c49b8f7c7eb1--c639f35d6e564aa3a6e0a3692a4dff62
676f05889abf466992ea376604a55111
RX(p2₀)
c639f35d6e564aa3a6e0a3692a4dff62--676f05889abf466992ea376604a55111
6951eeeac41c46c8a76da16ac9a2e0de
RY(p2₄)
676f05889abf466992ea376604a55111--6951eeeac41c46c8a76da16ac9a2e0de
b59448923b0d42e3949fe5d856f85760
RX(p2₈)
6951eeeac41c46c8a76da16ac9a2e0de--b59448923b0d42e3949fe5d856f85760
1779edf2c35746fba7b040ef17bd3495
b59448923b0d42e3949fe5d856f85760--1779edf2c35746fba7b040ef17bd3495
0eb22420247142d49c94a550e9c86904
1779edf2c35746fba7b040ef17bd3495--0eb22420247142d49c94a550e9c86904
683dfb137527481b84fb779e2337f9b0
RX(p2₁₂)
0eb22420247142d49c94a550e9c86904--683dfb137527481b84fb779e2337f9b0
ccc9846af0a74a4289524552e0d96d46
RY(p2₁₆)
683dfb137527481b84fb779e2337f9b0--ccc9846af0a74a4289524552e0d96d46
9f39fb9a53dd46de8d178258828188e9
RX(p2₂₀)
ccc9846af0a74a4289524552e0d96d46--9f39fb9a53dd46de8d178258828188e9
e560f39474d342959012cab6b47d2ec2
9f39fb9a53dd46de8d178258828188e9--e560f39474d342959012cab6b47d2ec2
df9135879a6048ff81022a88654f7dcf
e560f39474d342959012cab6b47d2ec2--df9135879a6048ff81022a88654f7dcf
82f1fcdc080b4efba935596b526d3e97
df9135879a6048ff81022a88654f7dcf--82f1fcdc080b4efba935596b526d3e97
38f2162848c4457a9ac7a69c87fb1f00
ab5bc2f597824035b13c152bc58db6f9
RX(p1₁)
bfcf7ee9008f4d739fc184d67b2d924c--ab5bc2f597824035b13c152bc58db6f9
6fd29caeae3241658e224236b3847018
2
7ada71af8e854e71902fd7a948bf470d
RY(p1₅)
ab5bc2f597824035b13c152bc58db6f9--7ada71af8e854e71902fd7a948bf470d
7f3955e8fb2448f68ed803d026758ac0
RX(p1₉)
7ada71af8e854e71902fd7a948bf470d--7f3955e8fb2448f68ed803d026758ac0
cc904d9b96fc46ef88a7bbce63b71cfb
X
7f3955e8fb2448f68ed803d026758ac0--cc904d9b96fc46ef88a7bbce63b71cfb
cc904d9b96fc46ef88a7bbce63b71cfb--bf278718ceab44b7bf83024a7a6439b7
f3cb4c26f674428f935d73d3a0586429
cc904d9b96fc46ef88a7bbce63b71cfb--f3cb4c26f674428f935d73d3a0586429
080e1a14300f4f0ca9c3f3689212bd5b
RX(p1₁₃)
f3cb4c26f674428f935d73d3a0586429--080e1a14300f4f0ca9c3f3689212bd5b
4c4d829b60c0405e801428f3c8fbcbe0
RY(p1₁₇)
080e1a14300f4f0ca9c3f3689212bd5b--4c4d829b60c0405e801428f3c8fbcbe0
f98a4a4929af4bc9b0d58ce1bbb3c65b
RX(p1₂₁)
4c4d829b60c0405e801428f3c8fbcbe0--f98a4a4929af4bc9b0d58ce1bbb3c65b
869a821dbf2844b98fe28d6c68f9bbda
X
f98a4a4929af4bc9b0d58ce1bbb3c65b--869a821dbf2844b98fe28d6c68f9bbda
869a821dbf2844b98fe28d6c68f9bbda--65a474e2305d4373b470c49b8f7c7eb1
55708b826f3b4fe9a1494a6f7c454aeb
869a821dbf2844b98fe28d6c68f9bbda--55708b826f3b4fe9a1494a6f7c454aeb
53db89e52a46494d8b293a7e0da044b6
RX(p2₁)
55708b826f3b4fe9a1494a6f7c454aeb--53db89e52a46494d8b293a7e0da044b6
c56550e7d2ee4f879017de278b77c00d
RY(p2₅)
53db89e52a46494d8b293a7e0da044b6--c56550e7d2ee4f879017de278b77c00d
9458dddf06714239b48220802de25168
RX(p2₉)
c56550e7d2ee4f879017de278b77c00d--9458dddf06714239b48220802de25168
c6d8780d8ce841e7b09b05a0eaf3606f
X
9458dddf06714239b48220802de25168--c6d8780d8ce841e7b09b05a0eaf3606f
c6d8780d8ce841e7b09b05a0eaf3606f--1779edf2c35746fba7b040ef17bd3495
969fb38996c74c90b4af45507cf679b2
c6d8780d8ce841e7b09b05a0eaf3606f--969fb38996c74c90b4af45507cf679b2
63314a45c96e499a8563cee9760f3275
RX(p2₁₃)
969fb38996c74c90b4af45507cf679b2--63314a45c96e499a8563cee9760f3275
f2938f6cedaa4c5c8371a939e60c89b4
RY(p2₁₇)
63314a45c96e499a8563cee9760f3275--f2938f6cedaa4c5c8371a939e60c89b4
37bf10bdc1c04c088988d074e8c898fa
RX(p2₂₁)
f2938f6cedaa4c5c8371a939e60c89b4--37bf10bdc1c04c088988d074e8c898fa
a91f25f00a054b038ece9ab05d6986bb
X
37bf10bdc1c04c088988d074e8c898fa--a91f25f00a054b038ece9ab05d6986bb
a91f25f00a054b038ece9ab05d6986bb--e560f39474d342959012cab6b47d2ec2
4396bd87d1ab428fa61d199331d10700
a91f25f00a054b038ece9ab05d6986bb--4396bd87d1ab428fa61d199331d10700
4396bd87d1ab428fa61d199331d10700--38f2162848c4457a9ac7a69c87fb1f00
ebf5fba8d42649af8b78b8cbb8070b8f
438cbf4738b649efb97fc0066f2dcaef
RX(p1₂)
6fd29caeae3241658e224236b3847018--438cbf4738b649efb97fc0066f2dcaef
f64d5108975246798b602468f2dcb5ae
3
191a4b0c360346ed86f00f91ab23358b
RY(p1₆)
438cbf4738b649efb97fc0066f2dcaef--191a4b0c360346ed86f00f91ab23358b
34f9a1022afd4ec5a9c5be0c828b1b5b
RX(p1₁₀)
191a4b0c360346ed86f00f91ab23358b--34f9a1022afd4ec5a9c5be0c828b1b5b
3f41412786bd47dc9b6a5a9f818ef94d
34f9a1022afd4ec5a9c5be0c828b1b5b--3f41412786bd47dc9b6a5a9f818ef94d
a42475b684e042e396d85f16da58669f
X
3f41412786bd47dc9b6a5a9f818ef94d--a42475b684e042e396d85f16da58669f
a42475b684e042e396d85f16da58669f--f3cb4c26f674428f935d73d3a0586429
397031953b644c92b6808f7df38f93fb
RX(p1₁₄)
a42475b684e042e396d85f16da58669f--397031953b644c92b6808f7df38f93fb
99b138e4d36a48ee8f67e160359afa32
RY(p1₁₈)
397031953b644c92b6808f7df38f93fb--99b138e4d36a48ee8f67e160359afa32
5be4bb4d281f4cfb973bb921350e7e6a
RX(p1₂₂)
99b138e4d36a48ee8f67e160359afa32--5be4bb4d281f4cfb973bb921350e7e6a
68ad187919074ddf81267ffb34583bb9
5be4bb4d281f4cfb973bb921350e7e6a--68ad187919074ddf81267ffb34583bb9
e076edb829984e4987c42ab1129eb609
X
68ad187919074ddf81267ffb34583bb9--e076edb829984e4987c42ab1129eb609
e076edb829984e4987c42ab1129eb609--55708b826f3b4fe9a1494a6f7c454aeb
baa4f139269a43b6a4372dc2805bab11
RX(p2₂)
e076edb829984e4987c42ab1129eb609--baa4f139269a43b6a4372dc2805bab11
1035fad2ef2849e8a3e8cc32302da81d
RY(p2₆)
baa4f139269a43b6a4372dc2805bab11--1035fad2ef2849e8a3e8cc32302da81d
319cde2fe7334e7fae541051d25d3eef
RX(p2₁₀)
1035fad2ef2849e8a3e8cc32302da81d--319cde2fe7334e7fae541051d25d3eef
3afbfef7ae7a42288994b105dc0d787a
319cde2fe7334e7fae541051d25d3eef--3afbfef7ae7a42288994b105dc0d787a
df22fa899c2a4c0d85f61b458f51fac3
X
3afbfef7ae7a42288994b105dc0d787a--df22fa899c2a4c0d85f61b458f51fac3
df22fa899c2a4c0d85f61b458f51fac3--969fb38996c74c90b4af45507cf679b2
e8f78b96260f4d3dad75e20e26760876
RX(p2₁₄)
df22fa899c2a4c0d85f61b458f51fac3--e8f78b96260f4d3dad75e20e26760876
49f62c6d52a249e49e2591d06e9cfa06
RY(p2₁₈)
e8f78b96260f4d3dad75e20e26760876--49f62c6d52a249e49e2591d06e9cfa06
973635210bb5483593bf79ad0696296c
RX(p2₂₂)
49f62c6d52a249e49e2591d06e9cfa06--973635210bb5483593bf79ad0696296c
29cfcb7b9a4e4713ab86fc97a7c4c155
973635210bb5483593bf79ad0696296c--29cfcb7b9a4e4713ab86fc97a7c4c155
820a14b6b98e4b88965888cb1ff3d803
X
29cfcb7b9a4e4713ab86fc97a7c4c155--820a14b6b98e4b88965888cb1ff3d803
820a14b6b98e4b88965888cb1ff3d803--4396bd87d1ab428fa61d199331d10700
820a14b6b98e4b88965888cb1ff3d803--ebf5fba8d42649af8b78b8cbb8070b8f
f1ec94e562d94b659b48434629eca77d
7537e3d4c4e94637847927ea5903fb04
RX(p1₃)
f64d5108975246798b602468f2dcb5ae--7537e3d4c4e94637847927ea5903fb04
8795896473fd43aea4d9a8f4cc7efc79
RY(p1₇)
7537e3d4c4e94637847927ea5903fb04--8795896473fd43aea4d9a8f4cc7efc79
9bc4b00ee99b4c82ae871d7c30b73253
RX(p1₁₁)
8795896473fd43aea4d9a8f4cc7efc79--9bc4b00ee99b4c82ae871d7c30b73253
a492c1e4d4cf4da89a7fea543c592d87
X
9bc4b00ee99b4c82ae871d7c30b73253--a492c1e4d4cf4da89a7fea543c592d87
a492c1e4d4cf4da89a7fea543c592d87--3f41412786bd47dc9b6a5a9f818ef94d
333ca9f53e644048a8589318c26c4d30
a492c1e4d4cf4da89a7fea543c592d87--333ca9f53e644048a8589318c26c4d30
5e5a9f6f5782446aa555353ef0a12535
RX(p1₁₅)
333ca9f53e644048a8589318c26c4d30--5e5a9f6f5782446aa555353ef0a12535
0b939f42a225456991d9386b16946312
RY(p1₁₉)
5e5a9f6f5782446aa555353ef0a12535--0b939f42a225456991d9386b16946312
670e8fb58cdb4e1faa115c9a03c7426a
RX(p1₂₃)
0b939f42a225456991d9386b16946312--670e8fb58cdb4e1faa115c9a03c7426a
a7a4832b73ad4f64933669dfe3ed5d42
X
670e8fb58cdb4e1faa115c9a03c7426a--a7a4832b73ad4f64933669dfe3ed5d42
a7a4832b73ad4f64933669dfe3ed5d42--68ad187919074ddf81267ffb34583bb9
ea023757cc8547508c300296db36d0e1
a7a4832b73ad4f64933669dfe3ed5d42--ea023757cc8547508c300296db36d0e1
34bb5d4c42914795bcb8daba39dbca07
RX(p2₃)
ea023757cc8547508c300296db36d0e1--34bb5d4c42914795bcb8daba39dbca07
2e17cd9faacc49cb9444b97f0afc2120
RY(p2₇)
34bb5d4c42914795bcb8daba39dbca07--2e17cd9faacc49cb9444b97f0afc2120
bda7da9ecbc34c54874a28c33a7631ad
RX(p2₁₁)
2e17cd9faacc49cb9444b97f0afc2120--bda7da9ecbc34c54874a28c33a7631ad
4718411f3ac542478be242adb0301af6
X
bda7da9ecbc34c54874a28c33a7631ad--4718411f3ac542478be242adb0301af6
4718411f3ac542478be242adb0301af6--3afbfef7ae7a42288994b105dc0d787a
f5892e56df2046c68670228ec152d49f
4718411f3ac542478be242adb0301af6--f5892e56df2046c68670228ec152d49f
2689571f35be4e99bcaf556a52977d54
RX(p2₁₅)
f5892e56df2046c68670228ec152d49f--2689571f35be4e99bcaf556a52977d54
3b9693985df24a60a238f602638a1580
RY(p2₁₉)
2689571f35be4e99bcaf556a52977d54--3b9693985df24a60a238f602638a1580
9e0969a514cc44a6941765ea212872ab
RX(p2₂₃)
3b9693985df24a60a238f602638a1580--9e0969a514cc44a6941765ea212872ab
49f8e416aba3499589573b2130634290
X
9e0969a514cc44a6941765ea212872ab--49f8e416aba3499589573b2130634290
49f8e416aba3499589573b2130634290--29cfcb7b9a4e4713ab86fc97a7c4c155
560ecd2dcefb437b939a52d8ee2c37ff
49f8e416aba3499589573b2130634290--560ecd2dcefb437b939a52d8ee2c37ff
560ecd2dcefb437b939a52d8ee2c37ff--f1ec94e562d94b659b48434629eca77d
The hea
function will be further explored in the QML Constructors tutorial .
Parametric observables
In Qadence, one can define quantum observables with classical optimizable parameters to
improve the convergence of QML calculations. This is particularly useful for differentiable quantum circuits.
from qadence import VariationalParameter , Z , add , tag
s = VariationalParameter ( "s" )
observable = add ( s * Z ( i ) for i in range ( n_qubits ))
Now, a quantum model can be created with the parametric observable.
The observable variational parameters are included among the model ones.
from qadence import QuantumModel , QuantumCircuit
circuit = QuantumCircuit ( n_qubits , hea ( n_qubits , depth ))
model = QuantumModel ( circuit , observable = observable )
Varia t io nal parame ters = OrderedDic t ( [ ('s' , tens or( [ 0.4060 ] )) , (' t he ta _ 0 ' , tens or( [ 0.7295 ] )) , (' t he ta _ 1 ' , tens or( [ 0.4842 ] )) , (' t he ta _ 10 ' , tens or( [ 0.2934 ] )) , (' t he ta _ 11 ' , tens or( [ 0.9087 ] )) , (' t he ta _ 12 ' , tens or( [ 0.5591 ] )) , (' t he ta _ 13 ' , tens or( [ 0.2918 ] )) , (' t he ta _ 14 ' , tens or( [ 0.6196 ] )) , (' t he ta _ 15 ' , tens or( [ 0.0873 ] )) , (' t he ta _ 16 ' , tens or( [ 0.7099 ] )) , (' t he ta _ 17 ' , tens or( [ 0.5362 ] )) , (' t he ta _ 18 ' , tens or( [ 0.3060 ] )) , (' t he ta _ 19 ' , tens or( [ 0.0122 ] )) , (' t he ta _ 2 ' , tens or( [ 0.4173 ] )) , (' t he ta _ 20 ' , tens or( [ 0.5521 ] )) , (' t he ta _ 21 ' , tens or( [ 0.0399 ] )) , (' t he ta _ 22 ' , tens or( [ 0.4448 ] )) , (' t he ta _ 23 ' , tens or( [ 0.8476 ] )) , (' t he ta _ 3 ' , tens or( [ 0.6639 ] )) , (' t he ta _ 4 ' , tens or( [ 0.6974 ] )) , (' t he ta _ 5 ' , tens or( [ 0.1438 ] )) , (' t he ta _ 6 ' , tens or( [ 0.6251 ] )) , (' t he ta _ 7 ' , tens or( [ 0.3880 ] )) , (' t he ta _ 8 ' , tens or( [ 0.2627 ] )) , (' t he ta _ 9 ' , tens or( [ 0.4693 ] )) ] )
One optimization step (forward and backward pass) can be performed using built-in torch
functionalities. Variational parameters
can be checked to have been updated accordingly:
import torch
mse_loss = torch . nn . MSELoss ()
optimizer = torch . optim . Adam ( model . parameters ())
# Compute forward & backward pass
optimizer . zero_grad ()
loss = mse_loss ( model . expectation ({}), torch . zeros ( 1 ))
loss . backward ()
# Update the parameters and check the parameters.
optimizer . step ()
Varia t io nal parame ters = OrderedDic t ( [ ('s' , tens or( [ 0.4050 ] )) , (' t he ta _ 0 ' , tens or( [ 0.7285 ] )) , (' t he ta _ 1 ' , tens or( [ 0.4832 ] )) , (' t he ta _ 10 ' , tens or( [ 0.2944 ] )) , (' t he ta _ 11 ' , tens or( [ 0.9097 ] )) , (' t he ta _ 12 ' , tens or( [ 0.5601 ] )) , (' t he ta _ 13 ' , tens or( [ 0.2908 ] )) , (' t he ta _ 14 ' , tens or( [ 0.6186 ] )) , (' t he ta _ 15 ' , tens or( [ 0.0883 ] )) , (' t he ta _ 16 ' , tens or( [ 0.7109 ] )) , (' t he ta _ 17 ' , tens or( [ 0.5372 ] )) , (' t he ta _ 18 ' , tens or( [ 0.3070 ] )) , (' t he ta _ 19 ' , tens or( [ 0.0112 ] )) , (' t he ta _ 2 ' , tens or( [ 0.4183 ] )) , (' t he ta _ 20 ' , tens or( [ 0.5531 ] )) , (' t he ta _ 21 ' , tens or( [ 0.0389 ] )) , (' t he ta _ 22 ' , tens or( [ 0.4438 ] )) , (' t he ta _ 23 ' , tens or( [ 0.8486 ] )) , (' t he ta _ 3 ' , tens or( [ 0.6649 ] )) , (' t he ta _ 4 ' , tens or( [ 0.6984 ] )) , (' t he ta _ 5 ' , tens or( [ 0.1448 ] )) , (' t he ta _ 6 ' , tens or( [ 0.6261 ] )) , (' t he ta _ 7 ' , tens or( [ 0.3870 ] )) , (' t he ta _ 8 ' , tens or( [ 0.2617 ] )) , (' t he ta _ 9 ' , tens or( [ 0.4683 ] )) ] )
Non-unitary circuits
Qadence allows composing with non-unitary blocks.
Here is an example of a non-unitary block as a sum of Pauli operators with complex coefficients.
Currently, only the PyQTorch
backend fully supports execution of non-unitary circuits.
from qadence import QuantumModel , QuantumCircuit , Z , X
c1 = 2.0
c2 = 2.0 + 2.0 j
block = c1 * Z ( 0 ) + c2 * X ( 1 ) + c1 * c2 * ( Z ( 2 ) + X ( 3 ))
circuit = QuantumCircuit ( 4 , block )
model = QuantumModel ( circuit ) # BackendName.PYQTORCH and DiffMode.AD by default.
w f = tens or( [[ 6.+4. j , 4.+4. j , 0.+0. j , 0.+0. j , 2.+2. j , 0.+0. j , 0.+0. j , 0.+0. j , 0.+0. j , 0.+0. j ,
0.+0. j , 0.+0. j , 0.+0. j , 0.+0. j , 0.+0. j , 0.+0. j ]] )