qml.decomposition.CompressedResourceOp¶
- class CompressedResourceOp(op_type, params=None)[source]¶
Bases:
objectA 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 usingregister_resources().The
CompressedResourceOpis 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.,Rotcan be decomposed into twoRZgates and anRYregardless of the angles, then every occurrence of this operator in the circuit is represented by the sameCompressedResourceOpwhich only specifies the operator type, i.e.,Rot.On the other hand, for some operators such as
MultiRZ, for which the number ofCNOTgates in its decomposition depends on the number of wires, the resource representation of aMultiRZmust include this information. To create aCompressedResourceOpobject for an operator, use theresource_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
Attributes