qml.estimator.ops.Adjoint

class Adjoint(base_op)[source]

Bases: ResourceOperator

Resource class for the symbolic Adjoint operation.

Parameters:

base_op (ResourceOperator) – The operator for which to retrieve the adjoint.

Resources:

This symbolic operation represents the adjoint of some base operation. If the base operation implements the .adjoint_resource_decomp() method, then the resources are obtained from this object. Otherwise, the adjoint resources are given as the adjoint of each operation in the base operation’s resources.

See also

The corresponding PennyLane operation Adjoint.

Example

The adjoint operation can be constructed like this:

>>> qft = qml.estimator.QFT(num_wires=3)
>>> adj_qft = qml.estimator.Adjoint(qft)

We can see how the resources differ by choosing a suitable gateset and estimating resources:

>>> import pennylane.estimator as qre
>>> gate_set = {
...     "SWAP",
...     "Adjoint(SWAP)",
...     "Hadamard",
...     "Adjoint(Hadamard)",
...     "ControlledPhaseShift",
...     "Adjoint(ControlledPhaseShift)",
... }
>>>
>>> print(qre.estimate(qft, gate_set))
--- Resources: ---
 Total wires: 3
    algorithmic wires: 3
    allocated wires: 0
             zero state: 0
             any state: 0
 Total gates : 7
  'SWAP': 1,
  'ControlledPhaseShift': 3,
  'Hadamard': 3
>>>
>>> print(qre.estimate(adj_qft, gate_set))
--- Resources: ---
 Total wires: 3
    algorithmic wires: 3
    allocated wires: 0
             zero state: 0
             any state: 0
 Total gates : 7
  'Adjoint(ControlledPhaseShift)': 3,
  'Adjoint(SWAP)': 1,
  'Adjoint(Hadamard)': 3

resource_keys

resource_params

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

resource_keys = {'base_cmpr_op'}
resource_params

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

Returns:

A dictionary containing the resource parameters:
  • base_cmpr_op (ResourceOperator): The operator that we want the adjoint of.

Return type:

dict

adjoint_resource_decomp(target_resource_params)

Returns a list representing the resources for the adjoint of the operator.

resource_decomp(base_cmpr_op, **kwargs)

Returns a list representing the resources of the operator.

resource_rep(base_cmpr_op)

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

tracking_name(base_cmpr_op)

Returns the tracking name built with the operator's parameters.

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:

The adjoint of an adjointed operation is just the original operation. The resources are given as one instance of the base 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 resource_decomp(base_cmpr_op, **kwargs)[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.

Parameters:

base_cmpr_op (CompressedResourceOp) – A compressed resource representation for the operator we want the adjoint of.

Resources:

This symbolic operation represents the adjoint of some base operation. The resources are determined as follows. If the base operation implements the .adjoint_resource_decomp() method, then the resources are obtained from this method. Otherwise, the adjoint resources are given as the adjoint of each operation in the base operation’s resources.

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(base_cmpr_op)[source]

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

Parameters:

base_cmpr_op (ResourceOperator) – The operator that we want the adjoint of.

Returns:

the operator in a compressed representation

Return type:

CompressedResourceOp

static tracking_name(base_cmpr_op)[source]

Returns the tracking name built with the operator’s parameters.

Contents

Using PennyLane

Release news

Development

API

Internals