qml.labs.resource_estimation.ResourceMultiControlledX

class ResourceMultiControlledX(num_ctrl_wires, num_ctrl_values, wires=None)[source]

Bases: ResourceOperator

Resource class for the MultiControlledX gate.

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

  • num_ctrl_values (int) – the number of control qubits, that are controlled when in the \(|0\rangle\) state

  • wires (Sequence[int], optional) – the wires this operation acts on

Resources:

The resources are obtained based on the unary iteration technique described in Babbush 2018. Specifically, the resources are defined as the following rules:

  • If there are no control qubits, treat the operation as a ResourceX gate.

  • If there is only one control qubit, treat the resources as a ResourceCNOT gate.

  • If there are two control qubits, treat the resources as a ResourceToffoli gate.

  • If there are three or more control qubits (\(n\)), the resources obtained based on the unary iteration technique described in Babbush 2018. Specifically, it requires \(n - 2\) clean qubits, and produces \(n - 2\) elbow gates and a single ResourceToffoli.

See also

MultiControlledX

Example

The resources for this operation are computed using:

>>> re.ResourceMultiControlledX.resource_decomp(num_ctrl_wires=5, num_ctrl_values=2)
[(4 x X), AllocWires(3), (3 x TempAND), (3 x Toffoli), (1 x Toffoli), FreeWires(3)]

num_wires

resource_keys

resource_params

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

num_wires = 1
resource_keys = {'num_ctrl_values', 'num_ctrl_wires'}
resource_params

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

Returns:

A dictionary containing the resource parameters:
  • num_ctrl_wires (int): the number of qubits the operation is controlled on

  • num_ctrl_values (int): the number of control qubits, that are controlled when in the \(|0\rangle\) state

Return type:

dict

adjoint_resource_decomp(num_ctrl_wires, ...)

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

controlled_resource_decomp(...)

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

dequeue(op_to_remove[, context])

Remove the given resource operator(s) from the Operator queue.

pow_resource_decomp(pow_z, num_ctrl_wires, ...)

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_ctrl_wires, ...)

Returns a list of GateCount objects representing the resources of the operator.

resource_rep(num_ctrl_wires, num_ctrl_values)

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.

tracking_name_from_op()

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

classmethod adjoint_resource_decomp(num_ctrl_wires, num_ctrl_values, **kwargs)[source]

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

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

  • num_ctrl_values (int) – the number of control qubits, that are controlled when in the \(|0\rangle\) state

Resources:

This operation is self-adjoint, so the resources of the adjoint operation results in the original 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 controlled_resource_decomp(ctrl_num_ctrl_wires, ctrl_num_ctrl_values, num_ctrl_wires, num_ctrl_values, **kwargs)[source]

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

Parameters:
  • ctrl_num_ctrl_wires (int) – The number of control qubits to further control the base controlled operation upon.

  • ctrl_num_ctrl_values (int) – The subset of those control qubits, which further control the base controlled operation, which are controlled when in the \(|0\rangle\) state.

  • num_ctrl_wires (int) – the number of control qubits of the operation

  • num_ctrl_values (int) – The subset of control qubits of the operation, that are controlled when in the \(|0\rangle\) state.

Resources:

The resources are derived by combining the control qubits, control-values and into a single instance of ResourceMultiControlledX gate, controlled on the whole set of control-qubits.

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]

static dequeue(op_to_remove, context=<class 'pennylane.queuing.QueuingManager'>)

Remove the given resource operator(s) from the Operator queue.

classmethod pow_resource_decomp(pow_z, num_ctrl_wires, num_ctrl_values, **kwargs)[source]

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

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

  • num_ctrl_wires (int) – the number of qubits the operation is controlled on

  • num_ctrl_values (int) – the number of control qubits, that are controlled when in the \(|0\rangle\) state

Resources:

This operation is self-inverse, thus when raised to even integer powers acts like the identity operator and raised to odd powers it produces itself.

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]

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

Append the operator to the Operator queue.

classmethod resource_decomp(num_ctrl_wires, num_ctrl_values, **kwargs)[source]

Returns a list of GateCount objects representing the resources of the operator. Each GateCount object specifies a gate type and its total occurrence count.

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

  • num_ctrl_values (int) – the number of control qubits, that are controlled when in the \(|0\rangle\) state

Resources:

The resources are obtained based on the unary iteration technique described in Babbush 2018. Specifically, the resources are defined as the following rules:

  • If there are no control qubits, treat the operation as a ResourceX gate.

  • If there is only one control qubit, treat the resources as a ResourceCNOT gate.

  • If there are two control qubits, treat the resources as a ResourceToffoli gate.

  • If there are three or more control qubits (\(n\)), the resources obtained based on the unary iteration technique described in Babbush 2018. Specifically, it requires \(n - 2\) clean qubits, and produces \(n - 2\) elbow gates and a single ResourceToffoli.

classmethod resource_rep(num_ctrl_wires, num_ctrl_values)[source]

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

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

  • num_ctrl_values (int) – the number of control qubits, that are controlled when in the \(|0\rangle\) state

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.

tracking_name_from_op()

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