qp.labs.estimator_beta.templates.LabsMottonenStatePreparation

class LabsMottonenStatePreparation(num_wires, wires=None)[source]

Bases: ResourceOperator

Resource class for Mottonen state preparation.

Parameters:
  • num_wires (int) – the number of wires the operation acts on

  • wires (WiresLike | None) – the wires the operation acts on

Resources:

Resources are described in Mottonen et al. (2008). The resources are defined as \(2^{n+2} - 5\) RZ gates and \(2^{n+2} - 4n - 4\) CNOT gates.

Example

The resources for this operation are computed using:

>>> import pennylane.labs.estimator_beta as qre
>>> mottonen_state = qre.MottonenStatePreparation(10)
>>> gate_set = {"RZ", "CNOT"}
>>> print(qre.estimate(mottonen_state, gate_set=gate_set))
--- Resources: ---
 Total wires: 10
   algorithmic wires: 10
   allocated wires: 0
     zero state: 0
     any state: 0
 Total gates : 1.841E+5
   'RZ': 4.091E+3,
   'CNOT': 4.052E+3

num_wires

resource_keys

resource_params

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

num_wires = None
resource_keys = {'num_wires'}
resource_params

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

Returns:

A dictionary containing the resource parameters:
  • num_wires (int): the number of wires that the operation acts on

Return type:

dict

add_parallel(other)

Adds a ResourceOperator or Resources in parallel.

add_series(other)

Adds a ResourceOperator or Resources in series.

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.

queue([context])

Append the operator to the Operator queue.

resource_decomp(num_wires)

Returns a list representing the resources of the operator.

resource_rep(num_wires)

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

resource_rep_from_op()

Returns a compressed representation directly from the operator

tracking_name(*args, **kwargs)

Returns a name used to track the operator during resource estimation.

add_parallel(other)

Adds a ResourceOperator or Resources in parallel.

Parameters:

other (ResourceOperator) – The other object to combine with, it can be another ResourceOperator or a Resources object.

Returns:

added Resources

Return type:

Resources

add_series(other)

Adds a ResourceOperator or Resources in series.

Parameters:

other (ResourceOperator) – The other object to combine with, it can be another ResourceOperator or a Resources object.

Returns:

added Resources

Return type:

Resources

classmethod adjoint_resource_decomp(target_resource_params=None)

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

For a ResourceOperator that doesn’t define an adjoint_resource_decomp method, this will be the default adjoint_resource_decomp method.

Resources:

The resources for the adjoint of an operator are obtained by tracking the adjoint of each gate in the resource decomposition of the operator.

Parameters:

target_resource_params (dict | None) – A dictionary containing the resource parameters of the target operator.

classmethod controlled_resource_decomp(num_ctrl_wires, num_zero_ctrl, target_resource_params=None)

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

For a ResourceOperator that doesn’t define a controlled_resource_decomp method, this will be the default controlled_resource_decomp method.

Resources:

The resources for the controlled operator are obtained by controlling (with the same number of control wires and zero controlled values) each gate in the base operator’s resource decomposition.

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 | None) – A dictionary containing the resource parameters of the target operator.

classmethod pow_resource_decomp(pow_z, target_resource_params=None)

Returns a list representing the resources for an operator raised to a power.

For a ResourceOperator that doesn’t define a pow_resource_decomp method, this will be its pow_resource_decomp method.

Resources:

The resources for an operator raised to some power are obtained by taking the base resource decomposition of the operator and tracking each gate raised to the given power. For a power of zero, the identity operator is returned. For a power of one, the base operator is returned.

Parameters:
  • pow_z (int) – exponent that the operator is raised to

  • target_resource_params (dict | None) – A dictionary containing the resource parameters of the target operator.

queue(context=<class 'pennylane.queuing.QueuingManager'>)

Append the operator to the Operator queue.

classmethod resource_decomp(num_wires)[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:

num_wires (int) – the number of wires that the operation acts on

Resources:

Resources are described in Mottonen et al. (2008). The resources are defined as \(2^{n+2} - 5\) RZ gates and \(2^{n+2} - 4n - 4\) CNOT gates.

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

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

Returns:

the operator in a compressed representation

Return type:

CompressedResourceOp

resource_rep_from_op()

Returns a compressed representation directly from the operator

classmethod tracking_name(*args, **kwargs)

Returns a name used to track the operator during resource estimation.