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.9903+0.0000 j , 0.0000-0.1388 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.8950+0.0000 j , 0.0000-0.4460 j ],
[ 0.9960+0.0000 j , 0.0000-0.0893 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.7308+0.0000 j , 0.6788+0.0000 j , 0.0000-0.0523 j , 0.0000-0.0486 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_9aa7e5cbc3c442c7a073b572eb4d4460
[* 2]
cluster_378cf4964662445f837893df4790c1fb
Rotations
df84abf7f0f94f98a91c407ac2c39b17
0
3bcd7ebc1d024ecbbbee121b6ea10bda
RX(phi/theta)
df84abf7f0f94f98a91c407ac2c39b17--3bcd7ebc1d024ecbbbee121b6ea10bda
f3ce1eb1046e47668a5a94fd07a53c77
1
67b4fbdb84c547cfb2e54a43aa103a8c
RX(phi)
3bcd7ebc1d024ecbbbee121b6ea10bda--67b4fbdb84c547cfb2e54a43aa103a8c
0470deebc089482ea8c214ddb60ee1d5
RX(phi)
67b4fbdb84c547cfb2e54a43aa103a8c--0470deebc089482ea8c214ddb60ee1d5
375485c6f9cb4b489b5fe9869f4bbf3d
RX(phi + theta)
0470deebc089482ea8c214ddb60ee1d5--375485c6f9cb4b489b5fe9869f4bbf3d
02280914d36240a899d1cbad7fd7134c
375485c6f9cb4b489b5fe9869f4bbf3d--02280914d36240a899d1cbad7fd7134c
0aa3dc67ed7144329bbeac0d443cd8f8
02280914d36240a899d1cbad7fd7134c--0aa3dc67ed7144329bbeac0d443cd8f8
9d97e180fb504a7b8293da97e9986c38
Z
0aa3dc67ed7144329bbeac0d443cd8f8--9d97e180fb504a7b8293da97e9986c38
c363e1fa79b24f1cb2cce61fc2f567fc
9d97e180fb504a7b8293da97e9986c38--c363e1fa79b24f1cb2cce61fc2f567fc
040ddf7e4e1340d694c39ae3fddfe589
96fb2fc5cc3949c5966800dff5ed7a63
RY(2*theta)
f3ce1eb1046e47668a5a94fd07a53c77--96fb2fc5cc3949c5966800dff5ed7a63
dd4215f55c9640e0b534c19fe7af3355
2
8907a0d298ba432fb77817a1dd7ce662
RY(theta)
96fb2fc5cc3949c5966800dff5ed7a63--8907a0d298ba432fb77817a1dd7ce662
a8774afdadd94ecb910546254ec9fb65
RY(theta)
8907a0d298ba432fb77817a1dd7ce662--a8774afdadd94ecb910546254ec9fb65
d575ba7ddf0f4695a78ba0c40edaa24a
RY(theta**2)
a8774afdadd94ecb910546254ec9fb65--d575ba7ddf0f4695a78ba0c40edaa24a
8fbaccfd34cb49c194645ccf9b3a9365
X
d575ba7ddf0f4695a78ba0c40edaa24a--8fbaccfd34cb49c194645ccf9b3a9365
8fbaccfd34cb49c194645ccf9b3a9365--02280914d36240a899d1cbad7fd7134c
ac9a4f86fefd49f1a24ab2ddffe284f2
8fbaccfd34cb49c194645ccf9b3a9365--ac9a4f86fefd49f1a24ab2ddffe284f2
3fb6e1422f814c6e8726e046712d04a5
Z
ac9a4f86fefd49f1a24ab2ddffe284f2--3fb6e1422f814c6e8726e046712d04a5
3fb6e1422f814c6e8726e046712d04a5--040ddf7e4e1340d694c39ae3fddfe589
9ce444796cbe4bdaadc43862f8e706ff
328ce74e0f30427e868f8a359f3f2b18
RZ(cos(phi))
dd4215f55c9640e0b534c19fe7af3355--328ce74e0f30427e868f8a359f3f2b18
e8249fc78bbe473ba2b9852f8334e69d
RZ(phi)
328ce74e0f30427e868f8a359f3f2b18--e8249fc78bbe473ba2b9852f8334e69d
d2bc140fa4f24948a624a1fbdeaa824e
RZ(phi)
e8249fc78bbe473ba2b9852f8334e69d--d2bc140fa4f24948a624a1fbdeaa824e
686821479795441eb23b8975470a3cfa
RZ(cos(phi))
d2bc140fa4f24948a624a1fbdeaa824e--686821479795441eb23b8975470a3cfa
88ac8214e5a445e790a4826f2aa1c6a6
686821479795441eb23b8975470a3cfa--88ac8214e5a445e790a4826f2aa1c6a6
3e90e5c90ae141af860831558ca34ef8
X
88ac8214e5a445e790a4826f2aa1c6a6--3e90e5c90ae141af860831558ca34ef8
3e90e5c90ae141af860831558ca34ef8--ac9a4f86fefd49f1a24ab2ddffe284f2
c72d7dcd0960404d8a79d7e67ac62052
Z
3e90e5c90ae141af860831558ca34ef8--c72d7dcd0960404d8a79d7e67ac62052
c72d7dcd0960404d8a79d7e67ac62052--9ce444796cbe4bdaadc43862f8e706ff
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.1479 ] )) ] )
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.9868+0.0000 j , 0.1142+0.0000 j , 0.0000-0.1142 j , 0.0000-0.0132 j ],
[ 0.9047+0.0000 j , 0.2937+0.0000 j , 0.0000-0.2937 j , 0.0000-0.0953 j ],
[ 0.8202+0.0000 j , 0.3840+0.0000 j , 0.0000-0.3840 j , 0.0000-0.1798 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
dc76db6ec219418686f3e9f833d769cb
0
1f2dc5ae6446455a89777a345c54d4a5
RX(theta₀)
dc76db6ec219418686f3e9f833d769cb--1f2dc5ae6446455a89777a345c54d4a5
bbd409c1550a4ad9bc5e091dd2359159
1
477fb21f31ec4eb18bdb7694a61043a9
RY(theta₄)
1f2dc5ae6446455a89777a345c54d4a5--477fb21f31ec4eb18bdb7694a61043a9
1abc1d3bdc9b4962960bda5db8eb4f39
RX(theta₈)
477fb21f31ec4eb18bdb7694a61043a9--1abc1d3bdc9b4962960bda5db8eb4f39
6805df645eb0496aa795460abdee85da
1abc1d3bdc9b4962960bda5db8eb4f39--6805df645eb0496aa795460abdee85da
f5c96a57c6a445c5a9cedb7ef55d489e
6805df645eb0496aa795460abdee85da--f5c96a57c6a445c5a9cedb7ef55d489e
06afcb57155247f786278c50145f8199
RX(theta₁₂)
f5c96a57c6a445c5a9cedb7ef55d489e--06afcb57155247f786278c50145f8199
0babb7438a5c46a38235d8f4b4ae7849
RY(theta₁₆)
06afcb57155247f786278c50145f8199--0babb7438a5c46a38235d8f4b4ae7849
7179fd6275e44db38604b5d8fca32325
RX(theta₂₀)
0babb7438a5c46a38235d8f4b4ae7849--7179fd6275e44db38604b5d8fca32325
ea035ba6ea244169842642d8282c65da
7179fd6275e44db38604b5d8fca32325--ea035ba6ea244169842642d8282c65da
b2102d1979894277b1619d3981c2ab93
ea035ba6ea244169842642d8282c65da--b2102d1979894277b1619d3981c2ab93
a29437c70e9741e59cf0bd2d499be90a
b2102d1979894277b1619d3981c2ab93--a29437c70e9741e59cf0bd2d499be90a
6ae2eeb7f1154c008af032a449d93306
aa4626b57c2349919d8347e6f9c7e324
RX(theta₁)
bbd409c1550a4ad9bc5e091dd2359159--aa4626b57c2349919d8347e6f9c7e324
49b1760fb51d41eda1c5ebc66bd68107
2
94c1d3107c5e4932bf3b6e7c039d640e
RY(theta₅)
aa4626b57c2349919d8347e6f9c7e324--94c1d3107c5e4932bf3b6e7c039d640e
89787966ab344e22950e6b10c1cd0c9a
RX(theta₉)
94c1d3107c5e4932bf3b6e7c039d640e--89787966ab344e22950e6b10c1cd0c9a
1ed2686395254075aa3e4d64c75579d9
X
89787966ab344e22950e6b10c1cd0c9a--1ed2686395254075aa3e4d64c75579d9
1ed2686395254075aa3e4d64c75579d9--6805df645eb0496aa795460abdee85da
f89a73b6d9974ee3a450cba53158e144
1ed2686395254075aa3e4d64c75579d9--f89a73b6d9974ee3a450cba53158e144
13badfda85b24f7a9b918d660f150e23
RX(theta₁₃)
f89a73b6d9974ee3a450cba53158e144--13badfda85b24f7a9b918d660f150e23
7c8f1e24ee4040c3b5695cb1c0b12009
RY(theta₁₇)
13badfda85b24f7a9b918d660f150e23--7c8f1e24ee4040c3b5695cb1c0b12009
a65015a6ccda4ae9b486c53627212853
RX(theta₂₁)
7c8f1e24ee4040c3b5695cb1c0b12009--a65015a6ccda4ae9b486c53627212853
fa3f20b7c6f44c61bd882bde9914727a
X
a65015a6ccda4ae9b486c53627212853--fa3f20b7c6f44c61bd882bde9914727a
fa3f20b7c6f44c61bd882bde9914727a--ea035ba6ea244169842642d8282c65da
d891f339b84f4164abe5dc646b519dd2
fa3f20b7c6f44c61bd882bde9914727a--d891f339b84f4164abe5dc646b519dd2
d891f339b84f4164abe5dc646b519dd2--6ae2eeb7f1154c008af032a449d93306
74de9b235ed745d2b6cbf11a72e00aec
02665a1dbc1b46128291a9a390f54d09
RX(theta₂)
49b1760fb51d41eda1c5ebc66bd68107--02665a1dbc1b46128291a9a390f54d09
5b0f4a43bd974782a8a6834760d5ac78
3
b2d007ce917842f987c4a5d7ff1f6384
RY(theta₆)
02665a1dbc1b46128291a9a390f54d09--b2d007ce917842f987c4a5d7ff1f6384
02ebf66f29594d0491f45c845c1e4693
RX(theta₁₀)
b2d007ce917842f987c4a5d7ff1f6384--02ebf66f29594d0491f45c845c1e4693
71ca3745c0dd4fdf84b5f0f75e21813d
02ebf66f29594d0491f45c845c1e4693--71ca3745c0dd4fdf84b5f0f75e21813d
41bbd6c180404139b929e207576baecc
X
71ca3745c0dd4fdf84b5f0f75e21813d--41bbd6c180404139b929e207576baecc
41bbd6c180404139b929e207576baecc--f89a73b6d9974ee3a450cba53158e144
61e897850d9849d9b0a8e154ad4ba4c5
RX(theta₁₄)
41bbd6c180404139b929e207576baecc--61e897850d9849d9b0a8e154ad4ba4c5
9a2559c306514473b3db95b370a6e47f
RY(theta₁₈)
61e897850d9849d9b0a8e154ad4ba4c5--9a2559c306514473b3db95b370a6e47f
3efde368b5074cebaa5dcab70f35b689
RX(theta₂₂)
9a2559c306514473b3db95b370a6e47f--3efde368b5074cebaa5dcab70f35b689
6890a6d9dce24ec78eb520c6e2adcbf9
3efde368b5074cebaa5dcab70f35b689--6890a6d9dce24ec78eb520c6e2adcbf9
4c34ae869d744aa5803c7e1af0a1b705
X
6890a6d9dce24ec78eb520c6e2adcbf9--4c34ae869d744aa5803c7e1af0a1b705
4c34ae869d744aa5803c7e1af0a1b705--d891f339b84f4164abe5dc646b519dd2
4c34ae869d744aa5803c7e1af0a1b705--74de9b235ed745d2b6cbf11a72e00aec
9bdcd00b86e54819b825980995360708
4879fd281ae647b29c1410ef437258a0
RX(theta₃)
5b0f4a43bd974782a8a6834760d5ac78--4879fd281ae647b29c1410ef437258a0
c7a749163cca44bc9ed6da029c79ef06
RY(theta₇)
4879fd281ae647b29c1410ef437258a0--c7a749163cca44bc9ed6da029c79ef06
77580ecc7fe64375b8765e667b158b22
RX(theta₁₁)
c7a749163cca44bc9ed6da029c79ef06--77580ecc7fe64375b8765e667b158b22
7b6f31215c614cc0b4612490f7940ab7
X
77580ecc7fe64375b8765e667b158b22--7b6f31215c614cc0b4612490f7940ab7
7b6f31215c614cc0b4612490f7940ab7--71ca3745c0dd4fdf84b5f0f75e21813d
fd9f44905e164372aa9caf9b98ed6d48
7b6f31215c614cc0b4612490f7940ab7--fd9f44905e164372aa9caf9b98ed6d48
d53bc3fa8d9b4e5da5604ab6ef2bf798
RX(theta₁₅)
fd9f44905e164372aa9caf9b98ed6d48--d53bc3fa8d9b4e5da5604ab6ef2bf798
c9addcb944f247df8aaa35c6fc25b485
RY(theta₁₉)
d53bc3fa8d9b4e5da5604ab6ef2bf798--c9addcb944f247df8aaa35c6fc25b485
09aeac1ce6af4c1ba9329bb66595a371
RX(theta₂₃)
c9addcb944f247df8aaa35c6fc25b485--09aeac1ce6af4c1ba9329bb66595a371
56c95012005c4af3a124799baa3dde94
X
09aeac1ce6af4c1ba9329bb66595a371--56c95012005c4af3a124799baa3dde94
56c95012005c4af3a124799baa3dde94--6890a6d9dce24ec78eb520c6e2adcbf9
a7e3ff84458c4308a43db3baf193cf7a
56c95012005c4af3a124799baa3dde94--a7e3ff84458c4308a43db3baf193cf7a
a7e3ff84458c4308a43db3baf193cf7a--9bdcd00b86e54819b825980995360708
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_053be443493843e48dc0b6cfa30978f0
HEA
cluster_e9cdae40075b482292b72dab8ae51be3
HEA
8175c34943a9489482bfdec2094ab2e5
0
8cf4e0d7873b4cd1a4e80d4c1d685f1c
RX(theta₀)
8175c34943a9489482bfdec2094ab2e5--8cf4e0d7873b4cd1a4e80d4c1d685f1c
50963c388a2d45a8a37195e9c44a23d5
1
b101c15148cf45aa821cbd77d9b9c998
RY(theta₄)
8cf4e0d7873b4cd1a4e80d4c1d685f1c--b101c15148cf45aa821cbd77d9b9c998
169f840298484012b376b339095432c5
RX(theta₈)
b101c15148cf45aa821cbd77d9b9c998--169f840298484012b376b339095432c5
baf92e5b562a47888457cb36cd099779
169f840298484012b376b339095432c5--baf92e5b562a47888457cb36cd099779
50f29f299db64e35a8ee1039bd0a8d97
baf92e5b562a47888457cb36cd099779--50f29f299db64e35a8ee1039bd0a8d97
7fa428a83b38445b9b1972f88fae19d7
RX(theta₁₂)
50f29f299db64e35a8ee1039bd0a8d97--7fa428a83b38445b9b1972f88fae19d7
5df1ac861f2d4c9ca6d52c4ada80289b
RY(theta₁₆)
7fa428a83b38445b9b1972f88fae19d7--5df1ac861f2d4c9ca6d52c4ada80289b
d95291722ec842348962e1ddb1c2c741
RX(theta₂₀)
5df1ac861f2d4c9ca6d52c4ada80289b--d95291722ec842348962e1ddb1c2c741
00aa1646311a4c30871a130e270a7946
d95291722ec842348962e1ddb1c2c741--00aa1646311a4c30871a130e270a7946
7035ced06d3a41f095e0db7564a3217c
00aa1646311a4c30871a130e270a7946--7035ced06d3a41f095e0db7564a3217c
1ba92aae8e954e5f8c7ee654ed95d148
RX(theta₀)
7035ced06d3a41f095e0db7564a3217c--1ba92aae8e954e5f8c7ee654ed95d148
54469788c3f6493dab90acc74032dc59
RY(theta₄)
1ba92aae8e954e5f8c7ee654ed95d148--54469788c3f6493dab90acc74032dc59
ba4e1e4db60644fe82366b5d4c095785
RX(theta₈)
54469788c3f6493dab90acc74032dc59--ba4e1e4db60644fe82366b5d4c095785
27b1fdda4c274416a331d95dc6caedc0
ba4e1e4db60644fe82366b5d4c095785--27b1fdda4c274416a331d95dc6caedc0
c45b15a5f0d541c9bc11d86005d18d57
27b1fdda4c274416a331d95dc6caedc0--c45b15a5f0d541c9bc11d86005d18d57
a8e7ad2e48db4768be86b5be8498eeb7
RX(theta₁₂)
c45b15a5f0d541c9bc11d86005d18d57--a8e7ad2e48db4768be86b5be8498eeb7
135921978d1d4c8d91d9490a3eb89241
RY(theta₁₆)
a8e7ad2e48db4768be86b5be8498eeb7--135921978d1d4c8d91d9490a3eb89241
58eab06bd6054980ae049b809ca8a88b
RX(theta₂₀)
135921978d1d4c8d91d9490a3eb89241--58eab06bd6054980ae049b809ca8a88b
1c14be7b28d24dda8040df74aef9c045
58eab06bd6054980ae049b809ca8a88b--1c14be7b28d24dda8040df74aef9c045
993f844c450f4f0f827df134f94037ce
1c14be7b28d24dda8040df74aef9c045--993f844c450f4f0f827df134f94037ce
a0de7e0f9b464f0b87ec0b02784e070b
993f844c450f4f0f827df134f94037ce--a0de7e0f9b464f0b87ec0b02784e070b
ed2c8bdbd6ac4f6cabeaaf28c72660ed
8824247294c04e77b82eb82f601ffe99
RX(theta₁)
50963c388a2d45a8a37195e9c44a23d5--8824247294c04e77b82eb82f601ffe99
1407bacc2232448b822afc647c208d1f
2
2c0216ef77424d17b70179b69c21147f
RY(theta₅)
8824247294c04e77b82eb82f601ffe99--2c0216ef77424d17b70179b69c21147f
d8547d6eafd644e897110ba9bff526ba
RX(theta₉)
2c0216ef77424d17b70179b69c21147f--d8547d6eafd644e897110ba9bff526ba
b47e1e69463840a993ab14a017974925
X
d8547d6eafd644e897110ba9bff526ba--b47e1e69463840a993ab14a017974925
b47e1e69463840a993ab14a017974925--baf92e5b562a47888457cb36cd099779
a4c1050d430540b5abda81d362c7990c
b47e1e69463840a993ab14a017974925--a4c1050d430540b5abda81d362c7990c
e2576e760cf9454e948259ca59c85b8d
RX(theta₁₃)
a4c1050d430540b5abda81d362c7990c--e2576e760cf9454e948259ca59c85b8d
2c71367eb1844802914074a8b14eb631
RY(theta₁₇)
e2576e760cf9454e948259ca59c85b8d--2c71367eb1844802914074a8b14eb631
7f5d0e442d24409b939a83fd93fde11d
RX(theta₂₁)
2c71367eb1844802914074a8b14eb631--7f5d0e442d24409b939a83fd93fde11d
6daa4d944fe84e20b271935e2ccadeab
X
7f5d0e442d24409b939a83fd93fde11d--6daa4d944fe84e20b271935e2ccadeab
6daa4d944fe84e20b271935e2ccadeab--00aa1646311a4c30871a130e270a7946
cceaf3de94884926b39cb0035cf8b71e
6daa4d944fe84e20b271935e2ccadeab--cceaf3de94884926b39cb0035cf8b71e
0467d5cbcb684c09a02e5ce9505c63d6
RX(theta₁)
cceaf3de94884926b39cb0035cf8b71e--0467d5cbcb684c09a02e5ce9505c63d6
01e7c62b6ab24bd39272e4aab35d7773
RY(theta₅)
0467d5cbcb684c09a02e5ce9505c63d6--01e7c62b6ab24bd39272e4aab35d7773
cb38f4eedad945eaa1eda5359d1043b5
RX(theta₉)
01e7c62b6ab24bd39272e4aab35d7773--cb38f4eedad945eaa1eda5359d1043b5
aca0ca29c878474cb746199a48a9213f
X
cb38f4eedad945eaa1eda5359d1043b5--aca0ca29c878474cb746199a48a9213f
aca0ca29c878474cb746199a48a9213f--27b1fdda4c274416a331d95dc6caedc0
5884b27520384884b7a2592b55a6766f
aca0ca29c878474cb746199a48a9213f--5884b27520384884b7a2592b55a6766f
c7f3d7aca36f46c6891662d40ae95b08
RX(theta₁₃)
5884b27520384884b7a2592b55a6766f--c7f3d7aca36f46c6891662d40ae95b08
f69de6c7772a421b8bde507a00f61cf7
RY(theta₁₇)
c7f3d7aca36f46c6891662d40ae95b08--f69de6c7772a421b8bde507a00f61cf7
e320f3b9fea5485d8a3afe460f2edeb3
RX(theta₂₁)
f69de6c7772a421b8bde507a00f61cf7--e320f3b9fea5485d8a3afe460f2edeb3
5a7d0d363e0e45cc86d9bc8af171f140
X
e320f3b9fea5485d8a3afe460f2edeb3--5a7d0d363e0e45cc86d9bc8af171f140
5a7d0d363e0e45cc86d9bc8af171f140--1c14be7b28d24dda8040df74aef9c045
c6921ae30ac247c1adb4b7bf8c700d34
5a7d0d363e0e45cc86d9bc8af171f140--c6921ae30ac247c1adb4b7bf8c700d34
c6921ae30ac247c1adb4b7bf8c700d34--ed2c8bdbd6ac4f6cabeaaf28c72660ed
65ea8f3d345d400e8c3f855f70546ed7
a14fd72f21844f2d9a837816d326b81f
RX(theta₂)
1407bacc2232448b822afc647c208d1f--a14fd72f21844f2d9a837816d326b81f
a951716e9a6840e7a1b30078a675dfb4
3
b8b1c101835e4cceac522129a5021beb
RY(theta₆)
a14fd72f21844f2d9a837816d326b81f--b8b1c101835e4cceac522129a5021beb
4651ca6dc43e47e392da9c2917b25009
RX(theta₁₀)
b8b1c101835e4cceac522129a5021beb--4651ca6dc43e47e392da9c2917b25009
3be16a1e2ff843abaa5bfd67216f5d7f
4651ca6dc43e47e392da9c2917b25009--3be16a1e2ff843abaa5bfd67216f5d7f
8faed86b9b1a488fbd38a1af15ae146d
X
3be16a1e2ff843abaa5bfd67216f5d7f--8faed86b9b1a488fbd38a1af15ae146d
8faed86b9b1a488fbd38a1af15ae146d--a4c1050d430540b5abda81d362c7990c
db2d8bb27cdd41339467ba3da723b7a2
RX(theta₁₄)
8faed86b9b1a488fbd38a1af15ae146d--db2d8bb27cdd41339467ba3da723b7a2
7560bbc2c6fe45ebbe6af6a73182cfdb
RY(theta₁₈)
db2d8bb27cdd41339467ba3da723b7a2--7560bbc2c6fe45ebbe6af6a73182cfdb
9921d4a1a5004281b8c44de12d317da9
RX(theta₂₂)
7560bbc2c6fe45ebbe6af6a73182cfdb--9921d4a1a5004281b8c44de12d317da9
ec9b0744009a4422afbc7771e41c2187
9921d4a1a5004281b8c44de12d317da9--ec9b0744009a4422afbc7771e41c2187
7c91f8d509a84cf69bfd70d19b2eed21
X
ec9b0744009a4422afbc7771e41c2187--7c91f8d509a84cf69bfd70d19b2eed21
7c91f8d509a84cf69bfd70d19b2eed21--cceaf3de94884926b39cb0035cf8b71e
169ccb94a68f4701969b1582c38a84e3
RX(theta₂)
7c91f8d509a84cf69bfd70d19b2eed21--169ccb94a68f4701969b1582c38a84e3
7e6b61b04a854546b71246b6369daa9d
RY(theta₆)
169ccb94a68f4701969b1582c38a84e3--7e6b61b04a854546b71246b6369daa9d
c202dc3a99b54e7cba1b48c22bfa0605
RX(theta₁₀)
7e6b61b04a854546b71246b6369daa9d--c202dc3a99b54e7cba1b48c22bfa0605
6fbe1682b5a64625b7eb0332ec137c39
c202dc3a99b54e7cba1b48c22bfa0605--6fbe1682b5a64625b7eb0332ec137c39
071fa610a5574040982e5ee2fc77e9b8
X
6fbe1682b5a64625b7eb0332ec137c39--071fa610a5574040982e5ee2fc77e9b8
071fa610a5574040982e5ee2fc77e9b8--5884b27520384884b7a2592b55a6766f
144a8f39853844c8b50728da57ee6335
RX(theta₁₄)
071fa610a5574040982e5ee2fc77e9b8--144a8f39853844c8b50728da57ee6335
14af9f077012440396da2b66fcdbaa80
RY(theta₁₈)
144a8f39853844c8b50728da57ee6335--14af9f077012440396da2b66fcdbaa80
55738cf902844fbb9c77fe330236c577
RX(theta₂₂)
14af9f077012440396da2b66fcdbaa80--55738cf902844fbb9c77fe330236c577
87c6b9596c154d73a7bf8e89fc0264b2
55738cf902844fbb9c77fe330236c577--87c6b9596c154d73a7bf8e89fc0264b2
7237181572bd424283f3a7648c004ee5
X
87c6b9596c154d73a7bf8e89fc0264b2--7237181572bd424283f3a7648c004ee5
7237181572bd424283f3a7648c004ee5--c6921ae30ac247c1adb4b7bf8c700d34
7237181572bd424283f3a7648c004ee5--65ea8f3d345d400e8c3f855f70546ed7
3da82fdf129f4b5d9e2a37c973adeb97
1f301856fb03483e8852a5e9c952440a
RX(theta₃)
a951716e9a6840e7a1b30078a675dfb4--1f301856fb03483e8852a5e9c952440a
4ef5f8e1088c410c839a51dfa558b953
RY(theta₇)
1f301856fb03483e8852a5e9c952440a--4ef5f8e1088c410c839a51dfa558b953
38493ecbc395454ebe66356b8cb1446b
RX(theta₁₁)
4ef5f8e1088c410c839a51dfa558b953--38493ecbc395454ebe66356b8cb1446b
64f8b20cf7e447fdb3fc00e95e5b0771
X
38493ecbc395454ebe66356b8cb1446b--64f8b20cf7e447fdb3fc00e95e5b0771
64f8b20cf7e447fdb3fc00e95e5b0771--3be16a1e2ff843abaa5bfd67216f5d7f
d9941d5ca5f841b5bdcc0800a9a4237c
64f8b20cf7e447fdb3fc00e95e5b0771--d9941d5ca5f841b5bdcc0800a9a4237c
01f23bf082374b218182675d0ec7ce43
RX(theta₁₅)
d9941d5ca5f841b5bdcc0800a9a4237c--01f23bf082374b218182675d0ec7ce43
d48766a7f864467cac5728ef8e393495
RY(theta₁₉)
01f23bf082374b218182675d0ec7ce43--d48766a7f864467cac5728ef8e393495
e301417d597e4fe4bf5abd758753da31
RX(theta₂₃)
d48766a7f864467cac5728ef8e393495--e301417d597e4fe4bf5abd758753da31
0a10a88b4d824b1da707ec09033904b1
X
e301417d597e4fe4bf5abd758753da31--0a10a88b4d824b1da707ec09033904b1
0a10a88b4d824b1da707ec09033904b1--ec9b0744009a4422afbc7771e41c2187
01cd1dc473eb46d1bc389fec0619445b
0a10a88b4d824b1da707ec09033904b1--01cd1dc473eb46d1bc389fec0619445b
678861f286b44fa5a761274b61911091
RX(theta₃)
01cd1dc473eb46d1bc389fec0619445b--678861f286b44fa5a761274b61911091
525a146a50d0454fa2eba4df8794e2d4
RY(theta₇)
678861f286b44fa5a761274b61911091--525a146a50d0454fa2eba4df8794e2d4
5075ab8da1a9409a94047b82e9122cb6
RX(theta₁₁)
525a146a50d0454fa2eba4df8794e2d4--5075ab8da1a9409a94047b82e9122cb6
0823553d60f9408bbaa35b10e121b6ce
X
5075ab8da1a9409a94047b82e9122cb6--0823553d60f9408bbaa35b10e121b6ce
0823553d60f9408bbaa35b10e121b6ce--6fbe1682b5a64625b7eb0332ec137c39
a522f98b87f0440cb0d635510aad971c
0823553d60f9408bbaa35b10e121b6ce--a522f98b87f0440cb0d635510aad971c
1ec96c56cd5a4fb2b04142e0b3464020
RX(theta₁₅)
a522f98b87f0440cb0d635510aad971c--1ec96c56cd5a4fb2b04142e0b3464020
6c50d659d81c48dcb9e4c290f035149e
RY(theta₁₉)
1ec96c56cd5a4fb2b04142e0b3464020--6c50d659d81c48dcb9e4c290f035149e
5e778a5da34b41db8c1b02b0d6a8984f
RX(theta₂₃)
6c50d659d81c48dcb9e4c290f035149e--5e778a5da34b41db8c1b02b0d6a8984f
2550c191ca3e42b38e66d7cdd21f19d9
X
5e778a5da34b41db8c1b02b0d6a8984f--2550c191ca3e42b38e66d7cdd21f19d9
2550c191ca3e42b38e66d7cdd21f19d9--87c6b9596c154d73a7bf8e89fc0264b2
40e288b310db43de9be0f09ffb157ade
2550c191ca3e42b38e66d7cdd21f19d9--40e288b310db43de9be0f09ffb157ade
40e288b310db43de9be0f09ffb157ade--3da82fdf129f4b5d9e2a37c973adeb97
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_f781f5d63ba040f1ac68416f7e2c1da1
HEA
cluster_c2e912ff01694829bbdd790e8bed2829
HEA
38ef22e8533f41dbad3e1c2313e53d5d
0
afd4cedfcb9f4b15b87095ad037a18bb
RX(p1₀)
38ef22e8533f41dbad3e1c2313e53d5d--afd4cedfcb9f4b15b87095ad037a18bb
4008d7092eb34f4fab2578cf305c27de
1
6dd572797383433e9922041d78480a50
RY(p1₄)
afd4cedfcb9f4b15b87095ad037a18bb--6dd572797383433e9922041d78480a50
426465ebd27046ee8b6eb7f9b72221f3
RX(p1₈)
6dd572797383433e9922041d78480a50--426465ebd27046ee8b6eb7f9b72221f3
93d79b3244df45268b3dba0e9763e1fd
426465ebd27046ee8b6eb7f9b72221f3--93d79b3244df45268b3dba0e9763e1fd
496a98f610d541e9bde16ba9d625db5d
93d79b3244df45268b3dba0e9763e1fd--496a98f610d541e9bde16ba9d625db5d
d7079b537a8f46f69474e666d2d04810
RX(p1₁₂)
496a98f610d541e9bde16ba9d625db5d--d7079b537a8f46f69474e666d2d04810
b8c467d62be04ed5ae9cb729999591c6
RY(p1₁₆)
d7079b537a8f46f69474e666d2d04810--b8c467d62be04ed5ae9cb729999591c6
609f24d4debc4237a40d59572d965a16
RX(p1₂₀)
b8c467d62be04ed5ae9cb729999591c6--609f24d4debc4237a40d59572d965a16
fff75b967b2f4579ac94500e89a254d1
609f24d4debc4237a40d59572d965a16--fff75b967b2f4579ac94500e89a254d1
0e8386d368514c2d8a7bc18f038c979c
fff75b967b2f4579ac94500e89a254d1--0e8386d368514c2d8a7bc18f038c979c
dede1728619c4d918a05d89464d161dd
RX(p2₀)
0e8386d368514c2d8a7bc18f038c979c--dede1728619c4d918a05d89464d161dd
1cad34d183c94af2963a3f96a3045be1
RY(p2₄)
dede1728619c4d918a05d89464d161dd--1cad34d183c94af2963a3f96a3045be1
217921fcc4804d87a08bae7e69014b77
RX(p2₈)
1cad34d183c94af2963a3f96a3045be1--217921fcc4804d87a08bae7e69014b77
42b72869a11b45ca88428f6de284dc62
217921fcc4804d87a08bae7e69014b77--42b72869a11b45ca88428f6de284dc62
898400c0adde45a49f8156fc8af3d9c4
42b72869a11b45ca88428f6de284dc62--898400c0adde45a49f8156fc8af3d9c4
d05c861d30c34dbe9093957e727f6d56
RX(p2₁₂)
898400c0adde45a49f8156fc8af3d9c4--d05c861d30c34dbe9093957e727f6d56
e1c8520619bc4e3782d48102e8883812
RY(p2₁₆)
d05c861d30c34dbe9093957e727f6d56--e1c8520619bc4e3782d48102e8883812
258c38c1148d46d29f2eafafbeeb4517
RX(p2₂₀)
e1c8520619bc4e3782d48102e8883812--258c38c1148d46d29f2eafafbeeb4517
fd8dc9d7020140dda166a79aff910fec
258c38c1148d46d29f2eafafbeeb4517--fd8dc9d7020140dda166a79aff910fec
65a4192367db47b9b0514b29c6f66139
fd8dc9d7020140dda166a79aff910fec--65a4192367db47b9b0514b29c6f66139
71253492466d44c49e705ab161790622
65a4192367db47b9b0514b29c6f66139--71253492466d44c49e705ab161790622
6e14cbe3473c489ea9980b3ae236fb87
fa0333e0ab5547419fc4ac387090cb40
RX(p1₁)
4008d7092eb34f4fab2578cf305c27de--fa0333e0ab5547419fc4ac387090cb40
9af881a4bdeb43ddb08dd60adc1cfc47
2
4857f1f9264c42d4a5675eca4f646284
RY(p1₅)
fa0333e0ab5547419fc4ac387090cb40--4857f1f9264c42d4a5675eca4f646284
0f18ff6a27464c6d9dc0ccaa54d23c9a
RX(p1₉)
4857f1f9264c42d4a5675eca4f646284--0f18ff6a27464c6d9dc0ccaa54d23c9a
73a21f2a206c4d25b9f97aae7eea0a88
X
0f18ff6a27464c6d9dc0ccaa54d23c9a--73a21f2a206c4d25b9f97aae7eea0a88
73a21f2a206c4d25b9f97aae7eea0a88--93d79b3244df45268b3dba0e9763e1fd
7946449448544a839524b9a74cfda043
73a21f2a206c4d25b9f97aae7eea0a88--7946449448544a839524b9a74cfda043
8d8a0bf333a14700aeaf87c7f8da5dd0
RX(p1₁₃)
7946449448544a839524b9a74cfda043--8d8a0bf333a14700aeaf87c7f8da5dd0
df8c894a02494ddb88c873d46b0114d4
RY(p1₁₇)
8d8a0bf333a14700aeaf87c7f8da5dd0--df8c894a02494ddb88c873d46b0114d4
98afeb59b37a41eab97143809079a14d
RX(p1₂₁)
df8c894a02494ddb88c873d46b0114d4--98afeb59b37a41eab97143809079a14d
d80a58592cbd47669d502471d32da8c1
X
98afeb59b37a41eab97143809079a14d--d80a58592cbd47669d502471d32da8c1
d80a58592cbd47669d502471d32da8c1--fff75b967b2f4579ac94500e89a254d1
ae0a754fe29e42bd9f2a50d24e64e139
d80a58592cbd47669d502471d32da8c1--ae0a754fe29e42bd9f2a50d24e64e139
f49e0510dc2e40d7a235edac4b9f766a
RX(p2₁)
ae0a754fe29e42bd9f2a50d24e64e139--f49e0510dc2e40d7a235edac4b9f766a
9b17adddc4784fce92f2d26546108d65
RY(p2₅)
f49e0510dc2e40d7a235edac4b9f766a--9b17adddc4784fce92f2d26546108d65
97049297d4ec4b70929a30015e4b754a
RX(p2₉)
9b17adddc4784fce92f2d26546108d65--97049297d4ec4b70929a30015e4b754a
0f3f73855fa646dda53d12bd17f44ae8
X
97049297d4ec4b70929a30015e4b754a--0f3f73855fa646dda53d12bd17f44ae8
0f3f73855fa646dda53d12bd17f44ae8--42b72869a11b45ca88428f6de284dc62
5f76b822db054d88a1bb64b90a74c369
0f3f73855fa646dda53d12bd17f44ae8--5f76b822db054d88a1bb64b90a74c369
748b8be73b8543b2905865b11324a901
RX(p2₁₃)
5f76b822db054d88a1bb64b90a74c369--748b8be73b8543b2905865b11324a901
8f31ad4ffcf44fea89ad5d39316bbad1
RY(p2₁₇)
748b8be73b8543b2905865b11324a901--8f31ad4ffcf44fea89ad5d39316bbad1
97938bc12567484ea76456bce33e19cf
RX(p2₂₁)
8f31ad4ffcf44fea89ad5d39316bbad1--97938bc12567484ea76456bce33e19cf
1a6fbc99012f49348a7fd58ca84ae039
X
97938bc12567484ea76456bce33e19cf--1a6fbc99012f49348a7fd58ca84ae039
1a6fbc99012f49348a7fd58ca84ae039--fd8dc9d7020140dda166a79aff910fec
757a7d9c380a405a8f40fdcf838dcad8
1a6fbc99012f49348a7fd58ca84ae039--757a7d9c380a405a8f40fdcf838dcad8
757a7d9c380a405a8f40fdcf838dcad8--6e14cbe3473c489ea9980b3ae236fb87
5951ea99116b458e8fe10b68361247bd
bbb35da1e3ae4ae9bbb44e9dc47154de
RX(p1₂)
9af881a4bdeb43ddb08dd60adc1cfc47--bbb35da1e3ae4ae9bbb44e9dc47154de
06a1a57ba4bf419cb921796762f9274a
3
4d14debb083e4b9890632b90b9ffacf3
RY(p1₆)
bbb35da1e3ae4ae9bbb44e9dc47154de--4d14debb083e4b9890632b90b9ffacf3
fb07d40a65904d3aa774ad5c8543297d
RX(p1₁₀)
4d14debb083e4b9890632b90b9ffacf3--fb07d40a65904d3aa774ad5c8543297d
fc2c815f43844ee2a65f91331715ddcf
fb07d40a65904d3aa774ad5c8543297d--fc2c815f43844ee2a65f91331715ddcf
9e56da7e5a6a4bc4a125b24b2a4139dd
X
fc2c815f43844ee2a65f91331715ddcf--9e56da7e5a6a4bc4a125b24b2a4139dd
9e56da7e5a6a4bc4a125b24b2a4139dd--7946449448544a839524b9a74cfda043
677ba165ac5c4d1e8ef5424caee571c1
RX(p1₁₄)
9e56da7e5a6a4bc4a125b24b2a4139dd--677ba165ac5c4d1e8ef5424caee571c1
6713fbdae84142f5893e1e936885d0ba
RY(p1₁₈)
677ba165ac5c4d1e8ef5424caee571c1--6713fbdae84142f5893e1e936885d0ba
47b755a70be14433bf90793ab8761ec1
RX(p1₂₂)
6713fbdae84142f5893e1e936885d0ba--47b755a70be14433bf90793ab8761ec1
ed46abe8ed4d41a7a13afeccab7b7165
47b755a70be14433bf90793ab8761ec1--ed46abe8ed4d41a7a13afeccab7b7165
5e429e85c882463392c6482edf181456
X
ed46abe8ed4d41a7a13afeccab7b7165--5e429e85c882463392c6482edf181456
5e429e85c882463392c6482edf181456--ae0a754fe29e42bd9f2a50d24e64e139
db6ffdd6941746b198fdd1004aa7b359
RX(p2₂)
5e429e85c882463392c6482edf181456--db6ffdd6941746b198fdd1004aa7b359
3333784745114a5fa6d1712a0e116550
RY(p2₆)
db6ffdd6941746b198fdd1004aa7b359--3333784745114a5fa6d1712a0e116550
d1ad1f1cf39d475aad272bc33c1f1ac3
RX(p2₁₀)
3333784745114a5fa6d1712a0e116550--d1ad1f1cf39d475aad272bc33c1f1ac3
4d0dcc51e52848798d16563d551e3c77
d1ad1f1cf39d475aad272bc33c1f1ac3--4d0dcc51e52848798d16563d551e3c77
218c3aca295740fc8e83901a64e1c00a
X
4d0dcc51e52848798d16563d551e3c77--218c3aca295740fc8e83901a64e1c00a
218c3aca295740fc8e83901a64e1c00a--5f76b822db054d88a1bb64b90a74c369
5f96dfab247f4c2eb5541dca440b6318
RX(p2₁₄)
218c3aca295740fc8e83901a64e1c00a--5f96dfab247f4c2eb5541dca440b6318
a82a421da23f464db525f8702da34c44
RY(p2₁₈)
5f96dfab247f4c2eb5541dca440b6318--a82a421da23f464db525f8702da34c44
38a53c6b1079435890ef09452a6d551b
RX(p2₂₂)
a82a421da23f464db525f8702da34c44--38a53c6b1079435890ef09452a6d551b
d2f6d59cbb814e0797f1061a10574822
38a53c6b1079435890ef09452a6d551b--d2f6d59cbb814e0797f1061a10574822
6d8c91a1a44d41e98c0795b9231c613f
X
d2f6d59cbb814e0797f1061a10574822--6d8c91a1a44d41e98c0795b9231c613f
6d8c91a1a44d41e98c0795b9231c613f--757a7d9c380a405a8f40fdcf838dcad8
6d8c91a1a44d41e98c0795b9231c613f--5951ea99116b458e8fe10b68361247bd
bec17f24bb464ca9aafd286531583200
eaa2e4bba4e04cd4bd20bddee47de0f2
RX(p1₃)
06a1a57ba4bf419cb921796762f9274a--eaa2e4bba4e04cd4bd20bddee47de0f2
eda650f0a5964f1db9a4d4fa1d50e25f
RY(p1₇)
eaa2e4bba4e04cd4bd20bddee47de0f2--eda650f0a5964f1db9a4d4fa1d50e25f
9e804ecc859642958d76cb9f85380762
RX(p1₁₁)
eda650f0a5964f1db9a4d4fa1d50e25f--9e804ecc859642958d76cb9f85380762
fb7d3dec734d46bb9b9c0831f55befff
X
9e804ecc859642958d76cb9f85380762--fb7d3dec734d46bb9b9c0831f55befff
fb7d3dec734d46bb9b9c0831f55befff--fc2c815f43844ee2a65f91331715ddcf
6b9285a2fbfc423893d988b3818bfcc4
fb7d3dec734d46bb9b9c0831f55befff--6b9285a2fbfc423893d988b3818bfcc4
aee48ba6290a46819a4c995ee73a18df
RX(p1₁₅)
6b9285a2fbfc423893d988b3818bfcc4--aee48ba6290a46819a4c995ee73a18df
d376978168ea4a02998ee6efcaf3ba1d
RY(p1₁₉)
aee48ba6290a46819a4c995ee73a18df--d376978168ea4a02998ee6efcaf3ba1d
43520c90db1140939cfad5a24be76756
RX(p1₂₃)
d376978168ea4a02998ee6efcaf3ba1d--43520c90db1140939cfad5a24be76756
a51d595a41e74b0bad1da0261c029276
X
43520c90db1140939cfad5a24be76756--a51d595a41e74b0bad1da0261c029276
a51d595a41e74b0bad1da0261c029276--ed46abe8ed4d41a7a13afeccab7b7165
3f27058d3d1948998fc6b679b26f1c7c
a51d595a41e74b0bad1da0261c029276--3f27058d3d1948998fc6b679b26f1c7c
da03bc3349294571b3781e045fd296cf
RX(p2₃)
3f27058d3d1948998fc6b679b26f1c7c--da03bc3349294571b3781e045fd296cf
28ebbc47626a4cfdbebb5971e048243e
RY(p2₇)
da03bc3349294571b3781e045fd296cf--28ebbc47626a4cfdbebb5971e048243e
a9091d3494364a5ba9bc374773e8abef
RX(p2₁₁)
28ebbc47626a4cfdbebb5971e048243e--a9091d3494364a5ba9bc374773e8abef
0a5a17800b0c4eebaa84b205da25bf2c
X
a9091d3494364a5ba9bc374773e8abef--0a5a17800b0c4eebaa84b205da25bf2c
0a5a17800b0c4eebaa84b205da25bf2c--4d0dcc51e52848798d16563d551e3c77
c84100b726a8448aa0c3b4ff581918e3
0a5a17800b0c4eebaa84b205da25bf2c--c84100b726a8448aa0c3b4ff581918e3
7ecd115aa4f042b197468c4413e6e7b8
RX(p2₁₅)
c84100b726a8448aa0c3b4ff581918e3--7ecd115aa4f042b197468c4413e6e7b8
a56f94090cca49c18ea69a19da68ee17
RY(p2₁₉)
7ecd115aa4f042b197468c4413e6e7b8--a56f94090cca49c18ea69a19da68ee17
4797a46d8d9940cf9df0fc71d2b6c1ac
RX(p2₂₃)
a56f94090cca49c18ea69a19da68ee17--4797a46d8d9940cf9df0fc71d2b6c1ac
2a60bd7635d2466d84c469f926ee8e2e
X
4797a46d8d9940cf9df0fc71d2b6c1ac--2a60bd7635d2466d84c469f926ee8e2e
2a60bd7635d2466d84c469f926ee8e2e--d2f6d59cbb814e0797f1061a10574822
f75a2315ef9841e5aebe2cc3a3793cda
2a60bd7635d2466d84c469f926ee8e2e--f75a2315ef9841e5aebe2cc3a3793cda
f75a2315ef9841e5aebe2cc3a3793cda--bec17f24bb464ca9aafd286531583200
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.6032 ] )) , (' t he ta _ 0 ' , tens or( [ 0.7060 ] )) , (' t he ta _ 1 ' , tens or( [ 0.8729 ] )) , (' t he ta _ 10 ' , tens or( [ 0.5824 ] )) , (' t he ta _ 11 ' , tens or( [ 0.7651 ] )) , (' t he ta _ 12 ' , tens or( [ 0.7259 ] )) , (' t he ta _ 13 ' , tens or( [ 0.8999 ] )) , (' t he ta _ 14 ' , tens or( [ 0.5249 ] )) , (' t he ta _ 15 ' , tens or( [ 0.8056 ] )) , (' t he ta _ 16 ' , tens or( [ 0.8753 ] )) , (' t he ta _ 17 ' , tens or( [ 0.9508 ] )) , (' t he ta _ 18 ' , tens or( [ 0.5994 ] )) , (' t he ta _ 19 ' , tens or( [ 0.5960 ] )) , (' t he ta _ 2 ' , tens or( [ 0.3586 ] )) , (' t he ta _ 20 ' , tens or( [ 0.0068 ] )) , (' t he ta _ 21 ' , tens or( [ 0.4744 ] )) , (' t he ta _ 22 ' , tens or( [ 0.3152 ] )) , (' t he ta _ 23 ' , tens or( [ 0.4480 ] )) , (' t he ta _ 3 ' , tens or( [ 0.7231 ] )) , (' t he ta _ 4 ' , tens or( [ 0.2878 ] )) , (' t he ta _ 5 ' , tens or( [ 0.8199 ] )) , (' t he ta _ 6 ' , tens or( [ 0.4943 ] )) , (' t he ta _ 7 ' , tens or( [ 0.6892 ] )) , (' t he ta _ 8 ' , tens or( [ 0.0667 ] )) , (' t he ta _ 9 ' , tens or( [ 0.9967 ] )) ] )
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.6022 ] )) , (' t he ta _ 0 ' , tens or( [ 0.7070 ] )) , (' t he ta _ 1 ' , tens or( [ 0.8719 ] )) , (' t he ta _ 10 ' , tens or( [ 0.5834 ] )) , (' t he ta _ 11 ' , tens or( [ 0.7661 ] )) , (' t he ta _ 12 ' , tens or( [ 0.7269 ] )) , (' t he ta _ 13 ' , tens or( [ 0.9009 ] )) , (' t he ta _ 14 ' , tens or( [ 0.5259 ] )) , (' t he ta _ 15 ' , tens or( [ 0.8066 ] )) , (' t he ta _ 16 ' , tens or( [ 0.8763 ] )) , (' t he ta _ 17 ' , tens or( [ 0.9518 ] )) , (' t he ta _ 18 ' , tens or( [ 0.5984 ] )) , (' t he ta _ 19 ' , tens or( [ 0.5970 ] )) , (' t he ta _ 2 ' , tens or( [ 0.3596 ] )) , (' t he ta _ 20 ' , tens or( [ 0.0078 ] )) , (' t he ta _ 21 ' , tens or( [ 0.4754 ] )) , (' t he ta _ 22 ' , tens or( [ 0.3162 ] )) , (' t he ta _ 23 ' , tens or( [ 0.4490 ] )) , (' t he ta _ 3 ' , tens or( [ 0.7241 ] )) , (' t he ta _ 4 ' , tens or( [ 0.2888 ] )) , (' t he ta _ 5 ' , tens or( [ 0.8209 ] )) , (' t he ta _ 6 ' , tens or( [ 0.4953 ] )) , (' t he ta _ 7 ' , tens or( [ 0.6902 ] )) , (' t he ta _ 8 ' , tens or( [ 0.0677 ] )) , (' t he ta _ 9 ' , tens or( [ 0.9957 ] )) ] )
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 ]] )