Types
Definition of all types supported in the IR.
This module is the defacto definition of the IR. A unit of IR code can only consist of instances of
the classes defined in this module. An IR Model
defines a complete set of instructions for a
backend to execute as a task. The instructions a Model
can take can be divided into two groups;
classical and quantum related instructions:
- Classical:
Alloc
: Allocates memory for holding variable values.Assign
: Assigns a value to a variable.Load
: Retrieves a value from a variable.Call
: Executes a classical function.
- Quantum:
AllocQubits
: Allocates qubits for the computation.QuInstruct
: Executes a quantum instruction.Support
: Defines on which qubit(s) and with what role, target or control, aQuInstruct
should act.
Alloc(size, trainable, **attributes)
Memory allocation for a parameter that is either a scalar value or an array of values.
With this class an allocation of memory is made for a parameter that is a scalar value, if
size = 1
or an array of values of length n
if size = n
. The type for the allocation is
defined by the backend, therefore it is not defined in the IR.
PARAMETER | DESCRIPTION |
---|---|
size
|
Number of values stored in the parameter, if
TYPE:
|
trainable
|
Indicates whether the parameter can be changed during a training loop.
TYPE:
|
attributes
|
Extra flags and information to be used as instructions/suggestions by the backend.
TYPE:
|
Source code in qadence2_ir/types.py
AllocQubits(num_qubits, qubit_positions=None, grid_type=None, grid_scale=1.0, connectivity=None, options=None)
Allocation of qubit in a register of a neutral-atom QPU.
PARAMETER | DESCRIPTION |
---|---|
num_qubits
|
Number of qubits, i.e atoms, to be allocated.
TYPE:
|
qubit_positions
|
A list of discrete coordinates for 2D grid, where (0,0) is the position at center of the grid. An empty list will indicate the backend is free to define the topology for devices that implement logical qubits.
TYPE:
|
grid_type
|
Allows to select the coordinates sets for 2D grids as "square" (orthogonal) or
"triangular" (skew). A "linear" will allow the backend to define the shape of the
register. When the
TYPE:
|
grid_scale
|
Adjust the distance between atoms based on a standard distance defined by the backend. Default value is 1.0.
TYPE:
|
connectivity
|
A dictionary that contains the interaction strength between connected qubit
pairs. It is used with compiler backends that implement crossing-lattice strategies or
gridless models, such as
TYPE:
|
options
|
Extra register related properties that may not be supported by all backends.
TYPE:
|
Source code in qadence2_ir/types.py
Assign(variable_name, value)
Assignment of a value to a variable.
PARAMETER | DESCRIPTION |
---|---|
variable_name
|
The name of the variable to assign a value to.
TYPE:
|
value
|
The value to be assigned to the variable.
TYPE:
|
Source code in qadence2_ir/types.py
Call(identifier, *args)
Instruction to call a classical function.
PARAMETER | DESCRIPTION |
---|---|
identifier
|
The identifier of the function to call, i.e. its name.
TYPE:
|
args
|
The arguments that the function should be called with.
TYPE:
|
Source code in qadence2_ir/types.py
Load(variable_name)
Model(register, inputs, instructions, directives=None, settings=None)
Aggregates the minimal information to construct sequence of instructions to execute on a QPU.
This class defines a unit of IR code. The structure of the class is mainly focused in neutral atoms devices but its agnostic nature may make it suitable for any quantum device.
PARAMETER | DESCRIPTION |
---|---|
register
|
Describes the atomic arrangement of the neutral atom register.
TYPE:
|
instructions
|
A list of abstract instructions with their arguments that a backend can use to execute a sequence.
TYPE:
|
directives
|
A dictionary containing QPU related options. For instance, it can be used to set the Rydberg level to be used or whether to allow digital-analog operations in the sequence.
TYPE:
|
settings
|
Backend specific configurations where the user can define for instance, the data
type like
TYPE:
|
Source code in qadence2_ir/types.py
QuInstruct(name, support, *args, **attributes)
Instruction to apply a quantum operation to one or more qubit(s).
PARAMETER | DESCRIPTION |
---|---|
name
|
The instruction name compatible with the standard instruction set.
TYPE:
|
support
|
The index of qubits to which the instruction is applied to.
TYPE:
|
args
|
Arguments of the instruction such as angle, duration, amplitude etc.
TYPE:
|
attributes
|
Extra flags and information to be used as instructions/suggestions by the backend.
TYPE:
|
Source code in qadence2_ir/types.py
Support(target, control=None)
Instruction that specifies the target and optionally control of a QuInstruct
.
Generic representation of qubit support, specifying a target and control for a quantum instruction. For single qubit operations, a multiple index support indicates apply the operation for each index in the support. Both target and control lists must be ordered!
PARAMETER | DESCRIPTION |
---|---|
target
|
Index or indices of qubits to which the operation is applied.
TYPE:
|
control
|
Index or indices of qubits which to which the operation is conditioned to.
TYPE:
|