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 be optimized.
Feature Parameter : A non-trainable parameter which can be used to encode classical data into a quantum state.
Fixed Parameters
To pass a fixed parameter to a gate (or any parametrizable block), one can simply use either Python numeric types or wrapped in
a torch.Tensor
.
from torch import pi
from qadence import RX , run
# Let's use a torch type.
block = RX ( 0 , pi )
wf = run ( block )
# Let's pass a simple float.
block = RX ( 0 , 1. )
wf = run ( block )
w f = tens or( [[ 6.1232e-17+0. j , 0.0000e+00-1. j ]] )
w f = tens or( [[ 0.8776+0.0000 j , 0.0000-0.4794 j ]] )
Variational Parameters
To parametrize a block by an angle theta
, either a Python string
or an instance of VariationalParameter
can be passed instead of a numeric type to the gate constructor:
from qadence import RX , run , VariationalParameter
block = RX ( 0 , "theta" )
# This is equivalent to:
block = RX ( 0 , VariationalParameter ( "theta" ))
wf = run ( block )
w f = tens or( [[ 0.9575+0.0000 j , 0.0000-0.2883 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.8818+0.0000 j , 0.0000-0.4716 j ],
[ 0.9827+0.0000 j , 0.0000-0.1854 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.8666+0.0000 j , 0.4489+0.0000 j , 0.0000-0.1937 j , 0.0000-0.1003 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_90adc0bff21549a2bf3cf9958b0d90d9
[* 2]
cluster_1fd3472d28634d14aa9626ff9933e158
Rotations
534b03f7891142cda8f6bc3b4eaa0093
0
8487a87e258a45888ee0cb782075f39b
RX(phi/theta)
534b03f7891142cda8f6bc3b4eaa0093--8487a87e258a45888ee0cb782075f39b
d2116026cf0e4bbbb5541339a4512b10
1
cbd0a5e0a2204ce6bc56474912751a72
RX(phi)
8487a87e258a45888ee0cb782075f39b--cbd0a5e0a2204ce6bc56474912751a72
671ed674f5244ae093bbabd232508344
RX(phi)
cbd0a5e0a2204ce6bc56474912751a72--671ed674f5244ae093bbabd232508344
ef5e8be6f4054c7a96521fbf8fa337bb
RX(phi + theta)
671ed674f5244ae093bbabd232508344--ef5e8be6f4054c7a96521fbf8fa337bb
a20c60d44ab94771bca251e24aadfa2b
ef5e8be6f4054c7a96521fbf8fa337bb--a20c60d44ab94771bca251e24aadfa2b
fa84113a57fd47d0b549be55bea9bede
a20c60d44ab94771bca251e24aadfa2b--fa84113a57fd47d0b549be55bea9bede
e3554223e03c401fba4cad52748851c3
Z
fa84113a57fd47d0b549be55bea9bede--e3554223e03c401fba4cad52748851c3
cbb180d8d56b437287d680f47f23de1f
e3554223e03c401fba4cad52748851c3--cbb180d8d56b437287d680f47f23de1f
51b82fb0c7c1458a8e9904f7c4eebcb7
739f9e4524704139a1a8243528389921
RY(2*theta)
d2116026cf0e4bbbb5541339a4512b10--739f9e4524704139a1a8243528389921
b8e6c63212e04c388b74dd73ab3a2f58
2
a9733346b81c4c679452746c20904320
RY(theta)
739f9e4524704139a1a8243528389921--a9733346b81c4c679452746c20904320
c766d4e87f5f4e9192b315d09722acc0
RY(theta)
a9733346b81c4c679452746c20904320--c766d4e87f5f4e9192b315d09722acc0
95f218707b334405a5e70716528698d2
RY(theta**2)
c766d4e87f5f4e9192b315d09722acc0--95f218707b334405a5e70716528698d2
81a2b5df70e449739ca1641416ef01a5
X
95f218707b334405a5e70716528698d2--81a2b5df70e449739ca1641416ef01a5
81a2b5df70e449739ca1641416ef01a5--a20c60d44ab94771bca251e24aadfa2b
02d0e1853ae445c3b0e279056b16dbb7
81a2b5df70e449739ca1641416ef01a5--02d0e1853ae445c3b0e279056b16dbb7
52f4cf5597484a5bac66f0213bc7519b
Z
02d0e1853ae445c3b0e279056b16dbb7--52f4cf5597484a5bac66f0213bc7519b
52f4cf5597484a5bac66f0213bc7519b--51b82fb0c7c1458a8e9904f7c4eebcb7
fdd60530eed84e3b8f81541c0843ce32
a750b66a50a6439a818f5e256b876e0b
RZ(cos(phi))
b8e6c63212e04c388b74dd73ab3a2f58--a750b66a50a6439a818f5e256b876e0b
05373a2138904bd18af72f7fbe695f5a
RZ(phi)
a750b66a50a6439a818f5e256b876e0b--05373a2138904bd18af72f7fbe695f5a
ece954b4eabd46589a7e2e5c8e8006d9
RZ(phi)
05373a2138904bd18af72f7fbe695f5a--ece954b4eabd46589a7e2e5c8e8006d9
5a44224f8c134647b80e731487d0834e
RZ(cos(phi))
ece954b4eabd46589a7e2e5c8e8006d9--5a44224f8c134647b80e731487d0834e
8cddda4852f046e3bf2db7157d272263
5a44224f8c134647b80e731487d0834e--8cddda4852f046e3bf2db7157d272263
b7f8699118c4462f8c7d061b709dc8d8
X
8cddda4852f046e3bf2db7157d272263--b7f8699118c4462f8c7d061b709dc8d8
b7f8699118c4462f8c7d061b709dc8d8--02d0e1853ae445c3b0e279056b16dbb7
318a8ffcda494455b2084fec74990394
Z
b7f8699118c4462f8c7d061b709dc8d8--318a8ffcda494455b2084fec74990394
318a8ffcda494455b2084fec74990394--fdd60530eed84e3b8f81541c0843ce32
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
vparams_values = model . vparams
nu m_vparams = 1
vparams_values = OrderedDic t ( [ (' t he ta ' , tens or( [ 0.5877 ] )) ] )
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.5120+0.0000 j , 0.4999+0.0000 j , 0.0000-0.4999 j , 0.0000-0.4880 j ],
[ 0.5607+0.0000 j , 0.4963+0.0000 j , 0.0000-0.4963 j , 0.0000-0.4393 j ],
[ 0.6286+0.0000 j , 0.4832+0.0000 j , 0.0000-0.4832 j , 0.0000-0.3714 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
d5167ed6781f4657b712237b1f1458ca
0
d94436daee0b4f7cbe6390310691f67a
RX(theta₀)
d5167ed6781f4657b712237b1f1458ca--d94436daee0b4f7cbe6390310691f67a
f78569cac8bf400ea9baabef513ca989
1
72d22cce8dd94a8d806104f6807b9cc6
RY(theta₄)
d94436daee0b4f7cbe6390310691f67a--72d22cce8dd94a8d806104f6807b9cc6
692e667b0ebf4efbbff91a05b5ec4062
RX(theta₈)
72d22cce8dd94a8d806104f6807b9cc6--692e667b0ebf4efbbff91a05b5ec4062
36ae858633c84217b3762b41fdda25f9
692e667b0ebf4efbbff91a05b5ec4062--36ae858633c84217b3762b41fdda25f9
bf311995dc2543489b03f20a95ed7989
36ae858633c84217b3762b41fdda25f9--bf311995dc2543489b03f20a95ed7989
84f440949693450f9c2ce552d9c71802
RX(theta₁₂)
bf311995dc2543489b03f20a95ed7989--84f440949693450f9c2ce552d9c71802
0d461be963ce43d19aacb68c4eef2b4f
RY(theta₁₆)
84f440949693450f9c2ce552d9c71802--0d461be963ce43d19aacb68c4eef2b4f
e03777dbf577408a8cf6178ae4986813
RX(theta₂₀)
0d461be963ce43d19aacb68c4eef2b4f--e03777dbf577408a8cf6178ae4986813
b9174aaa801b4e3abb06467e71aa3b62
e03777dbf577408a8cf6178ae4986813--b9174aaa801b4e3abb06467e71aa3b62
308dd9ec07e54ab7b4fce0f020b50f05
b9174aaa801b4e3abb06467e71aa3b62--308dd9ec07e54ab7b4fce0f020b50f05
0e2bb46c9a374efabed3e0ae56b389e8
308dd9ec07e54ab7b4fce0f020b50f05--0e2bb46c9a374efabed3e0ae56b389e8
5accdd84b66246adade8608f216ad10c
72c64d3a812e4c4390292a112bea8fa2
RX(theta₁)
f78569cac8bf400ea9baabef513ca989--72c64d3a812e4c4390292a112bea8fa2
88316228578347c8bc2284849515ba5a
2
a486b383464c4dbb86867a26d774137d
RY(theta₅)
72c64d3a812e4c4390292a112bea8fa2--a486b383464c4dbb86867a26d774137d
1612f29f85214f929f22e9a75f7aef46
RX(theta₉)
a486b383464c4dbb86867a26d774137d--1612f29f85214f929f22e9a75f7aef46
20c52924fdca48f3a70fdb7161bf0041
X
1612f29f85214f929f22e9a75f7aef46--20c52924fdca48f3a70fdb7161bf0041
20c52924fdca48f3a70fdb7161bf0041--36ae858633c84217b3762b41fdda25f9
2e70fb4a5e5a456e88e21f025cf167f5
20c52924fdca48f3a70fdb7161bf0041--2e70fb4a5e5a456e88e21f025cf167f5
1d08f6ea90f640d9a5c95354acf51e8a
RX(theta₁₃)
2e70fb4a5e5a456e88e21f025cf167f5--1d08f6ea90f640d9a5c95354acf51e8a
1cdfdf17f34b4a1d8dbd4f90ae3002b6
RY(theta₁₇)
1d08f6ea90f640d9a5c95354acf51e8a--1cdfdf17f34b4a1d8dbd4f90ae3002b6
36214872224c4293bf9c299e6396a8df
RX(theta₂₁)
1cdfdf17f34b4a1d8dbd4f90ae3002b6--36214872224c4293bf9c299e6396a8df
6bcf102010ea4db0a5fd9ec702836113
X
36214872224c4293bf9c299e6396a8df--6bcf102010ea4db0a5fd9ec702836113
6bcf102010ea4db0a5fd9ec702836113--b9174aaa801b4e3abb06467e71aa3b62
aba773bdebd34e9295fd53a02413ca57
6bcf102010ea4db0a5fd9ec702836113--aba773bdebd34e9295fd53a02413ca57
aba773bdebd34e9295fd53a02413ca57--5accdd84b66246adade8608f216ad10c
0de53a4546c543419d21013d33d3f2eb
9498aa83ff554fc2949694449f328abf
RX(theta₂)
88316228578347c8bc2284849515ba5a--9498aa83ff554fc2949694449f328abf
1a44c3b40ba64b2480a38784aa8164e6
3
564ed21308334885939f72934892fa10
RY(theta₆)
9498aa83ff554fc2949694449f328abf--564ed21308334885939f72934892fa10
aec891bd01d24d9fabd3b51d21dc2903
RX(theta₁₀)
564ed21308334885939f72934892fa10--aec891bd01d24d9fabd3b51d21dc2903
38ab3c828ddf45d58fff34efca36c14b
aec891bd01d24d9fabd3b51d21dc2903--38ab3c828ddf45d58fff34efca36c14b
28920e1cb7f24384a4df697b66e7c669
X
38ab3c828ddf45d58fff34efca36c14b--28920e1cb7f24384a4df697b66e7c669
28920e1cb7f24384a4df697b66e7c669--2e70fb4a5e5a456e88e21f025cf167f5
45167288c658447596943efbe37d488e
RX(theta₁₄)
28920e1cb7f24384a4df697b66e7c669--45167288c658447596943efbe37d488e
107d2d2df5f04c3181c531c10c2e6a62
RY(theta₁₈)
45167288c658447596943efbe37d488e--107d2d2df5f04c3181c531c10c2e6a62
9720901b2bc0409cb0f9668a372ca20e
RX(theta₂₂)
107d2d2df5f04c3181c531c10c2e6a62--9720901b2bc0409cb0f9668a372ca20e
591e6b875dc049ea9e86b310931d9eb5
9720901b2bc0409cb0f9668a372ca20e--591e6b875dc049ea9e86b310931d9eb5
adb40f25b9c74d8ca49a96d8e29abbf3
X
591e6b875dc049ea9e86b310931d9eb5--adb40f25b9c74d8ca49a96d8e29abbf3
adb40f25b9c74d8ca49a96d8e29abbf3--aba773bdebd34e9295fd53a02413ca57
adb40f25b9c74d8ca49a96d8e29abbf3--0de53a4546c543419d21013d33d3f2eb
5442d2420af240ca9ca2a08bbd65123b
e907de8905394eb4bd9b0bb5bf819ab6
RX(theta₃)
1a44c3b40ba64b2480a38784aa8164e6--e907de8905394eb4bd9b0bb5bf819ab6
b6063291b3054fb8ab5cf490647cdfa4
RY(theta₇)
e907de8905394eb4bd9b0bb5bf819ab6--b6063291b3054fb8ab5cf490647cdfa4
485e7f5f07674ad4aa21eb163fd7c128
RX(theta₁₁)
b6063291b3054fb8ab5cf490647cdfa4--485e7f5f07674ad4aa21eb163fd7c128
92edbfb993c744138182e47ce5eb1a0b
X
485e7f5f07674ad4aa21eb163fd7c128--92edbfb993c744138182e47ce5eb1a0b
92edbfb993c744138182e47ce5eb1a0b--38ab3c828ddf45d58fff34efca36c14b
135c10ee8517457c868b5d9c7f965654
92edbfb993c744138182e47ce5eb1a0b--135c10ee8517457c868b5d9c7f965654
b04c979f4bd6411788ac5f8655138876
RX(theta₁₅)
135c10ee8517457c868b5d9c7f965654--b04c979f4bd6411788ac5f8655138876
a8e262d3469449ca85f24b9ed71edb61
RY(theta₁₉)
b04c979f4bd6411788ac5f8655138876--a8e262d3469449ca85f24b9ed71edb61
a8b40ec7ce7f4ba1a94daa4207fbcf1a
RX(theta₂₃)
a8e262d3469449ca85f24b9ed71edb61--a8b40ec7ce7f4ba1a94daa4207fbcf1a
72f165be21c24f7bada297f8f2c2d70e
X
a8b40ec7ce7f4ba1a94daa4207fbcf1a--72f165be21c24f7bada297f8f2c2d70e
72f165be21c24f7bada297f8f2c2d70e--591e6b875dc049ea9e86b310931d9eb5
b090a1496ca5464b8b47d08fd9ff5f7d
72f165be21c24f7bada297f8f2c2d70e--b090a1496ca5464b8b47d08fd9ff5f7d
b090a1496ca5464b8b47d08fd9ff5f7d--5442d2420af240ca9ca2a08bbd65123b
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_b924c21c82eb4131a8d257a08347232c
HEA
cluster_545d65bc026d49218972c434c0f97232
HEA
76694ae0e41441fc8af5f35105555645
0
8d633546120846c6991c314dc50929a0
RX(theta₀)
76694ae0e41441fc8af5f35105555645--8d633546120846c6991c314dc50929a0
b7392b6a3b3a4ae3ab7ced806f19653b
1
9f8ad03c691c488780e1496ac3808109
RY(theta₄)
8d633546120846c6991c314dc50929a0--9f8ad03c691c488780e1496ac3808109
e3f5b41c82d54da395b3f05c660498c0
RX(theta₈)
9f8ad03c691c488780e1496ac3808109--e3f5b41c82d54da395b3f05c660498c0
1e1ebb8384c047078a1e3ac8cfb4cdde
e3f5b41c82d54da395b3f05c660498c0--1e1ebb8384c047078a1e3ac8cfb4cdde
27e1b36fef0643eda9e0a4c91e10303e
1e1ebb8384c047078a1e3ac8cfb4cdde--27e1b36fef0643eda9e0a4c91e10303e
6613972cbd384d77a48a2670a82f3f5e
RX(theta₁₂)
27e1b36fef0643eda9e0a4c91e10303e--6613972cbd384d77a48a2670a82f3f5e
85985fd5cf5940a4aa387723e157ab35
RY(theta₁₆)
6613972cbd384d77a48a2670a82f3f5e--85985fd5cf5940a4aa387723e157ab35
fec5029c63304f74a245a4983df350ea
RX(theta₂₀)
85985fd5cf5940a4aa387723e157ab35--fec5029c63304f74a245a4983df350ea
ba141aabbaad4fddbd443774b289d191
fec5029c63304f74a245a4983df350ea--ba141aabbaad4fddbd443774b289d191
86e298fcdf8849498209838766147a16
ba141aabbaad4fddbd443774b289d191--86e298fcdf8849498209838766147a16
11d3c7fdedf94827a1a9097772ffc7a4
RX(theta₀)
86e298fcdf8849498209838766147a16--11d3c7fdedf94827a1a9097772ffc7a4
939f2f30f4154309a8693e43a9e8bb3c
RY(theta₄)
11d3c7fdedf94827a1a9097772ffc7a4--939f2f30f4154309a8693e43a9e8bb3c
5384be70eec44c0782e69155699c65e9
RX(theta₈)
939f2f30f4154309a8693e43a9e8bb3c--5384be70eec44c0782e69155699c65e9
9972d794909e4d8c82cb1b7ec41c3045
5384be70eec44c0782e69155699c65e9--9972d794909e4d8c82cb1b7ec41c3045
3c30311c47854cb1b311a7a81f7964f0
9972d794909e4d8c82cb1b7ec41c3045--3c30311c47854cb1b311a7a81f7964f0
0fcd3c550c6b4cb893063205d7e4207c
RX(theta₁₂)
3c30311c47854cb1b311a7a81f7964f0--0fcd3c550c6b4cb893063205d7e4207c
08ed3c90b9544e4e8d2c2c4d7f26cb1f
RY(theta₁₆)
0fcd3c550c6b4cb893063205d7e4207c--08ed3c90b9544e4e8d2c2c4d7f26cb1f
e90d6ca0e7b64d60850365b97118f083
RX(theta₂₀)
08ed3c90b9544e4e8d2c2c4d7f26cb1f--e90d6ca0e7b64d60850365b97118f083
b8dd6c5a8d3f409e84d874b4335dbc9a
e90d6ca0e7b64d60850365b97118f083--b8dd6c5a8d3f409e84d874b4335dbc9a
3d90109f5acb4c8c8f03bcae2e066da4
b8dd6c5a8d3f409e84d874b4335dbc9a--3d90109f5acb4c8c8f03bcae2e066da4
008ce57bc0124932bc0f5d979e2bc48d
3d90109f5acb4c8c8f03bcae2e066da4--008ce57bc0124932bc0f5d979e2bc48d
b3266cde736e4674ae8d77e2944c7b51
eeb8f2c5a26b475a9983e003d3418d70
RX(theta₁)
b7392b6a3b3a4ae3ab7ced806f19653b--eeb8f2c5a26b475a9983e003d3418d70
9b07d92092e04d08bb99fe629c33538b
2
17ab949f3cf44fe3a48250b289f97130
RY(theta₅)
eeb8f2c5a26b475a9983e003d3418d70--17ab949f3cf44fe3a48250b289f97130
dcc85672d23f40f1a46973ddbd0e436d
RX(theta₉)
17ab949f3cf44fe3a48250b289f97130--dcc85672d23f40f1a46973ddbd0e436d
939a131f6e7346e6b4f8af57098dc902
X
dcc85672d23f40f1a46973ddbd0e436d--939a131f6e7346e6b4f8af57098dc902
939a131f6e7346e6b4f8af57098dc902--1e1ebb8384c047078a1e3ac8cfb4cdde
ca6b6d9ce45f48798ef439fd9a4524ff
939a131f6e7346e6b4f8af57098dc902--ca6b6d9ce45f48798ef439fd9a4524ff
9859338385d04d409b16af62aad6398c
RX(theta₁₃)
ca6b6d9ce45f48798ef439fd9a4524ff--9859338385d04d409b16af62aad6398c
216fe31bb3be44e688c663b37a3b8add
RY(theta₁₇)
9859338385d04d409b16af62aad6398c--216fe31bb3be44e688c663b37a3b8add
eefbe05d15f04e48852171048a1d309a
RX(theta₂₁)
216fe31bb3be44e688c663b37a3b8add--eefbe05d15f04e48852171048a1d309a
c9b9fb7804e449ef9c1e32603047813c
X
eefbe05d15f04e48852171048a1d309a--c9b9fb7804e449ef9c1e32603047813c
c9b9fb7804e449ef9c1e32603047813c--ba141aabbaad4fddbd443774b289d191
7d99d31133d1480b8d1f8517825e8477
c9b9fb7804e449ef9c1e32603047813c--7d99d31133d1480b8d1f8517825e8477
b74b522aabaa49ddbb0850d3b8975c01
RX(theta₁)
7d99d31133d1480b8d1f8517825e8477--b74b522aabaa49ddbb0850d3b8975c01
ef781d8b6fe54526bac5ae04bbad89c0
RY(theta₅)
b74b522aabaa49ddbb0850d3b8975c01--ef781d8b6fe54526bac5ae04bbad89c0
45a11cecdc824eaeb34b8ef03873518e
RX(theta₉)
ef781d8b6fe54526bac5ae04bbad89c0--45a11cecdc824eaeb34b8ef03873518e
8e90824967ed4143845ec02614a2d71a
X
45a11cecdc824eaeb34b8ef03873518e--8e90824967ed4143845ec02614a2d71a
8e90824967ed4143845ec02614a2d71a--9972d794909e4d8c82cb1b7ec41c3045
3142dee86a484ed5a582d2417f08889e
8e90824967ed4143845ec02614a2d71a--3142dee86a484ed5a582d2417f08889e
61bafe56377145079c4be6dd78a9aeb5
RX(theta₁₃)
3142dee86a484ed5a582d2417f08889e--61bafe56377145079c4be6dd78a9aeb5
c644ffe695524a84b1d2b35b710678ba
RY(theta₁₇)
61bafe56377145079c4be6dd78a9aeb5--c644ffe695524a84b1d2b35b710678ba
b4312ba07f384b53b41eeea153df4847
RX(theta₂₁)
c644ffe695524a84b1d2b35b710678ba--b4312ba07f384b53b41eeea153df4847
4b59923e6295477ab20413ddfcae5d89
X
b4312ba07f384b53b41eeea153df4847--4b59923e6295477ab20413ddfcae5d89
4b59923e6295477ab20413ddfcae5d89--b8dd6c5a8d3f409e84d874b4335dbc9a
30ca64651e0c40dea93d6b3cb948645d
4b59923e6295477ab20413ddfcae5d89--30ca64651e0c40dea93d6b3cb948645d
30ca64651e0c40dea93d6b3cb948645d--b3266cde736e4674ae8d77e2944c7b51
980c8406e6144904b6f1b9f1f7100f89
7be5f9504ae846a48c82fe7cdbd6ab8c
RX(theta₂)
9b07d92092e04d08bb99fe629c33538b--7be5f9504ae846a48c82fe7cdbd6ab8c
be79263194f3407899d10e9798371d82
3
92cb6a557e09418bbda40b0ab1c8ffeb
RY(theta₆)
7be5f9504ae846a48c82fe7cdbd6ab8c--92cb6a557e09418bbda40b0ab1c8ffeb
8570c0179f454a69b0c286233eac4ae5
RX(theta₁₀)
92cb6a557e09418bbda40b0ab1c8ffeb--8570c0179f454a69b0c286233eac4ae5
3d4a18a0d18a4d4abf6e74914da89baf
8570c0179f454a69b0c286233eac4ae5--3d4a18a0d18a4d4abf6e74914da89baf
0e7972f87fed415aba27f155adbf5b2f
X
3d4a18a0d18a4d4abf6e74914da89baf--0e7972f87fed415aba27f155adbf5b2f
0e7972f87fed415aba27f155adbf5b2f--ca6b6d9ce45f48798ef439fd9a4524ff
deb1406c84d14490a017dfd45e464713
RX(theta₁₄)
0e7972f87fed415aba27f155adbf5b2f--deb1406c84d14490a017dfd45e464713
8b651f12c22e4d03b836c38cdcfa2966
RY(theta₁₈)
deb1406c84d14490a017dfd45e464713--8b651f12c22e4d03b836c38cdcfa2966
a939625a2fd74b44ac216760b333dd11
RX(theta₂₂)
8b651f12c22e4d03b836c38cdcfa2966--a939625a2fd74b44ac216760b333dd11
14c1474635a54bfcaa5db2047b82a826
a939625a2fd74b44ac216760b333dd11--14c1474635a54bfcaa5db2047b82a826
9788a2b2fab74a5fa7f0775f24938948
X
14c1474635a54bfcaa5db2047b82a826--9788a2b2fab74a5fa7f0775f24938948
9788a2b2fab74a5fa7f0775f24938948--7d99d31133d1480b8d1f8517825e8477
2e31172eef33406f8c845dabe1fcd0be
RX(theta₂)
9788a2b2fab74a5fa7f0775f24938948--2e31172eef33406f8c845dabe1fcd0be
bca6115a9a99440aa70371ad5f371da4
RY(theta₆)
2e31172eef33406f8c845dabe1fcd0be--bca6115a9a99440aa70371ad5f371da4
09679d5705684d9ba3c7cc5785cf802b
RX(theta₁₀)
bca6115a9a99440aa70371ad5f371da4--09679d5705684d9ba3c7cc5785cf802b
1d32c7f3459341c6a93575b303515dea
09679d5705684d9ba3c7cc5785cf802b--1d32c7f3459341c6a93575b303515dea
1ae5f9c286df45a990104905040e7f03
X
1d32c7f3459341c6a93575b303515dea--1ae5f9c286df45a990104905040e7f03
1ae5f9c286df45a990104905040e7f03--3142dee86a484ed5a582d2417f08889e
92b412cdc3d2407aabad68414c0bb5b7
RX(theta₁₄)
1ae5f9c286df45a990104905040e7f03--92b412cdc3d2407aabad68414c0bb5b7
f8652de0b4d94922aad1f985d3a58585
RY(theta₁₈)
92b412cdc3d2407aabad68414c0bb5b7--f8652de0b4d94922aad1f985d3a58585
6fa2101fe65046eba0f878ae2444556d
RX(theta₂₂)
f8652de0b4d94922aad1f985d3a58585--6fa2101fe65046eba0f878ae2444556d
8d25a06990f24d3e87c34255d3755a5b
6fa2101fe65046eba0f878ae2444556d--8d25a06990f24d3e87c34255d3755a5b
0d0a3a5745bb4f94a87b06ee7c373d43
X
8d25a06990f24d3e87c34255d3755a5b--0d0a3a5745bb4f94a87b06ee7c373d43
0d0a3a5745bb4f94a87b06ee7c373d43--30ca64651e0c40dea93d6b3cb948645d
0d0a3a5745bb4f94a87b06ee7c373d43--980c8406e6144904b6f1b9f1f7100f89
650a511877f845e09a084ba71e84b1b2
08fa5f5707624e799a6456ca57ae5469
RX(theta₃)
be79263194f3407899d10e9798371d82--08fa5f5707624e799a6456ca57ae5469
de43c1e7cc034b43865c31120be007bc
RY(theta₇)
08fa5f5707624e799a6456ca57ae5469--de43c1e7cc034b43865c31120be007bc
5cf38f6a44484928becdd157325dbae4
RX(theta₁₁)
de43c1e7cc034b43865c31120be007bc--5cf38f6a44484928becdd157325dbae4
e3aed8126c6b40f497d7294fea15e96f
X
5cf38f6a44484928becdd157325dbae4--e3aed8126c6b40f497d7294fea15e96f
e3aed8126c6b40f497d7294fea15e96f--3d4a18a0d18a4d4abf6e74914da89baf
78ae3dd6b34a4351aad6123e9902f08d
e3aed8126c6b40f497d7294fea15e96f--78ae3dd6b34a4351aad6123e9902f08d
1277a4995b3c486f9527003857d598fe
RX(theta₁₅)
78ae3dd6b34a4351aad6123e9902f08d--1277a4995b3c486f9527003857d598fe
8eb74ed79d4c4213984c9ca8d2237a43
RY(theta₁₉)
1277a4995b3c486f9527003857d598fe--8eb74ed79d4c4213984c9ca8d2237a43
c4e9bd004383403b83ca95c4d2af66ad
RX(theta₂₃)
8eb74ed79d4c4213984c9ca8d2237a43--c4e9bd004383403b83ca95c4d2af66ad
b53918881f154e57bffd96c3376a2f95
X
c4e9bd004383403b83ca95c4d2af66ad--b53918881f154e57bffd96c3376a2f95
b53918881f154e57bffd96c3376a2f95--14c1474635a54bfcaa5db2047b82a826
77ca20abbb534438a02ed45475b56327
b53918881f154e57bffd96c3376a2f95--77ca20abbb534438a02ed45475b56327
195f673d8bc64252b67a482176b35161
RX(theta₃)
77ca20abbb534438a02ed45475b56327--195f673d8bc64252b67a482176b35161
047b0aa1fb1f447a97982b22accd6037
RY(theta₇)
195f673d8bc64252b67a482176b35161--047b0aa1fb1f447a97982b22accd6037
26bada4fc0a6447a8a4ddd5843ebe755
RX(theta₁₁)
047b0aa1fb1f447a97982b22accd6037--26bada4fc0a6447a8a4ddd5843ebe755
e0485df024b840928784f5a626633bdc
X
26bada4fc0a6447a8a4ddd5843ebe755--e0485df024b840928784f5a626633bdc
e0485df024b840928784f5a626633bdc--1d32c7f3459341c6a93575b303515dea
656f093e75fb4bd5a048dfcb61dd767b
e0485df024b840928784f5a626633bdc--656f093e75fb4bd5a048dfcb61dd767b
9ceb74ab735f44a5b40a674099baf6aa
RX(theta₁₅)
656f093e75fb4bd5a048dfcb61dd767b--9ceb74ab735f44a5b40a674099baf6aa
c0c30305470b4fd499241ef62fa34efd
RY(theta₁₉)
9ceb74ab735f44a5b40a674099baf6aa--c0c30305470b4fd499241ef62fa34efd
49bc51ee22c54305a3a740c2ad249758
RX(theta₂₃)
c0c30305470b4fd499241ef62fa34efd--49bc51ee22c54305a3a740c2ad249758
61baeacafab7454f87ffab62e0aeb0d2
X
49bc51ee22c54305a3a740c2ad249758--61baeacafab7454f87ffab62e0aeb0d2
61baeacafab7454f87ffab62e0aeb0d2--8d25a06990f24d3e87c34255d3755a5b
5767c5f9f277407996cc344b24a81a7e
61baeacafab7454f87ffab62e0aeb0d2--5767c5f9f277407996cc344b24a81a7e
5767c5f9f277407996cc344b24a81a7e--650a511877f845e09a084ba71e84b1b2
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_f9f55d8d1b4c45b687b01c4e9b9aa155
HEA
cluster_47f2a42a0e3c4f7db8ec63ec1bb6bdce
HEA
0ec53a4273914a828235db6ae44a30fe
0
041d85740f234842865a1e577d257ae9
RX(p1₀)
0ec53a4273914a828235db6ae44a30fe--041d85740f234842865a1e577d257ae9
845ca2c0dc3e42c48416c923d8e181e8
1
33bd735c4b9b4ecf88b401a6594b2971
RY(p1₄)
041d85740f234842865a1e577d257ae9--33bd735c4b9b4ecf88b401a6594b2971
6dff6a0f78d34a8b8ca6167ba2482ec6
RX(p1₈)
33bd735c4b9b4ecf88b401a6594b2971--6dff6a0f78d34a8b8ca6167ba2482ec6
3cd557c0b68b45b4b51663bdeb2ad51c
6dff6a0f78d34a8b8ca6167ba2482ec6--3cd557c0b68b45b4b51663bdeb2ad51c
5acf2b9392e1463ca74bb57542e4c203
3cd557c0b68b45b4b51663bdeb2ad51c--5acf2b9392e1463ca74bb57542e4c203
ea60d0979bc442fbb99291209e321570
RX(p1₁₂)
5acf2b9392e1463ca74bb57542e4c203--ea60d0979bc442fbb99291209e321570
d4a01ae63ed947be88574650ee269c62
RY(p1₁₆)
ea60d0979bc442fbb99291209e321570--d4a01ae63ed947be88574650ee269c62
a6129d595a814774ad9d2c31556091a8
RX(p1₂₀)
d4a01ae63ed947be88574650ee269c62--a6129d595a814774ad9d2c31556091a8
664624f0967a4bad911407888597880a
a6129d595a814774ad9d2c31556091a8--664624f0967a4bad911407888597880a
131f554e71c64f23953e2fad199aa2fb
664624f0967a4bad911407888597880a--131f554e71c64f23953e2fad199aa2fb
095e414f6df143d1bd47c8211f2a578a
RX(p2₀)
131f554e71c64f23953e2fad199aa2fb--095e414f6df143d1bd47c8211f2a578a
36b48812b2ba4d89941b717f81665735
RY(p2₄)
095e414f6df143d1bd47c8211f2a578a--36b48812b2ba4d89941b717f81665735
0d35f35891de4a4aa2f39eb98474eea0
RX(p2₈)
36b48812b2ba4d89941b717f81665735--0d35f35891de4a4aa2f39eb98474eea0
7c7cf0f4524249faaf4859666fc917eb
0d35f35891de4a4aa2f39eb98474eea0--7c7cf0f4524249faaf4859666fc917eb
0d8eecf1c2b644b4b4c21edae69e3217
7c7cf0f4524249faaf4859666fc917eb--0d8eecf1c2b644b4b4c21edae69e3217
f9cc746e44774639becc94f3d8e0fb0c
RX(p2₁₂)
0d8eecf1c2b644b4b4c21edae69e3217--f9cc746e44774639becc94f3d8e0fb0c
63458814eca54ce396eea3ddccc800eb
RY(p2₁₆)
f9cc746e44774639becc94f3d8e0fb0c--63458814eca54ce396eea3ddccc800eb
3c2c7bcb0df6471fbb9353380a559e1e
RX(p2₂₀)
63458814eca54ce396eea3ddccc800eb--3c2c7bcb0df6471fbb9353380a559e1e
5543155317344a258654a714fa77b1e4
3c2c7bcb0df6471fbb9353380a559e1e--5543155317344a258654a714fa77b1e4
adcb28dcd1674908ae5df32fa1901a11
5543155317344a258654a714fa77b1e4--adcb28dcd1674908ae5df32fa1901a11
12e6c67995ac4fd0bc85c5c96cb01a8a
adcb28dcd1674908ae5df32fa1901a11--12e6c67995ac4fd0bc85c5c96cb01a8a
cb5588a336014bf8a828c4baab297b62
301d0d7d2e884b79b5c89ca2aea0d286
RX(p1₁)
845ca2c0dc3e42c48416c923d8e181e8--301d0d7d2e884b79b5c89ca2aea0d286
de32d384661743c9a9398b4a957551db
2
b1d0bf2c17fa4118be7238cba05259f2
RY(p1₅)
301d0d7d2e884b79b5c89ca2aea0d286--b1d0bf2c17fa4118be7238cba05259f2
683b0bd5540349c88961a842ac1dc64e
RX(p1₉)
b1d0bf2c17fa4118be7238cba05259f2--683b0bd5540349c88961a842ac1dc64e
7c5387845c504067a4633d524c1fb68c
X
683b0bd5540349c88961a842ac1dc64e--7c5387845c504067a4633d524c1fb68c
7c5387845c504067a4633d524c1fb68c--3cd557c0b68b45b4b51663bdeb2ad51c
a1d4b8577c3a42dca9b33591f50f6b49
7c5387845c504067a4633d524c1fb68c--a1d4b8577c3a42dca9b33591f50f6b49
9a3953048ec04b9184d52cc0e8bbfa05
RX(p1₁₃)
a1d4b8577c3a42dca9b33591f50f6b49--9a3953048ec04b9184d52cc0e8bbfa05
17f64733d5354f1eb9cc3d903b15f002
RY(p1₁₇)
9a3953048ec04b9184d52cc0e8bbfa05--17f64733d5354f1eb9cc3d903b15f002
2404ab2e1dab4459bfbfac28257866b2
RX(p1₂₁)
17f64733d5354f1eb9cc3d903b15f002--2404ab2e1dab4459bfbfac28257866b2
3c028e4ac40b4638b551f6f81d8875f4
X
2404ab2e1dab4459bfbfac28257866b2--3c028e4ac40b4638b551f6f81d8875f4
3c028e4ac40b4638b551f6f81d8875f4--664624f0967a4bad911407888597880a
818dd1e9bf4446169511a2d6c5d537b5
3c028e4ac40b4638b551f6f81d8875f4--818dd1e9bf4446169511a2d6c5d537b5
48a5ce41dedd466db66ef2f044100d67
RX(p2₁)
818dd1e9bf4446169511a2d6c5d537b5--48a5ce41dedd466db66ef2f044100d67
1423f273779a487f9a2bb156378f2b9e
RY(p2₅)
48a5ce41dedd466db66ef2f044100d67--1423f273779a487f9a2bb156378f2b9e
fefa2c11baaa4045a698521c60302e36
RX(p2₉)
1423f273779a487f9a2bb156378f2b9e--fefa2c11baaa4045a698521c60302e36
8d3a63e19dc040edbc2c71467d9f9222
X
fefa2c11baaa4045a698521c60302e36--8d3a63e19dc040edbc2c71467d9f9222
8d3a63e19dc040edbc2c71467d9f9222--7c7cf0f4524249faaf4859666fc917eb
4fd7d4bb8c3549c69b5ac40aa42579cf
8d3a63e19dc040edbc2c71467d9f9222--4fd7d4bb8c3549c69b5ac40aa42579cf
073eab547457465bbf2cdbb71ca55835
RX(p2₁₃)
4fd7d4bb8c3549c69b5ac40aa42579cf--073eab547457465bbf2cdbb71ca55835
9b162a8f2c1247f9b0d47197eca2863c
RY(p2₁₇)
073eab547457465bbf2cdbb71ca55835--9b162a8f2c1247f9b0d47197eca2863c
866068338bd84ac2b208f7c99c01cdef
RX(p2₂₁)
9b162a8f2c1247f9b0d47197eca2863c--866068338bd84ac2b208f7c99c01cdef
61751f448833468e9069938cbd2a1234
X
866068338bd84ac2b208f7c99c01cdef--61751f448833468e9069938cbd2a1234
61751f448833468e9069938cbd2a1234--5543155317344a258654a714fa77b1e4
eb7aca270b3c44e695ae7982599faa1d
61751f448833468e9069938cbd2a1234--eb7aca270b3c44e695ae7982599faa1d
eb7aca270b3c44e695ae7982599faa1d--cb5588a336014bf8a828c4baab297b62
1c49ee8ea3f641b888dee22981c9072e
7d56fb2644934d289b6ab4c67232ec43
RX(p1₂)
de32d384661743c9a9398b4a957551db--7d56fb2644934d289b6ab4c67232ec43
dc29528873cc442088e86d66a6285d84
3
3ecd5435b58d48c0bb3cc1c038a4c8bf
RY(p1₆)
7d56fb2644934d289b6ab4c67232ec43--3ecd5435b58d48c0bb3cc1c038a4c8bf
7b6688ef86794494a09d3cf64f0442cc
RX(p1₁₀)
3ecd5435b58d48c0bb3cc1c038a4c8bf--7b6688ef86794494a09d3cf64f0442cc
2e265de3b16f4500b3c87cb4cc9133e5
7b6688ef86794494a09d3cf64f0442cc--2e265de3b16f4500b3c87cb4cc9133e5
05f7bdee1f9745b88679570c6efa3f42
X
2e265de3b16f4500b3c87cb4cc9133e5--05f7bdee1f9745b88679570c6efa3f42
05f7bdee1f9745b88679570c6efa3f42--a1d4b8577c3a42dca9b33591f50f6b49
bcce1cda88fa4a19abffa8106430ab98
RX(p1₁₄)
05f7bdee1f9745b88679570c6efa3f42--bcce1cda88fa4a19abffa8106430ab98
cf00386d66bb49f99d423d033fe51a31
RY(p1₁₈)
bcce1cda88fa4a19abffa8106430ab98--cf00386d66bb49f99d423d033fe51a31
a1f111161a0e413592b08d3daac3aea5
RX(p1₂₂)
cf00386d66bb49f99d423d033fe51a31--a1f111161a0e413592b08d3daac3aea5
10328d2cd3944bc795a3aa43cb43baec
a1f111161a0e413592b08d3daac3aea5--10328d2cd3944bc795a3aa43cb43baec
72e2d199a86040c1ba66783178a88f01
X
10328d2cd3944bc795a3aa43cb43baec--72e2d199a86040c1ba66783178a88f01
72e2d199a86040c1ba66783178a88f01--818dd1e9bf4446169511a2d6c5d537b5
b58d0d9c7bcd49bb9619c6771d4869d6
RX(p2₂)
72e2d199a86040c1ba66783178a88f01--b58d0d9c7bcd49bb9619c6771d4869d6
960bcc87ccf045fd91d44134775f59dc
RY(p2₆)
b58d0d9c7bcd49bb9619c6771d4869d6--960bcc87ccf045fd91d44134775f59dc
8521d3f99b384a5b85b9b51ab39335e1
RX(p2₁₀)
960bcc87ccf045fd91d44134775f59dc--8521d3f99b384a5b85b9b51ab39335e1
ce5caf4492f74d78a35f4b948cc6c06c
8521d3f99b384a5b85b9b51ab39335e1--ce5caf4492f74d78a35f4b948cc6c06c
926b66f8ed9646a389e9d6afaa3f359a
X
ce5caf4492f74d78a35f4b948cc6c06c--926b66f8ed9646a389e9d6afaa3f359a
926b66f8ed9646a389e9d6afaa3f359a--4fd7d4bb8c3549c69b5ac40aa42579cf
2d83338c96ac4b5fad9afde06546282f
RX(p2₁₄)
926b66f8ed9646a389e9d6afaa3f359a--2d83338c96ac4b5fad9afde06546282f
2a997929f83248f091fbfb0af58ee884
RY(p2₁₈)
2d83338c96ac4b5fad9afde06546282f--2a997929f83248f091fbfb0af58ee884
34ad3f568f3a4513929c1e717c1629d6
RX(p2₂₂)
2a997929f83248f091fbfb0af58ee884--34ad3f568f3a4513929c1e717c1629d6
111a2b68c61741709ab93f7e959afec6
34ad3f568f3a4513929c1e717c1629d6--111a2b68c61741709ab93f7e959afec6
d422c08844bf4bdc99cf320f5667e359
X
111a2b68c61741709ab93f7e959afec6--d422c08844bf4bdc99cf320f5667e359
d422c08844bf4bdc99cf320f5667e359--eb7aca270b3c44e695ae7982599faa1d
d422c08844bf4bdc99cf320f5667e359--1c49ee8ea3f641b888dee22981c9072e
c484b45799eb4f0c9b89c04c0eadaa47
ed9aa5c9b58c4744840bc6b7ec02b421
RX(p1₃)
dc29528873cc442088e86d66a6285d84--ed9aa5c9b58c4744840bc6b7ec02b421
e2c3158893184d08b666d78c575809d2
RY(p1₇)
ed9aa5c9b58c4744840bc6b7ec02b421--e2c3158893184d08b666d78c575809d2
399e562deb834803808b37c7a8825d85
RX(p1₁₁)
e2c3158893184d08b666d78c575809d2--399e562deb834803808b37c7a8825d85
60a5c3f8e7c14c1d87dbfa8eb2507be1
X
399e562deb834803808b37c7a8825d85--60a5c3f8e7c14c1d87dbfa8eb2507be1
60a5c3f8e7c14c1d87dbfa8eb2507be1--2e265de3b16f4500b3c87cb4cc9133e5
5749b512d1dd44099563f67e6363b5d3
60a5c3f8e7c14c1d87dbfa8eb2507be1--5749b512d1dd44099563f67e6363b5d3
cc14f4007df64ba3b6d7103bdf75c9fd
RX(p1₁₅)
5749b512d1dd44099563f67e6363b5d3--cc14f4007df64ba3b6d7103bdf75c9fd
7ebbb378a05545d3b711095ab33e5a84
RY(p1₁₉)
cc14f4007df64ba3b6d7103bdf75c9fd--7ebbb378a05545d3b711095ab33e5a84
71277c19d18d40c5aa3fa25af92a1832
RX(p1₂₃)
7ebbb378a05545d3b711095ab33e5a84--71277c19d18d40c5aa3fa25af92a1832
e90a32d699dc42feae1bf3f86f98fdbc
X
71277c19d18d40c5aa3fa25af92a1832--e90a32d699dc42feae1bf3f86f98fdbc
e90a32d699dc42feae1bf3f86f98fdbc--10328d2cd3944bc795a3aa43cb43baec
f532ec89619b4db6944f5fd3e70400a1
e90a32d699dc42feae1bf3f86f98fdbc--f532ec89619b4db6944f5fd3e70400a1
b35db25755e04cc4ab3d3083c978b549
RX(p2₃)
f532ec89619b4db6944f5fd3e70400a1--b35db25755e04cc4ab3d3083c978b549
82edd62e5bd2481d9b309b21136038b9
RY(p2₇)
b35db25755e04cc4ab3d3083c978b549--82edd62e5bd2481d9b309b21136038b9
18791387395c4e3f9b2c88c9827884c1
RX(p2₁₁)
82edd62e5bd2481d9b309b21136038b9--18791387395c4e3f9b2c88c9827884c1
0504c4dbdf6e4279a96571f75078be2a
X
18791387395c4e3f9b2c88c9827884c1--0504c4dbdf6e4279a96571f75078be2a
0504c4dbdf6e4279a96571f75078be2a--ce5caf4492f74d78a35f4b948cc6c06c
d3a9fe86f96d4e739eb1c8e6877814fe
0504c4dbdf6e4279a96571f75078be2a--d3a9fe86f96d4e739eb1c8e6877814fe
7b9cbd733a4148be9eb5e14e81cd0f70
RX(p2₁₅)
d3a9fe86f96d4e739eb1c8e6877814fe--7b9cbd733a4148be9eb5e14e81cd0f70
d14b19d107e648dd9fddb19fb8fe016d
RY(p2₁₉)
7b9cbd733a4148be9eb5e14e81cd0f70--d14b19d107e648dd9fddb19fb8fe016d
7caa20c3696d4eeda78c3c438283df9c
RX(p2₂₃)
d14b19d107e648dd9fddb19fb8fe016d--7caa20c3696d4eeda78c3c438283df9c
079f6a52dae04498a2bc166968bec704
X
7caa20c3696d4eeda78c3c438283df9c--079f6a52dae04498a2bc166968bec704
079f6a52dae04498a2bc166968bec704--111a2b68c61741709ab93f7e959afec6
5fa150467eb24422b3218ff662bdbccd
079f6a52dae04498a2bc166968bec704--5fa150467eb24422b3218ff662bdbccd
5fa150467eb24422b3218ff662bdbccd--c484b45799eb4f0c9b89c04c0eadaa47
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.3775 ] )) , (' t he ta _ 0 ' , tens or( [ 0.4898 ] )) , (' t he ta _ 1 ' , tens or( [ 0.2495 ] )) , (' t he ta _ 10 ' , tens or( [ 0.7195 ] )) , (' t he ta _ 11 ' , tens or( [ 0.9956 ] )) , (' t he ta _ 12 ' , tens or( [ 0.9429 ] )) , (' t he ta _ 13 ' , tens or( [ 0.2319 ] )) , (' t he ta _ 14 ' , tens or( [ 0.9940 ] )) , (' t he ta _ 15 ' , tens or( [ 0.9964 ] )) , (' t he ta _ 16 ' , tens or( [ 0.6051 ] )) , (' t he ta _ 17 ' , tens or( [ 0.7252 ] )) , (' t he ta _ 18 ' , tens or( [ 0.3309 ] )) , (' t he ta _ 19 ' , tens or( [ 0.5177 ] )) , (' t he ta _ 2 ' , tens or( [ 0.2404 ] )) , (' t he ta _ 20 ' , tens or( [ 0.1400 ] )) , (' t he ta _ 21 ' , tens or( [ 0.8528 ] )) , (' t he ta _ 22 ' , tens or( [ 0.3188 ] )) , (' t he ta _ 23 ' , tens or( [ 0.2410 ] )) , (' t he ta _ 3 ' , tens or( [ 0.8505 ] )) , (' t he ta _ 4 ' , tens or( [ 0.2859 ] )) , (' t he ta _ 5 ' , tens or( [ 0.2913 ] )) , (' t he ta _ 6 ' , tens or( [ 0.4297 ] )) , (' t he ta _ 7 ' , tens or( [ 0.0077 ] )) , (' t he ta _ 8 ' , tens or( [ 0.4412 ] )) , (' t he ta _ 9 ' , tens or( [ 0.8012 ] )) ] )
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.3765 ] )) , (' t he ta _ 0 ' , tens or( [ 0.4908 ] )) , (' t he ta _ 1 ' , tens or( [ 0.2485 ] )) , (' t he ta _ 10 ' , tens or( [ 0.7205 ] )) , (' t he ta _ 11 ' , tens or( [ 0.9966 ] )) , (' t he ta _ 12 ' , tens or( [ 0.9439 ] )) , (' t he ta _ 13 ' , tens or( [ 0.2329 ] )) , (' t he ta _ 14 ' , tens or( [ 0.9930 ] )) , (' t he ta _ 15 ' , tens or( [ 0.9974 ] )) , (' t he ta _ 16 ' , tens or( [ 0.6061 ] )) , (' t he ta _ 17 ' , tens or( [ 0.7262 ] )) , (' t he ta _ 18 ' , tens or( [ 0.3319 ] )) , (' t he ta _ 19 ' , tens or( [ 0.5167 ] )) , (' t he ta _ 2 ' , tens or( [ 0.2414 ] )) , (' t he ta _ 20 ' , tens or( [ 0.1410 ] )) , (' t he ta _ 21 ' , tens or( [ 0.8538 ] )) , (' t he ta _ 22 ' , tens or( [ 0.3178 ] )) , (' t he ta _ 23 ' , tens or( [ 0.2420 ] )) , (' t he ta _ 3 ' , tens or( [ 0.8515 ] )) , (' t he ta _ 4 ' , tens or( [ 0.2869 ] )) , (' t he ta _ 5 ' , tens or( [ 0.2923 ] )) , (' t he ta _ 6 ' , tens or( [ 0.4307 ] )) , (' t he ta _ 7 ' , tens or( [ 0.0067 ] )) , (' t he ta _ 8 ' , tens or( [ 0.4422 ] )) , (' t he ta _ 9 ' , tens or( [ 0.8002 ] )) ] )
Non-unitary circuits
Qadence allows to compose 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 with 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 ]] )