Operations
Operations are common PrimitiveBlocks
, these are often
called gates elsewhere.
Constant blocks
X(target, noise=None)
Y(target, noise=None)
Z(target, noise=None)
I(target, noise=None)
H(target, noise=None)
Bases:
The Hadamard or H gate.
Source code in qadence/operations/primitive.py
S(target, noise=None)
SDagger(target, noise=None)
Bases:
The Hermitian adjoint/conjugate transpose of the S / Phase gate.
Source code in qadence/operations/primitive.py
SWAP(control, target, noise=None)
Bases:
The SWAP gate.
Source code in qadence/operations/primitive.py
T(target, noise=None)
TDagger(target, noise=None)
Bases:
The Hermitian adjoint/conjugate transpose of the T gate.
Source code in qadence/operations/primitive.py
CNOT(control, target, noise=None)
CY gate not implemented
CZ(control, target, noise=None)
CPHASE(control, target, parameter, noise=None)
Bases:
The CPHASE gate.
Source code in qadence/operations/control_ops.py
Parametrized blocks
RX(target, parameter, noise=None)
Bases:
The Rx gate.
Source code in qadence/operations/parametric.py
RY(target, parameter, noise=None)
Bases:
The Ry gate.
Source code in qadence/operations/parametric.py
RZ(target, parameter, noise=None)
Bases:
The Rz gate.
Source code in qadence/operations/parametric.py
CRX(control, target, parameter, noise=None)
Bases:
The CRX gate.
Source code in qadence/operations/control_ops.py
CRY(control, target, parameter, noise=None)
CRZ(control, target, parameter, noise=None)
Bases:
The CRZ gate.
Source code in qadence/operations/control_ops.py
PHASE(target, parameter, noise=None)
Bases:
The Parametric Phase / S gate.
Source code in qadence/operations/parametric.py
Hamiltonian Evolution
HamEvo(generator, parameter, qubit_support=None, duration=None, noise_operators=list())
Bases:
The Hamiltonian evolution operator U(t).
For time-independent Hamiltonians the solution is exact:
U(t) = exp(-iGt)
where G represents an Hermitian generator, or Hamiltonian and t represents the time parameter. For time-dependent Hamiltonians, the solution is obtained by numerical integration of the Schrodinger equation.
PARAMETER | DESCRIPTION |
---|---|
generator |
Hamiltonian generator, either symbolic as an AbstractBlock, or as a torch.Tensor or numpy.ndarray.
TYPE:
|
parameter |
The time parameter for evolution operator. For the time-independent case, it represents the actual value for which the evolution will be evaluated. For the time-dependent case, it should be an instance of TimeParameter to signal the solver the variable that will be integrated over.
TYPE:
|
qubit_support |
The qubits on which the evolution will be performed on. Only required for generators that are not a composition of blocks.
TYPE:
|
duration |
(optional) duration of the evolution in case of time-dependent generator. By default, a FeatureParameter with tag "duration" will be initialized, and the value will then be required in the values dict.
TYPE:
|
noise_operators |
(optional) the list of jump operators to use when using a shrodinger solver, allowing to perform noisy simulations.
TYPE:
|
Examples:
from qadence import X, HamEvo, PI, add, run
from qadence import FeatureParameter, TimeParameter
import torch
n_qubits = 3
# Hamiltonian as a block composition
hamiltonian = add(X(i) for i in range(n_qubits))
hevo = HamEvo(hamiltonian, parameter=torch.rand(2))
state = run(hevo)
# Hamiltonian as a random matrix
hamiltonian = torch.rand(2, 2, dtype=torch.complex128)
hevo = HamEvo(hamiltonian, parameter=torch.rand(2), qubit_support=(0,))
state = run(hevo)
# Time-dependent Hamiltonian
t = TimeParameter("t")
hamiltonian = t * add(X(i) for i in range(n_qubits))
hevo = HamEvo(hamiltonian, parameter=t)
state = run(hevo, values = {"duration": torch.tensor(1.0)})
# Adding noise operators
noise_ops = [X(0)]
hevo = HamEvo(hamiltonian, parameter=t, noise_operators=noise_ops)
Source code in qadence/operations/ham_evo.py
digital_decomposition(approximation=LTSOrder.ST4)
Decompose the Hamiltonian evolution into digital gates.
PARAMETER | DESCRIPTION |
---|---|
approximation |
Choose the type of decomposition. Defaults to "st4". Available types are: * 'basic' = apply first-order Trotter formula and decompose each term of the exponential into digital gates. It is exact only if applied to an operator whose terms are mutually commuting. * 'st2' = Trotter-Suzuki 2nd order formula for approximating non-commuting Hamiltonians. * 'st4' = Trotter-Suzuki 4th order formula for approximating non-commuting Hamiltonians.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
AbstractBlock
|
a block with the digital decomposition
TYPE:
|
Source code in qadence/operations/ham_evo.py
AnalogSWAP(control, target, parameter=3 * PI / 4)
Bases:
Single time-independent Hamiltonian evolution over a Rydberg Ising.
hamiltonian yielding a SWAP (up to global phase).
Derived from Bapat et al. where it is applied to XX-type Hamiltonian
Source code in qadence/operations/analog.py
AnalogSWAP should be turned into a proper analog block
Analog blocks
AnalogRX(angle, qubit_support='global', add_pattern=True)
Analog X rotation.
Shorthand for AnalogRot
:
PARAMETER | DESCRIPTION |
---|---|
angle |
Rotation angle [rad]
TYPE:
|
qubit_support |
Defines the (local/global) qubit support
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
|
ConstantAnalogRotation |
Source code in qadence/operations/analog.py
AnalogRY(angle, qubit_support='global', add_pattern=True)
Analog Y rotation.
Shorthand for AnalogRot
:
RETURNS | DESCRIPTION |
---|---|
|
ConstantAnalogRotation |
Source code in qadence/operations/analog.py
AnalogRZ(angle, qubit_support='global', add_pattern=True)
Analog Z rotation. Shorthand for AnalogRot
:
Source code in qadence/operations/analog.py
AnalogRot(duration, omega=0, delta=0, phase=0, qubit_support='global', add_pattern=True)
General analog rotation operation.
PARAMETER | DESCRIPTION |
---|---|
duration |
Duration of the rotation [ns].
TYPE:
|
omega |
Rotation frequency [rad/μs]
TYPE:
|
delta |
Rotation frequency [rad/μs]
TYPE:
|
phase |
Phase angle [rad]
TYPE:
|
qubit_support |
Defines the (local/global) qubit support
TYPE:
|
add_pattern |
False disables the semi-local addressing pattern for the execution of this specific block.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
|
ConstantAnalogRotation |
Source code in qadence/operations/analog.py
AnalogInteraction(duration, qubit_support='global', add_pattern=True)
Evolution of the interaction term for a register of qubits.
Constructs a InteractionBlock
.
PARAMETER | DESCRIPTION |
---|---|
duration |
Time to evolve the interaction for in nanoseconds.
TYPE:
|
qubit_support |
Qubits the
TYPE:
|
add_pattern |
False disables the semi-local addressing pattern for the execution of this specific block.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
|
a |