quairkit.ansatz.container¶
The source file of the Sequential class.
- class quairkit.ansatz.container.OperatorList(num_systems, system_dim, physical_idx)¶
Sequential container for QuAIRKit operators.
- Parameters:¶
- property num_qubits : int¶
Number of qubits in this circuit.
- property num_qutrits : int¶
Number of qutrits in this circuit.
- property system_dim : list[int]¶
Dimension of systems in this circuit.
- property equal_dim : bool¶
Whether the systems in this circuit have the same dimension.
- property system_idx : list[int]¶
List of physical indices of systems.
-
add_systems(num_new_systems, new_system_dim=
None
, new_physical_idx=None
)¶ Add new systems to the list.
- sort()¶
Sort the systems in the circuit by their physical indices.
- property num_systems : int¶
Number of logical systems.
- register_idx(operator_idx, num_acted_system)¶
Update sequential according to input operator index information, or report error.
- append(op)¶
Appends an operator or an operator sub-list to the end.
- Parameters:¶
- op : Operator | OperatorList¶
module to append
- extend(sequential)¶
Extend the list with another sequential
- Parameters:¶
- sequential : OperatorList¶
a sequential of operators to be extended
- Returns:¶
Concatenation of two quantum operator sequential
- Return type:¶
- operators()¶
Yield all operators in this list.
- property operator_history : list[OperatorInfoType | list[OperatorInfoType]]¶
Return the operator history of this Sequential
- property param : Tensor¶
Flattened parameters in this list.
- property grad : ndarray¶
Gradients with respect to the flattened parameters.
- transfer_static()¶
set
stop_gradient
of all parameters of the list asTrue
-
randomize_param(arg0=
0
, arg1=6.283185307179586
, method='uniform'
)¶ Randomize parameters of the list based on the initializer. Current we only support Uniform and Normal initializer.
- property matrix : Tensor¶
Get the unitary matrix form of the operator list.
- unitary_matrix()¶
Get the unitary matrix form of the circuit.
- property depth : int¶
Depth of gate sequences.
- Returns:¶
depth of this circuit
Note
The measurement is omitted, and all gates are assumed to have depth 1. See Niel’s answer in the [StackExchange](https://quantumcomputing.stackexchange.com/a/5772).
- property qasm : str¶
String representation of the circuit in OpenQASM-like format.
TODO: remove n
-
class quairkit.ansatz.container.Layer(physical_idx, depth, name=
'Layer'
, system_dim=2
)¶ Base class for built-in trainable quantum circuit ansatz.
- Parameters:¶
Note
A Circuit instance needs to extend this Layer instance to be used in a circuit.
-
plot(style=
'standard'
, decimal=2
, dpi=300
, print_code=False
, show_plot=True
)¶ Plot the circuit layer using LaTeX
- Parameters:¶
- style : str¶
the style of the plot, can be ‘standard’, ‘compact’ or ‘detailed’. Defaults to
standard
.- decimal : int¶
number of decimal places to display. Defaults to 2.
- dpi : int¶
dots per inches of plot image. Defaults to 300.
- print_code : bool¶
whether print the LaTeX code of the circuit, default to
True
.- show_plot : bool¶
whether show the plotted circuit, default to
True
.