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.9895+0.0000 j , 0.0000-0.1448 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.8811+0.0000 j , 0.0000-0.4730 j ],
[ 0.9812+0.0000 j , 0.0000-0.1931 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.8543+0.0000 j , 0.3484+0.0000 j , 0.0000-0.3572 j , 0.0000-0.1457 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_5629aeb039a64a51b017432cfba2ce54
[* 2]
cluster_504b99878d1048e19766ba3cee3c8dc0
Rotations
9528cdd4d6654195964b778b4076cfb2
0
daba05b33b5e4e57b2225b3065974efc
RX(phi/theta)
9528cdd4d6654195964b778b4076cfb2--daba05b33b5e4e57b2225b3065974efc
9ba5fb6544044d4da1b17a41aa023931
1
cac6f4dc8fd449849db3ed652466963f
RX(phi)
daba05b33b5e4e57b2225b3065974efc--cac6f4dc8fd449849db3ed652466963f
8fab20888aeb4e898613f557a37fff3b
RX(phi)
cac6f4dc8fd449849db3ed652466963f--8fab20888aeb4e898613f557a37fff3b
c5d8c5607c904daebb9a4767a3d40b3d
RX(phi + theta)
8fab20888aeb4e898613f557a37fff3b--c5d8c5607c904daebb9a4767a3d40b3d
49c1fabc45dc4c06af169051a99c19b6
c5d8c5607c904daebb9a4767a3d40b3d--49c1fabc45dc4c06af169051a99c19b6
88368efc5a894bc191c47e7006c024f5
49c1fabc45dc4c06af169051a99c19b6--88368efc5a894bc191c47e7006c024f5
817877cd909444c98a86cbd118e15dca
Z
88368efc5a894bc191c47e7006c024f5--817877cd909444c98a86cbd118e15dca
2c290dd6d75b4ec4924ba344de700d62
817877cd909444c98a86cbd118e15dca--2c290dd6d75b4ec4924ba344de700d62
c8085891f683482992474c98e3393413
bc636de071f4423388b01a5f8973e904
RY(2*theta)
9ba5fb6544044d4da1b17a41aa023931--bc636de071f4423388b01a5f8973e904
35dcda5e27374a839fb96b554e74158d
2
f8a945b2b64d4099976c0a449d4bcffd
RY(theta)
bc636de071f4423388b01a5f8973e904--f8a945b2b64d4099976c0a449d4bcffd
b605ebd999864fa0af009a9a05f2f460
RY(theta)
f8a945b2b64d4099976c0a449d4bcffd--b605ebd999864fa0af009a9a05f2f460
38d259a03bf6455bbca9ecd4e7b71b7b
RY(theta**2)
b605ebd999864fa0af009a9a05f2f460--38d259a03bf6455bbca9ecd4e7b71b7b
a8ef18f6b7f4407bbd6c60c4c17f0ba5
X
38d259a03bf6455bbca9ecd4e7b71b7b--a8ef18f6b7f4407bbd6c60c4c17f0ba5
a8ef18f6b7f4407bbd6c60c4c17f0ba5--49c1fabc45dc4c06af169051a99c19b6
2c1d9fbc140d42e09606df2f9d9b4868
a8ef18f6b7f4407bbd6c60c4c17f0ba5--2c1d9fbc140d42e09606df2f9d9b4868
84312e74815e40a4a342d530fbded3a8
Z
2c1d9fbc140d42e09606df2f9d9b4868--84312e74815e40a4a342d530fbded3a8
84312e74815e40a4a342d530fbded3a8--c8085891f683482992474c98e3393413
1eaec3bdf0d7412b9116de4cca22dbea
09c35c42eed04750ad2c5678838a01fa
RZ(cos(phi))
35dcda5e27374a839fb96b554e74158d--09c35c42eed04750ad2c5678838a01fa
198cb655aa9242ad978bbe286c413438
RZ(phi)
09c35c42eed04750ad2c5678838a01fa--198cb655aa9242ad978bbe286c413438
928ebb638103477cbce324f2461d0366
RZ(phi)
198cb655aa9242ad978bbe286c413438--928ebb638103477cbce324f2461d0366
1d3a14e1c3e44852b4babb0b8ce66ad5
RZ(cos(phi))
928ebb638103477cbce324f2461d0366--1d3a14e1c3e44852b4babb0b8ce66ad5
c3f469c90f3949d29d5619375c3f52eb
1d3a14e1c3e44852b4babb0b8ce66ad5--c3f469c90f3949d29d5619375c3f52eb
b1d9461bd63f45dfb7c50bf4453410ce
X
c3f469c90f3949d29d5619375c3f52eb--b1d9461bd63f45dfb7c50bf4453410ce
b1d9461bd63f45dfb7c50bf4453410ce--2c1d9fbc140d42e09606df2f9d9b4868
6007ba35df8c41569719ed1436108612
Z
b1d9461bd63f45dfb7c50bf4453410ce--6007ba35df8c41569719ed1436108612
6007ba35df8c41569719ed1436108612--1eaec3bdf0d7412b9116de4cca22dbea
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.7213 ] )) ] )
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.4423+0.0000 j , 0.4967+0.0000 j , 0.0000-0.4967 j , 0.0000-0.5577 j ],
[ 0.5495+0.0000 j , 0.4975+0.0000 j , 0.0000-0.4975 j , 0.0000-0.4505 j ],
[ 0.8138+0.0000 j , 0.3893+0.0000 j , 0.0000-0.3893 j , 0.0000-0.1862 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
e80a7d0463af46c5942df8b146588f5e
0
e8e6545105ab48d6bfd570ee14e1bc86
RX(theta₀)
e80a7d0463af46c5942df8b146588f5e--e8e6545105ab48d6bfd570ee14e1bc86
4b2436ae81c24312a5c299917e4a0eb4
1
9d0e9f5bd1384a7ba5851e276d96a2cc
RY(theta₄)
e8e6545105ab48d6bfd570ee14e1bc86--9d0e9f5bd1384a7ba5851e276d96a2cc
ca560b5516684463988ea77fd2d99235
RX(theta₈)
9d0e9f5bd1384a7ba5851e276d96a2cc--ca560b5516684463988ea77fd2d99235
8bd3581707f94852aa70ca75e7df3467
ca560b5516684463988ea77fd2d99235--8bd3581707f94852aa70ca75e7df3467
edbd47f37e01446d8957362b409b557d
8bd3581707f94852aa70ca75e7df3467--edbd47f37e01446d8957362b409b557d
e2c2d96fbc004b4496d957a1b68d789a
RX(theta₁₂)
edbd47f37e01446d8957362b409b557d--e2c2d96fbc004b4496d957a1b68d789a
2f0dd7cb0cb14669b823c134cca7acf1
RY(theta₁₆)
e2c2d96fbc004b4496d957a1b68d789a--2f0dd7cb0cb14669b823c134cca7acf1
60061f7ba44140a38fc70b255f2c8fea
RX(theta₂₀)
2f0dd7cb0cb14669b823c134cca7acf1--60061f7ba44140a38fc70b255f2c8fea
b733cc559a30482bb1de7151bf6b02bf
60061f7ba44140a38fc70b255f2c8fea--b733cc559a30482bb1de7151bf6b02bf
d66be6ae03d0452795fc609dacdd2678
b733cc559a30482bb1de7151bf6b02bf--d66be6ae03d0452795fc609dacdd2678
644960624a20438e93376d92ef664305
d66be6ae03d0452795fc609dacdd2678--644960624a20438e93376d92ef664305
63141cc0fe494250a70886cc40281869
475407c1ee0d45778493d4e780dac3ff
RX(theta₁)
4b2436ae81c24312a5c299917e4a0eb4--475407c1ee0d45778493d4e780dac3ff
9ced370cbe3d49a9998e28a14e66193d
2
d7045da7c4db4f76aecd5000147bafcc
RY(theta₅)
475407c1ee0d45778493d4e780dac3ff--d7045da7c4db4f76aecd5000147bafcc
4d2d32ba2656465eab11885857facad5
RX(theta₉)
d7045da7c4db4f76aecd5000147bafcc--4d2d32ba2656465eab11885857facad5
5257fb900f244fb1bae6b630bf5f1e41
X
4d2d32ba2656465eab11885857facad5--5257fb900f244fb1bae6b630bf5f1e41
5257fb900f244fb1bae6b630bf5f1e41--8bd3581707f94852aa70ca75e7df3467
516d2a4662cc43c093b6819eb7a0ab6c
5257fb900f244fb1bae6b630bf5f1e41--516d2a4662cc43c093b6819eb7a0ab6c
4e1204f79e6b41c389466f9416ee0a51
RX(theta₁₃)
516d2a4662cc43c093b6819eb7a0ab6c--4e1204f79e6b41c389466f9416ee0a51
35c3b67d89cf4602b2396cff4c89ff2f
RY(theta₁₇)
4e1204f79e6b41c389466f9416ee0a51--35c3b67d89cf4602b2396cff4c89ff2f
9f7977fdaf1a4fed953cd09b0214da30
RX(theta₂₁)
35c3b67d89cf4602b2396cff4c89ff2f--9f7977fdaf1a4fed953cd09b0214da30
28c7c896e7924ec1807f2206c6374d5f
X
9f7977fdaf1a4fed953cd09b0214da30--28c7c896e7924ec1807f2206c6374d5f
28c7c896e7924ec1807f2206c6374d5f--b733cc559a30482bb1de7151bf6b02bf
69913a5627c34795bc72de8e6317c9bb
28c7c896e7924ec1807f2206c6374d5f--69913a5627c34795bc72de8e6317c9bb
69913a5627c34795bc72de8e6317c9bb--63141cc0fe494250a70886cc40281869
b9c2fbc51f9d46819d51cb375da6b24a
d8ce84ae18944490a7fb0c3d1ff1941b
RX(theta₂)
9ced370cbe3d49a9998e28a14e66193d--d8ce84ae18944490a7fb0c3d1ff1941b
ba21ada5c224440493100653d9696b9d
3
53a2106193d9424c96b59cf0a6653f9c
RY(theta₆)
d8ce84ae18944490a7fb0c3d1ff1941b--53a2106193d9424c96b59cf0a6653f9c
9b6e4ecc90c3430199fe037ad8b4f6c0
RX(theta₁₀)
53a2106193d9424c96b59cf0a6653f9c--9b6e4ecc90c3430199fe037ad8b4f6c0
ba30164cff004d9493bbe33a0c1997c3
9b6e4ecc90c3430199fe037ad8b4f6c0--ba30164cff004d9493bbe33a0c1997c3
187d1607f503424591fa3f39ad4e92db
X
ba30164cff004d9493bbe33a0c1997c3--187d1607f503424591fa3f39ad4e92db
187d1607f503424591fa3f39ad4e92db--516d2a4662cc43c093b6819eb7a0ab6c
cd57cf2da3c841b1a2ecef9270b48118
RX(theta₁₄)
187d1607f503424591fa3f39ad4e92db--cd57cf2da3c841b1a2ecef9270b48118
06d6421ada4a453080c659074efcffac
RY(theta₁₈)
cd57cf2da3c841b1a2ecef9270b48118--06d6421ada4a453080c659074efcffac
d226cbe014d343f0bcd13b3c9049904c
RX(theta₂₂)
06d6421ada4a453080c659074efcffac--d226cbe014d343f0bcd13b3c9049904c
4312811e32564148b19d9312d5184230
d226cbe014d343f0bcd13b3c9049904c--4312811e32564148b19d9312d5184230
f57d93daadf844c68aeb72279f43e6ee
X
4312811e32564148b19d9312d5184230--f57d93daadf844c68aeb72279f43e6ee
f57d93daadf844c68aeb72279f43e6ee--69913a5627c34795bc72de8e6317c9bb
f57d93daadf844c68aeb72279f43e6ee--b9c2fbc51f9d46819d51cb375da6b24a
f9996d66ccb3471caef7fb69a419e868
bf869211f01c491e93046894f2c27372
RX(theta₃)
ba21ada5c224440493100653d9696b9d--bf869211f01c491e93046894f2c27372
fb487609c0d447028d47771d2e6675b6
RY(theta₇)
bf869211f01c491e93046894f2c27372--fb487609c0d447028d47771d2e6675b6
44fcf82f13f24fa2ab2e7ea96361a31d
RX(theta₁₁)
fb487609c0d447028d47771d2e6675b6--44fcf82f13f24fa2ab2e7ea96361a31d
1ee1c21c8e86447183b8cc686dbe25ee
X
44fcf82f13f24fa2ab2e7ea96361a31d--1ee1c21c8e86447183b8cc686dbe25ee
1ee1c21c8e86447183b8cc686dbe25ee--ba30164cff004d9493bbe33a0c1997c3
9a1d756c6d044995949d046be82f7c33
1ee1c21c8e86447183b8cc686dbe25ee--9a1d756c6d044995949d046be82f7c33
2097bc5e4a4442928dacecf83c2c091f
RX(theta₁₅)
9a1d756c6d044995949d046be82f7c33--2097bc5e4a4442928dacecf83c2c091f
8bbfc5e97e7b470da3a4908ae4a1dd58
RY(theta₁₉)
2097bc5e4a4442928dacecf83c2c091f--8bbfc5e97e7b470da3a4908ae4a1dd58
282a63c38e6d4203807a3033c16600a6
RX(theta₂₃)
8bbfc5e97e7b470da3a4908ae4a1dd58--282a63c38e6d4203807a3033c16600a6
661e5315c28f433dbbf755bc13cd94ee
X
282a63c38e6d4203807a3033c16600a6--661e5315c28f433dbbf755bc13cd94ee
661e5315c28f433dbbf755bc13cd94ee--4312811e32564148b19d9312d5184230
4834edab954d44a1acbc4e3b22657d7f
661e5315c28f433dbbf755bc13cd94ee--4834edab954d44a1acbc4e3b22657d7f
4834edab954d44a1acbc4e3b22657d7f--f9996d66ccb3471caef7fb69a419e868
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_40cd27f6f37a41f08bfd671bb0fbd366
HEA
cluster_bc1ee8fe505048c7b75de1f3c85c7e72
HEA
1fd53a9a77e542958a71ae537194cea1
0
dba480b11e5a4c3287278cdffae69200
RX(theta₀)
1fd53a9a77e542958a71ae537194cea1--dba480b11e5a4c3287278cdffae69200
1a3defae34e8402a98bfea55d6655048
1
491e3fc1ee874501a746f10bba657e46
RY(theta₄)
dba480b11e5a4c3287278cdffae69200--491e3fc1ee874501a746f10bba657e46
c02e68bd57834701a4082ba31d94d28c
RX(theta₈)
491e3fc1ee874501a746f10bba657e46--c02e68bd57834701a4082ba31d94d28c
337a95ce3e9d4dc087cbd22950c7ac2e
c02e68bd57834701a4082ba31d94d28c--337a95ce3e9d4dc087cbd22950c7ac2e
0c450b31367b498dad753fb139d1dca3
337a95ce3e9d4dc087cbd22950c7ac2e--0c450b31367b498dad753fb139d1dca3
5b96cbf498314ff78edcb0935b2e003e
RX(theta₁₂)
0c450b31367b498dad753fb139d1dca3--5b96cbf498314ff78edcb0935b2e003e
093eab3ad1914478ae17b2d851b9c630
RY(theta₁₆)
5b96cbf498314ff78edcb0935b2e003e--093eab3ad1914478ae17b2d851b9c630
73404d5cd44a492981a148918f80d4f1
RX(theta₂₀)
093eab3ad1914478ae17b2d851b9c630--73404d5cd44a492981a148918f80d4f1
372bb926b4f042c5ac094c7639d84c05
73404d5cd44a492981a148918f80d4f1--372bb926b4f042c5ac094c7639d84c05
1e4a6b390cac40faa56efbcecbbb6c7b
372bb926b4f042c5ac094c7639d84c05--1e4a6b390cac40faa56efbcecbbb6c7b
eb0e3e1a6cda46468e93ac4090870286
RX(theta₀)
1e4a6b390cac40faa56efbcecbbb6c7b--eb0e3e1a6cda46468e93ac4090870286
c350357d2cf04c22abf9235644d783b1
RY(theta₄)
eb0e3e1a6cda46468e93ac4090870286--c350357d2cf04c22abf9235644d783b1
b51ef70972fd474f8905726a30acc8ea
RX(theta₈)
c350357d2cf04c22abf9235644d783b1--b51ef70972fd474f8905726a30acc8ea
be7d7c75482c40fd886e65a48cec4cad
b51ef70972fd474f8905726a30acc8ea--be7d7c75482c40fd886e65a48cec4cad
7e62ac9983ea43018a14a68dd52acf97
be7d7c75482c40fd886e65a48cec4cad--7e62ac9983ea43018a14a68dd52acf97
ea4d847a385e43bd9255d44d744b27ae
RX(theta₁₂)
7e62ac9983ea43018a14a68dd52acf97--ea4d847a385e43bd9255d44d744b27ae
76427fe47bf54f1e81f912fb070c28f4
RY(theta₁₆)
ea4d847a385e43bd9255d44d744b27ae--76427fe47bf54f1e81f912fb070c28f4
f9a9aba183a641f5a2b7daa83a53e1ab
RX(theta₂₀)
76427fe47bf54f1e81f912fb070c28f4--f9a9aba183a641f5a2b7daa83a53e1ab
b5aca07add9c413b899e602c6fec992c
f9a9aba183a641f5a2b7daa83a53e1ab--b5aca07add9c413b899e602c6fec992c
2ef7463a2c904c28baa09c99a4467242
b5aca07add9c413b899e602c6fec992c--2ef7463a2c904c28baa09c99a4467242
e9d52c90cecf48b9a1a7e807d9d982da
2ef7463a2c904c28baa09c99a4467242--e9d52c90cecf48b9a1a7e807d9d982da
4d698db2ea5743baabcf5d04825e49a7
89649cbd80cd4c89afc5e3bb5ec6008b
RX(theta₁)
1a3defae34e8402a98bfea55d6655048--89649cbd80cd4c89afc5e3bb5ec6008b
0ce0bb7d643a4ab986764606594ec511
2
e1df24e63a2a4c2b97eea9c4db513251
RY(theta₅)
89649cbd80cd4c89afc5e3bb5ec6008b--e1df24e63a2a4c2b97eea9c4db513251
b9972bb4721f4271a867aebcc7a1f174
RX(theta₉)
e1df24e63a2a4c2b97eea9c4db513251--b9972bb4721f4271a867aebcc7a1f174
8cf65be9e7874e60924a868d12b504be
X
b9972bb4721f4271a867aebcc7a1f174--8cf65be9e7874e60924a868d12b504be
8cf65be9e7874e60924a868d12b504be--337a95ce3e9d4dc087cbd22950c7ac2e
93f36dd3ab654ee59f649b7aed6dff59
8cf65be9e7874e60924a868d12b504be--93f36dd3ab654ee59f649b7aed6dff59
d06ef06338034412bd8e8563f2009bda
RX(theta₁₃)
93f36dd3ab654ee59f649b7aed6dff59--d06ef06338034412bd8e8563f2009bda
02e851b31ba343edbf135bbd795edfa1
RY(theta₁₇)
d06ef06338034412bd8e8563f2009bda--02e851b31ba343edbf135bbd795edfa1
72cd1f2b354f40eb940e4970255c4e1d
RX(theta₂₁)
02e851b31ba343edbf135bbd795edfa1--72cd1f2b354f40eb940e4970255c4e1d
7eb40652c52440f1b7f1b12e43b7a08e
X
72cd1f2b354f40eb940e4970255c4e1d--7eb40652c52440f1b7f1b12e43b7a08e
7eb40652c52440f1b7f1b12e43b7a08e--372bb926b4f042c5ac094c7639d84c05
6c11ec818c44473fba9c2fe2a5178307
7eb40652c52440f1b7f1b12e43b7a08e--6c11ec818c44473fba9c2fe2a5178307
81f1245392eb4248b4d86c2fe45c7b01
RX(theta₁)
6c11ec818c44473fba9c2fe2a5178307--81f1245392eb4248b4d86c2fe45c7b01
1ab54e41d32548399bc6b9331450131e
RY(theta₅)
81f1245392eb4248b4d86c2fe45c7b01--1ab54e41d32548399bc6b9331450131e
3a695477ac5843e7a78ba39fadfa654d
RX(theta₉)
1ab54e41d32548399bc6b9331450131e--3a695477ac5843e7a78ba39fadfa654d
220af812380f4876a17454ec3eb0b28e
X
3a695477ac5843e7a78ba39fadfa654d--220af812380f4876a17454ec3eb0b28e
220af812380f4876a17454ec3eb0b28e--be7d7c75482c40fd886e65a48cec4cad
d7db2fad21c647279bafd7ff23a4a1ef
220af812380f4876a17454ec3eb0b28e--d7db2fad21c647279bafd7ff23a4a1ef
88c2cb4ffd744aec867b2a82e1790f00
RX(theta₁₃)
d7db2fad21c647279bafd7ff23a4a1ef--88c2cb4ffd744aec867b2a82e1790f00
e830426f30e34dcaa6f6e45c2ea50be2
RY(theta₁₇)
88c2cb4ffd744aec867b2a82e1790f00--e830426f30e34dcaa6f6e45c2ea50be2
a5a29333a08b4073906fc6b8a2add63f
RX(theta₂₁)
e830426f30e34dcaa6f6e45c2ea50be2--a5a29333a08b4073906fc6b8a2add63f
df22f1288b1e4e6590c4d7b0b7c5cecd
X
a5a29333a08b4073906fc6b8a2add63f--df22f1288b1e4e6590c4d7b0b7c5cecd
df22f1288b1e4e6590c4d7b0b7c5cecd--b5aca07add9c413b899e602c6fec992c
56bb1c4fa68c4b40b2762f26a8231a61
df22f1288b1e4e6590c4d7b0b7c5cecd--56bb1c4fa68c4b40b2762f26a8231a61
56bb1c4fa68c4b40b2762f26a8231a61--4d698db2ea5743baabcf5d04825e49a7
d8f12567f6fd478a9eb58b24bee8ffe0
8de2a64fdb7d44819875b09585dd0823
RX(theta₂)
0ce0bb7d643a4ab986764606594ec511--8de2a64fdb7d44819875b09585dd0823
ca9a3b592de2478fa39cfa1b526666e2
3
2bf67ea39cec48fdaf373234e6bfaf88
RY(theta₆)
8de2a64fdb7d44819875b09585dd0823--2bf67ea39cec48fdaf373234e6bfaf88
c8b40943c2e34d45a33b0f22e0159c67
RX(theta₁₀)
2bf67ea39cec48fdaf373234e6bfaf88--c8b40943c2e34d45a33b0f22e0159c67
92b30ed4630844949b24ba2839f09b09
c8b40943c2e34d45a33b0f22e0159c67--92b30ed4630844949b24ba2839f09b09
c3c59d4eceb2487683dfb53fb87f2a01
X
92b30ed4630844949b24ba2839f09b09--c3c59d4eceb2487683dfb53fb87f2a01
c3c59d4eceb2487683dfb53fb87f2a01--93f36dd3ab654ee59f649b7aed6dff59
8feec3041550499895671d27441350cd
RX(theta₁₄)
c3c59d4eceb2487683dfb53fb87f2a01--8feec3041550499895671d27441350cd
175a2f69ba0f4d58a8e62825cf3692be
RY(theta₁₈)
8feec3041550499895671d27441350cd--175a2f69ba0f4d58a8e62825cf3692be
c1ef233e333e436f988ca1067561c7eb
RX(theta₂₂)
175a2f69ba0f4d58a8e62825cf3692be--c1ef233e333e436f988ca1067561c7eb
5398c09bcfaf4a70bdb2df5e6f3a5868
c1ef233e333e436f988ca1067561c7eb--5398c09bcfaf4a70bdb2df5e6f3a5868
f009f7fc852e41e88159606462a54fd8
X
5398c09bcfaf4a70bdb2df5e6f3a5868--f009f7fc852e41e88159606462a54fd8
f009f7fc852e41e88159606462a54fd8--6c11ec818c44473fba9c2fe2a5178307
8cf4cb7d1ecc4c92b2cc6328abf2c724
RX(theta₂)
f009f7fc852e41e88159606462a54fd8--8cf4cb7d1ecc4c92b2cc6328abf2c724
246eeaf7e1f24746903d11c4cecb51d3
RY(theta₆)
8cf4cb7d1ecc4c92b2cc6328abf2c724--246eeaf7e1f24746903d11c4cecb51d3
ca33802622824872998d17bb55b34028
RX(theta₁₀)
246eeaf7e1f24746903d11c4cecb51d3--ca33802622824872998d17bb55b34028
8c8b4d2693e9421c93e47a86246a15ca
ca33802622824872998d17bb55b34028--8c8b4d2693e9421c93e47a86246a15ca
19b4015b13a041259ed3cf1a81038a9a
X
8c8b4d2693e9421c93e47a86246a15ca--19b4015b13a041259ed3cf1a81038a9a
19b4015b13a041259ed3cf1a81038a9a--d7db2fad21c647279bafd7ff23a4a1ef
681417fb10564bfa80305c8d8b120bdd
RX(theta₁₄)
19b4015b13a041259ed3cf1a81038a9a--681417fb10564bfa80305c8d8b120bdd
2b706db71e1444ab95be8850a73987f9
RY(theta₁₈)
681417fb10564bfa80305c8d8b120bdd--2b706db71e1444ab95be8850a73987f9
c99e48728f594fa5a37e1d23899539f6
RX(theta₂₂)
2b706db71e1444ab95be8850a73987f9--c99e48728f594fa5a37e1d23899539f6
a0dabfb2a105456dbe001dfaeb23ebc3
c99e48728f594fa5a37e1d23899539f6--a0dabfb2a105456dbe001dfaeb23ebc3
29432e60a22b444d8f84ddbb7e5468a3
X
a0dabfb2a105456dbe001dfaeb23ebc3--29432e60a22b444d8f84ddbb7e5468a3
29432e60a22b444d8f84ddbb7e5468a3--56bb1c4fa68c4b40b2762f26a8231a61
29432e60a22b444d8f84ddbb7e5468a3--d8f12567f6fd478a9eb58b24bee8ffe0
404e7aa19c79437ca67a158f4bb46caa
983add09a8674e32a5abef0ec9894a42
RX(theta₃)
ca9a3b592de2478fa39cfa1b526666e2--983add09a8674e32a5abef0ec9894a42
70d18b7cfcab49d3871b51b6d91cbf05
RY(theta₇)
983add09a8674e32a5abef0ec9894a42--70d18b7cfcab49d3871b51b6d91cbf05
9e301112a10640fcb9f79d05884ac8a1
RX(theta₁₁)
70d18b7cfcab49d3871b51b6d91cbf05--9e301112a10640fcb9f79d05884ac8a1
fca90a1555d646118a0a55ee0d4f4650
X
9e301112a10640fcb9f79d05884ac8a1--fca90a1555d646118a0a55ee0d4f4650
fca90a1555d646118a0a55ee0d4f4650--92b30ed4630844949b24ba2839f09b09
f8cf8b48ad374a7fa0da69d008bebac4
fca90a1555d646118a0a55ee0d4f4650--f8cf8b48ad374a7fa0da69d008bebac4
d9fea217c98144fc89f82c7de1c38013
RX(theta₁₅)
f8cf8b48ad374a7fa0da69d008bebac4--d9fea217c98144fc89f82c7de1c38013
18b9e42056ea47e0954cf4f693f0e8ba
RY(theta₁₉)
d9fea217c98144fc89f82c7de1c38013--18b9e42056ea47e0954cf4f693f0e8ba
193c1ad94f4541398e824c12cb553eb0
RX(theta₂₃)
18b9e42056ea47e0954cf4f693f0e8ba--193c1ad94f4541398e824c12cb553eb0
26fa8593eb464f1da2cc76ddef0e25df
X
193c1ad94f4541398e824c12cb553eb0--26fa8593eb464f1da2cc76ddef0e25df
26fa8593eb464f1da2cc76ddef0e25df--5398c09bcfaf4a70bdb2df5e6f3a5868
ee0c5f3b87694193ab6669c260a6b250
26fa8593eb464f1da2cc76ddef0e25df--ee0c5f3b87694193ab6669c260a6b250
5ae62b382a2a47988344874e897cb549
RX(theta₃)
ee0c5f3b87694193ab6669c260a6b250--5ae62b382a2a47988344874e897cb549
9ec19ef4c59d4f4ca7a1e376f4462bf8
RY(theta₇)
5ae62b382a2a47988344874e897cb549--9ec19ef4c59d4f4ca7a1e376f4462bf8
6ba5590ab1db42c896f7dec695b1cba0
RX(theta₁₁)
9ec19ef4c59d4f4ca7a1e376f4462bf8--6ba5590ab1db42c896f7dec695b1cba0
6b9e1c67190941939da73121904b7db0
X
6ba5590ab1db42c896f7dec695b1cba0--6b9e1c67190941939da73121904b7db0
6b9e1c67190941939da73121904b7db0--8c8b4d2693e9421c93e47a86246a15ca
ca07c2f1433f4560ab6f0ad62d4ea27d
6b9e1c67190941939da73121904b7db0--ca07c2f1433f4560ab6f0ad62d4ea27d
c27c30bd5a234de682203643ab63593d
RX(theta₁₅)
ca07c2f1433f4560ab6f0ad62d4ea27d--c27c30bd5a234de682203643ab63593d
3b716fcdab284cbda50f0b241c186da7
RY(theta₁₉)
c27c30bd5a234de682203643ab63593d--3b716fcdab284cbda50f0b241c186da7
9245027676034b97805135ca62aa23ed
RX(theta₂₃)
3b716fcdab284cbda50f0b241c186da7--9245027676034b97805135ca62aa23ed
718d986f948e46409767a3fe8d93b7f6
X
9245027676034b97805135ca62aa23ed--718d986f948e46409767a3fe8d93b7f6
718d986f948e46409767a3fe8d93b7f6--a0dabfb2a105456dbe001dfaeb23ebc3
f7cabc9e246c47adb64b380620ede0d2
718d986f948e46409767a3fe8d93b7f6--f7cabc9e246c47adb64b380620ede0d2
f7cabc9e246c47adb64b380620ede0d2--404e7aa19c79437ca67a158f4bb46caa
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_ccd2d54eaa3547848479b6440b38b5a6
HEA
cluster_d1ae57776dee4fafbc15f758cd022439
HEA
2f63daa70c8e4e558778afcb9e10173f
0
de1144c51afa4880ae995856ce562ccf
RX(p1₀)
2f63daa70c8e4e558778afcb9e10173f--de1144c51afa4880ae995856ce562ccf
b32c4ef0c1744b3e98d455cd2027c8bd
1
d601f3f0284d46c489c921d51c220ea6
RY(p1₄)
de1144c51afa4880ae995856ce562ccf--d601f3f0284d46c489c921d51c220ea6
8c321dde9f6d49628260ba731542c49c
RX(p1₈)
d601f3f0284d46c489c921d51c220ea6--8c321dde9f6d49628260ba731542c49c
6fee42187a5242fe86c3bc6eed7bdf10
8c321dde9f6d49628260ba731542c49c--6fee42187a5242fe86c3bc6eed7bdf10
a7e9943a72334bcdb12c641fcdea1e3d
6fee42187a5242fe86c3bc6eed7bdf10--a7e9943a72334bcdb12c641fcdea1e3d
ee94eb6762a94a0283c542dd4fb2b0a4
RX(p1₁₂)
a7e9943a72334bcdb12c641fcdea1e3d--ee94eb6762a94a0283c542dd4fb2b0a4
ad66e113d024444d9fb7d46ad7b47109
RY(p1₁₆)
ee94eb6762a94a0283c542dd4fb2b0a4--ad66e113d024444d9fb7d46ad7b47109
fabb3c520a074bc5b2a5aa069784d757
RX(p1₂₀)
ad66e113d024444d9fb7d46ad7b47109--fabb3c520a074bc5b2a5aa069784d757
dfa93cbc7c3f47eb8d4c5221739f021e
fabb3c520a074bc5b2a5aa069784d757--dfa93cbc7c3f47eb8d4c5221739f021e
b67c745eae1b4d80b8fef738c245f32d
dfa93cbc7c3f47eb8d4c5221739f021e--b67c745eae1b4d80b8fef738c245f32d
ed01c7336c144037b69db793d8e77e86
RX(p2₀)
b67c745eae1b4d80b8fef738c245f32d--ed01c7336c144037b69db793d8e77e86
a7414ea6abc24b94b766f7fd7a05fa54
RY(p2₄)
ed01c7336c144037b69db793d8e77e86--a7414ea6abc24b94b766f7fd7a05fa54
061a717c2a0a42a6b8391864c478f4c5
RX(p2₈)
a7414ea6abc24b94b766f7fd7a05fa54--061a717c2a0a42a6b8391864c478f4c5
d187975ea18945cea0306d095f0b0ed0
061a717c2a0a42a6b8391864c478f4c5--d187975ea18945cea0306d095f0b0ed0
0333541dc9304d84b36caea5b83a8108
d187975ea18945cea0306d095f0b0ed0--0333541dc9304d84b36caea5b83a8108
96528b0fc23f45ca8aa2291d0eb69064
RX(p2₁₂)
0333541dc9304d84b36caea5b83a8108--96528b0fc23f45ca8aa2291d0eb69064
df9ff7782f6b48aca4e2aeafdebb4b2b
RY(p2₁₆)
96528b0fc23f45ca8aa2291d0eb69064--df9ff7782f6b48aca4e2aeafdebb4b2b
e17ba69b7fbc41c8a2b79af16690cfa1
RX(p2₂₀)
df9ff7782f6b48aca4e2aeafdebb4b2b--e17ba69b7fbc41c8a2b79af16690cfa1
faf56a8cddbe441782910ed3417954ad
e17ba69b7fbc41c8a2b79af16690cfa1--faf56a8cddbe441782910ed3417954ad
1d6a23d701b9462b882fe55d843d0c5f
faf56a8cddbe441782910ed3417954ad--1d6a23d701b9462b882fe55d843d0c5f
c8758a3aa4724ca28e06a4cdf86e0b88
1d6a23d701b9462b882fe55d843d0c5f--c8758a3aa4724ca28e06a4cdf86e0b88
70592e3cf7ed473cb18b8c4f3001df01
169a617d8b3242f9b88272c63ea7c6e5
RX(p1₁)
b32c4ef0c1744b3e98d455cd2027c8bd--169a617d8b3242f9b88272c63ea7c6e5
9b0ea831ea764b85abb6b228a014fca1
2
2cce6055e38649418e43476e2eba908f
RY(p1₅)
169a617d8b3242f9b88272c63ea7c6e5--2cce6055e38649418e43476e2eba908f
6d60c9b2a5ee421a9c85bae0b2115563
RX(p1₉)
2cce6055e38649418e43476e2eba908f--6d60c9b2a5ee421a9c85bae0b2115563
85fe65b63d3a4e909c16e203d9d23a7e
X
6d60c9b2a5ee421a9c85bae0b2115563--85fe65b63d3a4e909c16e203d9d23a7e
85fe65b63d3a4e909c16e203d9d23a7e--6fee42187a5242fe86c3bc6eed7bdf10
a36cb05e15c14e7b9fda1db915c7deb9
85fe65b63d3a4e909c16e203d9d23a7e--a36cb05e15c14e7b9fda1db915c7deb9
570b7ce24d0c4eb39dc0028f2d369935
RX(p1₁₃)
a36cb05e15c14e7b9fda1db915c7deb9--570b7ce24d0c4eb39dc0028f2d369935
bacf2c53baaa492da31cc9800b9ed7f0
RY(p1₁₇)
570b7ce24d0c4eb39dc0028f2d369935--bacf2c53baaa492da31cc9800b9ed7f0
7b42e3aa7b04451aa42b0e939a81b059
RX(p1₂₁)
bacf2c53baaa492da31cc9800b9ed7f0--7b42e3aa7b04451aa42b0e939a81b059
ff1c7941166c499a93367f4b2988ff80
X
7b42e3aa7b04451aa42b0e939a81b059--ff1c7941166c499a93367f4b2988ff80
ff1c7941166c499a93367f4b2988ff80--dfa93cbc7c3f47eb8d4c5221739f021e
14920686f64344d78e4c29f96768e30f
ff1c7941166c499a93367f4b2988ff80--14920686f64344d78e4c29f96768e30f
519c21c561ec475da5dc34298fe79343
RX(p2₁)
14920686f64344d78e4c29f96768e30f--519c21c561ec475da5dc34298fe79343
c81db79ed53344ea9a25a35189d673c0
RY(p2₅)
519c21c561ec475da5dc34298fe79343--c81db79ed53344ea9a25a35189d673c0
10fe9672538344c49f09e27faff6eb3c
RX(p2₉)
c81db79ed53344ea9a25a35189d673c0--10fe9672538344c49f09e27faff6eb3c
ea0ae681c13b43928be2dfd1e2fe6485
X
10fe9672538344c49f09e27faff6eb3c--ea0ae681c13b43928be2dfd1e2fe6485
ea0ae681c13b43928be2dfd1e2fe6485--d187975ea18945cea0306d095f0b0ed0
fdc647f1f2c4407fa66b83cc23b22aa7
ea0ae681c13b43928be2dfd1e2fe6485--fdc647f1f2c4407fa66b83cc23b22aa7
7feecb6cbd9a4c0e9e232ff63277f9bc
RX(p2₁₃)
fdc647f1f2c4407fa66b83cc23b22aa7--7feecb6cbd9a4c0e9e232ff63277f9bc
596fcfaf629e40e28e10a9f03b5f15eb
RY(p2₁₇)
7feecb6cbd9a4c0e9e232ff63277f9bc--596fcfaf629e40e28e10a9f03b5f15eb
ba2c7df74a6648bb924c82a14b6d2129
RX(p2₂₁)
596fcfaf629e40e28e10a9f03b5f15eb--ba2c7df74a6648bb924c82a14b6d2129
0076705df83744c89b1e4b46e84f2230
X
ba2c7df74a6648bb924c82a14b6d2129--0076705df83744c89b1e4b46e84f2230
0076705df83744c89b1e4b46e84f2230--faf56a8cddbe441782910ed3417954ad
314bc38cdfc04172ab1d065b1878e778
0076705df83744c89b1e4b46e84f2230--314bc38cdfc04172ab1d065b1878e778
314bc38cdfc04172ab1d065b1878e778--70592e3cf7ed473cb18b8c4f3001df01
1322fde026a443a9bdf89f2a4294652d
d70cc6a6adec44988369d6397a6bd0a1
RX(p1₂)
9b0ea831ea764b85abb6b228a014fca1--d70cc6a6adec44988369d6397a6bd0a1
42c2d99270914cd1a24007a9feb816a6
3
c23e9ba92fc94702a70993aa65579744
RY(p1₆)
d70cc6a6adec44988369d6397a6bd0a1--c23e9ba92fc94702a70993aa65579744
d26744f616eb4db6bc183b0b2e02f4dc
RX(p1₁₀)
c23e9ba92fc94702a70993aa65579744--d26744f616eb4db6bc183b0b2e02f4dc
2223f7159bd349f08aa35aa9ddc4a855
d26744f616eb4db6bc183b0b2e02f4dc--2223f7159bd349f08aa35aa9ddc4a855
7007d833da5c47ffb97099acc7c5ba31
X
2223f7159bd349f08aa35aa9ddc4a855--7007d833da5c47ffb97099acc7c5ba31
7007d833da5c47ffb97099acc7c5ba31--a36cb05e15c14e7b9fda1db915c7deb9
16e62698523e4ba29af8de4845741288
RX(p1₁₄)
7007d833da5c47ffb97099acc7c5ba31--16e62698523e4ba29af8de4845741288
7bed1c8e691d47f0a5df738085d1ae76
RY(p1₁₈)
16e62698523e4ba29af8de4845741288--7bed1c8e691d47f0a5df738085d1ae76
bce7e64649f34279a53bd9c4c569246d
RX(p1₂₂)
7bed1c8e691d47f0a5df738085d1ae76--bce7e64649f34279a53bd9c4c569246d
3567298effe04c2ab31c51478486e01e
bce7e64649f34279a53bd9c4c569246d--3567298effe04c2ab31c51478486e01e
439336c8471f4075a019022f1ccdc3c5
X
3567298effe04c2ab31c51478486e01e--439336c8471f4075a019022f1ccdc3c5
439336c8471f4075a019022f1ccdc3c5--14920686f64344d78e4c29f96768e30f
14e0f07119be42ae90bc815d26fbe65a
RX(p2₂)
439336c8471f4075a019022f1ccdc3c5--14e0f07119be42ae90bc815d26fbe65a
b12ec726962545569b4571f8a06fa477
RY(p2₆)
14e0f07119be42ae90bc815d26fbe65a--b12ec726962545569b4571f8a06fa477
b5c16077ca184f54983846d35ea98586
RX(p2₁₀)
b12ec726962545569b4571f8a06fa477--b5c16077ca184f54983846d35ea98586
1df6dd1ed64d452c8c6ce3a43fbd5c6b
b5c16077ca184f54983846d35ea98586--1df6dd1ed64d452c8c6ce3a43fbd5c6b
38db7ef0369f4fea9f54739b36eeafe1
X
1df6dd1ed64d452c8c6ce3a43fbd5c6b--38db7ef0369f4fea9f54739b36eeafe1
38db7ef0369f4fea9f54739b36eeafe1--fdc647f1f2c4407fa66b83cc23b22aa7
adf985dbb89a45cfb4ee0c6ce0614fb3
RX(p2₁₄)
38db7ef0369f4fea9f54739b36eeafe1--adf985dbb89a45cfb4ee0c6ce0614fb3
6ed5632a5ec145c4baea426f0ab597b5
RY(p2₁₈)
adf985dbb89a45cfb4ee0c6ce0614fb3--6ed5632a5ec145c4baea426f0ab597b5
3b5c75c7617f42e596ec718a2b5be389
RX(p2₂₂)
6ed5632a5ec145c4baea426f0ab597b5--3b5c75c7617f42e596ec718a2b5be389
1dc899299a7343cab0363a4863d21d22
3b5c75c7617f42e596ec718a2b5be389--1dc899299a7343cab0363a4863d21d22
7ca9cc11ef9b4240b70291ea9a71b74f
X
1dc899299a7343cab0363a4863d21d22--7ca9cc11ef9b4240b70291ea9a71b74f
7ca9cc11ef9b4240b70291ea9a71b74f--314bc38cdfc04172ab1d065b1878e778
7ca9cc11ef9b4240b70291ea9a71b74f--1322fde026a443a9bdf89f2a4294652d
486c4191f4b34536b468214e962c7caa
cff1d7ac4dd044128cf0411f38696f1e
RX(p1₃)
42c2d99270914cd1a24007a9feb816a6--cff1d7ac4dd044128cf0411f38696f1e
5d54336aa0f74554aa76a2e232168510
RY(p1₇)
cff1d7ac4dd044128cf0411f38696f1e--5d54336aa0f74554aa76a2e232168510
172d445360de4a49bec8669fc55f02f0
RX(p1₁₁)
5d54336aa0f74554aa76a2e232168510--172d445360de4a49bec8669fc55f02f0
b2761ca4b678441ca4636c8a528a71a0
X
172d445360de4a49bec8669fc55f02f0--b2761ca4b678441ca4636c8a528a71a0
b2761ca4b678441ca4636c8a528a71a0--2223f7159bd349f08aa35aa9ddc4a855
12330ca49fcf410787070669e0ab53b9
b2761ca4b678441ca4636c8a528a71a0--12330ca49fcf410787070669e0ab53b9
b6645f41cf8247e2bba8352ca758c560
RX(p1₁₅)
12330ca49fcf410787070669e0ab53b9--b6645f41cf8247e2bba8352ca758c560
e067ad244af04cf5a5559ab68e3230a4
RY(p1₁₉)
b6645f41cf8247e2bba8352ca758c560--e067ad244af04cf5a5559ab68e3230a4
0c472db97bb2436da1591faa7d85334b
RX(p1₂₃)
e067ad244af04cf5a5559ab68e3230a4--0c472db97bb2436da1591faa7d85334b
9225f92473964fd1a09d3a069d8076fa
X
0c472db97bb2436da1591faa7d85334b--9225f92473964fd1a09d3a069d8076fa
9225f92473964fd1a09d3a069d8076fa--3567298effe04c2ab31c51478486e01e
1dd6d819064243768842a4cd5aae51e6
9225f92473964fd1a09d3a069d8076fa--1dd6d819064243768842a4cd5aae51e6
204a5fcb2386430bbccd468211df5d11
RX(p2₃)
1dd6d819064243768842a4cd5aae51e6--204a5fcb2386430bbccd468211df5d11
7e59f1ff776740a48a747193bf234ff4
RY(p2₇)
204a5fcb2386430bbccd468211df5d11--7e59f1ff776740a48a747193bf234ff4
ab39012fabd44ecc9cfb88ab43c8e753
RX(p2₁₁)
7e59f1ff776740a48a747193bf234ff4--ab39012fabd44ecc9cfb88ab43c8e753
2d8b85ea14324faa9b7dbd674ae7468d
X
ab39012fabd44ecc9cfb88ab43c8e753--2d8b85ea14324faa9b7dbd674ae7468d
2d8b85ea14324faa9b7dbd674ae7468d--1df6dd1ed64d452c8c6ce3a43fbd5c6b
93cccdef0513426eb20922eaf670c74a
2d8b85ea14324faa9b7dbd674ae7468d--93cccdef0513426eb20922eaf670c74a
498827b3028242169628a4ef8078f795
RX(p2₁₅)
93cccdef0513426eb20922eaf670c74a--498827b3028242169628a4ef8078f795
67973b7627024253abd6b2b165b8fa25
RY(p2₁₉)
498827b3028242169628a4ef8078f795--67973b7627024253abd6b2b165b8fa25
e7bf5c728f634233b8a9cc8d56bad232
RX(p2₂₃)
67973b7627024253abd6b2b165b8fa25--e7bf5c728f634233b8a9cc8d56bad232
64059591ab954c9992cb6c1d1079a71d
X
e7bf5c728f634233b8a9cc8d56bad232--64059591ab954c9992cb6c1d1079a71d
64059591ab954c9992cb6c1d1079a71d--1dc899299a7343cab0363a4863d21d22
f2fb3d68f32e415b9779db573c2a86a0
64059591ab954c9992cb6c1d1079a71d--f2fb3d68f32e415b9779db573c2a86a0
f2fb3d68f32e415b9779db573c2a86a0--486c4191f4b34536b468214e962c7caa
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.6215 ] )) , (' t he ta _ 0 ' , tens or( [ 0.2697 ] )) , (' t he ta _ 1 ' , tens or( [ 0.6950 ] )) , (' t he ta _ 10 ' , tens or( [ 0.3464 ] )) , (' t he ta _ 11 ' , tens or( [ 0.9241 ] )) , (' t he ta _ 12 ' , tens or( [ 0.7898 ] )) , (' t he ta _ 13 ' , tens or( [ 0.9776 ] )) , (' t he ta _ 14 ' , tens or( [ 0.7308 ] )) , (' t he ta _ 15 ' , tens or( [ 0.7334 ] )) , (' t he ta _ 16 ' , tens or( [ 0.7720 ] )) , (' t he ta _ 17 ' , tens or( [ 0.0300 ] )) , (' t he ta _ 18 ' , tens or( [ 0.1428 ] )) , (' t he ta _ 19 ' , tens or( [ 0.2618 ] )) , (' t he ta _ 2 ' , tens or( [ 0.9746 ] )) , (' t he ta _ 20 ' , tens or( [ 0.4202 ] )) , (' t he ta _ 21 ' , tens or( [ 0.7802 ] )) , (' t he ta _ 22 ' , tens or( [ 0.2414 ] )) , (' t he ta _ 23 ' , tens or( [ 0.8382 ] )) , (' t he ta _ 3 ' , tens or( [ 0.5333 ] )) , (' t he ta _ 4 ' , tens or( [ 0.6383 ] )) , (' t he ta _ 5 ' , tens or( [ 0.0999 ] )) , (' t he ta _ 6 ' , tens or( [ 0.3065 ] )) , (' t he ta _ 7 ' , tens or( [ 0.3257 ] )) , (' t he ta _ 8 ' , tens or( [ 0.7024 ] )) , (' t he ta _ 9 ' , tens or( [ 0.8767 ] )) ] )
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.6205 ] )) , (' t he ta _ 0 ' , tens or( [ 0.2707 ] )) , (' t he ta _ 1 ' , tens or( [ 0.6940 ] )) , (' t he ta _ 10 ' , tens or( [ 0.3474 ] )) , (' t he ta _ 11 ' , tens or( [ 0.9251 ] )) , (' t he ta _ 12 ' , tens or( [ 0.7908 ] )) , (' t he ta _ 13 ' , tens or( [ 0.9786 ] )) , (' t he ta _ 14 ' , tens or( [ 0.7318 ] )) , (' t he ta _ 15 ' , tens or( [ 0.7344 ] )) , (' t he ta _ 16 ' , tens or( [ 0.7730 ] )) , (' t he ta _ 17 ' , tens or( [ 0.0310 ] )) , (' t he ta _ 18 ' , tens or( [ 0.1418 ] )) , (' t he ta _ 19 ' , tens or( [ 0.2628 ] )) , (' t he ta _ 2 ' , tens or( [ 0.9756 ] )) , (' t he ta _ 20 ' , tens or( [ 0.4212 ] )) , (' t he ta _ 21 ' , tens or( [ 0.7812 ] )) , (' t he ta _ 22 ' , tens or( [ 0.2424 ] )) , (' t he ta _ 23 ' , tens or( [ 0.8392 ] )) , (' t he ta _ 3 ' , tens or( [ 0.5343 ] )) , (' t he ta _ 4 ' , tens or( [ 0.6373 ] )) , (' t he ta _ 5 ' , tens or( [ 0.1009 ] )) , (' t he ta _ 6 ' , tens or( [ 0.3075 ] )) , (' t he ta _ 7 ' , tens or( [ 0.3247 ] )) , (' t he ta _ 8 ' , tens or( [ 0.7034 ] )) , (' t he ta _ 9 ' , tens or( [ 0.8757 ] )) ] )
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 ]] )