hybridlane.templates.fock_state.FockState¶
- class hybridlane.templates.fock_state.FockState(n, wires=None, id=None)¶
Bases:
pennylane.ops.Operation,hybridlane.ops.HybridPrepares a definite Fock state from the vacuum
Unlike PennyLane’s
FockState, this class uses a sequence ofRedandBluegates, requiring an ancilla qubit.Details:
Number of wires: 2
Wire arguments:
[qubit, qumode]Number of parameters: 1
Number of dimensions per parameter: (0,)
This prepares a definite Fock state on a qumode using a sequence of red and blue sideband gates, favoring the Sideband ISA [1]. The gate sequence to prepare Fock state \(\ket{n}\) is given by
\[X^{n\mod 2} JC(\frac{\pi}{2\sqrt{n+1}}, \frac{\pi}{2}) AJC(\frac{\pi}{2\sqrt{n}}, \frac{\pi}{2}) \dots JC(\frac{\pi}{2\sqrt{2}}, \frac{\pi}{2}) AJC(\frac{\pi}{2}, \frac{\pi}{2})\]The final \(X\) gate is applied if \(n\) is odd to uncompute the qubit.
This also provides a decomposition for PennyLane’s
FockStatethat uses an ancilla qubit to prepare the Fock state on the qumode, requiring dynamic qubit allocation.References
- num_params = 1¶
Number of trainable parameters that the operator depends on.
By default, this property returns as many parameters as were used for the operator creation. If the number of parameters for an operator subclass is fixed, this property can be overwritten to return the fixed value.
- Returns:
number of parameters
- Return type:
- num_wires = 2¶
Number of wires the operator acts on.
- num_qumodes = 1¶
The number of qumodes the gate acts on
- grad_method = None¶
Gradient computation method.
'A': analytic differentiation using the parameter-shift method.'F': finite difference numerical differentiation.None: the operation may not be differentiated.
Default is
'F', orNoneif the Operation has zero parameters.
- resource_keys¶
The set of parameters that affects the resource requirement of the operator.
All decomposition rules for this operator class are expected to have a resource function that accepts keyword arguments that match these keys exactly. The
resource_rep()function will also expect keyword arguments that match these keys when called with this operator type.The default implementation is an empty set, which is suitable for most operators.
See also
resource_params()
- property resource_params¶
A dictionary containing the minimal information needed to compute a resource estimate of the operator’s decomposition.
The keys of this dictionary should match the
resource_keysattribute of the operator class. Two instances of the same operator type should have identicalresource_paramsiff their decompositions exhibit the same counts for each gate type, even if the individual gate parameters differ.Examples
The
MultiRZhas non-emptyresource_keys:>>> qml.MultiRZ.resource_keys {'num_wires'}
The
resource_paramsof an instance ofMultiRZwill contain the number of wires:>>> op = qml.MultiRZ(0.5, wires=[0, 1]) >>> op.resource_params {'num_wires': 2}
Note that another
MultiRZmay have different parameters but the sameresource_params:>>> op2 = qml.MultiRZ(0.7, wires=[1, 2]) >>> op2.resource_params {'num_wires': 2}