sf.compilers.GBS¶

class
GBS
[source]¶ Bases:
strawberryfields.compilers.gaussian.Gaussian
Compiler for the general GBS class of circuits.
Attributes
A rigid circuit template that defines this circuit specification.
The allowed circuit topologies or connectivity of the class, modelled as a directed acyclic graph.

circuit
¶ A rigid circuit template that defines this circuit specification.
This property is optional. If arbitrary topologies are allowed in the circuit class, do not define this property. In such a case, it will simply return
None
.If a backend device expects a specific template for the recieved Blackbird script, this method will return the serialized Blackbird circuit in string form.
 Returns
Blackbird program or template representing the circuit
 Return type
Union[str, None]

decompositions
= {'Fouriergate': {}, 'S2gate': {}, 'Xgate': {}, 'Zgate': {}}¶

graph
¶ The allowed circuit topologies or connectivity of the class, modelled as a directed acyclic graph.
This property is optional; if arbitrary topologies are allowed in the circuit class, this will simply return
None
. Returns
a directed acyclic graph
 Return type
networkx.DiGraph

interactive
= True¶

primitives
= {'All', 'BSgate', 'Coherent', 'Dgate', 'DisplacedSqueezed', 'Fouriergate', 'Gaussian', 'LossChannel', 'MeasureFock', 'MeasureHeterodyne', 'MeasureHomodyne', 'MeasureThreshold', 'Rgate', 'Sgate', 'Squeezed', 'Thermal', 'ThermalLossChannel', 'Vacuum', '_Delete', '_New_modes'}¶

short_name
= 'gbs'¶
Methods
compile
(seq, registers)Try to arrange a quantum circuit into a form suitable for Gaussian boson sampling.
decompose
(seq)Recursively decompose all gates in a given sequence, as allowed by the circuit specification.

compile
(seq, registers)[source]¶ Try to arrange a quantum circuit into a form suitable for Gaussian boson sampling.
This method checks whether the circuit can be implemented as a Gaussian boson sampling problem, i.e., if it is equivalent to a circuit A+B, where the sequence A only contains Gaussian operations, and B only contains Fock measurements.
If the answer is yes, the circuit is arranged into the A+B order, and all the Fock measurements are combined into a single
MeasureFock
operation. Parameters
seq (Sequence[Command]) – quantum circuit to modify
registers (Sequence[RegRefs]) – quantum registers
 Returns
modified circuit
 Return type
List[Command]
 Raises
CircuitError – the circuit does not correspond to GBS

decompose
(seq)¶ Recursively decompose all gates in a given sequence, as allowed by the circuit specification.
This method follows the directives defined in the
primitives
anddecompositions
class attributes to determine whether a command should be decomposed.The order of precedence to determine whether decomposition should be applied is as follows.
First, we check if the operation is in
decompositions
. If not, decomposition is skipped, and the operation is applied as a primitive (if supported by theCompiler
).Next, we check if (a) the operation supports decomposition, and (b) if the user has explicitly requested no decomposition.
If both (a) and (b) are true, the operation is applied as a primitive (if supported by the
Compiler
).Otherwise, we attempt to decompose the operation by calling
decompose()
recursively.
 Parameters
list[strawberryfields.program_utils.Command] – list of commands to be decomposed
 Returns
list of compiled commands for the circuit specification
 Return type

Downloads