qml.estimator.templates.Qubitization¶
- class Qubitization(prep_op, select_op, wires=None)[source]
Bases:
ResourceOperatorResource class for the Qubitization operator. The operator is also referred to as the Quantum Walk operator.
The operator is constructed by encoding a Hamiltonian, written as a linear combination of unitaries, into a block encoding (see Figure 1 in arXiv:1805.03662).
\[Q = \text{Prep}_{H}(2|0\rangle\langle 0| - I)\text{Prep}_{H}^{\dagger} \text{Sel}_{H}.\]- Parameters:
prep_op (
ResourceOperator) – the operator that prepares the coefficients of the LCUselect_op (
ResourceOperator) – the operator that selectively applies the unitaries of the LCUwires (WiresLike | None) – the wires the operation acts on
- Resources:
The resources are obtained from Equation 9 in Babbush et al. (2018). Specifically, the walk operator is defined as \(W = R \cdot S\), where \(R\) is a reflection about the state prepared by the
Prepareoperator, and \(S\) is theSelectoperator. The cost is therefore oneSelectand oneReflection.
- Raises:
ValueError – if the wires provided don’t match the number of wires expected by the operator
Example
The resources for this operation are computed using:
>>> import pennylane.estimator as qre >>> prep_op = qre.Hadamard(wires=0) >>> select_op = qre.Z(wires=0) >>> qw_op = qre.Qubitization(prep_op, select_op) >>> print(qre.estimate(qw_op)) --- Resources: --- Total wires: 1 algorithmic wires: 1 allocated wires: 0 zero state: 0 any state: 0 Total gates : 10 'X': 4, 'Z': 4, 'Hadamard': 2
Attributes
Returns a dictionary containing the minimal information needed to compute the resources.
- resource_keys = {'prep_op', 'select_op'}¶
- resource_params¶
Returns a dictionary containing the minimal information needed to compute the resources.
- Returns:
- A dictionary containing the resource parameters:
prep_op (
CompressedResourceOp): a compressed representation for the operator that prepares the coefficients of the LCUselect_op (
CompressedResourceOp): a compressed representation for the operator that selectively applies the unitaries of the LCU
- 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.
resource_decomp(prep_op, select_op)Returns a list representing the resources of the operator.
resource_rep(prep_op, select_op)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:
Reflectionoperators are self-adjoint, and theSelectoperator is also self-adjoint. Thus the adjoint of this operator has the same resources, just applied in reverse order.
- Returns:
A list of
GateCountobjects, 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 qubits the operation is controlled on
num_zero_ctrl (int) – the number of control qubits, 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 obtained directly from Figure 1 in Babbush et al. (2018).
- Returns:
A list of
GateCountobjects, 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(prep_op, select_op)[source]¶
Returns a list representing the resources of the operator. Each object in the list represents a gate and the number of times it occurs in the circuit.
- Parameters:
prep_op (
CompressedResourceOp) – A compressed representation for the operator that prepares the coefficients of the LCU.select_op (
CompressedResourceOp) – A compressed representation for the operator that selectively applies the unitaries of the LCU.
- Resources:
The resources are obtained from Equation 9 in Babbush et al. (2018). Specifically, the walk operator is defined as \(W = R \cdot S\), where \(R\) is a reflection about the state prepared by the
Prepareoperator, and \(S\) is theSelectoperator.
- Returns:
A list of
GateCountobjects, 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(prep_op, select_op)[source]¶
Returns a compressed representation containing only the parameters of the Operator that are needed to compute the resources.
- Parameters:
prep_op (
CompressedResourceOp) – A compressed representation for the operator that prepares the coefficients of the LCU.select_op (
CompressedResourceOp) – A compressed representation for the operator that selectively applies the unitaries of the LCU.
- Returns:
the operator in a compressed representation
- Return type: