QNN Config
This module implements the QNN config
class.
AnsatzConfig(depth=1, ansatz_type=AnsatzType.HEA, ansatz_strategy=Strategy.DIGITAL, strategy_args=dict(), m_block_qubits=None, param_prefix='theta', tag=None)
dataclass
ansatz_strategy = Strategy.DIGITAL
class-attribute
instance-attribute
Ansatz strategy.
Strategy.DIGITAL
for fully digital ansatz. Required if ansatz_type
is AnsatzType.ALA
.
Strategy.SDAQC
for analog entangling block. Only available for AnsatzType.HEA
or
AnsatzType.ALA
.
Strategy.RYDBERG
for fully rydberg hea ansatz. Only available for AnsatzType.HEA
.
ansatz_type = AnsatzType.HEA
class-attribute
instance-attribute
What type of ansatz.
AnsatzType.HEA
for Hardware Efficient Ansatz.
AnsatzType.IIA
for Identity Intialized Ansatz.
AnsatzType.ALA
for Alternating Layer Ansatz.
depth = 1
class-attribute
instance-attribute
Number of layers of the ansatz.
m_block_qubits = None
class-attribute
instance-attribute
The number of qubits in the local entangling block of an Alternating Layer Ansatz (ALA).
Only used when ansatz_type
is AnsatzType.ALA
.
param_prefix = 'theta'
class-attribute
instance-attribute
The base bame of the variational parameter.
strategy_args = field(default_factory=dict)
class-attribute
instance-attribute
A dictionary containing keyword arguments to the function creating the ansatz.
Details about each below.
For Strategy.DIGITAL
strategy, accepts the following:
periodic (bool): if the qubits should be linked periodically.
periodic=False is not supported in emu-c.
operations (list): list of operations to cycle through in the
digital single-qubit rotations of each layer.
Defaults to [RX, RY, RX] for hea and [RX, RY] for iia.
entangler (AbstractBlock): 2-qubit entangling operation.
Supports CNOT, CZ, CRX, CRY, CRZ, CPHASE. Controlld rotations
will have variational parameters on the rotation angles.
Defaults to CNOT
For Strategy.SDAQC
strategy, accepts the following:
operations (list): list of operations to cycle through in the
digital single-qubit rotations of each layer.
Defaults to [RX, RY, RX] for hea and [RX, RY] for iia.
entangler (AbstractBlock): Hamiltonian generator for the
analog entangling layer. Time parameter is considered variational.
Defaults to NN interaction.
For Strategy.RYDBERG
strategy, accepts the following:
addressable_detuning: whether to turn on the trainable semi-local addressing pattern
on the detuning (n_i terms in the Hamiltonian).
Defaults to True.
addressable_drive: whether to turn on the trainable semi-local addressing pattern
on the drive (sigma_i^x terms in the Hamiltonian).
Defaults to False.
tunable_phase: whether to have a tunable phase to get both sigma^x and sigma^y rotations
in the drive term. If False, only a sigma^x term will be included in the drive part
of the Hamiltonian generator.
Defaults to False.
tag = None
class-attribute
instance-attribute
String to indicate the name tag of the ansatz.
Defaults to None, in which case no tag will be applied.
FeatureMapConfig(num_features=0, basis_set=BasisSet.FOURIER, reupload_scaling=ReuploadScaling.CONSTANT, feature_range=None, target_range=None, multivariate_strategy=MultivariateStrategy.PARALLEL, feature_map_strategy=Strategy.DIGITAL, param_prefix=None, num_repeats=0, operation=None, inputs=None, tag=None)
dataclass
basis_set = BasisSet.FOURIER
class-attribute
instance-attribute
Basis set for feature encoding.
Takes qadence.BasisSet. Give a single BasisSet to use the same for all features. Give a dict of (str, BasisSet) where the key is the name of the variable and the value is the BasisSet to use for encoding that feature. BasisSet.FOURIER for Fourier encoding. BasisSet.CHEBYSHEV for Chebyshev encoding.
feature_map_strategy = Strategy.DIGITAL
class-attribute
instance-attribute
Strategy for feature map.
Accepts DIGITAL, ANALOG or RYDBERG. Defaults to DIGITAL.
If the strategy is incompatible with the operation
chosen, then operation
gets preference and the given strategy is ignored.
feature_range = None
class-attribute
instance-attribute
Range of data that the input data is assumed to come from.
Give a single tuple to use the same range for all features. Give a dict of (str, tuple) where the key is the name of the variable and the value is the feature range to use for that feature.
inputs = None
class-attribute
instance-attribute
List that indicates the order of variables of the tensors that are passed.
Optional if a single feature is being encoded, required otherwise. Given input tensors
xs = torch.rand(batch_size, input_size:=2)
a QNN with inputs=["t", "x"]
will
assign t, x = xs[:,0], xs[:,1]
.
multivariate_strategy = MultivariateStrategy.PARALLEL
class-attribute
instance-attribute
The encoding strategy in case of multi-variate function.
Takes qadence.MultivariateStrategy.
If PARALLEL, the features are encoded in one block of rotation gates
with the register being split in sub-registers for each feature.
If SERIES, the features are encoded sequentially using the full register for each feature, with
an ansatz block between them. PARALLEL is allowed only for DIGITAL feature_map_strategy
.
num_features = 0
class-attribute
instance-attribute
Number of feature parameters to be encoded.
Defaults to 0. Thus, no feature parameters are encoded.
num_repeats = 0
class-attribute
instance-attribute
Number of feature map layers repeated in the data reuploading step.
If all features are to be repeated the same number of times, then can give a single
int
. For different number of repetitions for each feature, provide a dict
of (str, int) where the key is the name of the variable and the value is the
number of repetitions for that feature.
This amounts to the number of additional reuploads. So if num_repeats
is N,
the data gets uploaded N+1 times. Defaults to no repetition.
operation = None
class-attribute
instance-attribute
Type of operation.
Choose among the analog or digital rotations or a custom
callable function returning an AnalogBlock instance. If the type of operation is
incompatible with the strategy
chosen, then operation
gets preference and
the given strategy is ignored.
param_prefix = None
class-attribute
instance-attribute
String prefix to create trainable parameters in Feature Map.
A string prefix to create trainable parameters multiplying the feature parameter
inside the feature-encoding function. Note that currently this does not take into
account the domain of the feature-encoding function.
Defaults to None
and thus, the feature map is not trainable.
Note that this is separate from the name of the parameter.
The user can provide a single prefix for all features, and it will be appended
by appropriate feature name automatically.
reupload_scaling = ReuploadScaling.CONSTANT
class-attribute
instance-attribute
Scaling for encoding the same feature on different qubits.
Scaling used to encode the same feature on different qubits in the same layer of the feature maps. Takes qadence.ReuploadScaling. Give a single ReuploadScaling to use the same for all features. Give a dict of (str, ReuploadScaling) where the key is the name of the variable and the value is the ReuploadScaling to use for encoding that feature. ReuploadScaling.CONSTANT for constant scaling. ReuploadScaling.TOWER for linearly increasing scaling. ReuploadScaling.EXP for exponentially increasing scaling.
tag = None
class-attribute
instance-attribute
String to indicate the name tag of the feature map.
Defaults to None, in which case no tag will be applied.
target_range = None
class-attribute
instance-attribute
Range of data the data encoder assumes as natural range.
Give a single tuple to use the same range for all features. Give a dict of (str, tuple) where the key is the name of the variable and the value is the target range to use for that feature.