qml.decomposition.CompressedResourceOp

class CompressedResourceOp(op_type, params=None)[source]

Bases: object

A lightweight representation of an operator to be decomposed.

Note

This class is only relevant when the new experimental graph-based decomposition system (introduced in v0.41) is enabled via qml.decomposition.enable_graph(). This new way of doing decompositions is generally more resource efficient and accommodates multiple alternative decomposition rules for an operator. In this new system, custom decomposition rules are defined as quantum functions, and it is currently required that every decomposition rule declares its required resources using register_resources().

The CompressedResourceOp is a lightweight data structure that contains an operator type and a set of parameters that affects the resource requirement of this operator. If the decomposition of an operator is independent of its parameters, e.g., Rot can be decomposed into two RZ gates and an RY regardless of the angles, then every occurrence of this operator in the circuit is represented by the same CompressedResourceOp which only specifies the operator type, i.e., Rot.

On the other hand, for some operators such as MultiRZ, for which the number of CNOT gates in its decomposition depends on the number of wires, the resource representation of a MultiRZ must include this information. To create a CompressedResourceOp object for an operator, use the resource_rep() function.

Parameters:
  • op_type – the operator type

  • params (dict) – the parameters of the operator relevant to the resource estimation of its decompositions. This should only include parameters that affect the gate counts.

See also

resource_rep()

name

The name of the operator type.

name

The name of the operator type.