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 torch import pi
from qadence import RX , run
# 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.9754+0.0000 j , 0.0000-0.2203 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.9058+0.0000 j , 0.0000-0.4237 j ],
[ 0.9047+0.0000 j , 0.0000-0.4260 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.5444+0.0000 j , 0.8070+0.0000 j , 0.0000-0.1279 j , 0.0000-0.1896 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_c3c2226f332e4323a232aad0e4aafaf7
[* 2]
cluster_2e5ab058bcea4568a2f972b3ef844850
Rotations
01e40e2241d44db08be1987843ae9403
0
f0d9f87947e04fb5ac20c91ce3f42ef2
RX(phi/theta)
01e40e2241d44db08be1987843ae9403--f0d9f87947e04fb5ac20c91ce3f42ef2
920c8259c8c04b42af1aa29baa2df518
1
b0bbfdb0251e4971901aeb2c16682379
RX(phi)
f0d9f87947e04fb5ac20c91ce3f42ef2--b0bbfdb0251e4971901aeb2c16682379
f2e88d2cbcac45c5a741af70ab62545b
RX(phi)
b0bbfdb0251e4971901aeb2c16682379--f2e88d2cbcac45c5a741af70ab62545b
cc0ee54a912a4d988773aa023e2a603a
RX(phi + theta)
f2e88d2cbcac45c5a741af70ab62545b--cc0ee54a912a4d988773aa023e2a603a
72eb7ede135349d6a95229142bab1ccb
cc0ee54a912a4d988773aa023e2a603a--72eb7ede135349d6a95229142bab1ccb
fe01b462b4fa4468940b8d5e4f2d6e9b
72eb7ede135349d6a95229142bab1ccb--fe01b462b4fa4468940b8d5e4f2d6e9b
ac09ba8b2daf49099eb4b4539bee34af
Z
fe01b462b4fa4468940b8d5e4f2d6e9b--ac09ba8b2daf49099eb4b4539bee34af
b5f286c9cead471ca474ec1550dae8a9
ac09ba8b2daf49099eb4b4539bee34af--b5f286c9cead471ca474ec1550dae8a9
f29dc91ab828495d919b86b050c7a116
2ee2fa7e7e7e4f7eacfdc0f56bd67ec8
RY(2*theta)
920c8259c8c04b42af1aa29baa2df518--2ee2fa7e7e7e4f7eacfdc0f56bd67ec8
1d6b23eb7bd1476c91c2b6e5b252108a
2
8737a24bf0f04667bd96153e0b73385c
RY(theta)
2ee2fa7e7e7e4f7eacfdc0f56bd67ec8--8737a24bf0f04667bd96153e0b73385c
775c7135e4f94cf1a05bcf8826c123d7
RY(theta)
8737a24bf0f04667bd96153e0b73385c--775c7135e4f94cf1a05bcf8826c123d7
f729654a569444ba8206bf65f57a5555
RY(theta**2)
775c7135e4f94cf1a05bcf8826c123d7--f729654a569444ba8206bf65f57a5555
0f0bdb3725ee4c3c8ee2dd3ea51ccb60
X
f729654a569444ba8206bf65f57a5555--0f0bdb3725ee4c3c8ee2dd3ea51ccb60
0f0bdb3725ee4c3c8ee2dd3ea51ccb60--72eb7ede135349d6a95229142bab1ccb
4ae948a25c66487c8e402a9338d0c7f9
0f0bdb3725ee4c3c8ee2dd3ea51ccb60--4ae948a25c66487c8e402a9338d0c7f9
ed69ce25467c4b0b8bbdbb211b278413
Z
4ae948a25c66487c8e402a9338d0c7f9--ed69ce25467c4b0b8bbdbb211b278413
ed69ce25467c4b0b8bbdbb211b278413--f29dc91ab828495d919b86b050c7a116
ee619db9184a4ba1950219aae4979e3d
a081b79035d4454dbaeef5286f811bc7
RZ(cos(phi))
1d6b23eb7bd1476c91c2b6e5b252108a--a081b79035d4454dbaeef5286f811bc7
190e05d2bd644cfeb36df3a26da162d1
RZ(phi)
a081b79035d4454dbaeef5286f811bc7--190e05d2bd644cfeb36df3a26da162d1
120d676f90004743ad8323b42fa524bc
RZ(phi)
190e05d2bd644cfeb36df3a26da162d1--120d676f90004743ad8323b42fa524bc
337d2a6d4dcf47cbb482f4fd38e1e8a8
RZ(cos(phi))
120d676f90004743ad8323b42fa524bc--337d2a6d4dcf47cbb482f4fd38e1e8a8
4b1b3e7ec12b4a60b253881f50e26462
337d2a6d4dcf47cbb482f4fd38e1e8a8--4b1b3e7ec12b4a60b253881f50e26462
c28fbff4587642b59a1c18f1483d574a
X
4b1b3e7ec12b4a60b253881f50e26462--c28fbff4587642b59a1c18f1483d574a
c28fbff4587642b59a1c18f1483d574a--4ae948a25c66487c8e402a9338d0c7f9
e3d209c004574e00aa58ba82bd2f27d7
Z
c28fbff4587642b59a1c18f1483d574a--e3d209c004574e00aa58ba82bd2f27d7
e3d209c004574e00aa58ba82bd2f27d7--ee619db9184a4ba1950219aae4979e3d
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.3193 ] )) ] )
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.9192+0.0000 j , 0.2725+0.0000 j , 0.0000-0.2725 j , 0.0000-0.0808 j ],
[ 0.7623+0.0000 j , 0.4257+0.0000 j , 0.0000-0.4257 j , 0.0000-0.2377 j ],
[ 0.7010+0.0000 j , 0.4578+0.0000 j , 0.0000-0.4578 j , 0.0000-0.2990 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
cdfb29bfc9814deebdbcc6acdafdab34
0
0fe81e75e8624f569f13fa5aac48dea7
RX(theta₀)
cdfb29bfc9814deebdbcc6acdafdab34--0fe81e75e8624f569f13fa5aac48dea7
9fa111ef86f74698ac9e289c6256a46e
1
3bdeb38081df4268b9b573f92b839e5a
RY(theta₄)
0fe81e75e8624f569f13fa5aac48dea7--3bdeb38081df4268b9b573f92b839e5a
3c12d557e0f04589a54cc43fab1b07fd
RX(theta₈)
3bdeb38081df4268b9b573f92b839e5a--3c12d557e0f04589a54cc43fab1b07fd
38852498060546c6ac7aff0680094c8b
3c12d557e0f04589a54cc43fab1b07fd--38852498060546c6ac7aff0680094c8b
22c23e9af11d4af2b5b0b9465298bb79
38852498060546c6ac7aff0680094c8b--22c23e9af11d4af2b5b0b9465298bb79
a5be0e493ba3403bb4e5928e411e420a
RX(theta₁₂)
22c23e9af11d4af2b5b0b9465298bb79--a5be0e493ba3403bb4e5928e411e420a
4ed1d69892ae4e90be7c3b1804c3de1b
RY(theta₁₆)
a5be0e493ba3403bb4e5928e411e420a--4ed1d69892ae4e90be7c3b1804c3de1b
acf02f7d866747f48bd9acad29511494
RX(theta₂₀)
4ed1d69892ae4e90be7c3b1804c3de1b--acf02f7d866747f48bd9acad29511494
4ce58db0679b4e73a8152972bb7c9dda
acf02f7d866747f48bd9acad29511494--4ce58db0679b4e73a8152972bb7c9dda
cde12948c59b40a2987c05deff322894
4ce58db0679b4e73a8152972bb7c9dda--cde12948c59b40a2987c05deff322894
2ecb231c4fd84485a182acf7b5350c28
cde12948c59b40a2987c05deff322894--2ecb231c4fd84485a182acf7b5350c28
a61ca5e9af5e4c2583b7fe11f9ab1b2a
4395dcfa9ec44edaa4d98d52aea962b3
RX(theta₁)
9fa111ef86f74698ac9e289c6256a46e--4395dcfa9ec44edaa4d98d52aea962b3
ea349ade2fe4405e9ae5701b6908c2aa
2
ab8870a281dc4e0a8e30eb280e871575
RY(theta₅)
4395dcfa9ec44edaa4d98d52aea962b3--ab8870a281dc4e0a8e30eb280e871575
74ee99d24cf84cdca1e69740d0b30aea
RX(theta₉)
ab8870a281dc4e0a8e30eb280e871575--74ee99d24cf84cdca1e69740d0b30aea
744745fb819e4eb3b0e637e9d0ba92f3
X
74ee99d24cf84cdca1e69740d0b30aea--744745fb819e4eb3b0e637e9d0ba92f3
744745fb819e4eb3b0e637e9d0ba92f3--38852498060546c6ac7aff0680094c8b
15b34498a33544e490dd58cf3a2f7739
744745fb819e4eb3b0e637e9d0ba92f3--15b34498a33544e490dd58cf3a2f7739
9083b75bae194c0f9f9e2ecd04517ade
RX(theta₁₃)
15b34498a33544e490dd58cf3a2f7739--9083b75bae194c0f9f9e2ecd04517ade
ea04d0f0aa4b455f91cc427b661c20aa
RY(theta₁₇)
9083b75bae194c0f9f9e2ecd04517ade--ea04d0f0aa4b455f91cc427b661c20aa
7628c28d7fa348948bfc3e2b053fdc68
RX(theta₂₁)
ea04d0f0aa4b455f91cc427b661c20aa--7628c28d7fa348948bfc3e2b053fdc68
c42f25ac44c64212806930317c1039eb
X
7628c28d7fa348948bfc3e2b053fdc68--c42f25ac44c64212806930317c1039eb
c42f25ac44c64212806930317c1039eb--4ce58db0679b4e73a8152972bb7c9dda
d0ae6406f78b48a58070363894716acc
c42f25ac44c64212806930317c1039eb--d0ae6406f78b48a58070363894716acc
d0ae6406f78b48a58070363894716acc--a61ca5e9af5e4c2583b7fe11f9ab1b2a
3e0598b3cf574625972415b012058c67
c5be5276d304459896a077e0b3d21ee7
RX(theta₂)
ea349ade2fe4405e9ae5701b6908c2aa--c5be5276d304459896a077e0b3d21ee7
3b0c5eb74e714de9b5f0c424238b354a
3
336560464c1d491a91599ebe93c403b2
RY(theta₆)
c5be5276d304459896a077e0b3d21ee7--336560464c1d491a91599ebe93c403b2
023799043b31497993ceff507b903c43
RX(theta₁₀)
336560464c1d491a91599ebe93c403b2--023799043b31497993ceff507b903c43
1b77759e7dd24c85867ee8faad22afbf
023799043b31497993ceff507b903c43--1b77759e7dd24c85867ee8faad22afbf
582c57925c054fb59ddc9ec0f1be0126
X
1b77759e7dd24c85867ee8faad22afbf--582c57925c054fb59ddc9ec0f1be0126
582c57925c054fb59ddc9ec0f1be0126--15b34498a33544e490dd58cf3a2f7739
8753cd62e3de4136870515805f6c02b4
RX(theta₁₄)
582c57925c054fb59ddc9ec0f1be0126--8753cd62e3de4136870515805f6c02b4
2cefd2807ea040419da809d584b5716c
RY(theta₁₈)
8753cd62e3de4136870515805f6c02b4--2cefd2807ea040419da809d584b5716c
3366912a01d148ee87b216b6068e0c1b
RX(theta₂₂)
2cefd2807ea040419da809d584b5716c--3366912a01d148ee87b216b6068e0c1b
cec2d30adab0419f9ebcb0f600fe22d4
3366912a01d148ee87b216b6068e0c1b--cec2d30adab0419f9ebcb0f600fe22d4
460a8842acf645af83ea33da9a38ef64
X
cec2d30adab0419f9ebcb0f600fe22d4--460a8842acf645af83ea33da9a38ef64
460a8842acf645af83ea33da9a38ef64--d0ae6406f78b48a58070363894716acc
460a8842acf645af83ea33da9a38ef64--3e0598b3cf574625972415b012058c67
dce0b70c9cb54997bf08910a21a074ca
d2e3e24c19f14f56941430e6f3957bde
RX(theta₃)
3b0c5eb74e714de9b5f0c424238b354a--d2e3e24c19f14f56941430e6f3957bde
6a2e2051877a4808b54df6f360411b6a
RY(theta₇)
d2e3e24c19f14f56941430e6f3957bde--6a2e2051877a4808b54df6f360411b6a
974ce8d42f3a4f8794ba4baad351dfad
RX(theta₁₁)
6a2e2051877a4808b54df6f360411b6a--974ce8d42f3a4f8794ba4baad351dfad
9534535f010040758c9e032e28bffd28
X
974ce8d42f3a4f8794ba4baad351dfad--9534535f010040758c9e032e28bffd28
9534535f010040758c9e032e28bffd28--1b77759e7dd24c85867ee8faad22afbf
124b2c65aec94ddd902c0480bc5c885a
9534535f010040758c9e032e28bffd28--124b2c65aec94ddd902c0480bc5c885a
224548b62c924ca1b94895192148dcd9
RX(theta₁₅)
124b2c65aec94ddd902c0480bc5c885a--224548b62c924ca1b94895192148dcd9
6f3f3e866efa40e5ba1e01a400adaf6a
RY(theta₁₉)
224548b62c924ca1b94895192148dcd9--6f3f3e866efa40e5ba1e01a400adaf6a
957a05472933457eb08165923a70b0a9
RX(theta₂₃)
6f3f3e866efa40e5ba1e01a400adaf6a--957a05472933457eb08165923a70b0a9
8c843b5303844f599253c080a26382c5
X
957a05472933457eb08165923a70b0a9--8c843b5303844f599253c080a26382c5
8c843b5303844f599253c080a26382c5--cec2d30adab0419f9ebcb0f600fe22d4
13a45cf3cfe046ad87195a7919009750
8c843b5303844f599253c080a26382c5--13a45cf3cfe046ad87195a7919009750
13a45cf3cfe046ad87195a7919009750--dce0b70c9cb54997bf08910a21a074ca
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_04b7e45fc6c34fd284b43e5ae0b58bfd
HEA
cluster_3e3a8d96cf474d66bbb1a61b8d1793a7
HEA
c4916f7328f04b9193db16da5348c1f2
0
ae6947c3ba3b46d9a4a11da9bfe4deca
RX(theta₀)
c4916f7328f04b9193db16da5348c1f2--ae6947c3ba3b46d9a4a11da9bfe4deca
88d01ebc3b934529b8aff60285e17575
1
7948d67bd03e46538d06f77bfb1beea7
RY(theta₄)
ae6947c3ba3b46d9a4a11da9bfe4deca--7948d67bd03e46538d06f77bfb1beea7
f5c7b9241c094e02aefb89850f139404
RX(theta₈)
7948d67bd03e46538d06f77bfb1beea7--f5c7b9241c094e02aefb89850f139404
da64b2ab05bb49f18b155b1d37e8483b
f5c7b9241c094e02aefb89850f139404--da64b2ab05bb49f18b155b1d37e8483b
e097e6fae5134ce1884b71678b2ddb90
da64b2ab05bb49f18b155b1d37e8483b--e097e6fae5134ce1884b71678b2ddb90
d5a810944fe84693b62e7b368fc94ba4
RX(theta₁₂)
e097e6fae5134ce1884b71678b2ddb90--d5a810944fe84693b62e7b368fc94ba4
01fbe7cf4a554983ab1b76f346336c28
RY(theta₁₆)
d5a810944fe84693b62e7b368fc94ba4--01fbe7cf4a554983ab1b76f346336c28
d9b8e27b92a841b48c38fda82b6af171
RX(theta₂₀)
01fbe7cf4a554983ab1b76f346336c28--d9b8e27b92a841b48c38fda82b6af171
894154657d5544a49107edafbbcc73ef
d9b8e27b92a841b48c38fda82b6af171--894154657d5544a49107edafbbcc73ef
1e2b9e14cd49402cb0e24f7ccd13b254
894154657d5544a49107edafbbcc73ef--1e2b9e14cd49402cb0e24f7ccd13b254
9481f540754a414aa827f318a776d07a
RX(theta₀)
1e2b9e14cd49402cb0e24f7ccd13b254--9481f540754a414aa827f318a776d07a
e7513cb60b594a02b646bb23f74444a2
RY(theta₄)
9481f540754a414aa827f318a776d07a--e7513cb60b594a02b646bb23f74444a2
b36392d41104449fa2771cd6578ade5a
RX(theta₈)
e7513cb60b594a02b646bb23f74444a2--b36392d41104449fa2771cd6578ade5a
e5d07ca278614b8e80bf4cbe9b2a6ad3
b36392d41104449fa2771cd6578ade5a--e5d07ca278614b8e80bf4cbe9b2a6ad3
d3a68e172a1144e6b6b9331153036a30
e5d07ca278614b8e80bf4cbe9b2a6ad3--d3a68e172a1144e6b6b9331153036a30
8726ec291bf94f6d8b47569f9c353fb4
RX(theta₁₂)
d3a68e172a1144e6b6b9331153036a30--8726ec291bf94f6d8b47569f9c353fb4
76c6c65b01c04c559e1e6b43d8ed7fc1
RY(theta₁₆)
8726ec291bf94f6d8b47569f9c353fb4--76c6c65b01c04c559e1e6b43d8ed7fc1
9dc3b65cc33340a98b150ed1e46aba4c
RX(theta₂₀)
76c6c65b01c04c559e1e6b43d8ed7fc1--9dc3b65cc33340a98b150ed1e46aba4c
5104911badef4864bcbc744b3c94dad5
9dc3b65cc33340a98b150ed1e46aba4c--5104911badef4864bcbc744b3c94dad5
c939fa758a524a0082fa6c7fa560f6e2
5104911badef4864bcbc744b3c94dad5--c939fa758a524a0082fa6c7fa560f6e2
19f79437e3e042898b7bd917523e2b2f
c939fa758a524a0082fa6c7fa560f6e2--19f79437e3e042898b7bd917523e2b2f
e7645bb3c46e461abf64f876317f6258
256832bd5c6d476dad629f4c5f1316ea
RX(theta₁)
88d01ebc3b934529b8aff60285e17575--256832bd5c6d476dad629f4c5f1316ea
29fd1190605a4e71a6877d36e868ea74
2
1a7f3fd1d7284c05840391cf6b6bdc7e
RY(theta₅)
256832bd5c6d476dad629f4c5f1316ea--1a7f3fd1d7284c05840391cf6b6bdc7e
b22d9e5e166b4636b7969703894f6ec9
RX(theta₉)
1a7f3fd1d7284c05840391cf6b6bdc7e--b22d9e5e166b4636b7969703894f6ec9
88a24f2e1f04480c8d82c312d04b3724
X
b22d9e5e166b4636b7969703894f6ec9--88a24f2e1f04480c8d82c312d04b3724
88a24f2e1f04480c8d82c312d04b3724--da64b2ab05bb49f18b155b1d37e8483b
053ffde2d6054b81a7a2ce4858872918
88a24f2e1f04480c8d82c312d04b3724--053ffde2d6054b81a7a2ce4858872918
10ad8c32115b4d5d9ba9d9344e2a4918
RX(theta₁₃)
053ffde2d6054b81a7a2ce4858872918--10ad8c32115b4d5d9ba9d9344e2a4918
b0a681f278ee44fbb3a82dfc701dc560
RY(theta₁₇)
10ad8c32115b4d5d9ba9d9344e2a4918--b0a681f278ee44fbb3a82dfc701dc560
1358beb8cc0940a18b0989c6cedabff1
RX(theta₂₁)
b0a681f278ee44fbb3a82dfc701dc560--1358beb8cc0940a18b0989c6cedabff1
5da257dc52a245bf8a3f810087c5c93d
X
1358beb8cc0940a18b0989c6cedabff1--5da257dc52a245bf8a3f810087c5c93d
5da257dc52a245bf8a3f810087c5c93d--894154657d5544a49107edafbbcc73ef
d0b85555cd6e40f1bd7592a50dc34ba4
5da257dc52a245bf8a3f810087c5c93d--d0b85555cd6e40f1bd7592a50dc34ba4
781f6ac9d4994c7f96023819af718331
RX(theta₁)
d0b85555cd6e40f1bd7592a50dc34ba4--781f6ac9d4994c7f96023819af718331
44bcba8a6dfa4f1dbe047282db432c66
RY(theta₅)
781f6ac9d4994c7f96023819af718331--44bcba8a6dfa4f1dbe047282db432c66
d2eda8cbcffc431a8661348016c32bb9
RX(theta₉)
44bcba8a6dfa4f1dbe047282db432c66--d2eda8cbcffc431a8661348016c32bb9
ed9f55586a0d40b1ad7b97fb096e3d03
X
d2eda8cbcffc431a8661348016c32bb9--ed9f55586a0d40b1ad7b97fb096e3d03
ed9f55586a0d40b1ad7b97fb096e3d03--e5d07ca278614b8e80bf4cbe9b2a6ad3
9d3a3324533b447ba155060e60705842
ed9f55586a0d40b1ad7b97fb096e3d03--9d3a3324533b447ba155060e60705842
91668df6d0d84fb8a90fc090de1c7bc3
RX(theta₁₃)
9d3a3324533b447ba155060e60705842--91668df6d0d84fb8a90fc090de1c7bc3
c3cfa35463c84c0e90decaa424f48859
RY(theta₁₇)
91668df6d0d84fb8a90fc090de1c7bc3--c3cfa35463c84c0e90decaa424f48859
bf50484ad04247f5be6f3d13b6892886
RX(theta₂₁)
c3cfa35463c84c0e90decaa424f48859--bf50484ad04247f5be6f3d13b6892886
33f99d45fad24eb8a945d72d18a44bdd
X
bf50484ad04247f5be6f3d13b6892886--33f99d45fad24eb8a945d72d18a44bdd
33f99d45fad24eb8a945d72d18a44bdd--5104911badef4864bcbc744b3c94dad5
c2e0afa29b344ac3b706f6ed9c46e422
33f99d45fad24eb8a945d72d18a44bdd--c2e0afa29b344ac3b706f6ed9c46e422
c2e0afa29b344ac3b706f6ed9c46e422--e7645bb3c46e461abf64f876317f6258
26199b3e0caf449a90d5a5794a030f63
3697a1c9358540758cc0a35e5ce598e6
RX(theta₂)
29fd1190605a4e71a6877d36e868ea74--3697a1c9358540758cc0a35e5ce598e6
40587f754ab2462bbbc576489930af07
3
cfa88087e0b24d89baac6e2f9dfdfeae
RY(theta₆)
3697a1c9358540758cc0a35e5ce598e6--cfa88087e0b24d89baac6e2f9dfdfeae
9e0fa0ee33b845179371615314a3b7bd
RX(theta₁₀)
cfa88087e0b24d89baac6e2f9dfdfeae--9e0fa0ee33b845179371615314a3b7bd
d1e91ff48f9e477399909b5cd88ba5bd
9e0fa0ee33b845179371615314a3b7bd--d1e91ff48f9e477399909b5cd88ba5bd
276e6a33222847fd8921904c3d2052bb
X
d1e91ff48f9e477399909b5cd88ba5bd--276e6a33222847fd8921904c3d2052bb
276e6a33222847fd8921904c3d2052bb--053ffde2d6054b81a7a2ce4858872918
befd46a3df12465aa9ac2cf0b64c592f
RX(theta₁₄)
276e6a33222847fd8921904c3d2052bb--befd46a3df12465aa9ac2cf0b64c592f
d8460c6a48de4c2f88cda182ce6854a5
RY(theta₁₈)
befd46a3df12465aa9ac2cf0b64c592f--d8460c6a48de4c2f88cda182ce6854a5
813dc23541114abbbfeab2421b14ba68
RX(theta₂₂)
d8460c6a48de4c2f88cda182ce6854a5--813dc23541114abbbfeab2421b14ba68
fca3a83bf3604513849edad056067f92
813dc23541114abbbfeab2421b14ba68--fca3a83bf3604513849edad056067f92
a8654d15cae74608b7f5ea31ecd48a86
X
fca3a83bf3604513849edad056067f92--a8654d15cae74608b7f5ea31ecd48a86
a8654d15cae74608b7f5ea31ecd48a86--d0b85555cd6e40f1bd7592a50dc34ba4
7c5769f957134b48a6b4937d1931e4ee
RX(theta₂)
a8654d15cae74608b7f5ea31ecd48a86--7c5769f957134b48a6b4937d1931e4ee
3bdc58bc88a8400db7843ef2c4720679
RY(theta₆)
7c5769f957134b48a6b4937d1931e4ee--3bdc58bc88a8400db7843ef2c4720679
662b8ea4c142456494800c4a48f7e09b
RX(theta₁₀)
3bdc58bc88a8400db7843ef2c4720679--662b8ea4c142456494800c4a48f7e09b
797cea5e3498467a89b4003665cb5afd
662b8ea4c142456494800c4a48f7e09b--797cea5e3498467a89b4003665cb5afd
4ce8ba68ff1647f7a92cbbbb25f91271
X
797cea5e3498467a89b4003665cb5afd--4ce8ba68ff1647f7a92cbbbb25f91271
4ce8ba68ff1647f7a92cbbbb25f91271--9d3a3324533b447ba155060e60705842
3b21d64608824bfba6748d5ea0d928d6
RX(theta₁₄)
4ce8ba68ff1647f7a92cbbbb25f91271--3b21d64608824bfba6748d5ea0d928d6
436faa5b026848fa99cbd1877ca6e9ae
RY(theta₁₈)
3b21d64608824bfba6748d5ea0d928d6--436faa5b026848fa99cbd1877ca6e9ae
a30f7da10c1c4156a84c2cc9bed9ce11
RX(theta₂₂)
436faa5b026848fa99cbd1877ca6e9ae--a30f7da10c1c4156a84c2cc9bed9ce11
86e0a0e9fea5440ca1792857de165322
a30f7da10c1c4156a84c2cc9bed9ce11--86e0a0e9fea5440ca1792857de165322
daf58617207e42aa954e364765f9f194
X
86e0a0e9fea5440ca1792857de165322--daf58617207e42aa954e364765f9f194
daf58617207e42aa954e364765f9f194--c2e0afa29b344ac3b706f6ed9c46e422
daf58617207e42aa954e364765f9f194--26199b3e0caf449a90d5a5794a030f63
5c0a067240a64f36b38932955f3bd76c
799452197328428b8b733477b2d84ea7
RX(theta₃)
40587f754ab2462bbbc576489930af07--799452197328428b8b733477b2d84ea7
a84f6e01577b476aba0b1642b96f5747
RY(theta₇)
799452197328428b8b733477b2d84ea7--a84f6e01577b476aba0b1642b96f5747
e73ddc9a6da54e25a8f8edf6b5a1ff8b
RX(theta₁₁)
a84f6e01577b476aba0b1642b96f5747--e73ddc9a6da54e25a8f8edf6b5a1ff8b
9352560c4d1545a68460c8342c11fd74
X
e73ddc9a6da54e25a8f8edf6b5a1ff8b--9352560c4d1545a68460c8342c11fd74
9352560c4d1545a68460c8342c11fd74--d1e91ff48f9e477399909b5cd88ba5bd
8c6da519a55f43fba0834cc8d341c7db
9352560c4d1545a68460c8342c11fd74--8c6da519a55f43fba0834cc8d341c7db
29f40e537f624121b7eb8231f8346468
RX(theta₁₅)
8c6da519a55f43fba0834cc8d341c7db--29f40e537f624121b7eb8231f8346468
bce443798dd64652bfc0f4abc55b2e19
RY(theta₁₉)
29f40e537f624121b7eb8231f8346468--bce443798dd64652bfc0f4abc55b2e19
3928c32cb6f4414b84611a6b5cb5d8f8
RX(theta₂₃)
bce443798dd64652bfc0f4abc55b2e19--3928c32cb6f4414b84611a6b5cb5d8f8
fd755ec6614f4b83a6d73d65d360e8e7
X
3928c32cb6f4414b84611a6b5cb5d8f8--fd755ec6614f4b83a6d73d65d360e8e7
fd755ec6614f4b83a6d73d65d360e8e7--fca3a83bf3604513849edad056067f92
78506149ac8341799979114bee3106a5
fd755ec6614f4b83a6d73d65d360e8e7--78506149ac8341799979114bee3106a5
2bc35d00e2d844bb92f4809a4d01a62b
RX(theta₃)
78506149ac8341799979114bee3106a5--2bc35d00e2d844bb92f4809a4d01a62b
931465c06a71403b90093a892a2e4cec
RY(theta₇)
2bc35d00e2d844bb92f4809a4d01a62b--931465c06a71403b90093a892a2e4cec
88dc8133892f406ea2563af3c118ba7d
RX(theta₁₁)
931465c06a71403b90093a892a2e4cec--88dc8133892f406ea2563af3c118ba7d
05f2c6047d464261865b6dc3ebda60b4
X
88dc8133892f406ea2563af3c118ba7d--05f2c6047d464261865b6dc3ebda60b4
05f2c6047d464261865b6dc3ebda60b4--797cea5e3498467a89b4003665cb5afd
7580b08245a24abe80793568acbe50ff
05f2c6047d464261865b6dc3ebda60b4--7580b08245a24abe80793568acbe50ff
fd5e6a6dc02f4d96a31d91d84759676d
RX(theta₁₅)
7580b08245a24abe80793568acbe50ff--fd5e6a6dc02f4d96a31d91d84759676d
ac74afa502f344f08c923319bf6a94cb
RY(theta₁₉)
fd5e6a6dc02f4d96a31d91d84759676d--ac74afa502f344f08c923319bf6a94cb
dac236d9ab1c42bdac14ce54d44bf93f
RX(theta₂₃)
ac74afa502f344f08c923319bf6a94cb--dac236d9ab1c42bdac14ce54d44bf93f
c13b5cccb2ac4d56b83a4024f5558aa4
X
dac236d9ab1c42bdac14ce54d44bf93f--c13b5cccb2ac4d56b83a4024f5558aa4
c13b5cccb2ac4d56b83a4024f5558aa4--86e0a0e9fea5440ca1792857de165322
bbbcfcf43a124c36829ab6b7046cf822
c13b5cccb2ac4d56b83a4024f5558aa4--bbbcfcf43a124c36829ab6b7046cf822
bbbcfcf43a124c36829ab6b7046cf822--5c0a067240a64f36b38932955f3bd76c
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_d705988408ad438697efe2a4f98450d1
HEA
cluster_7dc06f89720b4a7f825f3d1879042380
HEA
53de1da1269240748744cc9aaf1e5a5c
0
83d64be6aac6420a8a3cfa1301cc1d20
RX(p1₀)
53de1da1269240748744cc9aaf1e5a5c--83d64be6aac6420a8a3cfa1301cc1d20
990035753009494b80bd5ee3834545bf
1
2c3d38bef4c94f5cad11fba865b3acf1
RY(p1₄)
83d64be6aac6420a8a3cfa1301cc1d20--2c3d38bef4c94f5cad11fba865b3acf1
ff70c07523fe480aa2f472608176d259
RX(p1₈)
2c3d38bef4c94f5cad11fba865b3acf1--ff70c07523fe480aa2f472608176d259
3014fb9501704e649fd34b93056f1de3
ff70c07523fe480aa2f472608176d259--3014fb9501704e649fd34b93056f1de3
c8170368a3c646418e8bf1287a6a0931
3014fb9501704e649fd34b93056f1de3--c8170368a3c646418e8bf1287a6a0931
eaa3d897527049058b0077e86ef545a4
RX(p1₁₂)
c8170368a3c646418e8bf1287a6a0931--eaa3d897527049058b0077e86ef545a4
5fd600930f2d48b4974545666e799e90
RY(p1₁₆)
eaa3d897527049058b0077e86ef545a4--5fd600930f2d48b4974545666e799e90
f99423760a064bd395624d2367432a77
RX(p1₂₀)
5fd600930f2d48b4974545666e799e90--f99423760a064bd395624d2367432a77
be711a1510d543fd8ddbaeaeadb51c9d
f99423760a064bd395624d2367432a77--be711a1510d543fd8ddbaeaeadb51c9d
e937920ee2e243c582d5c67b232a2a61
be711a1510d543fd8ddbaeaeadb51c9d--e937920ee2e243c582d5c67b232a2a61
679a34db5a5945b694b78c94a9d5c483
RX(p2₀)
e937920ee2e243c582d5c67b232a2a61--679a34db5a5945b694b78c94a9d5c483
980dc687d98f4277b60218cfae4a8504
RY(p2₄)
679a34db5a5945b694b78c94a9d5c483--980dc687d98f4277b60218cfae4a8504
4cfa707877484b9781a351eb4bf2cf54
RX(p2₈)
980dc687d98f4277b60218cfae4a8504--4cfa707877484b9781a351eb4bf2cf54
98edb9a303ab418faafd3b682c25123d
4cfa707877484b9781a351eb4bf2cf54--98edb9a303ab418faafd3b682c25123d
5870f82f82ae49ada66566620b4eee99
98edb9a303ab418faafd3b682c25123d--5870f82f82ae49ada66566620b4eee99
de4e00c647ab4a408b89bb76c595694d
RX(p2₁₂)
5870f82f82ae49ada66566620b4eee99--de4e00c647ab4a408b89bb76c595694d
7809620c9d66466eb07a30d28fba970e
RY(p2₁₆)
de4e00c647ab4a408b89bb76c595694d--7809620c9d66466eb07a30d28fba970e
cef268b7224148b5b1c43c78e9f2d5fb
RX(p2₂₀)
7809620c9d66466eb07a30d28fba970e--cef268b7224148b5b1c43c78e9f2d5fb
e7030ee3fca744e6b557b292ff953057
cef268b7224148b5b1c43c78e9f2d5fb--e7030ee3fca744e6b557b292ff953057
2d7da5b383194629bf2aaf7c834e8e18
e7030ee3fca744e6b557b292ff953057--2d7da5b383194629bf2aaf7c834e8e18
34ba76c6547142f080fd5648ef8fcedb
2d7da5b383194629bf2aaf7c834e8e18--34ba76c6547142f080fd5648ef8fcedb
c908d82195544a4b8fa9862d2bcf0280
d1bd7a52039e437f91c290453216efaf
RX(p1₁)
990035753009494b80bd5ee3834545bf--d1bd7a52039e437f91c290453216efaf
96da39d9f03b4d6b99ec132f693cebc5
2
56203d9af36b4af59d2cbf0eba59cca5
RY(p1₅)
d1bd7a52039e437f91c290453216efaf--56203d9af36b4af59d2cbf0eba59cca5
bcc2c06d3b1f4efd9c712ae010f05a8e
RX(p1₉)
56203d9af36b4af59d2cbf0eba59cca5--bcc2c06d3b1f4efd9c712ae010f05a8e
0bc5fc13706c45c5a903486fa8bafd4f
X
bcc2c06d3b1f4efd9c712ae010f05a8e--0bc5fc13706c45c5a903486fa8bafd4f
0bc5fc13706c45c5a903486fa8bafd4f--3014fb9501704e649fd34b93056f1de3
35df7d6996954ffe8619feed49c06ae9
0bc5fc13706c45c5a903486fa8bafd4f--35df7d6996954ffe8619feed49c06ae9
b00abe27d6a1440a8ab9347a92a75cb0
RX(p1₁₃)
35df7d6996954ffe8619feed49c06ae9--b00abe27d6a1440a8ab9347a92a75cb0
4e2c98b32219434985a8d9b0ae305dbd
RY(p1₁₇)
b00abe27d6a1440a8ab9347a92a75cb0--4e2c98b32219434985a8d9b0ae305dbd
4cbe319c97e242c0878cfc17f458b6f2
RX(p1₂₁)
4e2c98b32219434985a8d9b0ae305dbd--4cbe319c97e242c0878cfc17f458b6f2
dbb9850ec93749fe8da6b6d199bd8018
X
4cbe319c97e242c0878cfc17f458b6f2--dbb9850ec93749fe8da6b6d199bd8018
dbb9850ec93749fe8da6b6d199bd8018--be711a1510d543fd8ddbaeaeadb51c9d
d2c12187653b4eb69bcbe00fe85d5877
dbb9850ec93749fe8da6b6d199bd8018--d2c12187653b4eb69bcbe00fe85d5877
a1bc8593842549a688bcb3006ab3d15f
RX(p2₁)
d2c12187653b4eb69bcbe00fe85d5877--a1bc8593842549a688bcb3006ab3d15f
17657c20bd8e4146a19d0ed1295df45f
RY(p2₅)
a1bc8593842549a688bcb3006ab3d15f--17657c20bd8e4146a19d0ed1295df45f
e397e6a03c83442ab777804c5375252b
RX(p2₉)
17657c20bd8e4146a19d0ed1295df45f--e397e6a03c83442ab777804c5375252b
b5be67d36dc3461a865671d0edb54de4
X
e397e6a03c83442ab777804c5375252b--b5be67d36dc3461a865671d0edb54de4
b5be67d36dc3461a865671d0edb54de4--98edb9a303ab418faafd3b682c25123d
214e060b03f64f3b8abd2f4df926ab94
b5be67d36dc3461a865671d0edb54de4--214e060b03f64f3b8abd2f4df926ab94
050497798dc3416799b6c42e135a2961
RX(p2₁₃)
214e060b03f64f3b8abd2f4df926ab94--050497798dc3416799b6c42e135a2961
318cf5acb96a44b89e07bbae3b0f279b
RY(p2₁₇)
050497798dc3416799b6c42e135a2961--318cf5acb96a44b89e07bbae3b0f279b
0a968f5bd2f242d48098e6e27de1fddf
RX(p2₂₁)
318cf5acb96a44b89e07bbae3b0f279b--0a968f5bd2f242d48098e6e27de1fddf
b659000d3a3b46f9841b0a033af47adc
X
0a968f5bd2f242d48098e6e27de1fddf--b659000d3a3b46f9841b0a033af47adc
b659000d3a3b46f9841b0a033af47adc--e7030ee3fca744e6b557b292ff953057
bad1e32d17f84aa28dd660d83e36bd40
b659000d3a3b46f9841b0a033af47adc--bad1e32d17f84aa28dd660d83e36bd40
bad1e32d17f84aa28dd660d83e36bd40--c908d82195544a4b8fa9862d2bcf0280
593858f1e5664d7eae7fac448adbb6e0
7276478bee364ecbb083dc818c94619f
RX(p1₂)
96da39d9f03b4d6b99ec132f693cebc5--7276478bee364ecbb083dc818c94619f
a5b2cf0c583c45a693eb9c17560b9140
3
ff846ce39e0c44618413c6684e2ad411
RY(p1₆)
7276478bee364ecbb083dc818c94619f--ff846ce39e0c44618413c6684e2ad411
0a932be724724fbbb6a6c6673d6b3fcf
RX(p1₁₀)
ff846ce39e0c44618413c6684e2ad411--0a932be724724fbbb6a6c6673d6b3fcf
a822e971b488436b88849a128d2136d7
0a932be724724fbbb6a6c6673d6b3fcf--a822e971b488436b88849a128d2136d7
f62fc79b0ff04dcb9091bcc71475d09e
X
a822e971b488436b88849a128d2136d7--f62fc79b0ff04dcb9091bcc71475d09e
f62fc79b0ff04dcb9091bcc71475d09e--35df7d6996954ffe8619feed49c06ae9
77957b54430345eb97e43f7998d4489a
RX(p1₁₄)
f62fc79b0ff04dcb9091bcc71475d09e--77957b54430345eb97e43f7998d4489a
1ab3ddd3cfde4fb192bf88ad592ec1fb
RY(p1₁₈)
77957b54430345eb97e43f7998d4489a--1ab3ddd3cfde4fb192bf88ad592ec1fb
16e915536ab74f2aa7a5912068b4499f
RX(p1₂₂)
1ab3ddd3cfde4fb192bf88ad592ec1fb--16e915536ab74f2aa7a5912068b4499f
6b175c0cdfad4981a4b29609cfb0494c
16e915536ab74f2aa7a5912068b4499f--6b175c0cdfad4981a4b29609cfb0494c
5e036d71ac4041b0af3a4cd31d075cc0
X
6b175c0cdfad4981a4b29609cfb0494c--5e036d71ac4041b0af3a4cd31d075cc0
5e036d71ac4041b0af3a4cd31d075cc0--d2c12187653b4eb69bcbe00fe85d5877
bc44774c3d0f48c9b3e6ba84ade1716f
RX(p2₂)
5e036d71ac4041b0af3a4cd31d075cc0--bc44774c3d0f48c9b3e6ba84ade1716f
ab439dc2062849f4a39879759b1a9b99
RY(p2₆)
bc44774c3d0f48c9b3e6ba84ade1716f--ab439dc2062849f4a39879759b1a9b99
fa86dba2669b46499d9c7106d0e6ad22
RX(p2₁₀)
ab439dc2062849f4a39879759b1a9b99--fa86dba2669b46499d9c7106d0e6ad22
5af11aaf155a4a7bafad4f1f53d27801
fa86dba2669b46499d9c7106d0e6ad22--5af11aaf155a4a7bafad4f1f53d27801
4e1d010246ee48acabf81eae363ec055
X
5af11aaf155a4a7bafad4f1f53d27801--4e1d010246ee48acabf81eae363ec055
4e1d010246ee48acabf81eae363ec055--214e060b03f64f3b8abd2f4df926ab94
d160211e15a54bd6a000073af1d2c5ea
RX(p2₁₄)
4e1d010246ee48acabf81eae363ec055--d160211e15a54bd6a000073af1d2c5ea
c484bae75fde4b008a8cf120c7c4a5bb
RY(p2₁₈)
d160211e15a54bd6a000073af1d2c5ea--c484bae75fde4b008a8cf120c7c4a5bb
f956c42d8dc8450a9b4152e554f4bf45
RX(p2₂₂)
c484bae75fde4b008a8cf120c7c4a5bb--f956c42d8dc8450a9b4152e554f4bf45
2084db3040c049f492c223e5064b75cc
f956c42d8dc8450a9b4152e554f4bf45--2084db3040c049f492c223e5064b75cc
f9774b1c0a4149c3afac2604b48bf45e
X
2084db3040c049f492c223e5064b75cc--f9774b1c0a4149c3afac2604b48bf45e
f9774b1c0a4149c3afac2604b48bf45e--bad1e32d17f84aa28dd660d83e36bd40
f9774b1c0a4149c3afac2604b48bf45e--593858f1e5664d7eae7fac448adbb6e0
b329f1e65d1a4630ada4d1a484083cb1
dc360531ecd0433ba081aad86b816a1d
RX(p1₃)
a5b2cf0c583c45a693eb9c17560b9140--dc360531ecd0433ba081aad86b816a1d
e7c07c196102410a99a322ca335a3fe6
RY(p1₇)
dc360531ecd0433ba081aad86b816a1d--e7c07c196102410a99a322ca335a3fe6
5c64ed0efd684d3786554fedbc13d397
RX(p1₁₁)
e7c07c196102410a99a322ca335a3fe6--5c64ed0efd684d3786554fedbc13d397
5b44a48682b5490d9156cec34b5abffb
X
5c64ed0efd684d3786554fedbc13d397--5b44a48682b5490d9156cec34b5abffb
5b44a48682b5490d9156cec34b5abffb--a822e971b488436b88849a128d2136d7
618ed30e9643426cb6220aa99cd224de
5b44a48682b5490d9156cec34b5abffb--618ed30e9643426cb6220aa99cd224de
099963bcbb7b4c14b4098e2ec15824b8
RX(p1₁₅)
618ed30e9643426cb6220aa99cd224de--099963bcbb7b4c14b4098e2ec15824b8
fb94e29732464fec95c9f6a675bf359d
RY(p1₁₉)
099963bcbb7b4c14b4098e2ec15824b8--fb94e29732464fec95c9f6a675bf359d
e07b82b492a84b7db85fd9a7c431028d
RX(p1₂₃)
fb94e29732464fec95c9f6a675bf359d--e07b82b492a84b7db85fd9a7c431028d
06dff2aaca4e4960900389b7fe29a752
X
e07b82b492a84b7db85fd9a7c431028d--06dff2aaca4e4960900389b7fe29a752
06dff2aaca4e4960900389b7fe29a752--6b175c0cdfad4981a4b29609cfb0494c
fb0e4b72089d46cd8516ee88f6ef6f18
06dff2aaca4e4960900389b7fe29a752--fb0e4b72089d46cd8516ee88f6ef6f18
3e90fbf07085493ebe968f7a95e8023a
RX(p2₃)
fb0e4b72089d46cd8516ee88f6ef6f18--3e90fbf07085493ebe968f7a95e8023a
b947a3d533bd4308aed64d1e840e8674
RY(p2₇)
3e90fbf07085493ebe968f7a95e8023a--b947a3d533bd4308aed64d1e840e8674
3c24680c47824c3cb0463cd7a2c0b007
RX(p2₁₁)
b947a3d533bd4308aed64d1e840e8674--3c24680c47824c3cb0463cd7a2c0b007
4ed095f553cf41b58a61710beb7fc171
X
3c24680c47824c3cb0463cd7a2c0b007--4ed095f553cf41b58a61710beb7fc171
4ed095f553cf41b58a61710beb7fc171--5af11aaf155a4a7bafad4f1f53d27801
b9ecccec0faa4b51b140c62e56a1b516
4ed095f553cf41b58a61710beb7fc171--b9ecccec0faa4b51b140c62e56a1b516
8311729a3c4e4f558a9d2b2de54c2db0
RX(p2₁₅)
b9ecccec0faa4b51b140c62e56a1b516--8311729a3c4e4f558a9d2b2de54c2db0
5b75fe332e55486e80134c1168f684e5
RY(p2₁₉)
8311729a3c4e4f558a9d2b2de54c2db0--5b75fe332e55486e80134c1168f684e5
059565824cd24dc0ab43b3a1d605e842
RX(p2₂₃)
5b75fe332e55486e80134c1168f684e5--059565824cd24dc0ab43b3a1d605e842
18e0a2509b6f42a5887e94c1374e5285
X
059565824cd24dc0ab43b3a1d605e842--18e0a2509b6f42a5887e94c1374e5285
18e0a2509b6f42a5887e94c1374e5285--2084db3040c049f492c223e5064b75cc
010d38d7dce84ba5982a23f401e09888
18e0a2509b6f42a5887e94c1374e5285--010d38d7dce84ba5982a23f401e09888
010d38d7dce84ba5982a23f401e09888--b329f1e65d1a4630ada4d1a484083cb1
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.6723 ] )) , (' t he ta _ 0 ' , tens or( [ 0.1476 ] )) , (' t he ta _ 1 ' , tens or( [ 0.6309 ] )) , (' t he ta _ 10 ' , tens or( [ 0.8657 ] )) , (' t he ta _ 11 ' , tens or( [ 0.8418 ] )) , (' t he ta _ 12 ' , tens or( [ 0.1063 ] )) , (' t he ta _ 13 ' , tens or( [ 0.6077 ] )) , (' t he ta _ 14 ' , tens or( [ 0.8846 ] )) , (' t he ta _ 15 ' , tens or( [ 0.9668 ] )) , (' t he ta _ 16 ' , tens or( [ 0.2565 ] )) , (' t he ta _ 17 ' , tens or( [ 0.1043 ] )) , (' t he ta _ 18 ' , tens or( [ 0.9783 ] )) , (' t he ta _ 19 ' , tens or( [ 0.0618 ] )) , (' t he ta _ 2 ' , tens or( [ 0.1834 ] )) , (' t he ta _ 20 ' , tens or( [ 0.4442 ] )) , (' t he ta _ 21 ' , tens or( [ 0.6389 ] )) , (' t he ta _ 22 ' , tens or( [ 0.6250 ] )) , (' t he ta _ 23 ' , tens or( [ 0.5487 ] )) , (' t he ta _ 3 ' , tens or( [ 0.8038 ] )) , (' t he ta _ 4 ' , tens or( [ 0.9408 ] )) , (' t he ta _ 5 ' , tens or( [ 0.4441 ] )) , (' t he ta _ 6 ' , tens or( [ 0.6926 ] )) , (' t he ta _ 7 ' , tens or( [ 0.3457 ] )) , (' t he ta _ 8 ' , tens or( [ 0.6128 ] )) , (' t he ta _ 9 ' , tens or( [ 0.6174 ] )) ] )
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.6713 ] )) , (' t he ta _ 0 ' , tens or( [ 0.1486 ] )) , (' t he ta _ 1 ' , tens or( [ 0.6319 ] )) , (' t he ta _ 10 ' , tens or( [ 0.8667 ] )) , (' t he ta _ 11 ' , tens or( [ 0.8428 ] )) , (' t he ta _ 12 ' , tens or( [ 0.1073 ] )) , (' t he ta _ 13 ' , tens or( [ 0.6067 ] )) , (' t he ta _ 14 ' , tens or( [ 0.8856 ] )) , (' t he ta _ 15 ' , tens or( [ 0.9678 ] )) , (' t he ta _ 16 ' , tens or( [ 0.2575 ] )) , (' t he ta _ 17 ' , tens or( [ 0.1033 ] )) , (' t he ta _ 18 ' , tens or( [ 0.9773 ] )) , (' t he ta _ 19 ' , tens or( [ 0.0608 ] )) , (' t he ta _ 2 ' , tens or( [ 0.1844 ] )) , (' t he ta _ 20 ' , tens or( [ 0.4452 ] )) , (' t he ta _ 21 ' , tens or( [ 0.6379 ] )) , (' t he ta _ 22 ' , tens or( [ 0.6260 ] )) , (' t he ta _ 23 ' , tens or( [ 0.5497 ] )) , (' t he ta _ 3 ' , tens or( [ 0.8048 ] )) , (' t he ta _ 4 ' , tens or( [ 0.9418 ] )) , (' t he ta _ 5 ' , tens or( [ 0.4451 ] )) , (' t he ta _ 6 ' , tens or( [ 0.6936 ] )) , (' t he ta _ 7 ' , tens or( [ 0.3467 ] )) , (' t he ta _ 8 ' , tens or( [ 0.6138 ] )) , (' t he ta _ 9 ' , tens or( [ 0.6184 ] )) ] )
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 ]] )