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 usingregister_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 twoRZ
gates and anRY
regardless of the angles, then every occurrence of this operator in the circuit is represented by the sameCompressedResourceOp
which only specifies the operator type, i.e.,Rot
.On the other hand, for some operators such as
MultiRZ
, for which the number ofCNOT
gates in its decomposition depends on the number of wires, the resource representation of aMultiRZ
must include this information. To create aCompressedResourceOp
object 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