qml.estimator.templates.SelectPauli¶
- class SelectPauli(pauli_ham, wires=None)[source]
Bases:
ResourceOperatorResource class for the
Selectopreation used with a Hamiltonian expressed as a linear combination of unitaries (LCU) where each unitary is a Pauli word.- Parameters:
pauli_ham (
PauliHamiltonian) – A Hamiltonian expressed as a linear combination of Pauli words, over whichSelectis applied.wires (WiresLike | None) – the wires the operation acts on
- Resources:
The resources are based on the analysis in Babbush et al. (2018), Section III.A, ‘Unary Iteration and Indexed Operations’, and Figures 4, 6, and 7.
Note: This implementation assumes we have access to \(n - 1\) additional auxiliary qubits, where \(n = \left\lceil log_{2}(N) \right\rceil\) and \(N\) is the number of batches of unitaries to select.
- Raises:
TypeError – If the input
pauli_hamisn’t an instance ofPauliHamiltonian.ValueError – if the wires provided don’t match the number of wires expected by the operator
See also
Example
The resources for this operation are computed using:
>>> import pennylane.estimator as qre >>> pauli_ham = qre.PauliHamiltonian(num_qubits=4, pauli_terms={"XY": 1, "Z": 2}) >>> select_pauli = qre.SelectPauli(pauli_ham) >>> print(qre.estimate(select_pauli)) --- Resources: --- Total wires: 7 algorithmic wires: 6 allocated wires: 1 zero state: 1 any state: 0 Total gates : 27 'Toffoli': 2, 'CNOT': 8, 'X': 4, 'Z': 1, 'S': 2, 'Hadamard': 10
Attributes
Returns a dictionary containing the minimal information needed to compute the resources.
- resource_keys = {'pauli_ham'}¶
- resource_params¶
Returns a dictionary containing the minimal information needed to compute the resources.
- Returns:
- A dictionary containing the resource parameters:
pauli_ham (
PauliHamiltonian): A Hamiltonian expressed as a linear combination of Pauli words, over whichSelectis applied.
- 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(pauli_ham)The resources for a select implementation taking advantage of the unary iterator trick.
resource_rep(pauli_ham)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:
Because each target operation is self-adjoint, the resources of the adjoint operation are the same as the original operation (up to some re-ordering of the application of the gates).
- 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 based on the analysis in Babbush et al. (2018), Section III.A, ‘Unary Iteration and Indexed Operations’. See Figures 4, 6, and 7. This presents the cost of a single qubit controlled
Selectoperator. In the case of multiple control wires, we use one additional auxiliary qubit and two multi-controlledXgates.Note: This implementation assumes we have access to \(n\) additional auxiliary qubits, where \(n = \left\lceil log_{2}(N) \right\rceil\) and \(N\) is the number of batches of unitaries to select.
- 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(pauli_ham)[source]¶
The resources for a select implementation taking advantage of the unary iterator trick.
- Parameters:
pauli_ham (
PauliHamiltonian) – A Hamiltonian expressed as a linear combination of Pauli words, over whichSelectis applied.
- Resources:
The resources are based on the analysis in Babbush et al. (2018), Section III.A, ‘Unary Iteration and Indexed Operations’, and Figures 4, 6, and 7.
Note: This implementation assumes we have access to \(n - 1\) additional auxiliary qubits, where \(n = \left\lceil log_{2}(N) \right\rceil\) and \(N\) is the number of batches of unitaries to select.
- 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(pauli_ham)[source]¶
Returns a compressed representation containing only the parameters of the Operator that are needed to compute the resources.
- Parameters:
pauli_ham (
PauliHamiltonian) – A Hamiltonian expressed as a linear combination of Pauli words, over whichSelectis applied.- Returns:
the operator in a compressed representation
- Return type: