Expression system
Qadence 2 Expression system is designed to create expressive, self-contained and abstract symbolic expressions to represent quantum programs in the digital-analog paradigm. These expressions can be transpiled later with concretized and specific data types, such as numpy
, pytorch
and jax
for execution on targeted backends.
The Expression system defines syntactic rules to generate symbolic quantum expressions, that can contain parametric expressions for parameters (static, FeatureParameter
) and variables (dynamic, VariationalParameter
) to be used for training purposes. Expression composition can be seamlessly applied to quantum operators for digital, analog and digital-analog computations. It also supports arithmetic operations for both classical and quantum expressions as well as reduction, simplification and replacement methods.
Symbolic manipulation
In these examples, basic arithmetic expressions on symbols (parameters) are evaluated to illustrate simplifications and reductions.
Products of sums are expanded
But exponentiations of sums are not as power simplifications take precedence.
Quantum operators
Standard quantum operators are defined as Python Callable
that accept a qubit support as argument. Please note that the support can either be a single int
for single qubit operations or a tuple of qubit indices for operations that span across multiple qubits or nothing to create global operations that span across the whole register (denoted by the *
wildcard).
(Multi-)Controlled operators need to be provided with non-overlapping tuples for control and target qubits. The notation convention is to display target indices first followed by control indices in increasing ordering.
Quantum operators can be parametrized and expressions expanded.
Global and local operators can be combined.
Custom operators can be created as functions or based on other operators. For instance, the CNOT
:
CNOT = lambda ctrl, tgt: NOT(target=(tgt,), control=(ctrl,))
Y(4) * X(3) * Y(5,4) * CNOT(1,2) * Z(3)
Or the number operator. Expansion rules still hold.
Parametric operators need to get passed a parameter as first argument, then the qubit support. This ensures syntactic consistency across operators. Unitarity still holds.
Arithmetic operations still hold for operator parameters defined over the same support.
As opposed to: