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.9048+0.0000 j , 0.0000-0.4258 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.8776+0.0000 j , 0.0000-0.4794 j ],
[ 0.9633+0.0000 j , 0.0000-0.2685 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.8746+0.0000 j , 0.3181+0.0000 j , 0.0000-0.3439 j , 0.0000-0.1251 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_46f3795f5751467ebb4ba1eb505922c6
[* 2]
cluster_ba3ab2e1c9104792b5dce9d4a11defb9
Rotations
630ebed8da7c4958822607ecfbf405bb
0
538d9192b9144c5d8dd86302575d5a74
RX(phi/theta)
630ebed8da7c4958822607ecfbf405bb--538d9192b9144c5d8dd86302575d5a74
f69865c057e049f88d15baa8ef2b7b00
1
97f4f0f3b3c146a095bbf552a954428c
RX(phi)
538d9192b9144c5d8dd86302575d5a74--97f4f0f3b3c146a095bbf552a954428c
930a8c49c85d4272a7e08090cd811a14
RX(phi)
97f4f0f3b3c146a095bbf552a954428c--930a8c49c85d4272a7e08090cd811a14
fece82fe719e4876a82b87f46d92b55b
RX(phi + theta)
930a8c49c85d4272a7e08090cd811a14--fece82fe719e4876a82b87f46d92b55b
c40f134d7c894ccdb6b2974952a9905d
fece82fe719e4876a82b87f46d92b55b--c40f134d7c894ccdb6b2974952a9905d
b7b43e0bd4144e778c9d9f936c86982e
c40f134d7c894ccdb6b2974952a9905d--b7b43e0bd4144e778c9d9f936c86982e
3f9f218dfae6486199dfcb0c5eebce56
Z
b7b43e0bd4144e778c9d9f936c86982e--3f9f218dfae6486199dfcb0c5eebce56
a2fe4ba8b3654c2990df4a0d436f72fa
3f9f218dfae6486199dfcb0c5eebce56--a2fe4ba8b3654c2990df4a0d436f72fa
5b5c263673394c3d8f3ef8928a090c6e
bfca42085d2142ed9b35217aeaa4583d
RY(2*theta)
f69865c057e049f88d15baa8ef2b7b00--bfca42085d2142ed9b35217aeaa4583d
4799373416d54166a451a026a0205c41
2
6a485b3e1b294cc78d72b4fa9058b3cf
RY(theta)
bfca42085d2142ed9b35217aeaa4583d--6a485b3e1b294cc78d72b4fa9058b3cf
bfe57cd5fc5f43f882a9b70b6b7df0f2
RY(theta)
6a485b3e1b294cc78d72b4fa9058b3cf--bfe57cd5fc5f43f882a9b70b6b7df0f2
aee23cbb6b8d42a3aef1a0ab5e7def8c
RY(theta**2)
bfe57cd5fc5f43f882a9b70b6b7df0f2--aee23cbb6b8d42a3aef1a0ab5e7def8c
b88e61e5c35a47b784cf57add92d4604
X
aee23cbb6b8d42a3aef1a0ab5e7def8c--b88e61e5c35a47b784cf57add92d4604
b88e61e5c35a47b784cf57add92d4604--c40f134d7c894ccdb6b2974952a9905d
dd173beaeb42409fab3a921c7c4a2c30
b88e61e5c35a47b784cf57add92d4604--dd173beaeb42409fab3a921c7c4a2c30
e1ce0af121704be181008b4a94a579a2
Z
dd173beaeb42409fab3a921c7c4a2c30--e1ce0af121704be181008b4a94a579a2
e1ce0af121704be181008b4a94a579a2--5b5c263673394c3d8f3ef8928a090c6e
10156a06641f47c593336c4f688d89f4
3c61eb6cd67f4b54aec4127769c1bbd4
RZ(cos(phi))
4799373416d54166a451a026a0205c41--3c61eb6cd67f4b54aec4127769c1bbd4
6a678f83a6d349429fb93588d128f511
RZ(phi)
3c61eb6cd67f4b54aec4127769c1bbd4--6a678f83a6d349429fb93588d128f511
a5f4c1ecabea47be903ab674e7778581
RZ(phi)
6a678f83a6d349429fb93588d128f511--a5f4c1ecabea47be903ab674e7778581
e22b6290437d4928b4441bd4312fdd00
RZ(cos(phi))
a5f4c1ecabea47be903ab674e7778581--e22b6290437d4928b4441bd4312fdd00
783096f549704bf7b70b07751c546380
e22b6290437d4928b4441bd4312fdd00--783096f549704bf7b70b07751c546380
9782518acbfb4bf6916339b497c55ceb
X
783096f549704bf7b70b07751c546380--9782518acbfb4bf6916339b497c55ceb
9782518acbfb4bf6916339b497c55ceb--dd173beaeb42409fab3a921c7c4a2c30
9f2eb47b63a64ee39084639cc61db172
Z
9782518acbfb4bf6916339b497c55ceb--9f2eb47b63a64ee39084639cc61db172
9f2eb47b63a64ee39084639cc61db172--10156a06641f47c593336c4f688d89f4
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.6122 ] )) ] )
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.8583+0.0000 j , 0.3487+0.0000 j , 0.0000-0.3487 j , 0.0000-0.1417 j ],
[ 0.9034+0.0000 j , 0.2954+0.0000 j , 0.0000-0.2954 j , 0.0000-0.0966 j ],
[ 0.6968+0.0000 j , 0.4597+0.0000 j , 0.0000-0.4597 j , 0.0000-0.3032 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
6bd5cdb6358b4b328ac3079b3ca5aa2d
0
d2dee1d3e6644a4ca048a6ba10835972
RX(theta₀)
6bd5cdb6358b4b328ac3079b3ca5aa2d--d2dee1d3e6644a4ca048a6ba10835972
1988908b29ca487e92b05a8b37c61f7b
1
392c46d049554d0d856364bbc124d3ff
RY(theta₄)
d2dee1d3e6644a4ca048a6ba10835972--392c46d049554d0d856364bbc124d3ff
145549be7b7d4092b8b5641c6e7a381f
RX(theta₈)
392c46d049554d0d856364bbc124d3ff--145549be7b7d4092b8b5641c6e7a381f
3e47908682d6408c9a4978be48f5bef3
145549be7b7d4092b8b5641c6e7a381f--3e47908682d6408c9a4978be48f5bef3
6a65e310ee8f4816b38c8111c264de85
3e47908682d6408c9a4978be48f5bef3--6a65e310ee8f4816b38c8111c264de85
0c84ca025db340cb86ae99dc10ba35e4
RX(theta₁₂)
6a65e310ee8f4816b38c8111c264de85--0c84ca025db340cb86ae99dc10ba35e4
ce0a889114d34c38a8acc0ca6105d93f
RY(theta₁₆)
0c84ca025db340cb86ae99dc10ba35e4--ce0a889114d34c38a8acc0ca6105d93f
0b448633e5054a7db6baaff03aa5341b
RX(theta₂₀)
ce0a889114d34c38a8acc0ca6105d93f--0b448633e5054a7db6baaff03aa5341b
c625fcd3d3514ae1be385c500bbae196
0b448633e5054a7db6baaff03aa5341b--c625fcd3d3514ae1be385c500bbae196
4a2631ce204a4c6c8e5db8b250c52348
c625fcd3d3514ae1be385c500bbae196--4a2631ce204a4c6c8e5db8b250c52348
f2e27204ec56452398f6341f25feb374
4a2631ce204a4c6c8e5db8b250c52348--f2e27204ec56452398f6341f25feb374
381c32e2e02847a0b2f4472bf33f2f47
12cc33bac82744f0910228364349d826
RX(theta₁)
1988908b29ca487e92b05a8b37c61f7b--12cc33bac82744f0910228364349d826
1caf20dcd8054c1488b091076b1b7243
2
341769c994c94ebba43bbc551089c1ba
RY(theta₅)
12cc33bac82744f0910228364349d826--341769c994c94ebba43bbc551089c1ba
3311c23d73cc4dfd90f0205d2f1915b8
RX(theta₉)
341769c994c94ebba43bbc551089c1ba--3311c23d73cc4dfd90f0205d2f1915b8
f48998460a5e42eb9ac056c273193d1e
X
3311c23d73cc4dfd90f0205d2f1915b8--f48998460a5e42eb9ac056c273193d1e
f48998460a5e42eb9ac056c273193d1e--3e47908682d6408c9a4978be48f5bef3
e6581d3ea7ac4acd910ff73afaac8c10
f48998460a5e42eb9ac056c273193d1e--e6581d3ea7ac4acd910ff73afaac8c10
230df82bf6724136a53bf025acb99e0f
RX(theta₁₃)
e6581d3ea7ac4acd910ff73afaac8c10--230df82bf6724136a53bf025acb99e0f
28f8546650674450a9def031fa710d8d
RY(theta₁₇)
230df82bf6724136a53bf025acb99e0f--28f8546650674450a9def031fa710d8d
3ff33bb374684a49b291d069d65db1e5
RX(theta₂₁)
28f8546650674450a9def031fa710d8d--3ff33bb374684a49b291d069d65db1e5
e38cec285fcc460f976e727d63c35661
X
3ff33bb374684a49b291d069d65db1e5--e38cec285fcc460f976e727d63c35661
e38cec285fcc460f976e727d63c35661--c625fcd3d3514ae1be385c500bbae196
a8e24dfe215d413caca9b627c93e6e1f
e38cec285fcc460f976e727d63c35661--a8e24dfe215d413caca9b627c93e6e1f
a8e24dfe215d413caca9b627c93e6e1f--381c32e2e02847a0b2f4472bf33f2f47
1ec078f98dee458186d659760611a0bb
bcac28bb28fe46c591880056cf714f84
RX(theta₂)
1caf20dcd8054c1488b091076b1b7243--bcac28bb28fe46c591880056cf714f84
3a87c063551d4670929937493d5b124c
3
3927f336293f4c4186931b9c3b25a83f
RY(theta₆)
bcac28bb28fe46c591880056cf714f84--3927f336293f4c4186931b9c3b25a83f
2a76641a13b34a6382a31575b2b8ce57
RX(theta₁₀)
3927f336293f4c4186931b9c3b25a83f--2a76641a13b34a6382a31575b2b8ce57
90c708c353fd40c685411ac23668b1ae
2a76641a13b34a6382a31575b2b8ce57--90c708c353fd40c685411ac23668b1ae
f6ace178c03d47458bf59c9b0f59d916
X
90c708c353fd40c685411ac23668b1ae--f6ace178c03d47458bf59c9b0f59d916
f6ace178c03d47458bf59c9b0f59d916--e6581d3ea7ac4acd910ff73afaac8c10
126aadad56e341c6abf5113f4aa5dfab
RX(theta₁₄)
f6ace178c03d47458bf59c9b0f59d916--126aadad56e341c6abf5113f4aa5dfab
6d723611c6d44675a9da8e46b6ed0072
RY(theta₁₈)
126aadad56e341c6abf5113f4aa5dfab--6d723611c6d44675a9da8e46b6ed0072
9236f513bb4d486e9d399fe9559de556
RX(theta₂₂)
6d723611c6d44675a9da8e46b6ed0072--9236f513bb4d486e9d399fe9559de556
1e87e4fb9ca645c8a0f6c6e2ef7da4a7
9236f513bb4d486e9d399fe9559de556--1e87e4fb9ca645c8a0f6c6e2ef7da4a7
3a106d13962a4de3b82afb5411ef08e4
X
1e87e4fb9ca645c8a0f6c6e2ef7da4a7--3a106d13962a4de3b82afb5411ef08e4
3a106d13962a4de3b82afb5411ef08e4--a8e24dfe215d413caca9b627c93e6e1f
3a106d13962a4de3b82afb5411ef08e4--1ec078f98dee458186d659760611a0bb
7950a6fa63e2495fa7a5b720ad345bdd
e4e2597dbb4a48f9943367c6a8c84f39
RX(theta₃)
3a87c063551d4670929937493d5b124c--e4e2597dbb4a48f9943367c6a8c84f39
d478113e7656407086c6343214a602e2
RY(theta₇)
e4e2597dbb4a48f9943367c6a8c84f39--d478113e7656407086c6343214a602e2
73198e77837841f89238882996450e0c
RX(theta₁₁)
d478113e7656407086c6343214a602e2--73198e77837841f89238882996450e0c
cdcf55c46d9e43689ab1322789a1a060
X
73198e77837841f89238882996450e0c--cdcf55c46d9e43689ab1322789a1a060
cdcf55c46d9e43689ab1322789a1a060--90c708c353fd40c685411ac23668b1ae
3d93ce81ec1f46febea257fc8d8d9f22
cdcf55c46d9e43689ab1322789a1a060--3d93ce81ec1f46febea257fc8d8d9f22
c39ea74f93344bba9a6896e697d7ec08
RX(theta₁₅)
3d93ce81ec1f46febea257fc8d8d9f22--c39ea74f93344bba9a6896e697d7ec08
c3b668aba8fb4c3799bb4d770e8b9ce6
RY(theta₁₉)
c39ea74f93344bba9a6896e697d7ec08--c3b668aba8fb4c3799bb4d770e8b9ce6
503a50ca45334f4ab507ec86760fcb8a
RX(theta₂₃)
c3b668aba8fb4c3799bb4d770e8b9ce6--503a50ca45334f4ab507ec86760fcb8a
90fcd504509b4c7f9ef14d5db6ec6660
X
503a50ca45334f4ab507ec86760fcb8a--90fcd504509b4c7f9ef14d5db6ec6660
90fcd504509b4c7f9ef14d5db6ec6660--1e87e4fb9ca645c8a0f6c6e2ef7da4a7
e6b14fbffb30491b801068a89028f0aa
90fcd504509b4c7f9ef14d5db6ec6660--e6b14fbffb30491b801068a89028f0aa
e6b14fbffb30491b801068a89028f0aa--7950a6fa63e2495fa7a5b720ad345bdd
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_149432d5882346e785bfd08eef146d40
HEA
cluster_db3122fc6c57414bbcab01e05d1781ba
HEA
497ea0a02b204dfc9a595dbc17bae46f
0
3f09f417bb7d4a469fa1412b4c3fcda5
RX(theta₀)
497ea0a02b204dfc9a595dbc17bae46f--3f09f417bb7d4a469fa1412b4c3fcda5
0b513dc612624ed1b10be0f4e1c63a90
1
0465dc60990e4c009ee7705c8ab2cb8c
RY(theta₄)
3f09f417bb7d4a469fa1412b4c3fcda5--0465dc60990e4c009ee7705c8ab2cb8c
9028e154c63c4be98d3e5d7a80cc01e0
RX(theta₈)
0465dc60990e4c009ee7705c8ab2cb8c--9028e154c63c4be98d3e5d7a80cc01e0
4ac589cfac8e4689a9edd6390fb4f5c5
9028e154c63c4be98d3e5d7a80cc01e0--4ac589cfac8e4689a9edd6390fb4f5c5
d2ff282b465d4855b8ada43d52bcfcf1
4ac589cfac8e4689a9edd6390fb4f5c5--d2ff282b465d4855b8ada43d52bcfcf1
ede27b20e2c54a82b243970c0b5d3c53
RX(theta₁₂)
d2ff282b465d4855b8ada43d52bcfcf1--ede27b20e2c54a82b243970c0b5d3c53
dd086b0ecf994c70a90e55d71ff7bd80
RY(theta₁₆)
ede27b20e2c54a82b243970c0b5d3c53--dd086b0ecf994c70a90e55d71ff7bd80
8fddc2a690124d598a80e245b71130e4
RX(theta₂₀)
dd086b0ecf994c70a90e55d71ff7bd80--8fddc2a690124d598a80e245b71130e4
fea773db6a814398902866579031a942
8fddc2a690124d598a80e245b71130e4--fea773db6a814398902866579031a942
b3a2bb4f1da744fcac759d751a337f68
fea773db6a814398902866579031a942--b3a2bb4f1da744fcac759d751a337f68
f5c557e2a3d445c6a6c88db0e76ce039
RX(theta₀)
b3a2bb4f1da744fcac759d751a337f68--f5c557e2a3d445c6a6c88db0e76ce039
2990a2c7763e4797ab0cf858a55adac6
RY(theta₄)
f5c557e2a3d445c6a6c88db0e76ce039--2990a2c7763e4797ab0cf858a55adac6
87c7eb629972491bb77e475cbe72174e
RX(theta₈)
2990a2c7763e4797ab0cf858a55adac6--87c7eb629972491bb77e475cbe72174e
c249e6e634794f37b579256c698f877c
87c7eb629972491bb77e475cbe72174e--c249e6e634794f37b579256c698f877c
a603b68c42bb4d36a61c0ef42e047eff
c249e6e634794f37b579256c698f877c--a603b68c42bb4d36a61c0ef42e047eff
edd0fc7093be4ea0bdc486b0aefd9020
RX(theta₁₂)
a603b68c42bb4d36a61c0ef42e047eff--edd0fc7093be4ea0bdc486b0aefd9020
2fcf82979bbd42f696104fa90e3ce389
RY(theta₁₆)
edd0fc7093be4ea0bdc486b0aefd9020--2fcf82979bbd42f696104fa90e3ce389
e6234923698f4e3fa94e19fc0f189b72
RX(theta₂₀)
2fcf82979bbd42f696104fa90e3ce389--e6234923698f4e3fa94e19fc0f189b72
984a484633994e0297f17aef2241ac7c
e6234923698f4e3fa94e19fc0f189b72--984a484633994e0297f17aef2241ac7c
3e50bd9d79c34139923715af36bbc4a1
984a484633994e0297f17aef2241ac7c--3e50bd9d79c34139923715af36bbc4a1
e6405aac5ce4421c862a824997a67de7
3e50bd9d79c34139923715af36bbc4a1--e6405aac5ce4421c862a824997a67de7
8ef1d9e287944f31be0118b4b09aabfb
72be641dfb014841925c83bb0346ecf8
RX(theta₁)
0b513dc612624ed1b10be0f4e1c63a90--72be641dfb014841925c83bb0346ecf8
6c6801d775cb417282548777182a1855
2
6372094460924095861f14e35b94c03c
RY(theta₅)
72be641dfb014841925c83bb0346ecf8--6372094460924095861f14e35b94c03c
7eacf282cf184e29ada0e613b30ff197
RX(theta₉)
6372094460924095861f14e35b94c03c--7eacf282cf184e29ada0e613b30ff197
60204a79115b48819b89a1f7218e6337
X
7eacf282cf184e29ada0e613b30ff197--60204a79115b48819b89a1f7218e6337
60204a79115b48819b89a1f7218e6337--4ac589cfac8e4689a9edd6390fb4f5c5
88c05993ce0d46df90b75c2ca24f8d77
60204a79115b48819b89a1f7218e6337--88c05993ce0d46df90b75c2ca24f8d77
642cfc1333494af48c226c4e23e533b6
RX(theta₁₃)
88c05993ce0d46df90b75c2ca24f8d77--642cfc1333494af48c226c4e23e533b6
0251eec89fd947818256e8ea707dac12
RY(theta₁₇)
642cfc1333494af48c226c4e23e533b6--0251eec89fd947818256e8ea707dac12
7f564e8b279749358d4a21a1a66b5f52
RX(theta₂₁)
0251eec89fd947818256e8ea707dac12--7f564e8b279749358d4a21a1a66b5f52
adc0e8ef06d547d0bebf84d805a8ed2a
X
7f564e8b279749358d4a21a1a66b5f52--adc0e8ef06d547d0bebf84d805a8ed2a
adc0e8ef06d547d0bebf84d805a8ed2a--fea773db6a814398902866579031a942
8b6d9bca63e74abcadc28bc4d58e246d
adc0e8ef06d547d0bebf84d805a8ed2a--8b6d9bca63e74abcadc28bc4d58e246d
39e126fb01244ec58e98fa4be4ff8e20
RX(theta₁)
8b6d9bca63e74abcadc28bc4d58e246d--39e126fb01244ec58e98fa4be4ff8e20
970f0315f44746ec9bd4af1f143b0206
RY(theta₅)
39e126fb01244ec58e98fa4be4ff8e20--970f0315f44746ec9bd4af1f143b0206
381c056ea4c048eda1482e932635f15f
RX(theta₉)
970f0315f44746ec9bd4af1f143b0206--381c056ea4c048eda1482e932635f15f
a50801ad841a4473a30a5bd55766a60c
X
381c056ea4c048eda1482e932635f15f--a50801ad841a4473a30a5bd55766a60c
a50801ad841a4473a30a5bd55766a60c--c249e6e634794f37b579256c698f877c
45ae63ba66604a9e81c5926336659847
a50801ad841a4473a30a5bd55766a60c--45ae63ba66604a9e81c5926336659847
793fa113391742a89617b8c23f823e10
RX(theta₁₃)
45ae63ba66604a9e81c5926336659847--793fa113391742a89617b8c23f823e10
3e796c0f5453408b9e39c1b3afdfb1c2
RY(theta₁₇)
793fa113391742a89617b8c23f823e10--3e796c0f5453408b9e39c1b3afdfb1c2
abcc6d90aa59474d961a515a57495a64
RX(theta₂₁)
3e796c0f5453408b9e39c1b3afdfb1c2--abcc6d90aa59474d961a515a57495a64
e8bede438132441487fb0616c9ba0778
X
abcc6d90aa59474d961a515a57495a64--e8bede438132441487fb0616c9ba0778
e8bede438132441487fb0616c9ba0778--984a484633994e0297f17aef2241ac7c
d24262097e964aafa8c174930d3bf596
e8bede438132441487fb0616c9ba0778--d24262097e964aafa8c174930d3bf596
d24262097e964aafa8c174930d3bf596--8ef1d9e287944f31be0118b4b09aabfb
73188c1aa0fd45789cf8386e8ccf3e63
bca20bf15d4d41ce9fde9c38b94b8dd3
RX(theta₂)
6c6801d775cb417282548777182a1855--bca20bf15d4d41ce9fde9c38b94b8dd3
df155672002e47cfb58b24a4d2f7f0d7
3
2a7ae6f8694d47b29a70f0fa1609a487
RY(theta₆)
bca20bf15d4d41ce9fde9c38b94b8dd3--2a7ae6f8694d47b29a70f0fa1609a487
23176939b8a84635a284d412734b743d
RX(theta₁₀)
2a7ae6f8694d47b29a70f0fa1609a487--23176939b8a84635a284d412734b743d
cac37515453d4ff7963902ca7f6b2375
23176939b8a84635a284d412734b743d--cac37515453d4ff7963902ca7f6b2375
ba4f4a99062d4c8ca331374ea4854ba0
X
cac37515453d4ff7963902ca7f6b2375--ba4f4a99062d4c8ca331374ea4854ba0
ba4f4a99062d4c8ca331374ea4854ba0--88c05993ce0d46df90b75c2ca24f8d77
d1ac69d31e9d474b9ecd4118d624adac
RX(theta₁₄)
ba4f4a99062d4c8ca331374ea4854ba0--d1ac69d31e9d474b9ecd4118d624adac
fd8d1ce811db4422944f9125be46e928
RY(theta₁₈)
d1ac69d31e9d474b9ecd4118d624adac--fd8d1ce811db4422944f9125be46e928
62c414eb007f4bc492ce70b1db5e91e1
RX(theta₂₂)
fd8d1ce811db4422944f9125be46e928--62c414eb007f4bc492ce70b1db5e91e1
0863c0139da34f8fb9c999ed291fdbb8
62c414eb007f4bc492ce70b1db5e91e1--0863c0139da34f8fb9c999ed291fdbb8
c8f9e034b25f4f1093de99602a25bbbf
X
0863c0139da34f8fb9c999ed291fdbb8--c8f9e034b25f4f1093de99602a25bbbf
c8f9e034b25f4f1093de99602a25bbbf--8b6d9bca63e74abcadc28bc4d58e246d
cf73f6214c5f4cada493c3e24c184d6f
RX(theta₂)
c8f9e034b25f4f1093de99602a25bbbf--cf73f6214c5f4cada493c3e24c184d6f
ee7eb83a62d8494a878005dd014956e2
RY(theta₆)
cf73f6214c5f4cada493c3e24c184d6f--ee7eb83a62d8494a878005dd014956e2
4b05d28709f04db0b0992a0aec147462
RX(theta₁₀)
ee7eb83a62d8494a878005dd014956e2--4b05d28709f04db0b0992a0aec147462
8079978efdc24d76baf67127387014c6
4b05d28709f04db0b0992a0aec147462--8079978efdc24d76baf67127387014c6
24ac72b8cb864dbfa98dc7cf7503bcbb
X
8079978efdc24d76baf67127387014c6--24ac72b8cb864dbfa98dc7cf7503bcbb
24ac72b8cb864dbfa98dc7cf7503bcbb--45ae63ba66604a9e81c5926336659847
1817f3f3ac64472c9a40c0cddc95ce22
RX(theta₁₄)
24ac72b8cb864dbfa98dc7cf7503bcbb--1817f3f3ac64472c9a40c0cddc95ce22
4d3a3925c44b400793f562debe0ff1ae
RY(theta₁₈)
1817f3f3ac64472c9a40c0cddc95ce22--4d3a3925c44b400793f562debe0ff1ae
70edd4211b29403a9217f09daf6d416e
RX(theta₂₂)
4d3a3925c44b400793f562debe0ff1ae--70edd4211b29403a9217f09daf6d416e
3a521043c4bc4aabbf360a4cb43181a3
70edd4211b29403a9217f09daf6d416e--3a521043c4bc4aabbf360a4cb43181a3
a5fced1a0df3445bbfec739ce7d5ee99
X
3a521043c4bc4aabbf360a4cb43181a3--a5fced1a0df3445bbfec739ce7d5ee99
a5fced1a0df3445bbfec739ce7d5ee99--d24262097e964aafa8c174930d3bf596
a5fced1a0df3445bbfec739ce7d5ee99--73188c1aa0fd45789cf8386e8ccf3e63
afba3f80b8074fac8b58600b253b2233
353360019fd84ff1a9f92682565a90d7
RX(theta₃)
df155672002e47cfb58b24a4d2f7f0d7--353360019fd84ff1a9f92682565a90d7
36a230592c31437b83f29a305c74470e
RY(theta₇)
353360019fd84ff1a9f92682565a90d7--36a230592c31437b83f29a305c74470e
429fbccd09e940e1b92c7828de5f96d4
RX(theta₁₁)
36a230592c31437b83f29a305c74470e--429fbccd09e940e1b92c7828de5f96d4
a46349d8e71242ee9a2d083bfa099469
X
429fbccd09e940e1b92c7828de5f96d4--a46349d8e71242ee9a2d083bfa099469
a46349d8e71242ee9a2d083bfa099469--cac37515453d4ff7963902ca7f6b2375
e4c12e2c3a2f4e89bc6b47812259f83d
a46349d8e71242ee9a2d083bfa099469--e4c12e2c3a2f4e89bc6b47812259f83d
355d6c1d2ba2478faa831af63d2b4c01
RX(theta₁₅)
e4c12e2c3a2f4e89bc6b47812259f83d--355d6c1d2ba2478faa831af63d2b4c01
c19fd89097db4d90927af0a14bb9bd8d
RY(theta₁₉)
355d6c1d2ba2478faa831af63d2b4c01--c19fd89097db4d90927af0a14bb9bd8d
9ab3b82dffb042cd8e5825c6f26ff598
RX(theta₂₃)
c19fd89097db4d90927af0a14bb9bd8d--9ab3b82dffb042cd8e5825c6f26ff598
7c56cb8393ae4b918a9cdaec47baaeb7
X
9ab3b82dffb042cd8e5825c6f26ff598--7c56cb8393ae4b918a9cdaec47baaeb7
7c56cb8393ae4b918a9cdaec47baaeb7--0863c0139da34f8fb9c999ed291fdbb8
d1fee822e5854b5fb2d36d8570d295f7
7c56cb8393ae4b918a9cdaec47baaeb7--d1fee822e5854b5fb2d36d8570d295f7
f697da6e5eeb4f55a480507997436ea9
RX(theta₃)
d1fee822e5854b5fb2d36d8570d295f7--f697da6e5eeb4f55a480507997436ea9
42dd5036c00f4ba5b3a088198ecec085
RY(theta₇)
f697da6e5eeb4f55a480507997436ea9--42dd5036c00f4ba5b3a088198ecec085
556d3135a7384729b29924680055be82
RX(theta₁₁)
42dd5036c00f4ba5b3a088198ecec085--556d3135a7384729b29924680055be82
4479312490ad4069a36fea978ab068ac
X
556d3135a7384729b29924680055be82--4479312490ad4069a36fea978ab068ac
4479312490ad4069a36fea978ab068ac--8079978efdc24d76baf67127387014c6
e3bc3bb91bdf462489c9312ee081fd1b
4479312490ad4069a36fea978ab068ac--e3bc3bb91bdf462489c9312ee081fd1b
e3964b9a20854ff8a017a4b944f317df
RX(theta₁₅)
e3bc3bb91bdf462489c9312ee081fd1b--e3964b9a20854ff8a017a4b944f317df
6a9c1b375101437da4c19b46e085f58b
RY(theta₁₉)
e3964b9a20854ff8a017a4b944f317df--6a9c1b375101437da4c19b46e085f58b
54c935a9734f44ce918fbffe3b291aa9
RX(theta₂₃)
6a9c1b375101437da4c19b46e085f58b--54c935a9734f44ce918fbffe3b291aa9
1341a0205fc248a493d07ac6db585f27
X
54c935a9734f44ce918fbffe3b291aa9--1341a0205fc248a493d07ac6db585f27
1341a0205fc248a493d07ac6db585f27--3a521043c4bc4aabbf360a4cb43181a3
9b8e32b3ab3e489e85b22a0ef32dd35d
1341a0205fc248a493d07ac6db585f27--9b8e32b3ab3e489e85b22a0ef32dd35d
9b8e32b3ab3e489e85b22a0ef32dd35d--afba3f80b8074fac8b58600b253b2233
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_ee8c72e36256443aa3b2a4f153479ae2
HEA
cluster_f4980ef810374b989df794d71042b32f
HEA
9ea55bd0809145029958e1fcdc02fa0c
0
38445ec06cc94ecaaee32910c21bc5b8
RX(p1₀)
9ea55bd0809145029958e1fcdc02fa0c--38445ec06cc94ecaaee32910c21bc5b8
1b30dfcaec7443fc9021cc184aa03046
1
1fd071ebcb0641078abb608b8e45348c
RY(p1₄)
38445ec06cc94ecaaee32910c21bc5b8--1fd071ebcb0641078abb608b8e45348c
a11b8d98a39b4fb28a3e77c0b068488c
RX(p1₈)
1fd071ebcb0641078abb608b8e45348c--a11b8d98a39b4fb28a3e77c0b068488c
55045b4af95f481ba2beff9bfc7017bc
a11b8d98a39b4fb28a3e77c0b068488c--55045b4af95f481ba2beff9bfc7017bc
8ec6f7c906824fb29c8b0858e325d73f
55045b4af95f481ba2beff9bfc7017bc--8ec6f7c906824fb29c8b0858e325d73f
38a31073a0b64f198be1f4ae9cca7fb1
RX(p1₁₂)
8ec6f7c906824fb29c8b0858e325d73f--38a31073a0b64f198be1f4ae9cca7fb1
749527e7bd0a4ccebba816661e3a47c9
RY(p1₁₆)
38a31073a0b64f198be1f4ae9cca7fb1--749527e7bd0a4ccebba816661e3a47c9
c8105172b6184add96a909c795c59db8
RX(p1₂₀)
749527e7bd0a4ccebba816661e3a47c9--c8105172b6184add96a909c795c59db8
4933ef2252c1442bb8d8655e05e36bee
c8105172b6184add96a909c795c59db8--4933ef2252c1442bb8d8655e05e36bee
ac8d45b2437243cf84ebaddc2f02e866
4933ef2252c1442bb8d8655e05e36bee--ac8d45b2437243cf84ebaddc2f02e866
b36803561f834f02a4b96dde7af785ab
RX(p2₀)
ac8d45b2437243cf84ebaddc2f02e866--b36803561f834f02a4b96dde7af785ab
f986ae3403f646658ec3c21f356b6f66
RY(p2₄)
b36803561f834f02a4b96dde7af785ab--f986ae3403f646658ec3c21f356b6f66
d5b07a6d84014099aa535f4d02efa143
RX(p2₈)
f986ae3403f646658ec3c21f356b6f66--d5b07a6d84014099aa535f4d02efa143
c0595ff1eb9d4a2bb8a77f81b5eaee9e
d5b07a6d84014099aa535f4d02efa143--c0595ff1eb9d4a2bb8a77f81b5eaee9e
f2c4b716dffd4ac48f2759da2e06815f
c0595ff1eb9d4a2bb8a77f81b5eaee9e--f2c4b716dffd4ac48f2759da2e06815f
9f21a2562ee8400ebfde043112dde3f2
RX(p2₁₂)
f2c4b716dffd4ac48f2759da2e06815f--9f21a2562ee8400ebfde043112dde3f2
f64b5942309e49bcaa2ff6ac7017447a
RY(p2₁₆)
9f21a2562ee8400ebfde043112dde3f2--f64b5942309e49bcaa2ff6ac7017447a
3f3872999b7347ba978d744b9a229231
RX(p2₂₀)
f64b5942309e49bcaa2ff6ac7017447a--3f3872999b7347ba978d744b9a229231
180e82c6aa0d44b39b620bb868a10d53
3f3872999b7347ba978d744b9a229231--180e82c6aa0d44b39b620bb868a10d53
2181e0fd468b4e6385af795be62f797d
180e82c6aa0d44b39b620bb868a10d53--2181e0fd468b4e6385af795be62f797d
658b949787624ce7882e5bcc36964d52
2181e0fd468b4e6385af795be62f797d--658b949787624ce7882e5bcc36964d52
085935ac21b141bab2fc0558f77bcc0d
9fa1887548d64f62b396e725896ad192
RX(p1₁)
1b30dfcaec7443fc9021cc184aa03046--9fa1887548d64f62b396e725896ad192
00c5ca4c1f4d4d2c932f6bc898e5f7ec
2
d24d975821674580b777a4c4cbae7695
RY(p1₅)
9fa1887548d64f62b396e725896ad192--d24d975821674580b777a4c4cbae7695
b24936154a274162b06c278e362636b7
RX(p1₉)
d24d975821674580b777a4c4cbae7695--b24936154a274162b06c278e362636b7
2ab76531c1f648e39d33423a5b141797
X
b24936154a274162b06c278e362636b7--2ab76531c1f648e39d33423a5b141797
2ab76531c1f648e39d33423a5b141797--55045b4af95f481ba2beff9bfc7017bc
be7204a7fc4c4e878bb8b5901b544140
2ab76531c1f648e39d33423a5b141797--be7204a7fc4c4e878bb8b5901b544140
669982128d8f47b083e35dd694adb309
RX(p1₁₃)
be7204a7fc4c4e878bb8b5901b544140--669982128d8f47b083e35dd694adb309
948c2f9c81db485591fc10afd9586881
RY(p1₁₇)
669982128d8f47b083e35dd694adb309--948c2f9c81db485591fc10afd9586881
fa92966f0ad940159b221e201398cf70
RX(p1₂₁)
948c2f9c81db485591fc10afd9586881--fa92966f0ad940159b221e201398cf70
40d64999584847718464b640db265fac
X
fa92966f0ad940159b221e201398cf70--40d64999584847718464b640db265fac
40d64999584847718464b640db265fac--4933ef2252c1442bb8d8655e05e36bee
53024334cf8e479f93e22e0817fcf6a7
40d64999584847718464b640db265fac--53024334cf8e479f93e22e0817fcf6a7
f64ce852a4624aeda08769af7450f0b1
RX(p2₁)
53024334cf8e479f93e22e0817fcf6a7--f64ce852a4624aeda08769af7450f0b1
24e8d1a0610d4194adca7e1a4f5915a2
RY(p2₅)
f64ce852a4624aeda08769af7450f0b1--24e8d1a0610d4194adca7e1a4f5915a2
f27f4b569c174b8b94b222452ee91ca8
RX(p2₉)
24e8d1a0610d4194adca7e1a4f5915a2--f27f4b569c174b8b94b222452ee91ca8
03f5b3b0c1494677945862efe28b65d4
X
f27f4b569c174b8b94b222452ee91ca8--03f5b3b0c1494677945862efe28b65d4
03f5b3b0c1494677945862efe28b65d4--c0595ff1eb9d4a2bb8a77f81b5eaee9e
d5f77ef75bdb4e2ea20b85fb6274b3f1
03f5b3b0c1494677945862efe28b65d4--d5f77ef75bdb4e2ea20b85fb6274b3f1
23b2dff52496451383c52f300cbff80b
RX(p2₁₃)
d5f77ef75bdb4e2ea20b85fb6274b3f1--23b2dff52496451383c52f300cbff80b
30e1655db8024c0a9ae7123d21bfc40d
RY(p2₁₇)
23b2dff52496451383c52f300cbff80b--30e1655db8024c0a9ae7123d21bfc40d
a7b39f4493094ec69875a557eeba4428
RX(p2₂₁)
30e1655db8024c0a9ae7123d21bfc40d--a7b39f4493094ec69875a557eeba4428
b1ee6937b0b944659410fd5d1376624b
X
a7b39f4493094ec69875a557eeba4428--b1ee6937b0b944659410fd5d1376624b
b1ee6937b0b944659410fd5d1376624b--180e82c6aa0d44b39b620bb868a10d53
7ed321751fe243bc9873913af55ba467
b1ee6937b0b944659410fd5d1376624b--7ed321751fe243bc9873913af55ba467
7ed321751fe243bc9873913af55ba467--085935ac21b141bab2fc0558f77bcc0d
6fbc6a66f8a64a5ca467b30de6c99022
7cfb861872514c949286763e1db3e441
RX(p1₂)
00c5ca4c1f4d4d2c932f6bc898e5f7ec--7cfb861872514c949286763e1db3e441
9f82ae988f684a7498b1ae7687693f3e
3
3c2fc838ce784a018adc1b0f7ee8c8ac
RY(p1₆)
7cfb861872514c949286763e1db3e441--3c2fc838ce784a018adc1b0f7ee8c8ac
1b2cfa9db2fa42aeb41959c8a6397dc7
RX(p1₁₀)
3c2fc838ce784a018adc1b0f7ee8c8ac--1b2cfa9db2fa42aeb41959c8a6397dc7
975b0cfe3cc94ae6985ba29a41e0d437
1b2cfa9db2fa42aeb41959c8a6397dc7--975b0cfe3cc94ae6985ba29a41e0d437
9594d24a5f41427f91f9c18bead90e07
X
975b0cfe3cc94ae6985ba29a41e0d437--9594d24a5f41427f91f9c18bead90e07
9594d24a5f41427f91f9c18bead90e07--be7204a7fc4c4e878bb8b5901b544140
a6383a7b14a0414fa0ef52ac8b98016e
RX(p1₁₄)
9594d24a5f41427f91f9c18bead90e07--a6383a7b14a0414fa0ef52ac8b98016e
af69b903de864643b14566e5c5fb4df0
RY(p1₁₈)
a6383a7b14a0414fa0ef52ac8b98016e--af69b903de864643b14566e5c5fb4df0
9eb1fc0d697043c883543c368a752832
RX(p1₂₂)
af69b903de864643b14566e5c5fb4df0--9eb1fc0d697043c883543c368a752832
f8364ca7c0654e27bc92e7a86cc99e34
9eb1fc0d697043c883543c368a752832--f8364ca7c0654e27bc92e7a86cc99e34
ed94dac42be34f08b5ba6dbfa68891c2
X
f8364ca7c0654e27bc92e7a86cc99e34--ed94dac42be34f08b5ba6dbfa68891c2
ed94dac42be34f08b5ba6dbfa68891c2--53024334cf8e479f93e22e0817fcf6a7
3c1b84be373c4acfa1751284a09371f1
RX(p2₂)
ed94dac42be34f08b5ba6dbfa68891c2--3c1b84be373c4acfa1751284a09371f1
daf19c98c5f04bb9a2ad59fa72fa4b92
RY(p2₆)
3c1b84be373c4acfa1751284a09371f1--daf19c98c5f04bb9a2ad59fa72fa4b92
1687ca9fe2c84c8d846ccd8288aad920
RX(p2₁₀)
daf19c98c5f04bb9a2ad59fa72fa4b92--1687ca9fe2c84c8d846ccd8288aad920
177aa561624b406aa6f83095959e4eda
1687ca9fe2c84c8d846ccd8288aad920--177aa561624b406aa6f83095959e4eda
3bd5539f329449d09ec62cddbb0fcbf5
X
177aa561624b406aa6f83095959e4eda--3bd5539f329449d09ec62cddbb0fcbf5
3bd5539f329449d09ec62cddbb0fcbf5--d5f77ef75bdb4e2ea20b85fb6274b3f1
1fcb5579c10b4be2b0023915a7e472ec
RX(p2₁₄)
3bd5539f329449d09ec62cddbb0fcbf5--1fcb5579c10b4be2b0023915a7e472ec
e7bcaa66c3a34388a5b7d1a0a26efaf3
RY(p2₁₈)
1fcb5579c10b4be2b0023915a7e472ec--e7bcaa66c3a34388a5b7d1a0a26efaf3
8038de8f35c24eaeb6562e69efc3825b
RX(p2₂₂)
e7bcaa66c3a34388a5b7d1a0a26efaf3--8038de8f35c24eaeb6562e69efc3825b
953dd9b8e107492abb0655aaa03412ca
8038de8f35c24eaeb6562e69efc3825b--953dd9b8e107492abb0655aaa03412ca
ac6dc2bc2f58412bbfc55663ffe674e1
X
953dd9b8e107492abb0655aaa03412ca--ac6dc2bc2f58412bbfc55663ffe674e1
ac6dc2bc2f58412bbfc55663ffe674e1--7ed321751fe243bc9873913af55ba467
ac6dc2bc2f58412bbfc55663ffe674e1--6fbc6a66f8a64a5ca467b30de6c99022
91d1a1e1e8804a70b54a4b45aa8eb67f
e23860caa697405eaebd98ca5baaa10a
RX(p1₃)
9f82ae988f684a7498b1ae7687693f3e--e23860caa697405eaebd98ca5baaa10a
b666fb28037245efb04c8db92c65e516
RY(p1₇)
e23860caa697405eaebd98ca5baaa10a--b666fb28037245efb04c8db92c65e516
29b75d92bafb423a880633ce46b088a5
RX(p1₁₁)
b666fb28037245efb04c8db92c65e516--29b75d92bafb423a880633ce46b088a5
fe3c0f0cdf3f46e785c7b7bdf90db77e
X
29b75d92bafb423a880633ce46b088a5--fe3c0f0cdf3f46e785c7b7bdf90db77e
fe3c0f0cdf3f46e785c7b7bdf90db77e--975b0cfe3cc94ae6985ba29a41e0d437
bca1f3415ad64199a36cb265b6fde79d
fe3c0f0cdf3f46e785c7b7bdf90db77e--bca1f3415ad64199a36cb265b6fde79d
8d99fd3d88bd44d5bc552979f19ffa30
RX(p1₁₅)
bca1f3415ad64199a36cb265b6fde79d--8d99fd3d88bd44d5bc552979f19ffa30
5eef3c4f2370453b8d7415f21edf9397
RY(p1₁₉)
8d99fd3d88bd44d5bc552979f19ffa30--5eef3c4f2370453b8d7415f21edf9397
4cda0e9b0f704f0fa4de0fc3fd893c59
RX(p1₂₃)
5eef3c4f2370453b8d7415f21edf9397--4cda0e9b0f704f0fa4de0fc3fd893c59
091d306674f34e9fb6d12ba637647a64
X
4cda0e9b0f704f0fa4de0fc3fd893c59--091d306674f34e9fb6d12ba637647a64
091d306674f34e9fb6d12ba637647a64--f8364ca7c0654e27bc92e7a86cc99e34
13020328b28d412ca9e141c1e125150f
091d306674f34e9fb6d12ba637647a64--13020328b28d412ca9e141c1e125150f
66ac4d715b314f4abec5c7fbfa9d47b1
RX(p2₃)
13020328b28d412ca9e141c1e125150f--66ac4d715b314f4abec5c7fbfa9d47b1
1884396dce154f72a01deeb384139865
RY(p2₇)
66ac4d715b314f4abec5c7fbfa9d47b1--1884396dce154f72a01deeb384139865
b976bd81e7f04d0bb07826a025270603
RX(p2₁₁)
1884396dce154f72a01deeb384139865--b976bd81e7f04d0bb07826a025270603
a996145bbb574dfcbcb26d1bb153e16a
X
b976bd81e7f04d0bb07826a025270603--a996145bbb574dfcbcb26d1bb153e16a
a996145bbb574dfcbcb26d1bb153e16a--177aa561624b406aa6f83095959e4eda
44af1a1750f1499abecc8e9b8fe22dc9
a996145bbb574dfcbcb26d1bb153e16a--44af1a1750f1499abecc8e9b8fe22dc9
ac7b6ab134d6433ba3ac18cf0d33a96b
RX(p2₁₅)
44af1a1750f1499abecc8e9b8fe22dc9--ac7b6ab134d6433ba3ac18cf0d33a96b
afa971ae376f428bb739ec38cd071eea
RY(p2₁₉)
ac7b6ab134d6433ba3ac18cf0d33a96b--afa971ae376f428bb739ec38cd071eea
120121ea9fda4cf8bf83ec7fc14adf58
RX(p2₂₃)
afa971ae376f428bb739ec38cd071eea--120121ea9fda4cf8bf83ec7fc14adf58
64aa281139584fdda4705b13f3fb0842
X
120121ea9fda4cf8bf83ec7fc14adf58--64aa281139584fdda4705b13f3fb0842
64aa281139584fdda4705b13f3fb0842--953dd9b8e107492abb0655aaa03412ca
c62d10a58f674cbab01d8b0b9a9f7291
64aa281139584fdda4705b13f3fb0842--c62d10a58f674cbab01d8b0b9a9f7291
c62d10a58f674cbab01d8b0b9a9f7291--91d1a1e1e8804a70b54a4b45aa8eb67f
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.0855 ] )) , (' t he ta _ 0 ' , tens or( [ 0.5155 ] )) , (' t he ta _ 1 ' , tens or( [ 0.9281 ] )) , (' t he ta _ 10 ' , tens or( [ 0.9866 ] )) , (' t he ta _ 11 ' , tens or( [ 0.2450 ] )) , (' t he ta _ 12 ' , tens or( [ 0.4834 ] )) , (' t he ta _ 13 ' , tens or( [ 0.1215 ] )) , (' t he ta _ 14 ' , tens or( [ 0.0793 ] )) , (' t he ta _ 15 ' , tens or( [ 0.7420 ] )) , (' t he ta _ 16 ' , tens or( [ 0.6813 ] )) , (' t he ta _ 17 ' , tens or( [ 0.5558 ] )) , (' t he ta _ 18 ' , tens or( [ 0.9943 ] )) , (' t he ta _ 19 ' , tens or( [ 0.4941 ] )) , (' t he ta _ 2 ' , tens or( [ 0.8950 ] )) , (' t he ta _ 20 ' , tens or( [ 0.5997 ] )) , (' t he ta _ 21 ' , tens or( [ 0.0895 ] )) , (' t he ta _ 22 ' , tens or( [ 0.9110 ] )) , (' t he ta _ 23 ' , tens or( [ 0.1405 ] )) , (' t he ta _ 3 ' , tens or( [ 0.2954 ] )) , (' t he ta _ 4 ' , tens or( [ 0.5823 ] )) , (' t he ta _ 5 ' , tens or( [ 0.5412 ] )) , (' t he ta _ 6 ' , tens or( [ 0.5837 ] )) , (' t he ta _ 7 ' , tens or( [ 0.3800 ] )) , (' t he ta _ 8 ' , tens or( [ 0.2195 ] )) , (' t he ta _ 9 ' , tens or( [ 0.9872 ] )) ] )
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.0845 ] )) , (' t he ta _ 0 ' , tens or( [ 0.5145 ] )) , (' t he ta _ 1 ' , tens or( [ 0.9291 ] )) , (' t he ta _ 10 ' , tens or( [ 0.9876 ] )) , (' t he ta _ 11 ' , tens or( [ 0.2440 ] )) , (' t he ta _ 12 ' , tens or( [ 0.4844 ] )) , (' t he ta _ 13 ' , tens or( [ 0.1225 ] )) , (' t he ta _ 14 ' , tens or( [ 0.0803 ] )) , (' t he ta _ 15 ' , tens or( [ 0.7410 ] )) , (' t he ta _ 16 ' , tens or( [ 0.6803 ] )) , (' t he ta _ 17 ' , tens or( [ 0.5568 ] )) , (' t he ta _ 18 ' , tens or( [ 0.9933 ] )) , (' t he ta _ 19 ' , tens or( [ 0.4951 ] )) , (' t he ta _ 2 ' , tens or( [ 0.8960 ] )) , (' t he ta _ 20 ' , tens or( [ 0.6007 ] )) , (' t he ta _ 21 ' , tens or( [ 0.0905 ] )) , (' t he ta _ 22 ' , tens or( [ 0.9120 ] )) , (' t he ta _ 23 ' , tens or( [ 0.1395 ] )) , (' t he ta _ 3 ' , tens or( [ 0.2944 ] )) , (' t he ta _ 4 ' , tens or( [ 0.5833 ] )) , (' t he ta _ 5 ' , tens or( [ 0.5422 ] )) , (' t he ta _ 6 ' , tens or( [ 0.5827 ] )) , (' t he ta _ 7 ' , tens or( [ 0.3790 ] )) , (' t he ta _ 8 ' , tens or( [ 0.2205 ] )) , (' t he ta _ 9 ' , tens or( [ 0.9882 ] )) ] )
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 ]] )