qml.estimator.ops.MultiControlledX¶
- class MultiControlledX(num_ctrl_wires=None, num_zero_ctrl=0, wires=None)[source]
Bases:
ResourceOperator
Resource class for the MultiControlledX gate.
- Parameters:
num_ctrl_wires (int | None) – the number of qubits the operation is controlled on
num_zero_ctrl (int) – the number of control qubits, that are controlled when in the \(|0\rangle\) state
wires (Sequence[int] | None) – the wires this operation acts on
- Resources:
The resources are obtained based on the unary iteration technique described in Babbush et al. (2018). Specifically, the resources are defined as the following rules:
If there are no control qubits, treat the operation as a
X
gate.If there is only one control qubit, treat the resources as a
CNOT
gate.If there are two control qubits, treat the resources as a
Toffoli
gate.If there are three or more control qubits (\(n\)), the resources obtained based on the unary iteration technique described in Babbush et al. (2018). Specifically, it requires \(n - 2\) clean qubits, and produces \(n - 2\) elbow gates and a single
Toffoli
.
See also
The corresponding PennyLane operation
MultiControlledX
.Example
The resources for this operation are computed using:
>>> qml.estimator.MultiControlledX.resource_decomp(num_ctrl_wires=5, num_zero_ctrl=2) [(4 x X), Allocate(3), (3 x TemporaryAND), (3 x Adjoint(TemporaryAND)), (1 x Toffoli), Deallocate(3)]
Attributes
Returns a dictionary containing the minimal information needed to compute the resources.
- resource_keys = {'num_ctrl_wires', 'num_zero_ctrl'}¶
- resource_params¶
Returns a dictionary containing the minimal information needed to compute the resources.
- Returns:
- A dictionary containing the resource parameters:
num_ctrl_wires (int): the number of qubits the operation is controlled on
num_zero_ctrl (int): the number of control qubits, that are controlled when in the \(|0\rangle\) state
- Return type:
dict
Methods
adjoint_resource_decomp
(target_resource_params)Returns a list representing the resources for the adjoint of the operator.
controlled_resource_decomp
(num_ctrl_wires, ...)Returns a list representing the resources for a controlled version of the operator.
pow_resource_decomp
(pow_z, ...)Returns a list representing the resources for an operator raised to a power.
resource_decomp
(num_ctrl_wires, num_zero_ctrl)Returns a list representing the resources of the operator.
resource_rep
(num_ctrl_wires, num_zero_ctrl)Returns a compressed representation containing only the parameters of the operator that are needed to compute the resources.
- classmethod adjoint_resource_decomp(target_resource_params)[source]¶
Returns a list representing the resources for the adjoint of the operator.
- Parameters:
target_resource_params (dict) – A dictionary containing the resource parameters of the target operator.
- Resources:
This operation is self-adjoint, so the resources of the adjoint operation results are same as the originial operation.
- Returns:
A list of
GateCount
objects, where each object represents a specific quantum gate and the number of times it appears in the decomposition.- Return type:
list[
GateCount
]
- classmethod controlled_resource_decomp(num_ctrl_wires, num_zero_ctrl, target_resource_params)[source]¶
Returns a list representing the resources for a controlled version of the operator.
- Parameters:
num_ctrl_wires (int) – the number of control qubits of the operation
num_zero_ctrl (int) – The subset of control qubits of the operation, that are controlled when in the \(|0\rangle\) state.
target_resource_params (dict) – A dictionary containing the resource parameters of the target operator.
- Resources:
The resources are derived by combining the control qubits, control-values and into a single instance of
MultiControlledX
gate, controlled on the whole set of control-qubits.
- Returns:
A list of
GateCount
objects, where each object represents a specific quantum gate and the number of times it appears in the decomposition.- Return type:
list[
GateCount
]
- classmethod pow_resource_decomp(pow_z, target_resource_params)[source]¶
Returns a list representing the resources for an operator raised to a power.
- Parameters:
pow_z (int) – the power that the operator is being raised to
target_resource_params (dict) – A dictionary containing the resource parameters of the target operator.
- Resources:
This operation is self-inverse, thus when raised to even integer powers acts like the identity operator and raised to odd powers it produces itself.
- Returns:
A list of
GateCount
objects, where each object represents a specific quantum gate and the number of times it appears in the decomposition.- Return type:
list[
GateCount
]
- classmethod resource_decomp(num_ctrl_wires, num_zero_ctrl)[source]¶
Returns a list representing the resources of the operator.
- Parameters:
num_ctrl_wires (int) – the number of qubits the operation is controlled on
num_zero_ctrl (int) – the number of control qubits, that are controlled when in the \(|0\rangle\) state
- Resources:
The resources are obtained based on the unary iteration technique described in Babbush et al. (2018). Specifically, the resources are defined as the following rules:
If there are no control qubits, treat the operation as a
X
gate.If there is only one control qubit, treat the resources as a
CNOT
gate.If there are two control qubits, treat the resources as a
Toffoli
gate.If there are three or more control qubits (\(n\)), the resources obtained based on the unary iteration technique described in Babbush et al. (2018). Specifically, it requires \(n - 2\) clean qubits, and produces \(n - 2\) elbow gates and a single
Toffoli
.
- Returns:
A list of
GateCount
objects, where each object represents a specific quantum gate and the number of times it appears in the decomposition.- Return type:
list[
GateCount
]
- classmethod resource_rep(num_ctrl_wires, num_zero_ctrl)[source]¶
Returns a compressed representation containing only the parameters of the operator that are needed to compute the resources.
- Parameters:
num_ctrl_wires (int) – the number of qubits the operation is controlled on
num_zero_ctrl (int) – the number of control qubits, that are controlled when in the \(|0\rangle\) state
- Returns:
the operator in a compressed representation
- Return type: