Parametric programs
Qadence base Parameter
type is a subtype of sympy.Symbol
. There are three kinds of parameter subtypes used:
Fixed Parameter : A constant with a fixed, non-trainable value (e.g. \(\dfrac{\pi}{2}\) ).
Variational Parameter : A trainable parameter which can be optimized.
Feature Parameter : A non-trainable parameter which can be used to encode classical data into a quantum state.
Fixed Parameters
To pass a fixed parameter to a gate (or any parametrizable block), one can simply use either Python numeric types or wrapped in
a torch.Tensor
.
from torch import pi
from qadence import RX , run
# Let's use a torch type.
block = RX ( 0 , pi )
wf = run ( block )
# Let's pass a simple float.
block = RX ( 0 , 1. )
wf = run ( block )
w f = tens or( [[ 6.1232e-17+0. j , 0.0000e+00-1. j ]] )
w f = tens or( [[ 0.8776+0.0000 j , 0.0000-0.4794 j ]] )
Variational Parameters
To parametrize a block by an angle theta
, either a Python string
or an instance of VariationalParameter
can be passed instead of a numeric type to the gate constructor:
from qadence import RX , run , VariationalParameter
block = RX ( 0 , "theta" )
# This is equivalent to:
block = RX ( 0 , VariationalParameter ( "theta" ))
wf = run ( block )
w f = tens or( [[ 0.9974+0.0000 j , 0.0000-0.0725 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.8777+0.0000 j , 0.0000-0.4793 j ],
[ 0.9664+0.0000 j , 0.0000-0.2571 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.8728+0.0000 j , 0.2312+0.0000 j , 0.0000-0.4155 j , 0.0000-0.1101 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_99bbdfa7b6a146228d2d5a7dd28c3d65
[* 2]
cluster_08aac9d9f7734c778efb1b098786d7fe
Rotations
775f3e3cb3bc4151a95fe36f6c10b74d
0
7d0a4955cbbe46438a8ddb51e2ca75c8
RX(phi/theta)
775f3e3cb3bc4151a95fe36f6c10b74d--7d0a4955cbbe46438a8ddb51e2ca75c8
50ebd86fd4b94f37ba71b555d76aa1b7
1
5621c91a94984267a5e25e4b5e04e4d6
RX(phi)
7d0a4955cbbe46438a8ddb51e2ca75c8--5621c91a94984267a5e25e4b5e04e4d6
ecb9576f39ab4b2f9ffb6342018f3361
RX(phi)
5621c91a94984267a5e25e4b5e04e4d6--ecb9576f39ab4b2f9ffb6342018f3361
a3da8d012f7c4bd2883b224abb9a7808
RX(phi + theta)
ecb9576f39ab4b2f9ffb6342018f3361--a3da8d012f7c4bd2883b224abb9a7808
278e4dfbcd4e486fb3f633a848c8f076
a3da8d012f7c4bd2883b224abb9a7808--278e4dfbcd4e486fb3f633a848c8f076
5560dcffa3ec4b60882a9bf3a248f80d
278e4dfbcd4e486fb3f633a848c8f076--5560dcffa3ec4b60882a9bf3a248f80d
3f06a0a731ee44bd99ed9eaea812ea83
Z
5560dcffa3ec4b60882a9bf3a248f80d--3f06a0a731ee44bd99ed9eaea812ea83
eaf61dbb766643bbb17da5a164ed7010
3f06a0a731ee44bd99ed9eaea812ea83--eaf61dbb766643bbb17da5a164ed7010
379567128ba442a187f4649479e9a255
3275d7531364417e97bf125a85ebe205
RY(2*theta)
50ebd86fd4b94f37ba71b555d76aa1b7--3275d7531364417e97bf125a85ebe205
9aa38b04278347fca375d7ed926851de
2
9dcf68f7e9a347959ebd89ab4310fdf5
RY(theta)
3275d7531364417e97bf125a85ebe205--9dcf68f7e9a347959ebd89ab4310fdf5
08f4ecc00d5349f7bab4b30f55be4717
RY(theta)
9dcf68f7e9a347959ebd89ab4310fdf5--08f4ecc00d5349f7bab4b30f55be4717
b1d946175bce49fcbd753bf83e5eb0b1
RY(theta**2)
08f4ecc00d5349f7bab4b30f55be4717--b1d946175bce49fcbd753bf83e5eb0b1
6c1a39c53e324c8d8594e5fbdced49b3
X
b1d946175bce49fcbd753bf83e5eb0b1--6c1a39c53e324c8d8594e5fbdced49b3
6c1a39c53e324c8d8594e5fbdced49b3--278e4dfbcd4e486fb3f633a848c8f076
445fbc5991df43b8b2c6a6539d43ffbe
6c1a39c53e324c8d8594e5fbdced49b3--445fbc5991df43b8b2c6a6539d43ffbe
a9e314c4b7d64d828572e11b9b1161fa
Z
445fbc5991df43b8b2c6a6539d43ffbe--a9e314c4b7d64d828572e11b9b1161fa
a9e314c4b7d64d828572e11b9b1161fa--379567128ba442a187f4649479e9a255
4f26bc79be524574861b60e2c6bf77c7
53a29cf9c59b49328b210ad1af3ab0b9
RZ(cos(phi))
9aa38b04278347fca375d7ed926851de--53a29cf9c59b49328b210ad1af3ab0b9
5133477aba35435f92608adf10b6cd23
RZ(phi)
53a29cf9c59b49328b210ad1af3ab0b9--5133477aba35435f92608adf10b6cd23
d841c4fb957a4fd38f8a8b5db900c72a
RZ(phi)
5133477aba35435f92608adf10b6cd23--d841c4fb957a4fd38f8a8b5db900c72a
ae71c376989f4fe9b356d46cfd1f59ad
RZ(cos(phi))
d841c4fb957a4fd38f8a8b5db900c72a--ae71c376989f4fe9b356d46cfd1f59ad
0d3104be8e88466e8295073bd7ec611f
ae71c376989f4fe9b356d46cfd1f59ad--0d3104be8e88466e8295073bd7ec611f
3bd8f954fa3144d9bdb53c9298c1b056
X
0d3104be8e88466e8295073bd7ec611f--3bd8f954fa3144d9bdb53c9298c1b056
3bd8f954fa3144d9bdb53c9298c1b056--445fbc5991df43b8b2c6a6539d43ffbe
1abb6bb303fc4c42a5b8f3467fdffdda
Z
3bd8f954fa3144d9bdb53c9298c1b056--1abb6bb303fc4c42a5b8f3467fdffdda
1abb6bb303fc4c42a5b8f3467fdffdda--4f26bc79be524574861b60e2c6bf77c7
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.4176 ] )) ] )
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.7455+0.0000 j , 0.4356+0.0000 j , 0.0000-0.4356 j , 0.0000-0.2545 j ],
[ 0.6912+0.0000 j , 0.4620+0.0000 j , 0.0000-0.4620 j , 0.0000-0.3088 j ],
[ 0.9451+0.0000 j , 0.2277+0.0000 j , 0.0000-0.2277 j , 0.0000-0.0549 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
d214759bab6c4de191ed16126111cc10
0
56813477e0204b61a16d4f113930795c
RX(theta₀)
d214759bab6c4de191ed16126111cc10--56813477e0204b61a16d4f113930795c
fca2166b9b2b4a2fb67b4b41e0a1e264
1
05a3403987f14b1593363f676f496e13
RY(theta₄)
56813477e0204b61a16d4f113930795c--05a3403987f14b1593363f676f496e13
3745ac9025b84f21be8c6077c106ad70
RX(theta₈)
05a3403987f14b1593363f676f496e13--3745ac9025b84f21be8c6077c106ad70
df7c88c1a4994a218819b3f9753db1df
3745ac9025b84f21be8c6077c106ad70--df7c88c1a4994a218819b3f9753db1df
769a4143e9454bd9a75af557d0bc65be
df7c88c1a4994a218819b3f9753db1df--769a4143e9454bd9a75af557d0bc65be
a8a033f779c14daeb58a210760eaa3c6
RX(theta₁₂)
769a4143e9454bd9a75af557d0bc65be--a8a033f779c14daeb58a210760eaa3c6
6addc22bd6a943c3a1b51a09419734fb
RY(theta₁₆)
a8a033f779c14daeb58a210760eaa3c6--6addc22bd6a943c3a1b51a09419734fb
0b755ea06713475f92c70afb86ee2417
RX(theta₂₀)
6addc22bd6a943c3a1b51a09419734fb--0b755ea06713475f92c70afb86ee2417
8ebdbcf9e684455ca661020e7f41662d
0b755ea06713475f92c70afb86ee2417--8ebdbcf9e684455ca661020e7f41662d
276ea01e42b548ba80a7f6994323f320
8ebdbcf9e684455ca661020e7f41662d--276ea01e42b548ba80a7f6994323f320
21f339b41a754a9e97db063a025924f5
276ea01e42b548ba80a7f6994323f320--21f339b41a754a9e97db063a025924f5
0ca7a05c073b422384e62703005dbe27
3fd6940527064e7cbe63e97a7ac3f75c
RX(theta₁)
fca2166b9b2b4a2fb67b4b41e0a1e264--3fd6940527064e7cbe63e97a7ac3f75c
6a68a637bfb94637805a3fd3d4c6bce0
2
846947f4937741e7848773733f65b92e
RY(theta₅)
3fd6940527064e7cbe63e97a7ac3f75c--846947f4937741e7848773733f65b92e
f2192acc4c7446949dd432415d41b34e
RX(theta₉)
846947f4937741e7848773733f65b92e--f2192acc4c7446949dd432415d41b34e
e10e7ec4618643468015f36ef3e09967
X
f2192acc4c7446949dd432415d41b34e--e10e7ec4618643468015f36ef3e09967
e10e7ec4618643468015f36ef3e09967--df7c88c1a4994a218819b3f9753db1df
8e948f73a7a3483b8a710b5372237ae5
e10e7ec4618643468015f36ef3e09967--8e948f73a7a3483b8a710b5372237ae5
620e563208614b46bfea7249ab9106d2
RX(theta₁₃)
8e948f73a7a3483b8a710b5372237ae5--620e563208614b46bfea7249ab9106d2
c08e6c5a48ea40138c42055a73681349
RY(theta₁₇)
620e563208614b46bfea7249ab9106d2--c08e6c5a48ea40138c42055a73681349
464580efd2a64b0a80527b18f7945637
RX(theta₂₁)
c08e6c5a48ea40138c42055a73681349--464580efd2a64b0a80527b18f7945637
438ce34327af458195c46868f83ae420
X
464580efd2a64b0a80527b18f7945637--438ce34327af458195c46868f83ae420
438ce34327af458195c46868f83ae420--8ebdbcf9e684455ca661020e7f41662d
00e48ab7b5094019b9c8a6d563a8b0b8
438ce34327af458195c46868f83ae420--00e48ab7b5094019b9c8a6d563a8b0b8
00e48ab7b5094019b9c8a6d563a8b0b8--0ca7a05c073b422384e62703005dbe27
465cee3f5ba5432695427ddc15795bde
c14ed8449d924363881997b00f30ea1b
RX(theta₂)
6a68a637bfb94637805a3fd3d4c6bce0--c14ed8449d924363881997b00f30ea1b
12c5021210f04ed49dc0b7b628df99b2
3
75d52281a09e40b984d1721a30ff1faf
RY(theta₆)
c14ed8449d924363881997b00f30ea1b--75d52281a09e40b984d1721a30ff1faf
e01fa4b3ceff4de293b0a8c575ad02ff
RX(theta₁₀)
75d52281a09e40b984d1721a30ff1faf--e01fa4b3ceff4de293b0a8c575ad02ff
d487b74b08934d659dfc76e639e247b4
e01fa4b3ceff4de293b0a8c575ad02ff--d487b74b08934d659dfc76e639e247b4
08d62011052945078f17b7e27696d1fd
X
d487b74b08934d659dfc76e639e247b4--08d62011052945078f17b7e27696d1fd
08d62011052945078f17b7e27696d1fd--8e948f73a7a3483b8a710b5372237ae5
b380c797700548d488608265baa93c60
RX(theta₁₄)
08d62011052945078f17b7e27696d1fd--b380c797700548d488608265baa93c60
82e8431b07514fba98a0193807b8e047
RY(theta₁₈)
b380c797700548d488608265baa93c60--82e8431b07514fba98a0193807b8e047
fc052f1802f142d1a3e6b6bae5b9d88d
RX(theta₂₂)
82e8431b07514fba98a0193807b8e047--fc052f1802f142d1a3e6b6bae5b9d88d
ad1a4efefaf748ef97b078af9b05e313
fc052f1802f142d1a3e6b6bae5b9d88d--ad1a4efefaf748ef97b078af9b05e313
fa57eafea484493cb46e45a3dd25a89f
X
ad1a4efefaf748ef97b078af9b05e313--fa57eafea484493cb46e45a3dd25a89f
fa57eafea484493cb46e45a3dd25a89f--00e48ab7b5094019b9c8a6d563a8b0b8
fa57eafea484493cb46e45a3dd25a89f--465cee3f5ba5432695427ddc15795bde
f00cbead27fd4adcb74f916a91161141
e3405c6e1b994141b376d85c13bb8c99
RX(theta₃)
12c5021210f04ed49dc0b7b628df99b2--e3405c6e1b994141b376d85c13bb8c99
d7d50baadead47acbd00ba1f2abcd5d0
RY(theta₇)
e3405c6e1b994141b376d85c13bb8c99--d7d50baadead47acbd00ba1f2abcd5d0
ed907c6acc044b97a9fe9c2c82b50451
RX(theta₁₁)
d7d50baadead47acbd00ba1f2abcd5d0--ed907c6acc044b97a9fe9c2c82b50451
b1fae8ce89f7462587c605ceb42ff64d
X
ed907c6acc044b97a9fe9c2c82b50451--b1fae8ce89f7462587c605ceb42ff64d
b1fae8ce89f7462587c605ceb42ff64d--d487b74b08934d659dfc76e639e247b4
d9e380874add4a88887e84a298a606aa
b1fae8ce89f7462587c605ceb42ff64d--d9e380874add4a88887e84a298a606aa
a86bac58be7a4fafbcc91b78e99ef64a
RX(theta₁₅)
d9e380874add4a88887e84a298a606aa--a86bac58be7a4fafbcc91b78e99ef64a
4439767d12b44f2182b92878667ed06a
RY(theta₁₉)
a86bac58be7a4fafbcc91b78e99ef64a--4439767d12b44f2182b92878667ed06a
0df8d6b80cc241e8a70d2476687fea9e
RX(theta₂₃)
4439767d12b44f2182b92878667ed06a--0df8d6b80cc241e8a70d2476687fea9e
c7b2daad9a5f4c1e8b973d2d66c20c4a
X
0df8d6b80cc241e8a70d2476687fea9e--c7b2daad9a5f4c1e8b973d2d66c20c4a
c7b2daad9a5f4c1e8b973d2d66c20c4a--ad1a4efefaf748ef97b078af9b05e313
77c50898f46342e7afcda17f32f9fbe5
c7b2daad9a5f4c1e8b973d2d66c20c4a--77c50898f46342e7afcda17f32f9fbe5
77c50898f46342e7afcda17f32f9fbe5--f00cbead27fd4adcb74f916a91161141
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_845259bda6064ff48d6804e7e8f18c75
HEA
cluster_3123b6b4121546b8b8561e16425d9805
HEA
04f1bbc1743d4adebab227a7df0c5c50
0
29055866c3d04a4da09d25104ba059ed
RX(theta₀)
04f1bbc1743d4adebab227a7df0c5c50--29055866c3d04a4da09d25104ba059ed
e45218487e544cba92c511104acb49aa
1
2e42c33844e243b2b7d4fa870d71a795
RY(theta₄)
29055866c3d04a4da09d25104ba059ed--2e42c33844e243b2b7d4fa870d71a795
6ff65be4386c40dfbc414584e86bf59d
RX(theta₈)
2e42c33844e243b2b7d4fa870d71a795--6ff65be4386c40dfbc414584e86bf59d
43e919f291e043afbb0d0680eac1176a
6ff65be4386c40dfbc414584e86bf59d--43e919f291e043afbb0d0680eac1176a
c30ded9a91694b918e3212285038c9e7
43e919f291e043afbb0d0680eac1176a--c30ded9a91694b918e3212285038c9e7
7d660caceb6946ec9924ba8961638c99
RX(theta₁₂)
c30ded9a91694b918e3212285038c9e7--7d660caceb6946ec9924ba8961638c99
4d6cce01699f49d6b963ae260d4eab69
RY(theta₁₆)
7d660caceb6946ec9924ba8961638c99--4d6cce01699f49d6b963ae260d4eab69
3fce4d5b14554245b2a724eab9c9e257
RX(theta₂₀)
4d6cce01699f49d6b963ae260d4eab69--3fce4d5b14554245b2a724eab9c9e257
3dea7ac1b6ac418fa7b2f6258adddf4d
3fce4d5b14554245b2a724eab9c9e257--3dea7ac1b6ac418fa7b2f6258adddf4d
c3cf4d178d424a11a1b764af7fd48c29
3dea7ac1b6ac418fa7b2f6258adddf4d--c3cf4d178d424a11a1b764af7fd48c29
73000cac9ef14f2ebcb74cbb0dee2500
RX(theta₀)
c3cf4d178d424a11a1b764af7fd48c29--73000cac9ef14f2ebcb74cbb0dee2500
79ab8f3dfe6f434eab39721c41f42bf6
RY(theta₄)
73000cac9ef14f2ebcb74cbb0dee2500--79ab8f3dfe6f434eab39721c41f42bf6
eb05cc87ac5d40a0b8f33f099b43b43c
RX(theta₈)
79ab8f3dfe6f434eab39721c41f42bf6--eb05cc87ac5d40a0b8f33f099b43b43c
c52a200dcbf74449addcc97811ece2d5
eb05cc87ac5d40a0b8f33f099b43b43c--c52a200dcbf74449addcc97811ece2d5
0edad8865d6c43d7ab40a8f0149deae0
c52a200dcbf74449addcc97811ece2d5--0edad8865d6c43d7ab40a8f0149deae0
5a38a03164e34d8db2763e8e830efcfa
RX(theta₁₂)
0edad8865d6c43d7ab40a8f0149deae0--5a38a03164e34d8db2763e8e830efcfa
1c253c6d5bb1400d8bff4a2cde4bc770
RY(theta₁₆)
5a38a03164e34d8db2763e8e830efcfa--1c253c6d5bb1400d8bff4a2cde4bc770
c50add91e8944f72a614ef486f111e23
RX(theta₂₀)
1c253c6d5bb1400d8bff4a2cde4bc770--c50add91e8944f72a614ef486f111e23
2282b5fe147f4c2180faf6c23edaeb9d
c50add91e8944f72a614ef486f111e23--2282b5fe147f4c2180faf6c23edaeb9d
7fe65c55b0494a11bf72e2f85fe18dac
2282b5fe147f4c2180faf6c23edaeb9d--7fe65c55b0494a11bf72e2f85fe18dac
9d29bd88aabe42bea888496191ba2268
7fe65c55b0494a11bf72e2f85fe18dac--9d29bd88aabe42bea888496191ba2268
3f151acbdb1846cd89e933d8876ebf34
dc294e4c5d7346eab3b530bfc8672a52
RX(theta₁)
e45218487e544cba92c511104acb49aa--dc294e4c5d7346eab3b530bfc8672a52
e36366ba610647b7b3f1553a28f3eb09
2
5434ab37eeba45138dabfdc848eceb27
RY(theta₅)
dc294e4c5d7346eab3b530bfc8672a52--5434ab37eeba45138dabfdc848eceb27
960d9e995a53499a8a7b5d2f993c4de6
RX(theta₉)
5434ab37eeba45138dabfdc848eceb27--960d9e995a53499a8a7b5d2f993c4de6
b2fc8b26d6ac414da537c0d5e7b02869
X
960d9e995a53499a8a7b5d2f993c4de6--b2fc8b26d6ac414da537c0d5e7b02869
b2fc8b26d6ac414da537c0d5e7b02869--43e919f291e043afbb0d0680eac1176a
a253e9c67440495fbb4057089f3256e8
b2fc8b26d6ac414da537c0d5e7b02869--a253e9c67440495fbb4057089f3256e8
ee14a8d7283e4f9dade4c176ecd73790
RX(theta₁₃)
a253e9c67440495fbb4057089f3256e8--ee14a8d7283e4f9dade4c176ecd73790
2a91f8fe34804b8ca6a32f76f95f601c
RY(theta₁₇)
ee14a8d7283e4f9dade4c176ecd73790--2a91f8fe34804b8ca6a32f76f95f601c
b5e24870c5c14762b9d39c3871c7c805
RX(theta₂₁)
2a91f8fe34804b8ca6a32f76f95f601c--b5e24870c5c14762b9d39c3871c7c805
24a52c25ec724a449e8ae7a5dc928664
X
b5e24870c5c14762b9d39c3871c7c805--24a52c25ec724a449e8ae7a5dc928664
24a52c25ec724a449e8ae7a5dc928664--3dea7ac1b6ac418fa7b2f6258adddf4d
ea75d78ffb19460893a952829b841f7e
24a52c25ec724a449e8ae7a5dc928664--ea75d78ffb19460893a952829b841f7e
27c7cfded54c49b1a8d25ae4ba1a00ae
RX(theta₁)
ea75d78ffb19460893a952829b841f7e--27c7cfded54c49b1a8d25ae4ba1a00ae
813eed0acd9f4ad8ad6629e21c09e0f0
RY(theta₅)
27c7cfded54c49b1a8d25ae4ba1a00ae--813eed0acd9f4ad8ad6629e21c09e0f0
c680a271d7d843d882c289a9711f4c3c
RX(theta₉)
813eed0acd9f4ad8ad6629e21c09e0f0--c680a271d7d843d882c289a9711f4c3c
39ab5b299d384182bb089215b989c581
X
c680a271d7d843d882c289a9711f4c3c--39ab5b299d384182bb089215b989c581
39ab5b299d384182bb089215b989c581--c52a200dcbf74449addcc97811ece2d5
1637aaea13fe41efa7aa1210354be52a
39ab5b299d384182bb089215b989c581--1637aaea13fe41efa7aa1210354be52a
f14422ac94f048b081ea8dc193a69c76
RX(theta₁₃)
1637aaea13fe41efa7aa1210354be52a--f14422ac94f048b081ea8dc193a69c76
70ca449d45cc4e7391f66171068d8d2e
RY(theta₁₇)
f14422ac94f048b081ea8dc193a69c76--70ca449d45cc4e7391f66171068d8d2e
3c0c4114d81447758a05752ad3a32511
RX(theta₂₁)
70ca449d45cc4e7391f66171068d8d2e--3c0c4114d81447758a05752ad3a32511
0039561e5e46488da69db1e395aae25f
X
3c0c4114d81447758a05752ad3a32511--0039561e5e46488da69db1e395aae25f
0039561e5e46488da69db1e395aae25f--2282b5fe147f4c2180faf6c23edaeb9d
7103960c862640938e5994d3f6697fbe
0039561e5e46488da69db1e395aae25f--7103960c862640938e5994d3f6697fbe
7103960c862640938e5994d3f6697fbe--3f151acbdb1846cd89e933d8876ebf34
054a2717c468498b93378e853147617d
d6fc3033a382491082250ad4f80c4788
RX(theta₂)
e36366ba610647b7b3f1553a28f3eb09--d6fc3033a382491082250ad4f80c4788
7c5939bf8ec149ee8194dbc1b4de10ac
3
0141da5233ae4636947260e7a6bcbfc1
RY(theta₆)
d6fc3033a382491082250ad4f80c4788--0141da5233ae4636947260e7a6bcbfc1
7d6d87386c9e45a8bfaa740dc3bc247c
RX(theta₁₀)
0141da5233ae4636947260e7a6bcbfc1--7d6d87386c9e45a8bfaa740dc3bc247c
d5910c284081425cb3f7bfe4a0676258
7d6d87386c9e45a8bfaa740dc3bc247c--d5910c284081425cb3f7bfe4a0676258
07b7e44b41c84a9b93a611120744fc7e
X
d5910c284081425cb3f7bfe4a0676258--07b7e44b41c84a9b93a611120744fc7e
07b7e44b41c84a9b93a611120744fc7e--a253e9c67440495fbb4057089f3256e8
6c0b4f5441a74cd981d0c93b71ec8846
RX(theta₁₄)
07b7e44b41c84a9b93a611120744fc7e--6c0b4f5441a74cd981d0c93b71ec8846
06f8ac34cd284c7583ae9ccbee6719f3
RY(theta₁₈)
6c0b4f5441a74cd981d0c93b71ec8846--06f8ac34cd284c7583ae9ccbee6719f3
38fe9436d9134ee8a27dcc04d4fb3364
RX(theta₂₂)
06f8ac34cd284c7583ae9ccbee6719f3--38fe9436d9134ee8a27dcc04d4fb3364
ff70d34b751f4e72a52afdb4c3669fe5
38fe9436d9134ee8a27dcc04d4fb3364--ff70d34b751f4e72a52afdb4c3669fe5
3c23220f406f44c9a3535f7b9bcf2037
X
ff70d34b751f4e72a52afdb4c3669fe5--3c23220f406f44c9a3535f7b9bcf2037
3c23220f406f44c9a3535f7b9bcf2037--ea75d78ffb19460893a952829b841f7e
1e8f4ad4a8714fd78112ffdba1db220a
RX(theta₂)
3c23220f406f44c9a3535f7b9bcf2037--1e8f4ad4a8714fd78112ffdba1db220a
f21fdb411a1042c5bea6bcb489743709
RY(theta₆)
1e8f4ad4a8714fd78112ffdba1db220a--f21fdb411a1042c5bea6bcb489743709
3fa81841aec14fd3a4a5786ab2757a06
RX(theta₁₀)
f21fdb411a1042c5bea6bcb489743709--3fa81841aec14fd3a4a5786ab2757a06
cefcc5d981e5430bab11fb1ab5ce79b4
3fa81841aec14fd3a4a5786ab2757a06--cefcc5d981e5430bab11fb1ab5ce79b4
6505c394bc50418d91c266b30d35c53c
X
cefcc5d981e5430bab11fb1ab5ce79b4--6505c394bc50418d91c266b30d35c53c
6505c394bc50418d91c266b30d35c53c--1637aaea13fe41efa7aa1210354be52a
3d3da1c11dbe47389409043b54dc216f
RX(theta₁₄)
6505c394bc50418d91c266b30d35c53c--3d3da1c11dbe47389409043b54dc216f
6e3ac85627854b9bbe95d75765c76874
RY(theta₁₈)
3d3da1c11dbe47389409043b54dc216f--6e3ac85627854b9bbe95d75765c76874
709afc515d9c423fb4d10597f0e35259
RX(theta₂₂)
6e3ac85627854b9bbe95d75765c76874--709afc515d9c423fb4d10597f0e35259
fa6f5acd06c54ae6b17a01bf75bff845
709afc515d9c423fb4d10597f0e35259--fa6f5acd06c54ae6b17a01bf75bff845
b15a43cacf4341a0a1bd6f6f08aa2453
X
fa6f5acd06c54ae6b17a01bf75bff845--b15a43cacf4341a0a1bd6f6f08aa2453
b15a43cacf4341a0a1bd6f6f08aa2453--7103960c862640938e5994d3f6697fbe
b15a43cacf4341a0a1bd6f6f08aa2453--054a2717c468498b93378e853147617d
c400b2524f42401fae831d2296679d9f
358c07400aaa4d85908f428cb31f55e1
RX(theta₃)
7c5939bf8ec149ee8194dbc1b4de10ac--358c07400aaa4d85908f428cb31f55e1
79167e9724f043e7a92696448355bfba
RY(theta₇)
358c07400aaa4d85908f428cb31f55e1--79167e9724f043e7a92696448355bfba
d37129e819324d639b16457b5f5a5f74
RX(theta₁₁)
79167e9724f043e7a92696448355bfba--d37129e819324d639b16457b5f5a5f74
0103d093fe61465fa563c26d11b7e46e
X
d37129e819324d639b16457b5f5a5f74--0103d093fe61465fa563c26d11b7e46e
0103d093fe61465fa563c26d11b7e46e--d5910c284081425cb3f7bfe4a0676258
9a869006a5b04f4c9695c9394a152c9b
0103d093fe61465fa563c26d11b7e46e--9a869006a5b04f4c9695c9394a152c9b
935127bf9a2b4e91b5a56b9f23be4ed3
RX(theta₁₅)
9a869006a5b04f4c9695c9394a152c9b--935127bf9a2b4e91b5a56b9f23be4ed3
107c28a23c824366819e552e70b19161
RY(theta₁₉)
935127bf9a2b4e91b5a56b9f23be4ed3--107c28a23c824366819e552e70b19161
151b9fa472dc4262b79774b655b00634
RX(theta₂₃)
107c28a23c824366819e552e70b19161--151b9fa472dc4262b79774b655b00634
2c14c2457ebb404c97629d6602e2baf8
X
151b9fa472dc4262b79774b655b00634--2c14c2457ebb404c97629d6602e2baf8
2c14c2457ebb404c97629d6602e2baf8--ff70d34b751f4e72a52afdb4c3669fe5
426aa0f0ce6b411b8c86d55b18fc3bdb
2c14c2457ebb404c97629d6602e2baf8--426aa0f0ce6b411b8c86d55b18fc3bdb
dc0f060b9cfd42c8b72ce4192162d2d5
RX(theta₃)
426aa0f0ce6b411b8c86d55b18fc3bdb--dc0f060b9cfd42c8b72ce4192162d2d5
6753303a41214cc686b306b42a5cd3ac
RY(theta₇)
dc0f060b9cfd42c8b72ce4192162d2d5--6753303a41214cc686b306b42a5cd3ac
37a1ca6e67174df080db65ec214bcb4b
RX(theta₁₁)
6753303a41214cc686b306b42a5cd3ac--37a1ca6e67174df080db65ec214bcb4b
c3dbe44ed0e7498a9c5eaf6207d12a32
X
37a1ca6e67174df080db65ec214bcb4b--c3dbe44ed0e7498a9c5eaf6207d12a32
c3dbe44ed0e7498a9c5eaf6207d12a32--cefcc5d981e5430bab11fb1ab5ce79b4
70cced3cfa9c436ea89b9be0c86b71bb
c3dbe44ed0e7498a9c5eaf6207d12a32--70cced3cfa9c436ea89b9be0c86b71bb
ee234c203e584d18a9dff92b53fe4f1e
RX(theta₁₅)
70cced3cfa9c436ea89b9be0c86b71bb--ee234c203e584d18a9dff92b53fe4f1e
67f635cefac8422aaec7d9b6562d3aa7
RY(theta₁₉)
ee234c203e584d18a9dff92b53fe4f1e--67f635cefac8422aaec7d9b6562d3aa7
ff1991b5f2ea4dea8f4af8bc43109320
RX(theta₂₃)
67f635cefac8422aaec7d9b6562d3aa7--ff1991b5f2ea4dea8f4af8bc43109320
6d36ee18785147eabba3082db508fcf8
X
ff1991b5f2ea4dea8f4af8bc43109320--6d36ee18785147eabba3082db508fcf8
6d36ee18785147eabba3082db508fcf8--fa6f5acd06c54ae6b17a01bf75bff845
b4c234895c184b7daba61b803598c558
6d36ee18785147eabba3082db508fcf8--b4c234895c184b7daba61b803598c558
b4c234895c184b7daba61b803598c558--c400b2524f42401fae831d2296679d9f
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_826984297b934e4bab0e33b4e1816b1c
HEA
cluster_d8d1623e60d14913b9a3b95f8e9ce9ec
HEA
3f1b285a55c3455ea6e85c7694f2d079
0
ae34925a920946589dfb60a67245f38c
RX(p1₀)
3f1b285a55c3455ea6e85c7694f2d079--ae34925a920946589dfb60a67245f38c
a7b0b8d79d43430895403f50a3df4f83
1
db642af5564a46b7a31c904901a232e4
RY(p1₄)
ae34925a920946589dfb60a67245f38c--db642af5564a46b7a31c904901a232e4
845d3ff9840d454983cad12fa5b1f650
RX(p1₈)
db642af5564a46b7a31c904901a232e4--845d3ff9840d454983cad12fa5b1f650
729efda83a6d4401a4cf839c738c6e32
845d3ff9840d454983cad12fa5b1f650--729efda83a6d4401a4cf839c738c6e32
9eafef5167da418db648fc36e3ae571b
729efda83a6d4401a4cf839c738c6e32--9eafef5167da418db648fc36e3ae571b
e56c708139494fb9b825e7b37aedeadc
RX(p1₁₂)
9eafef5167da418db648fc36e3ae571b--e56c708139494fb9b825e7b37aedeadc
c83345e992d541ec967e60bd8b6afb22
RY(p1₁₆)
e56c708139494fb9b825e7b37aedeadc--c83345e992d541ec967e60bd8b6afb22
711c95a525554683a8c9eafff5eace1b
RX(p1₂₀)
c83345e992d541ec967e60bd8b6afb22--711c95a525554683a8c9eafff5eace1b
3801bc3fece24ed88fee45b6e527e508
711c95a525554683a8c9eafff5eace1b--3801bc3fece24ed88fee45b6e527e508
9b355d2d8a784569a0bcf2710d56b92a
3801bc3fece24ed88fee45b6e527e508--9b355d2d8a784569a0bcf2710d56b92a
4191b9be222d4c73afaf3b6fe53d1bcb
RX(p2₀)
9b355d2d8a784569a0bcf2710d56b92a--4191b9be222d4c73afaf3b6fe53d1bcb
756fea91d0df4bc8ac7a1ab61cd8eef9
RY(p2₄)
4191b9be222d4c73afaf3b6fe53d1bcb--756fea91d0df4bc8ac7a1ab61cd8eef9
67806026b49d460797e28cb05691cd80
RX(p2₈)
756fea91d0df4bc8ac7a1ab61cd8eef9--67806026b49d460797e28cb05691cd80
b7c50d31dd7a4f54be6e36a83790cdde
67806026b49d460797e28cb05691cd80--b7c50d31dd7a4f54be6e36a83790cdde
5367bc2908d14b459b5aa0f9e3592afd
b7c50d31dd7a4f54be6e36a83790cdde--5367bc2908d14b459b5aa0f9e3592afd
c37b64aaed51453ab3f1da7b5bf8e81a
RX(p2₁₂)
5367bc2908d14b459b5aa0f9e3592afd--c37b64aaed51453ab3f1da7b5bf8e81a
826ac0b946ee46f49b2b9c2f998dfd79
RY(p2₁₆)
c37b64aaed51453ab3f1da7b5bf8e81a--826ac0b946ee46f49b2b9c2f998dfd79
0a0aa339cb4e4b4697277fe353787a75
RX(p2₂₀)
826ac0b946ee46f49b2b9c2f998dfd79--0a0aa339cb4e4b4697277fe353787a75
431b5219513f48eb9bc471825678cf65
0a0aa339cb4e4b4697277fe353787a75--431b5219513f48eb9bc471825678cf65
a1ce1859992147298a14405ff081c751
431b5219513f48eb9bc471825678cf65--a1ce1859992147298a14405ff081c751
534899b4149b4b65a23bb4f5cff28ace
a1ce1859992147298a14405ff081c751--534899b4149b4b65a23bb4f5cff28ace
3ab8979d6d004f2b9107673f2f7d8843
40bedc602e964efd84d93c4ea4adbb65
RX(p1₁)
a7b0b8d79d43430895403f50a3df4f83--40bedc602e964efd84d93c4ea4adbb65
700ecd5724254d76b9721a3fd8890ce1
2
e7f27c9c5591416d953dae4eeacc092b
RY(p1₅)
40bedc602e964efd84d93c4ea4adbb65--e7f27c9c5591416d953dae4eeacc092b
c9f8eb02d3034e158b52e2a7c693c23f
RX(p1₉)
e7f27c9c5591416d953dae4eeacc092b--c9f8eb02d3034e158b52e2a7c693c23f
8f7c69567c7c4c9396f2a36a8c59f076
X
c9f8eb02d3034e158b52e2a7c693c23f--8f7c69567c7c4c9396f2a36a8c59f076
8f7c69567c7c4c9396f2a36a8c59f076--729efda83a6d4401a4cf839c738c6e32
1b0f59fed3e3404087b07c41e554e44c
8f7c69567c7c4c9396f2a36a8c59f076--1b0f59fed3e3404087b07c41e554e44c
4a421208993a4b2bbe02c769a825bf77
RX(p1₁₃)
1b0f59fed3e3404087b07c41e554e44c--4a421208993a4b2bbe02c769a825bf77
188d906254c04b27bf87a3f364880049
RY(p1₁₇)
4a421208993a4b2bbe02c769a825bf77--188d906254c04b27bf87a3f364880049
6109731a793a45419c36c8a770a2f619
RX(p1₂₁)
188d906254c04b27bf87a3f364880049--6109731a793a45419c36c8a770a2f619
db008de2292d45139ebbc4e6ade411f4
X
6109731a793a45419c36c8a770a2f619--db008de2292d45139ebbc4e6ade411f4
db008de2292d45139ebbc4e6ade411f4--3801bc3fece24ed88fee45b6e527e508
4b797d05742943cba341dd5b96f842ad
db008de2292d45139ebbc4e6ade411f4--4b797d05742943cba341dd5b96f842ad
1cc493f8a44e4c4c8c255ddebd5bb091
RX(p2₁)
4b797d05742943cba341dd5b96f842ad--1cc493f8a44e4c4c8c255ddebd5bb091
c2e83a19cedc45078901ed680f7c31de
RY(p2₅)
1cc493f8a44e4c4c8c255ddebd5bb091--c2e83a19cedc45078901ed680f7c31de
e4e4290944f64b51879488d794fac1c8
RX(p2₉)
c2e83a19cedc45078901ed680f7c31de--e4e4290944f64b51879488d794fac1c8
9dbc598c37e447138da54a0c6e70d497
X
e4e4290944f64b51879488d794fac1c8--9dbc598c37e447138da54a0c6e70d497
9dbc598c37e447138da54a0c6e70d497--b7c50d31dd7a4f54be6e36a83790cdde
04ecdb528857413c89180efe83c04aee
9dbc598c37e447138da54a0c6e70d497--04ecdb528857413c89180efe83c04aee
ce4fb7cfed2048b2a2b7bdf7c60898ed
RX(p2₁₃)
04ecdb528857413c89180efe83c04aee--ce4fb7cfed2048b2a2b7bdf7c60898ed
404c74181dc541f7a02a476526ea398b
RY(p2₁₇)
ce4fb7cfed2048b2a2b7bdf7c60898ed--404c74181dc541f7a02a476526ea398b
a07fe77facee4489892eab25940939ed
RX(p2₂₁)
404c74181dc541f7a02a476526ea398b--a07fe77facee4489892eab25940939ed
a5961c9c09f94bf5aa3a089c2426b1a0
X
a07fe77facee4489892eab25940939ed--a5961c9c09f94bf5aa3a089c2426b1a0
a5961c9c09f94bf5aa3a089c2426b1a0--431b5219513f48eb9bc471825678cf65
3d1039ca10c040bf85604b99696c6c5e
a5961c9c09f94bf5aa3a089c2426b1a0--3d1039ca10c040bf85604b99696c6c5e
3d1039ca10c040bf85604b99696c6c5e--3ab8979d6d004f2b9107673f2f7d8843
860ffce8158b43fe88b35e07b4c0b005
6d69b63b507f4c65a368ef0334ae1dbd
RX(p1₂)
700ecd5724254d76b9721a3fd8890ce1--6d69b63b507f4c65a368ef0334ae1dbd
327e3adb027d477bafd03d1c05a82f18
3
6789c7568234430db850c2bc0731b4fb
RY(p1₆)
6d69b63b507f4c65a368ef0334ae1dbd--6789c7568234430db850c2bc0731b4fb
bd5a731bba454032b6c7583f44561b04
RX(p1₁₀)
6789c7568234430db850c2bc0731b4fb--bd5a731bba454032b6c7583f44561b04
d32b3bfb76ba49b081c4bf29a3d78c2f
bd5a731bba454032b6c7583f44561b04--d32b3bfb76ba49b081c4bf29a3d78c2f
7634d2892d5c42548c0c3dbeafd67b53
X
d32b3bfb76ba49b081c4bf29a3d78c2f--7634d2892d5c42548c0c3dbeafd67b53
7634d2892d5c42548c0c3dbeafd67b53--1b0f59fed3e3404087b07c41e554e44c
240167f22f8440b39664b585d769dad0
RX(p1₁₄)
7634d2892d5c42548c0c3dbeafd67b53--240167f22f8440b39664b585d769dad0
52d6fb7b446b4a36a7f513e731fa6add
RY(p1₁₈)
240167f22f8440b39664b585d769dad0--52d6fb7b446b4a36a7f513e731fa6add
330e7b14befa41d989be16c5b2e01bfb
RX(p1₂₂)
52d6fb7b446b4a36a7f513e731fa6add--330e7b14befa41d989be16c5b2e01bfb
0afdfc9a168a4a86bc9f5066cd941fd8
330e7b14befa41d989be16c5b2e01bfb--0afdfc9a168a4a86bc9f5066cd941fd8
922bf0e94a6049fa8169e4dc51a453d3
X
0afdfc9a168a4a86bc9f5066cd941fd8--922bf0e94a6049fa8169e4dc51a453d3
922bf0e94a6049fa8169e4dc51a453d3--4b797d05742943cba341dd5b96f842ad
f7f5943df4c14b8faf2011c912a189b1
RX(p2₂)
922bf0e94a6049fa8169e4dc51a453d3--f7f5943df4c14b8faf2011c912a189b1
f8d91a5b59df4726bf9163cf4a735638
RY(p2₆)
f7f5943df4c14b8faf2011c912a189b1--f8d91a5b59df4726bf9163cf4a735638
49e81880809b4a7eaeff20ea7d373432
RX(p2₁₀)
f8d91a5b59df4726bf9163cf4a735638--49e81880809b4a7eaeff20ea7d373432
4e6533596521480d99626a20215f89a5
49e81880809b4a7eaeff20ea7d373432--4e6533596521480d99626a20215f89a5
d4efbc01a6ff437a8af9121209501eea
X
4e6533596521480d99626a20215f89a5--d4efbc01a6ff437a8af9121209501eea
d4efbc01a6ff437a8af9121209501eea--04ecdb528857413c89180efe83c04aee
191dc81f3a5d4216bccae7c08726faeb
RX(p2₁₄)
d4efbc01a6ff437a8af9121209501eea--191dc81f3a5d4216bccae7c08726faeb
418909f0d1c9452a894aa71f79d4e489
RY(p2₁₈)
191dc81f3a5d4216bccae7c08726faeb--418909f0d1c9452a894aa71f79d4e489
a4dc5f7f6b844bb4845c85b3537f57c5
RX(p2₂₂)
418909f0d1c9452a894aa71f79d4e489--a4dc5f7f6b844bb4845c85b3537f57c5
0c3aee26700c45638834332edfcb35c4
a4dc5f7f6b844bb4845c85b3537f57c5--0c3aee26700c45638834332edfcb35c4
f65b0b1de96f4cfc84881a037a2237a9
X
0c3aee26700c45638834332edfcb35c4--f65b0b1de96f4cfc84881a037a2237a9
f65b0b1de96f4cfc84881a037a2237a9--3d1039ca10c040bf85604b99696c6c5e
f65b0b1de96f4cfc84881a037a2237a9--860ffce8158b43fe88b35e07b4c0b005
8f53042945a94e18be0f09cd85904c0d
a79230d518924a08a3bd33a67c25944d
RX(p1₃)
327e3adb027d477bafd03d1c05a82f18--a79230d518924a08a3bd33a67c25944d
c6501dbf6bae475399f6c9863b00a32c
RY(p1₇)
a79230d518924a08a3bd33a67c25944d--c6501dbf6bae475399f6c9863b00a32c
9370d5e59ebb4008a04f18b729577302
RX(p1₁₁)
c6501dbf6bae475399f6c9863b00a32c--9370d5e59ebb4008a04f18b729577302
e58c7a4cfac3431898207ee9dc8dd719
X
9370d5e59ebb4008a04f18b729577302--e58c7a4cfac3431898207ee9dc8dd719
e58c7a4cfac3431898207ee9dc8dd719--d32b3bfb76ba49b081c4bf29a3d78c2f
95770df1701d45c7a144193fe7a51b04
e58c7a4cfac3431898207ee9dc8dd719--95770df1701d45c7a144193fe7a51b04
047f0071093940d2bc744a36124298cb
RX(p1₁₅)
95770df1701d45c7a144193fe7a51b04--047f0071093940d2bc744a36124298cb
dd2546cbc7fa479881247dcc410aa6d7
RY(p1₁₉)
047f0071093940d2bc744a36124298cb--dd2546cbc7fa479881247dcc410aa6d7
7690602144ee4aa98cfc529a859571d9
RX(p1₂₃)
dd2546cbc7fa479881247dcc410aa6d7--7690602144ee4aa98cfc529a859571d9
26175596a04e436d935be321ed87581b
X
7690602144ee4aa98cfc529a859571d9--26175596a04e436d935be321ed87581b
26175596a04e436d935be321ed87581b--0afdfc9a168a4a86bc9f5066cd941fd8
c998e1d19dc34c2080a0769beed2cdb0
26175596a04e436d935be321ed87581b--c998e1d19dc34c2080a0769beed2cdb0
3df4a145afbc42d9a8e8a7c6cf96781e
RX(p2₃)
c998e1d19dc34c2080a0769beed2cdb0--3df4a145afbc42d9a8e8a7c6cf96781e
df2df968649444af84b3c2fd0faec61d
RY(p2₇)
3df4a145afbc42d9a8e8a7c6cf96781e--df2df968649444af84b3c2fd0faec61d
c7ec112de2df402095e71e47ee8899d5
RX(p2₁₁)
df2df968649444af84b3c2fd0faec61d--c7ec112de2df402095e71e47ee8899d5
5def2c3a19f1483482b27efdfa6adb69
X
c7ec112de2df402095e71e47ee8899d5--5def2c3a19f1483482b27efdfa6adb69
5def2c3a19f1483482b27efdfa6adb69--4e6533596521480d99626a20215f89a5
c4972266ea5e40579c3c7a472824c987
5def2c3a19f1483482b27efdfa6adb69--c4972266ea5e40579c3c7a472824c987
25763adf436f44f7a208198790bf8985
RX(p2₁₅)
c4972266ea5e40579c3c7a472824c987--25763adf436f44f7a208198790bf8985
08d874ef805c4848af42b8f83ab1e411
RY(p2₁₉)
25763adf436f44f7a208198790bf8985--08d874ef805c4848af42b8f83ab1e411
c7d7a73353924dd29eac1dc039513613
RX(p2₂₃)
08d874ef805c4848af42b8f83ab1e411--c7d7a73353924dd29eac1dc039513613
66e47b17915c40c8878135614f4ed7d1
X
c7d7a73353924dd29eac1dc039513613--66e47b17915c40c8878135614f4ed7d1
66e47b17915c40c8878135614f4ed7d1--0c3aee26700c45638834332edfcb35c4
510084a316b54a2da1747719dde6681f
66e47b17915c40c8878135614f4ed7d1--510084a316b54a2da1747719dde6681f
510084a316b54a2da1747719dde6681f--8f53042945a94e18be0f09cd85904c0d
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.8235 ] )) , (' t he ta _ 0 ' , tens or( [ 0.2038 ] )) , (' t he ta _ 1 ' , tens or( [ 0.7853 ] )) , (' t he ta _ 10 ' , tens or( [ 0.9408 ] )) , (' t he ta _ 11 ' , tens or( [ 0.4441 ] )) , (' t he ta _ 12 ' , tens or( [ 0.6926 ] )) , (' t he ta _ 13 ' , tens or( [ 0.3457 ] )) , (' t he ta _ 14 ' , tens or( [ 0.6128 ] )) , (' t he ta _ 15 ' , tens or( [ 0.6174 ] )) , (' t he ta _ 16 ' , tens or( [ 0.8657 ] )) , (' t he ta _ 17 ' , tens or( [ 0.8418 ] )) , (' t he ta _ 18 ' , tens or( [ 0.1063 ] )) , (' t he ta _ 19 ' , tens or( [ 0.6077 ] )) , (' t he ta _ 2 ' , tens or( [ 0.2668 ] )) , (' t he ta _ 20 ' , tens or( [ 0.8846 ] )) , (' t he ta _ 21 ' , tens or( [ 0.9668 ] )) , (' t he ta _ 22 ' , tens or( [ 0.2565 ] )) , (' t he ta _ 23 ' , tens or( [ 0.1043 ] )) , (' t he ta _ 3 ' , tens or( [ 0.5797 ] )) , (' t he ta _ 4 ' , tens or( [ 0.4227 ] )) , (' t he ta _ 5 ' , tens or( [ 0.6723 ] )) , (' t he ta _ 6 ' , tens or( [ 0.1476 ] )) , (' t he ta _ 7 ' , tens or( [ 0.6309 ] )) , (' t he ta _ 8 ' , tens or( [ 0.1834 ] )) , (' t he ta _ 9 ' , tens or( [ 0.8038 ] )) ] )
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.8225 ] )) , (' t he ta _ 0 ' , tens or( [ 0.2048 ] )) , (' t he ta _ 1 ' , tens or( [ 0.7863 ] )) , (' t he ta _ 10 ' , tens or( [ 0.9398 ] )) , (' t he ta _ 11 ' , tens or( [ 0.4451 ] )) , (' t he ta _ 12 ' , tens or( [ 0.6916 ] )) , (' t he ta _ 13 ' , tens or( [ 0.3467 ] )) , (' t he ta _ 14 ' , tens or( [ 0.6118 ] )) , (' t he ta _ 15 ' , tens or( [ 0.6184 ] )) , (' t he ta _ 16 ' , tens or( [ 0.8647 ] )) , (' t he ta _ 17 ' , tens or( [ 0.8408 ] )) , (' t he ta _ 18 ' , tens or( [ 0.1073 ] )) , (' t he ta _ 19 ' , tens or( [ 0.6067 ] )) , (' t he ta _ 2 ' , tens or( [ 0.2658 ] )) , (' t he ta _ 20 ' , tens or( [ 0.8836 ] )) , (' t he ta _ 21 ' , tens or( [ 0.9678 ] )) , (' t he ta _ 22 ' , tens or( [ 0.2555 ] )) , (' t he ta _ 23 ' , tens or( [ 0.1053 ] )) , (' t he ta _ 3 ' , tens or( [ 0.5787 ] )) , (' t he ta _ 4 ' , tens or( [ 0.4217 ] )) , (' t he ta _ 5 ' , tens or( [ 0.6713 ] )) , (' t he ta _ 6 ' , tens or( [ 0.1486 ] )) , (' t he ta _ 7 ' , tens or( [ 0.6319 ] )) , (' t he ta _ 8 ' , tens or( [ 0.1844 ] )) , (' t he ta _ 9 ' , tens or( [ 0.8028 ] )) ] )
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 ]] )