qml.estimator.templates.SelectTHC

class SelectTHC(thc_ham, num_batches=1, rotation_precision=15, select_swap_depth=None, wires=None)[source]

Bases: ResourceOperator

Resource class for creating the custom Select operator for tensor hypercontracted (THC) Hamiltonian.

Note

This decomposition assumes that an appropriately sized phase gradient state is available. Users should ensure that the cost of constructing this state has been accounted for. See also PhaseGradient.

Parameters:
  • thc_ham (THCHamiltonian) – A tensor hypercontracted Hamiltonian on which this Select operator is being applied.

  • num_batches (int) – The number of batches for loading Givens rotation angles into temporary quantum registers. Must be less than the number of orbitals in thc_ham. The default value of 1 loads all angles in one batch.

  • rotation_precision (int) – The number of bits used to represent the precision for loading the rotation angles for basis rotation. The default value is set to 15 bits.

  • select_swap_depth (int | None) – A parameter of QROM used to trade off extra wires for reduced circuit depth. Defaults to None, in which case, the select_swap_depth is set to the optimal depth that minimizes the total T-gate count.

  • wires (WiresLike | None) – the wires on which the operator acts

Raises:
  • TypeError – If thc_ham is not a THCHamiltonian.

  • TypeError – If rotation_precision is not a positive integer.

  • ValueError – If num_batches is not a positive integer or is greater than or equal to the number of orbitals in thc_ham.

  • ValueError – If the number of provided wires does not match the calculated num_wires required for the operation.

Resources:

The resources are calculated based on Figure 5 in arXiv:2011.03494 and Figure 4 in arXiv:2501.06165.

Example

The resources for this operation are computed using:

>>> import pennylane.estimator as qre
>>> thc_ham = qre.THCHamiltonian(num_orbitals=20, tensor_rank=40)
>>> res = qre.estimate(qre.SelectTHC(thc_ham, rotation_precision=15))
>>> print(res)
--- Resources: ---
 Total wires: 356
   algorithmic wires: 58
   allocated wires: 298
     zero state: 298
     any state: 0
 Total gates : 3.336E+4
   'Toffoli': 2.249E+3,
   'CNOT': 2.344E+4,
   'X': 392,
   'Z': 41,
   'S': 80,
   'Hadamard': 7.160E+3

Let’s also see how the resources change when more batches are used for the rotations:

>>> res = qre.estimate(qre.SelectTHC(thc_ham, num_batches=2, rotation_precision=15))
>>> print(res)
--- Resources: ---
 Total wires: 221
   algorithmic wires: 58
   allocated wires: 163
     zero state: 163
     any state: 0
 Total gates : 3.461E+4
   'Toffoli': 2.345E+3,
   'CNOT': 2.438E+4,
   'X': 582,
   'Z': 45,
   'S': 80,
   'Hadamard': 7.178E+3

We can see that by batching the rotations, the number of allocated wires decreases at the cost of an increased number of Toffoli gates.

resource_keys

resource_params

Returns a dictionary containing the minimal information needed to compute the resources.

resource_keys = {'num_batches', 'rotation_precision', 'select_swap_depth', 'thc_ham'}
resource_params

Returns a dictionary containing the minimal information needed to compute the resources.

Returns:

A dictionary containing the resource parameters:
  • thc_ham (THCHamiltonian): a tensor hypercontracted Hamiltonian on which this Select operator is being applied

  • num_batches (int): The number of batches for loading Givens rotation angles into temporary quantum registers. Must be less than the number of orbitals in thc_ham. The default value of 1 loads all angles in one batch.

  • rotation_precision (int): The number of bits used to represent the precision for loading the rotation angles for basis rotation. The default value is set to 15 bits.

  • select_swap_depth (int | None): A parameter of QROM used to trade off extra wires for reduced circuit depth. Defaults to None, in which case, the select_swap_depth is set to the optimal depth that minimizes the total T-gate count.

Return type:

dict

controlled_resource_decomp(num_ctrl_wires, ...)

Returns a list representing the resources for the controlled version of the operator.

resource_decomp(thc_ham[, num_batches, ...])

Returns a list representing the resources of the operator.

resource_rep(thc_ham[, num_batches, ...])

Returns a compressed representation containing only the parameters of the Operator that are needed to compute a resource estimation.

classmethod controlled_resource_decomp(num_ctrl_wires, num_zero_ctrl, target_resource_params)[source]

Returns a list representing the resources for the controlled version of the operator.

Note

This decomposition assumes that an appropriately sized phase gradient state is available. Users should ensure that the cost of constructing this state has been accounted for. See also PhaseGradient.

Parameters:
  • num_ctrl_wires (int) – the number of wires the operation is controlled on

  • num_zero_ctrl (int) – the number of control wires, 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 calculated based on Figure 5 in arXiv:2011.03494.

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(thc_ham, num_batches=1, rotation_precision=15, select_swap_depth=None)[source]

Returns a list representing the resources of the operator. Each object represents a quantum gate and the number of times it occurs in the decomposition.

Note

This decomposition assumes that an appropriately sized phase gradient state is available. Users should ensure that the cost of constructing this state has been accounted for. See also PhaseGradient.

Parameters:
  • thc_ham (THCHamiltonian) – A tensor hypercontracted Hamiltonian on which this Select operator is being applied.

  • num_batches (int) – The number of batches for loading Givens rotation angles into temporary quantum registers. Must be less than the number of orbitals in thc_ham. The default value of 1 loads all angles in one batch.

  • rotation_precision (int) – The number of bits used to represent the precision for loading the rotation angles for basis rotation. The default value is set to 15 bits.

  • select_swap_depth (int | None) – A parameter of QROM used to trade off extra wires for reduced circuit depth. Defaults to None, in which case, the select_swap_depth is set to the optimal depth that minimizes the total T-gate count.

Resources:

The resources are calculated based on Figure 5 in arXiv:2011.03494 and Figure 4 in arXiv:2501.06165.

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(thc_ham, num_batches=1, rotation_precision=15, select_swap_depth=None)[source]

Returns a compressed representation containing only the parameters of the Operator that are needed to compute a resource estimation.

Parameters:
  • thc_ham (THCHamiltonian) – A tensor hypercontracted Hamiltonian on which this Select operator is being applied.

  • num_batches (int) – The number of batches for loading Givens rotation angles into temporary quantum registers. Must be less than the number of orbitals in thc_ham. The default value of 1 loads all angles in one batch.

  • rotation_precision (int) – The number of bits used to represent the precision for loading the rotation angles for basis rotation. The default value is set to 15 bits.

  • select_swap_depth (int | None) – A parameter of QROM used to trade off extra wires for reduced circuit depth. Defaults to None, in which case, the select_swap_depth is set to the optimal depth that minimizes the total T-gate count.

Returns:

the operator in a compressed representation

Return type:

CompressedResourceOp

Contents

Using PennyLane

Release news

Development

API

Internals