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_7e0685147e6f420197a29a0f8152c889
[* 2]
cluster_75f02c65b29b4e188e9b9ec1e7d59556
Rotations
b55d71e8c2c546da83ab6892bf1b2cc4
0
c4db64c86f5e46629ba7c4fcc96f087a
RX(phi/theta)
b55d71e8c2c546da83ab6892bf1b2cc4--c4db64c86f5e46629ba7c4fcc96f087a
1e027fb1df7f4a3e98797ae9896e0129
1
65192721b04a4211a20ecd76888d68fb
RX(phi)
c4db64c86f5e46629ba7c4fcc96f087a--65192721b04a4211a20ecd76888d68fb
6b4dc90cce124b7aaf0c69421a6b5d17
RX(phi)
65192721b04a4211a20ecd76888d68fb--6b4dc90cce124b7aaf0c69421a6b5d17
278a1edb416e49b2aa26cad5a3cec1dd
RX(phi + theta)
6b4dc90cce124b7aaf0c69421a6b5d17--278a1edb416e49b2aa26cad5a3cec1dd
62ad636cdd964b1a8626d648ff524225
278a1edb416e49b2aa26cad5a3cec1dd--62ad636cdd964b1a8626d648ff524225
7b9a9e8ba9c1434fba892288c1993e55
62ad636cdd964b1a8626d648ff524225--7b9a9e8ba9c1434fba892288c1993e55
0ac3d1fcf3814ab696482469cc8a3b53
Z
7b9a9e8ba9c1434fba892288c1993e55--0ac3d1fcf3814ab696482469cc8a3b53
ab5ac52f616e4777b83af3b664f54156
0ac3d1fcf3814ab696482469cc8a3b53--ab5ac52f616e4777b83af3b664f54156
69d7ce3fc22b4a1a84fd615474d1c53d
677c9afd49f2466da9cbd66cf6689f06
RY(2*theta)
1e027fb1df7f4a3e98797ae9896e0129--677c9afd49f2466da9cbd66cf6689f06
da9f4d808c244e088a6998f7a634fa90
2
ced5fcae0115440a92c614456e57c8ae
RY(theta)
677c9afd49f2466da9cbd66cf6689f06--ced5fcae0115440a92c614456e57c8ae
979137e9d3a14ff689359ca6b316dd5b
RY(theta)
ced5fcae0115440a92c614456e57c8ae--979137e9d3a14ff689359ca6b316dd5b
28dc4e2896634898bb389c2325673027
RY(theta**2)
979137e9d3a14ff689359ca6b316dd5b--28dc4e2896634898bb389c2325673027
07a5b89c9bb743f4849785211b2a67dc
X
28dc4e2896634898bb389c2325673027--07a5b89c9bb743f4849785211b2a67dc
07a5b89c9bb743f4849785211b2a67dc--62ad636cdd964b1a8626d648ff524225
0bb7461f70b14b5f8705ca6dde7318ea
07a5b89c9bb743f4849785211b2a67dc--0bb7461f70b14b5f8705ca6dde7318ea
04870bf157214793b9703d278344ca76
Z
0bb7461f70b14b5f8705ca6dde7318ea--04870bf157214793b9703d278344ca76
04870bf157214793b9703d278344ca76--69d7ce3fc22b4a1a84fd615474d1c53d
6c42442c30e74e499c0b0b9beab7e7dc
33b221d435b844fe87e94a011bdcc21e
RZ(cos(phi))
da9f4d808c244e088a6998f7a634fa90--33b221d435b844fe87e94a011bdcc21e
5f7292244a384bbf9fef03c01a3752f9
RZ(phi)
33b221d435b844fe87e94a011bdcc21e--5f7292244a384bbf9fef03c01a3752f9
baddaeb198f64e99aac77d8130e423b2
RZ(phi)
5f7292244a384bbf9fef03c01a3752f9--baddaeb198f64e99aac77d8130e423b2
b61f4b57e21048989016798e5036fbb0
RZ(cos(phi))
baddaeb198f64e99aac77d8130e423b2--b61f4b57e21048989016798e5036fbb0
95d3fe195a6b428e969908effd4df986
b61f4b57e21048989016798e5036fbb0--95d3fe195a6b428e969908effd4df986
a15f3cb90eee4027a862d61d80334dc0
X
95d3fe195a6b428e969908effd4df986--a15f3cb90eee4027a862d61d80334dc0
a15f3cb90eee4027a862d61d80334dc0--0bb7461f70b14b5f8705ca6dde7318ea
414992d59f3d4a3aaae9b36571ad49db
Z
a15f3cb90eee4027a862d61d80334dc0--414992d59f3d4a3aaae9b36571ad49db
414992d59f3d4a3aaae9b36571ad49db--6c42442c30e74e499c0b0b9beab7e7dc
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
9931952e87054c57a7c4f9b569cfe106
0
f2ded4438ccd4d43b71e93dfaff62595
RX(theta₀)
9931952e87054c57a7c4f9b569cfe106--f2ded4438ccd4d43b71e93dfaff62595
f18e26a6a9a346aaaf6499d4773b2d85
1
5adc547418c04afcb4dc35fef624f138
RY(theta₄)
f2ded4438ccd4d43b71e93dfaff62595--5adc547418c04afcb4dc35fef624f138
1dc4d56c0d6049629a1a3b8feb3b7232
RX(theta₈)
5adc547418c04afcb4dc35fef624f138--1dc4d56c0d6049629a1a3b8feb3b7232
7a5f559bc139413f8dadbc493a94feb8
1dc4d56c0d6049629a1a3b8feb3b7232--7a5f559bc139413f8dadbc493a94feb8
019a96c19fed454cb49808c6e6d66f8c
7a5f559bc139413f8dadbc493a94feb8--019a96c19fed454cb49808c6e6d66f8c
509dac88a5c545ea9c571be98c5ffda0
RX(theta₁₂)
019a96c19fed454cb49808c6e6d66f8c--509dac88a5c545ea9c571be98c5ffda0
9730bb1ebde64a2e90693b2fc099a029
RY(theta₁₆)
509dac88a5c545ea9c571be98c5ffda0--9730bb1ebde64a2e90693b2fc099a029
a34e89f97fb84f1898fdfd97b5cf3fc4
RX(theta₂₀)
9730bb1ebde64a2e90693b2fc099a029--a34e89f97fb84f1898fdfd97b5cf3fc4
9d926fac452444e49393377a39d4dac6
a34e89f97fb84f1898fdfd97b5cf3fc4--9d926fac452444e49393377a39d4dac6
a257d7831e0940bdb4538cf3fdb45e24
9d926fac452444e49393377a39d4dac6--a257d7831e0940bdb4538cf3fdb45e24
bac708edfd50452ba2ab488bedf57148
a257d7831e0940bdb4538cf3fdb45e24--bac708edfd50452ba2ab488bedf57148
90010270a52e4d19a8947852309f7140
3f1f7b33c6b543eeb6fa504cb6d1834e
RX(theta₁)
f18e26a6a9a346aaaf6499d4773b2d85--3f1f7b33c6b543eeb6fa504cb6d1834e
f14ea5ef97604c9ca90ea57ae4d00051
2
2978cb17c8b9456e8d73c2671811bdda
RY(theta₅)
3f1f7b33c6b543eeb6fa504cb6d1834e--2978cb17c8b9456e8d73c2671811bdda
5192aecbdece4e9cac2ecd97b5f11a38
RX(theta₉)
2978cb17c8b9456e8d73c2671811bdda--5192aecbdece4e9cac2ecd97b5f11a38
dd69d0c9391b4043ab0c5e3c06bafacd
X
5192aecbdece4e9cac2ecd97b5f11a38--dd69d0c9391b4043ab0c5e3c06bafacd
dd69d0c9391b4043ab0c5e3c06bafacd--7a5f559bc139413f8dadbc493a94feb8
d81d47d117fc4253a48a00ea05de3773
dd69d0c9391b4043ab0c5e3c06bafacd--d81d47d117fc4253a48a00ea05de3773
7656edecff964f75b321982bf53da284
RX(theta₁₃)
d81d47d117fc4253a48a00ea05de3773--7656edecff964f75b321982bf53da284
cb33116ea1e2477a82b939165e8e13bc
RY(theta₁₇)
7656edecff964f75b321982bf53da284--cb33116ea1e2477a82b939165e8e13bc
dd655774334345069fef2893ded3541b
RX(theta₂₁)
cb33116ea1e2477a82b939165e8e13bc--dd655774334345069fef2893ded3541b
430de1f17b4045bfb3e45fdca3682e56
X
dd655774334345069fef2893ded3541b--430de1f17b4045bfb3e45fdca3682e56
430de1f17b4045bfb3e45fdca3682e56--9d926fac452444e49393377a39d4dac6
5f82757ec7e5411881a8d3812cd73507
430de1f17b4045bfb3e45fdca3682e56--5f82757ec7e5411881a8d3812cd73507
5f82757ec7e5411881a8d3812cd73507--90010270a52e4d19a8947852309f7140
ca85c01b42c945d3b56b7f9b3c1c8b57
32033e0b58e1470fb7179817bc89f80b
RX(theta₂)
f14ea5ef97604c9ca90ea57ae4d00051--32033e0b58e1470fb7179817bc89f80b
5b2bbf8ffd494cb882c6c7c6a65eea8b
3
9d66be8b5824402090ddd43ca385190a
RY(theta₆)
32033e0b58e1470fb7179817bc89f80b--9d66be8b5824402090ddd43ca385190a
c7b3eaf05bc74606b3db475eb554891f
RX(theta₁₀)
9d66be8b5824402090ddd43ca385190a--c7b3eaf05bc74606b3db475eb554891f
e72da705f5414b65b2d6f59514a122c8
c7b3eaf05bc74606b3db475eb554891f--e72da705f5414b65b2d6f59514a122c8
27b7de0997d34829a140d94df8feb14c
X
e72da705f5414b65b2d6f59514a122c8--27b7de0997d34829a140d94df8feb14c
27b7de0997d34829a140d94df8feb14c--d81d47d117fc4253a48a00ea05de3773
26a814b3cc71490881c497b52c71101a
RX(theta₁₄)
27b7de0997d34829a140d94df8feb14c--26a814b3cc71490881c497b52c71101a
558d3a7458e1472fa165d16b69812cee
RY(theta₁₈)
26a814b3cc71490881c497b52c71101a--558d3a7458e1472fa165d16b69812cee
ae578d814f41481bbe09a68b6717fe77
RX(theta₂₂)
558d3a7458e1472fa165d16b69812cee--ae578d814f41481bbe09a68b6717fe77
efc0626507764c44a98c7e3ffc0a0d00
ae578d814f41481bbe09a68b6717fe77--efc0626507764c44a98c7e3ffc0a0d00
f409798a677d40cea876d03e4f3069fa
X
efc0626507764c44a98c7e3ffc0a0d00--f409798a677d40cea876d03e4f3069fa
f409798a677d40cea876d03e4f3069fa--5f82757ec7e5411881a8d3812cd73507
f409798a677d40cea876d03e4f3069fa--ca85c01b42c945d3b56b7f9b3c1c8b57
1753c7fc1ab24cb3a7e7675f1bb3de7f
19a47156548d433d86ffed94268d8fcc
RX(theta₃)
5b2bbf8ffd494cb882c6c7c6a65eea8b--19a47156548d433d86ffed94268d8fcc
3156ef258ef64de5940151535f8373a5
RY(theta₇)
19a47156548d433d86ffed94268d8fcc--3156ef258ef64de5940151535f8373a5
15821843339f452996e05e426e47cb05
RX(theta₁₁)
3156ef258ef64de5940151535f8373a5--15821843339f452996e05e426e47cb05
50f4d3846c074868bc222a246da09799
X
15821843339f452996e05e426e47cb05--50f4d3846c074868bc222a246da09799
50f4d3846c074868bc222a246da09799--e72da705f5414b65b2d6f59514a122c8
892679b67f0a4bd3acbab464d31aa3c6
50f4d3846c074868bc222a246da09799--892679b67f0a4bd3acbab464d31aa3c6
e9e9aeeb9e6348878ebb7c9c84a8916d
RX(theta₁₅)
892679b67f0a4bd3acbab464d31aa3c6--e9e9aeeb9e6348878ebb7c9c84a8916d
3bfd0bde73a74071925e39c6ae58a50f
RY(theta₁₉)
e9e9aeeb9e6348878ebb7c9c84a8916d--3bfd0bde73a74071925e39c6ae58a50f
b5c2b35616234893890bde6fd3c00cf1
RX(theta₂₃)
3bfd0bde73a74071925e39c6ae58a50f--b5c2b35616234893890bde6fd3c00cf1
7f442474d0c74d4f8a83713d9733dbb1
X
b5c2b35616234893890bde6fd3c00cf1--7f442474d0c74d4f8a83713d9733dbb1
7f442474d0c74d4f8a83713d9733dbb1--efc0626507764c44a98c7e3ffc0a0d00
ede1a51c69be41f184e3e6ffded4d135
7f442474d0c74d4f8a83713d9733dbb1--ede1a51c69be41f184e3e6ffded4d135
ede1a51c69be41f184e3e6ffded4d135--1753c7fc1ab24cb3a7e7675f1bb3de7f
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_d7c4de01668e435e893ec84d3ee675e5
HEA
cluster_ebb6a008fe8f4f32aba923bc5faa70d6
HEA
24c931950b6e4cae86e6d8b9f70afee1
0
3b484993ca34450daef770074e5547a0
RX(theta₀)
24c931950b6e4cae86e6d8b9f70afee1--3b484993ca34450daef770074e5547a0
c8f673998f044064afe6cace53202687
1
fae43969156b4d1a82ab629ed0f37bd2
RY(theta₄)
3b484993ca34450daef770074e5547a0--fae43969156b4d1a82ab629ed0f37bd2
e7b11a3ec55a42bda901a72716918523
RX(theta₈)
fae43969156b4d1a82ab629ed0f37bd2--e7b11a3ec55a42bda901a72716918523
ec4bcd10fc7f429aa7c6b0da1742eb51
e7b11a3ec55a42bda901a72716918523--ec4bcd10fc7f429aa7c6b0da1742eb51
21bca86a97bf49a68820301fe3974abf
ec4bcd10fc7f429aa7c6b0da1742eb51--21bca86a97bf49a68820301fe3974abf
dd7dfc7b1b3c44948b70746d09f1502d
RX(theta₁₂)
21bca86a97bf49a68820301fe3974abf--dd7dfc7b1b3c44948b70746d09f1502d
73c1233e3c3948e788cfdfae7b1812aa
RY(theta₁₆)
dd7dfc7b1b3c44948b70746d09f1502d--73c1233e3c3948e788cfdfae7b1812aa
0fe88b5a812040a9b3a8687434800afa
RX(theta₂₀)
73c1233e3c3948e788cfdfae7b1812aa--0fe88b5a812040a9b3a8687434800afa
8609b8801aaf4ce39e7f38e6391e6460
0fe88b5a812040a9b3a8687434800afa--8609b8801aaf4ce39e7f38e6391e6460
825807886e754b12b2f059f9c754a096
8609b8801aaf4ce39e7f38e6391e6460--825807886e754b12b2f059f9c754a096
82f070a744a44ebaa21c0b28d3b69ce9
RX(theta₀)
825807886e754b12b2f059f9c754a096--82f070a744a44ebaa21c0b28d3b69ce9
533f24c171554094ba996592ee547160
RY(theta₄)
82f070a744a44ebaa21c0b28d3b69ce9--533f24c171554094ba996592ee547160
935e0ce4c1e4446a87c1f5207799705b
RX(theta₈)
533f24c171554094ba996592ee547160--935e0ce4c1e4446a87c1f5207799705b
8c52defc23cc43d781d311874c86fdd2
935e0ce4c1e4446a87c1f5207799705b--8c52defc23cc43d781d311874c86fdd2
b91282dcb1964dac82aa039bb00728fa
8c52defc23cc43d781d311874c86fdd2--b91282dcb1964dac82aa039bb00728fa
e6646c40cc6e4debb38095b92dc4a836
RX(theta₁₂)
b91282dcb1964dac82aa039bb00728fa--e6646c40cc6e4debb38095b92dc4a836
afa1e95f908847679de18aaca1fa8135
RY(theta₁₆)
e6646c40cc6e4debb38095b92dc4a836--afa1e95f908847679de18aaca1fa8135
d0f435dc7fc54e32b48581dbe5e7ac51
RX(theta₂₀)
afa1e95f908847679de18aaca1fa8135--d0f435dc7fc54e32b48581dbe5e7ac51
67a235d81a654a048a8d8a91100c35c0
d0f435dc7fc54e32b48581dbe5e7ac51--67a235d81a654a048a8d8a91100c35c0
d61aa6d8c4474e2d9dd067048b852b03
67a235d81a654a048a8d8a91100c35c0--d61aa6d8c4474e2d9dd067048b852b03
78b9bd2379954ffa80aa83d2efd1d6f2
d61aa6d8c4474e2d9dd067048b852b03--78b9bd2379954ffa80aa83d2efd1d6f2
1d3a8f2d6e8c48db86487b0e62965468
04b57351d3084a0d86a094d2b7bda9f4
RX(theta₁)
c8f673998f044064afe6cace53202687--04b57351d3084a0d86a094d2b7bda9f4
fceb1997d98348d299277b934cac144e
2
79cf53e3ef87408c9eff20c83802169e
RY(theta₅)
04b57351d3084a0d86a094d2b7bda9f4--79cf53e3ef87408c9eff20c83802169e
5af3e15cd8464ed7b1801a3914f112fa
RX(theta₉)
79cf53e3ef87408c9eff20c83802169e--5af3e15cd8464ed7b1801a3914f112fa
7f90f24913dd49fdb5581895fda10991
X
5af3e15cd8464ed7b1801a3914f112fa--7f90f24913dd49fdb5581895fda10991
7f90f24913dd49fdb5581895fda10991--ec4bcd10fc7f429aa7c6b0da1742eb51
e74f8f980e404defa5dbf421e059415b
7f90f24913dd49fdb5581895fda10991--e74f8f980e404defa5dbf421e059415b
eda63b1642e746d4a29b5f25a715160e
RX(theta₁₃)
e74f8f980e404defa5dbf421e059415b--eda63b1642e746d4a29b5f25a715160e
7cb7d035fd2d440c9acfd1d0aa7c424a
RY(theta₁₇)
eda63b1642e746d4a29b5f25a715160e--7cb7d035fd2d440c9acfd1d0aa7c424a
1d3f9d7695084ee4bcc76f7ff4722c2c
RX(theta₂₁)
7cb7d035fd2d440c9acfd1d0aa7c424a--1d3f9d7695084ee4bcc76f7ff4722c2c
4994dcb0aa1a4d2696f37b5d2d3fac4e
X
1d3f9d7695084ee4bcc76f7ff4722c2c--4994dcb0aa1a4d2696f37b5d2d3fac4e
4994dcb0aa1a4d2696f37b5d2d3fac4e--8609b8801aaf4ce39e7f38e6391e6460
c65d008ab0e943c195a9238a58601c7e
4994dcb0aa1a4d2696f37b5d2d3fac4e--c65d008ab0e943c195a9238a58601c7e
72eb3f55432f45d997793ec514ba06cd
RX(theta₁)
c65d008ab0e943c195a9238a58601c7e--72eb3f55432f45d997793ec514ba06cd
4ceabbd98d1840228fbc2481b87b8fe1
RY(theta₅)
72eb3f55432f45d997793ec514ba06cd--4ceabbd98d1840228fbc2481b87b8fe1
490904c68066434e8d5ad3d2f64ff44e
RX(theta₉)
4ceabbd98d1840228fbc2481b87b8fe1--490904c68066434e8d5ad3d2f64ff44e
2cb1c23ca8994e80ab3766041bdf8370
X
490904c68066434e8d5ad3d2f64ff44e--2cb1c23ca8994e80ab3766041bdf8370
2cb1c23ca8994e80ab3766041bdf8370--8c52defc23cc43d781d311874c86fdd2
3c64e11665c34838b307837951c067f3
2cb1c23ca8994e80ab3766041bdf8370--3c64e11665c34838b307837951c067f3
7603121dd7554d9e97f1f2e65b60b3a1
RX(theta₁₃)
3c64e11665c34838b307837951c067f3--7603121dd7554d9e97f1f2e65b60b3a1
e1dd7ca5863c458080a435e7deb82b97
RY(theta₁₇)
7603121dd7554d9e97f1f2e65b60b3a1--e1dd7ca5863c458080a435e7deb82b97
cde27699d4bb45b5bbd5e250773930ff
RX(theta₂₁)
e1dd7ca5863c458080a435e7deb82b97--cde27699d4bb45b5bbd5e250773930ff
3410cc2999a14c078de4d44118c254e3
X
cde27699d4bb45b5bbd5e250773930ff--3410cc2999a14c078de4d44118c254e3
3410cc2999a14c078de4d44118c254e3--67a235d81a654a048a8d8a91100c35c0
9f9d9cbfa5c24027a11a0b4db64e06ea
3410cc2999a14c078de4d44118c254e3--9f9d9cbfa5c24027a11a0b4db64e06ea
9f9d9cbfa5c24027a11a0b4db64e06ea--1d3a8f2d6e8c48db86487b0e62965468
a2dc2e5e261e42658d571c5e0b613c3e
06cb3381c8f34a50a351c8fe333b2613
RX(theta₂)
fceb1997d98348d299277b934cac144e--06cb3381c8f34a50a351c8fe333b2613
3660e7945467497581f3239f9775b59a
3
81e4468399de46119a0c991de1c731ad
RY(theta₆)
06cb3381c8f34a50a351c8fe333b2613--81e4468399de46119a0c991de1c731ad
044c350cf4b44c72a23e1d1c0217c383
RX(theta₁₀)
81e4468399de46119a0c991de1c731ad--044c350cf4b44c72a23e1d1c0217c383
050a828c1e25472fa73e39ec0e6542e0
044c350cf4b44c72a23e1d1c0217c383--050a828c1e25472fa73e39ec0e6542e0
adcd4e08b1704415b5c76fcb2a1b4b63
X
050a828c1e25472fa73e39ec0e6542e0--adcd4e08b1704415b5c76fcb2a1b4b63
adcd4e08b1704415b5c76fcb2a1b4b63--e74f8f980e404defa5dbf421e059415b
08593fe02e244116946a975231815457
RX(theta₁₄)
adcd4e08b1704415b5c76fcb2a1b4b63--08593fe02e244116946a975231815457
15268349b504492094d5f6946fa298ff
RY(theta₁₈)
08593fe02e244116946a975231815457--15268349b504492094d5f6946fa298ff
a85a96b7247347deaf582e684846eae6
RX(theta₂₂)
15268349b504492094d5f6946fa298ff--a85a96b7247347deaf582e684846eae6
596af2a6677e47dfb6429ecdf3fc04da
a85a96b7247347deaf582e684846eae6--596af2a6677e47dfb6429ecdf3fc04da
7dc5ffe6b56f40bead35bd536a4745e1
X
596af2a6677e47dfb6429ecdf3fc04da--7dc5ffe6b56f40bead35bd536a4745e1
7dc5ffe6b56f40bead35bd536a4745e1--c65d008ab0e943c195a9238a58601c7e
1b290022a0f9400c94e6ca52464b9712
RX(theta₂)
7dc5ffe6b56f40bead35bd536a4745e1--1b290022a0f9400c94e6ca52464b9712
fee2b3aaccfd4a9fac24b0cb252219d5
RY(theta₆)
1b290022a0f9400c94e6ca52464b9712--fee2b3aaccfd4a9fac24b0cb252219d5
d9a0cddb3c3a4d6a94e13d1b40d0caac
RX(theta₁₀)
fee2b3aaccfd4a9fac24b0cb252219d5--d9a0cddb3c3a4d6a94e13d1b40d0caac
75af2745c4c34a7f8b43ad828e65f70a
d9a0cddb3c3a4d6a94e13d1b40d0caac--75af2745c4c34a7f8b43ad828e65f70a
43fc8fcbb41c4b2198241a6cc2488f40
X
75af2745c4c34a7f8b43ad828e65f70a--43fc8fcbb41c4b2198241a6cc2488f40
43fc8fcbb41c4b2198241a6cc2488f40--3c64e11665c34838b307837951c067f3
f95d9fcda59d4f4dba8b3359e2a68d65
RX(theta₁₄)
43fc8fcbb41c4b2198241a6cc2488f40--f95d9fcda59d4f4dba8b3359e2a68d65
e9ec2ed6099f4995834344b62d6dc3f1
RY(theta₁₈)
f95d9fcda59d4f4dba8b3359e2a68d65--e9ec2ed6099f4995834344b62d6dc3f1
f08e73576ae34fef9dd02a03aab5c7cb
RX(theta₂₂)
e9ec2ed6099f4995834344b62d6dc3f1--f08e73576ae34fef9dd02a03aab5c7cb
2bffd39a29d8419bbc0229b0c56b0833
f08e73576ae34fef9dd02a03aab5c7cb--2bffd39a29d8419bbc0229b0c56b0833
e38ac2ac50ed471fb2ac46b2b6672f46
X
2bffd39a29d8419bbc0229b0c56b0833--e38ac2ac50ed471fb2ac46b2b6672f46
e38ac2ac50ed471fb2ac46b2b6672f46--9f9d9cbfa5c24027a11a0b4db64e06ea
e38ac2ac50ed471fb2ac46b2b6672f46--a2dc2e5e261e42658d571c5e0b613c3e
301e2149fe294dbf981e8e594f813d0d
c1d8cb52b83148de97a6a2085d41dbe1
RX(theta₃)
3660e7945467497581f3239f9775b59a--c1d8cb52b83148de97a6a2085d41dbe1
9beb64e8f9274e29a4ffe98e15bd784f
RY(theta₇)
c1d8cb52b83148de97a6a2085d41dbe1--9beb64e8f9274e29a4ffe98e15bd784f
75186fa3d4ac47c4b57d0c36e0980f00
RX(theta₁₁)
9beb64e8f9274e29a4ffe98e15bd784f--75186fa3d4ac47c4b57d0c36e0980f00
6be022939572481a9bcd7696e3fd7ffa
X
75186fa3d4ac47c4b57d0c36e0980f00--6be022939572481a9bcd7696e3fd7ffa
6be022939572481a9bcd7696e3fd7ffa--050a828c1e25472fa73e39ec0e6542e0
c8c351d93cb64ae09210ca9b5b367d68
6be022939572481a9bcd7696e3fd7ffa--c8c351d93cb64ae09210ca9b5b367d68
8d3fd136d6ae473cba4e292504eec9e5
RX(theta₁₅)
c8c351d93cb64ae09210ca9b5b367d68--8d3fd136d6ae473cba4e292504eec9e5
ccc91630a23348c2a2517009bf97e2e4
RY(theta₁₉)
8d3fd136d6ae473cba4e292504eec9e5--ccc91630a23348c2a2517009bf97e2e4
944a814b1f25419bb9e9210e6102f9c1
RX(theta₂₃)
ccc91630a23348c2a2517009bf97e2e4--944a814b1f25419bb9e9210e6102f9c1
b1d94ced26024477b9ede85a571b0c42
X
944a814b1f25419bb9e9210e6102f9c1--b1d94ced26024477b9ede85a571b0c42
b1d94ced26024477b9ede85a571b0c42--596af2a6677e47dfb6429ecdf3fc04da
e24f98205eec48e6ac2e4b9cdd90a937
b1d94ced26024477b9ede85a571b0c42--e24f98205eec48e6ac2e4b9cdd90a937
81be5e547a1a427783d59803c4e58c3b
RX(theta₃)
e24f98205eec48e6ac2e4b9cdd90a937--81be5e547a1a427783d59803c4e58c3b
453512e33bea45e182f6777c581a81f1
RY(theta₇)
81be5e547a1a427783d59803c4e58c3b--453512e33bea45e182f6777c581a81f1
f2aa5259bf1e480babd54110924bd52e
RX(theta₁₁)
453512e33bea45e182f6777c581a81f1--f2aa5259bf1e480babd54110924bd52e
7a5d8c3770c94300bbe7e9828759f5ce
X
f2aa5259bf1e480babd54110924bd52e--7a5d8c3770c94300bbe7e9828759f5ce
7a5d8c3770c94300bbe7e9828759f5ce--75af2745c4c34a7f8b43ad828e65f70a
e17db6f87a294e3cb3ba49c3c0471cc0
7a5d8c3770c94300bbe7e9828759f5ce--e17db6f87a294e3cb3ba49c3c0471cc0
1b1117e39e2b48c39efa78b46a873bb8
RX(theta₁₅)
e17db6f87a294e3cb3ba49c3c0471cc0--1b1117e39e2b48c39efa78b46a873bb8
1ce6f61a79cf4e0693a354f3d9f980d9
RY(theta₁₉)
1b1117e39e2b48c39efa78b46a873bb8--1ce6f61a79cf4e0693a354f3d9f980d9
ec3a3a72d4d54726bd474dae7db067ad
RX(theta₂₃)
1ce6f61a79cf4e0693a354f3d9f980d9--ec3a3a72d4d54726bd474dae7db067ad
dae639e8db184eab9d3e90063492bee0
X
ec3a3a72d4d54726bd474dae7db067ad--dae639e8db184eab9d3e90063492bee0
dae639e8db184eab9d3e90063492bee0--2bffd39a29d8419bbc0229b0c56b0833
f6bc03c80b6d4d9988ea30ab86490e82
dae639e8db184eab9d3e90063492bee0--f6bc03c80b6d4d9988ea30ab86490e82
f6bc03c80b6d4d9988ea30ab86490e82--301e2149fe294dbf981e8e594f813d0d
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_977975ec83954ada92ab19e431cf269a
HEA
cluster_43eff9842f8e4ce5a113452e11ef746b
HEA
b983fd096d2d4a77bdb75746fe568270
0
f2c4c8ddd8064766a5d5b217c2073957
RX(p1₀)
b983fd096d2d4a77bdb75746fe568270--f2c4c8ddd8064766a5d5b217c2073957
c5f5f032d3a3475897d2cdc45cfbf6bf
1
66a18d606b7f4133ab302f141e632cc4
RY(p1₄)
f2c4c8ddd8064766a5d5b217c2073957--66a18d606b7f4133ab302f141e632cc4
b2eb6a042a9d40f5b1cfa4d9a3c9b69a
RX(p1₈)
66a18d606b7f4133ab302f141e632cc4--b2eb6a042a9d40f5b1cfa4d9a3c9b69a
4c1c5ca94ccd476b8d933ebeae980ef8
b2eb6a042a9d40f5b1cfa4d9a3c9b69a--4c1c5ca94ccd476b8d933ebeae980ef8
4273262a18714505b63e986d2ab9f962
4c1c5ca94ccd476b8d933ebeae980ef8--4273262a18714505b63e986d2ab9f962
0cdc44abd4594d53b8316e3a289d04c0
RX(p1₁₂)
4273262a18714505b63e986d2ab9f962--0cdc44abd4594d53b8316e3a289d04c0
c74a622fe7534c659fd5e8e0b01798b3
RY(p1₁₆)
0cdc44abd4594d53b8316e3a289d04c0--c74a622fe7534c659fd5e8e0b01798b3
88429cfbba8c47abb035d6e3dfddb954
RX(p1₂₀)
c74a622fe7534c659fd5e8e0b01798b3--88429cfbba8c47abb035d6e3dfddb954
4806a135758e4fcdbdb939d399121b5e
88429cfbba8c47abb035d6e3dfddb954--4806a135758e4fcdbdb939d399121b5e
3d2943ce1fda4e52a1edcb6f2e4788c2
4806a135758e4fcdbdb939d399121b5e--3d2943ce1fda4e52a1edcb6f2e4788c2
b095edcdc9274225bc4aa959297e5401
RX(p2₀)
3d2943ce1fda4e52a1edcb6f2e4788c2--b095edcdc9274225bc4aa959297e5401
1a42a13463324777807f82a5b07382a3
RY(p2₄)
b095edcdc9274225bc4aa959297e5401--1a42a13463324777807f82a5b07382a3
de9a627b264f4a14b8e52c8f8a526afa
RX(p2₈)
1a42a13463324777807f82a5b07382a3--de9a627b264f4a14b8e52c8f8a526afa
f2921f49ee3346ce9332194a0eadb54d
de9a627b264f4a14b8e52c8f8a526afa--f2921f49ee3346ce9332194a0eadb54d
69e7c008c6e84d58b60ea8acf2f7dd98
f2921f49ee3346ce9332194a0eadb54d--69e7c008c6e84d58b60ea8acf2f7dd98
8e636a740bb54f6199a04d1470f56d42
RX(p2₁₂)
69e7c008c6e84d58b60ea8acf2f7dd98--8e636a740bb54f6199a04d1470f56d42
4ed25dd1e1864d70bf024fb60f385c14
RY(p2₁₆)
8e636a740bb54f6199a04d1470f56d42--4ed25dd1e1864d70bf024fb60f385c14
5de5ac669c0741808829774528df6cc8
RX(p2₂₀)
4ed25dd1e1864d70bf024fb60f385c14--5de5ac669c0741808829774528df6cc8
4b13038c63d04560bbcc7ab2e8704710
5de5ac669c0741808829774528df6cc8--4b13038c63d04560bbcc7ab2e8704710
dbc3c0685d544dc5aa4dfc03ab12f9a8
4b13038c63d04560bbcc7ab2e8704710--dbc3c0685d544dc5aa4dfc03ab12f9a8
177934ca87c645aa9ad02113191a5e00
dbc3c0685d544dc5aa4dfc03ab12f9a8--177934ca87c645aa9ad02113191a5e00
33bc9364643a4273a0f74df5171f1bb6
f5177ced06dc49dd9249d36ef9fd2d33
RX(p1₁)
c5f5f032d3a3475897d2cdc45cfbf6bf--f5177ced06dc49dd9249d36ef9fd2d33
2eb533ec1b234fa387d0b79b7515e6e0
2
9a352b005b9c48b6899cff608505e30c
RY(p1₅)
f5177ced06dc49dd9249d36ef9fd2d33--9a352b005b9c48b6899cff608505e30c
2fabe5b8a54e428492977be30c311159
RX(p1₉)
9a352b005b9c48b6899cff608505e30c--2fabe5b8a54e428492977be30c311159
c8cbd82b841b4861bc8e3a3f2330483e
X
2fabe5b8a54e428492977be30c311159--c8cbd82b841b4861bc8e3a3f2330483e
c8cbd82b841b4861bc8e3a3f2330483e--4c1c5ca94ccd476b8d933ebeae980ef8
d1ef7ea509164aca874096649f8a2cec
c8cbd82b841b4861bc8e3a3f2330483e--d1ef7ea509164aca874096649f8a2cec
9c4228c1795a47bb86928588b7b3c900
RX(p1₁₃)
d1ef7ea509164aca874096649f8a2cec--9c4228c1795a47bb86928588b7b3c900
827f9306bbbd489db94fc7cc81d74a8b
RY(p1₁₇)
9c4228c1795a47bb86928588b7b3c900--827f9306bbbd489db94fc7cc81d74a8b
a22df1fbbae6467390ceb6f484a967f1
RX(p1₂₁)
827f9306bbbd489db94fc7cc81d74a8b--a22df1fbbae6467390ceb6f484a967f1
171440b44ad14d1f8ceb6ce45dbcb325
X
a22df1fbbae6467390ceb6f484a967f1--171440b44ad14d1f8ceb6ce45dbcb325
171440b44ad14d1f8ceb6ce45dbcb325--4806a135758e4fcdbdb939d399121b5e
f9282f041625450fa6edb937c645ca52
171440b44ad14d1f8ceb6ce45dbcb325--f9282f041625450fa6edb937c645ca52
dbe1d7a1789a4761b1cb24520a2c0583
RX(p2₁)
f9282f041625450fa6edb937c645ca52--dbe1d7a1789a4761b1cb24520a2c0583
6b6b3551a6f241ff808c109e656f9ae7
RY(p2₅)
dbe1d7a1789a4761b1cb24520a2c0583--6b6b3551a6f241ff808c109e656f9ae7
e6d25fb315ff4d4184b948bb0cba6eab
RX(p2₉)
6b6b3551a6f241ff808c109e656f9ae7--e6d25fb315ff4d4184b948bb0cba6eab
78d0ba415f2a4e83bd28717b58a16fce
X
e6d25fb315ff4d4184b948bb0cba6eab--78d0ba415f2a4e83bd28717b58a16fce
78d0ba415f2a4e83bd28717b58a16fce--f2921f49ee3346ce9332194a0eadb54d
319c1ade3cbe4b4e8736b862cc583032
78d0ba415f2a4e83bd28717b58a16fce--319c1ade3cbe4b4e8736b862cc583032
2b08ed39e97b4cb8b764a221f7be6b62
RX(p2₁₃)
319c1ade3cbe4b4e8736b862cc583032--2b08ed39e97b4cb8b764a221f7be6b62
3b22a7adf4814c7c964430cc554952d7
RY(p2₁₇)
2b08ed39e97b4cb8b764a221f7be6b62--3b22a7adf4814c7c964430cc554952d7
f7db645c48654e3e928f52cce60f19fb
RX(p2₂₁)
3b22a7adf4814c7c964430cc554952d7--f7db645c48654e3e928f52cce60f19fb
c904ae73e4b447019b93c0e22be45e6d
X
f7db645c48654e3e928f52cce60f19fb--c904ae73e4b447019b93c0e22be45e6d
c904ae73e4b447019b93c0e22be45e6d--4b13038c63d04560bbcc7ab2e8704710
a00df2490495431a8ff959c468ff747f
c904ae73e4b447019b93c0e22be45e6d--a00df2490495431a8ff959c468ff747f
a00df2490495431a8ff959c468ff747f--33bc9364643a4273a0f74df5171f1bb6
edff0d850bb545139214670dba5de82f
e946666af7474411851acb2973afba24
RX(p1₂)
2eb533ec1b234fa387d0b79b7515e6e0--e946666af7474411851acb2973afba24
019d7d24d78a417ab28fdafb02af52fe
3
c2bd0aff992545009a277372e53733ec
RY(p1₆)
e946666af7474411851acb2973afba24--c2bd0aff992545009a277372e53733ec
81ac6d72d6534e31a20a3f56724fc9f7
RX(p1₁₀)
c2bd0aff992545009a277372e53733ec--81ac6d72d6534e31a20a3f56724fc9f7
ca24ef515dc74102a2618b72a7b2d79e
81ac6d72d6534e31a20a3f56724fc9f7--ca24ef515dc74102a2618b72a7b2d79e
966d96aa70fc401184c2e32ebdbc48c7
X
ca24ef515dc74102a2618b72a7b2d79e--966d96aa70fc401184c2e32ebdbc48c7
966d96aa70fc401184c2e32ebdbc48c7--d1ef7ea509164aca874096649f8a2cec
3620f1c5a3ee4a418e05d25e4574a653
RX(p1₁₄)
966d96aa70fc401184c2e32ebdbc48c7--3620f1c5a3ee4a418e05d25e4574a653
7b98b0bc7b0d467abf12e53b431f3052
RY(p1₁₈)
3620f1c5a3ee4a418e05d25e4574a653--7b98b0bc7b0d467abf12e53b431f3052
7e8e7d6f13a14471a7857cd924704ddd
RX(p1₂₂)
7b98b0bc7b0d467abf12e53b431f3052--7e8e7d6f13a14471a7857cd924704ddd
3513b7e5ce344d37994d0dbb64c70279
7e8e7d6f13a14471a7857cd924704ddd--3513b7e5ce344d37994d0dbb64c70279
d367426a1bfd43b6b570d704f681d195
X
3513b7e5ce344d37994d0dbb64c70279--d367426a1bfd43b6b570d704f681d195
d367426a1bfd43b6b570d704f681d195--f9282f041625450fa6edb937c645ca52
0ae33b0237b849ac9e9cdb433853f79d
RX(p2₂)
d367426a1bfd43b6b570d704f681d195--0ae33b0237b849ac9e9cdb433853f79d
b910a9e6a20746df915a4a5c6a929edd
RY(p2₆)
0ae33b0237b849ac9e9cdb433853f79d--b910a9e6a20746df915a4a5c6a929edd
2243b48f5ff8411b80a7087de44b00bf
RX(p2₁₀)
b910a9e6a20746df915a4a5c6a929edd--2243b48f5ff8411b80a7087de44b00bf
d1f1cd02d2bb44b68da4e6c490b7c059
2243b48f5ff8411b80a7087de44b00bf--d1f1cd02d2bb44b68da4e6c490b7c059
a00bcad8ba8c40d3a9b591a87e0d4991
X
d1f1cd02d2bb44b68da4e6c490b7c059--a00bcad8ba8c40d3a9b591a87e0d4991
a00bcad8ba8c40d3a9b591a87e0d4991--319c1ade3cbe4b4e8736b862cc583032
bd40360634bc4de791a95a4fbf723db4
RX(p2₁₄)
a00bcad8ba8c40d3a9b591a87e0d4991--bd40360634bc4de791a95a4fbf723db4
a4e359ea085249baa684cb5e7b98580f
RY(p2₁₈)
bd40360634bc4de791a95a4fbf723db4--a4e359ea085249baa684cb5e7b98580f
dcf6e5e395bf4161bfde8de1c3946efb
RX(p2₂₂)
a4e359ea085249baa684cb5e7b98580f--dcf6e5e395bf4161bfde8de1c3946efb
df4362f455c1449ea173c105bcba17f1
dcf6e5e395bf4161bfde8de1c3946efb--df4362f455c1449ea173c105bcba17f1
98f230e8cb584e708254ac206c701aa1
X
df4362f455c1449ea173c105bcba17f1--98f230e8cb584e708254ac206c701aa1
98f230e8cb584e708254ac206c701aa1--a00df2490495431a8ff959c468ff747f
98f230e8cb584e708254ac206c701aa1--edff0d850bb545139214670dba5de82f
7e4aa5daab0e4fe89061570ded706567
1434a6593ce64aed82df9714464636be
RX(p1₃)
019d7d24d78a417ab28fdafb02af52fe--1434a6593ce64aed82df9714464636be
157dc3c8790e49ceb06df08b81c6586d
RY(p1₇)
1434a6593ce64aed82df9714464636be--157dc3c8790e49ceb06df08b81c6586d
a4595ed7980f476999a6b845bc0cb078
RX(p1₁₁)
157dc3c8790e49ceb06df08b81c6586d--a4595ed7980f476999a6b845bc0cb078
cf62c8d3ab0b445d8d3e7b1b18ae6c49
X
a4595ed7980f476999a6b845bc0cb078--cf62c8d3ab0b445d8d3e7b1b18ae6c49
cf62c8d3ab0b445d8d3e7b1b18ae6c49--ca24ef515dc74102a2618b72a7b2d79e
33aa830fbab74ef48df2c651a8466b02
cf62c8d3ab0b445d8d3e7b1b18ae6c49--33aa830fbab74ef48df2c651a8466b02
d01965f50c9b4328ad387f6c46db221e
RX(p1₁₅)
33aa830fbab74ef48df2c651a8466b02--d01965f50c9b4328ad387f6c46db221e
051218c0083840358dae93b296e21ffe
RY(p1₁₉)
d01965f50c9b4328ad387f6c46db221e--051218c0083840358dae93b296e21ffe
7ef812ea57494b03b4a5e8307b7d0fbf
RX(p1₂₃)
051218c0083840358dae93b296e21ffe--7ef812ea57494b03b4a5e8307b7d0fbf
f1cd85985ec4485a98da770e5e59a370
X
7ef812ea57494b03b4a5e8307b7d0fbf--f1cd85985ec4485a98da770e5e59a370
f1cd85985ec4485a98da770e5e59a370--3513b7e5ce344d37994d0dbb64c70279
1fdb93d259ee4d8b88a2fd09fe7f9d15
f1cd85985ec4485a98da770e5e59a370--1fdb93d259ee4d8b88a2fd09fe7f9d15
2b72ea4aa7d94111b4c24777105f9d62
RX(p2₃)
1fdb93d259ee4d8b88a2fd09fe7f9d15--2b72ea4aa7d94111b4c24777105f9d62
71d3e5c7055347438ccab16996fb9829
RY(p2₇)
2b72ea4aa7d94111b4c24777105f9d62--71d3e5c7055347438ccab16996fb9829
a7b47b2df7ee4674907d99e1bcb8a31c
RX(p2₁₁)
71d3e5c7055347438ccab16996fb9829--a7b47b2df7ee4674907d99e1bcb8a31c
885d9e549f4f4604a887bbd19527623c
X
a7b47b2df7ee4674907d99e1bcb8a31c--885d9e549f4f4604a887bbd19527623c
885d9e549f4f4604a887bbd19527623c--d1f1cd02d2bb44b68da4e6c490b7c059
85ca4796d4ef45358091da2a3299153e
885d9e549f4f4604a887bbd19527623c--85ca4796d4ef45358091da2a3299153e
1a3613d7af5c40b8b5ac803e64ab3410
RX(p2₁₅)
85ca4796d4ef45358091da2a3299153e--1a3613d7af5c40b8b5ac803e64ab3410
8280c2c7017849aab4f2c6e265d5dc63
RY(p2₁₉)
1a3613d7af5c40b8b5ac803e64ab3410--8280c2c7017849aab4f2c6e265d5dc63
3b8cb3e8f0534cbfa434936c56144f4b
RX(p2₂₃)
8280c2c7017849aab4f2c6e265d5dc63--3b8cb3e8f0534cbfa434936c56144f4b
c279a7e57a114e22b034262aef404322
X
3b8cb3e8f0534cbfa434936c56144f4b--c279a7e57a114e22b034262aef404322
c279a7e57a114e22b034262aef404322--df4362f455c1449ea173c105bcba17f1
17bf768b8b7648a3a60ac0ad159b7db1
c279a7e57a114e22b034262aef404322--17bf768b8b7648a3a60ac0ad159b7db1
17bf768b8b7648a3a60ac0ad159b7db1--7e4aa5daab0e4fe89061570ded706567
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 ]] )