sf.compilers

Warning

Unless you are a Strawberry Fields developer, you likely do not need to use these classes directly.

This subpackage implements the Compiler class, an abstract base class used to define and compile families of quantum circuits, e.g., circuits that can be executed on particular hardware or simulator backends.

The information in the Compiler instances is used by Program.compile() to validate and compile quantum programs. By querying the Compiler class representing the requested compilation target, Program.compile() can

  1. Validate that the Program consists of valid quantum operations in the correct topology for the targeted circuit class.

  2. Compile the Program into an equivalent circuit that has the topology required by the targeted circuit class, decomposing circuit operations as required.

Note that the compilation process is not perfect and can provide false negatives: it can admit failure by raising a CircuitError even if the Program theoretically is equivalent to a circuit that belongs in the target circuit class.

The circuit class database circuit_db is a dictionary mapping the circuit family short name to the corresponding Compiler instance. In particular, for each backend supported by Strawberry Fields the database contains a corresponding Compiler instance with the same short name, used to validate Programs to be executed on that backend.

Classes

Compiler

Abstract base class for describing circuit compilation.

Ranges(*args[, variable_name])

Lightweight class for representing a set of ranges of floats.

Fock

Compiler for general Fock backends.

Gaussian

Compiler for general Gaussian backends.

Bosonic

Compiler for general Bosonic backends.

GBS

Compiler for the general GBS class of circuits.

GaussianUnitary

Compiler to arrange a Gaussian quantum circuit into the canonical Symplectic form.

Xcov

General state compiler for the X class of circuits.

Xstrict

Strict compiler for the X class of circuits.

Xunitary

General interferometer or unitary compiler for the X class of circuits.

GaussianMerge()

Compiler that merges adjacent Gaussian operations into a single symplectic transformation, to reduce the depth of non-Gaussian programs.

Passive

Compiler to write a sequence of passive operations as a single passive operation

TDM

General compiler for Time-Domain Multiplexing (TDM) circuits.

TD2

Compiler for 2-loop time-domain circuits with homodyne measurements.

Borealis

Compiler for 3-loop time-domain circuits with Fock measurements.

Variables

compiler_db

Map from compiler name to the corresponding class.

Class Inheritance Diagram

digraph inheritance3983d0f6fc { rankdir=LR; size="8.0, 12.0"; "ABC" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Helper class that provides a standard way to create an ABC using"]; "Borealis" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Compiler for 3-loop time-domain circuits with Fock measurements."]; "TDM" -> "Borealis" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Bosonic" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Compiler for general Bosonic backends."]; "Compiler" -> "Bosonic" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Compiler" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Abstract base class for describing circuit compilation."]; "ABC" -> "Compiler" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Fock" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Compiler for general Fock backends."]; "Compiler" -> "Fock" [arrowsize=0.5,style="setlinewidth(0.5)"]; "GBS" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Compiler for the general GBS class of circuits."]; "Gaussian" -> "GBS" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Gaussian" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Compiler for general Gaussian backends."]; "Compiler" -> "Gaussian" [arrowsize=0.5,style="setlinewidth(0.5)"]; "GaussianMerge" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Compiler that merges adjacent Gaussian operations into a single symplectic transformation,"]; "Compiler" -> "GaussianMerge" [arrowsize=0.5,style="setlinewidth(0.5)"]; "GaussianUnitary" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Compiler to arrange a Gaussian quantum circuit into the canonical Symplectic form."]; "Compiler" -> "GaussianUnitary" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Passive" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Compiler to write a sequence of passive operations as a single passive operation"]; "Compiler" -> "Passive" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Ranges" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Lightweight class for representing a set of ranges of floats."]; "TD2" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Compiler for 2-loop time-domain circuits with homodyne measurements."]; "TDM" -> "TD2" [arrowsize=0.5,style="setlinewidth(0.5)"]; "TDM" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="General compiler for Time-Domain Multiplexing (TDM) circuits."]; "Compiler" -> "TDM" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Xcov" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="General state compiler for the X class of circuits."]; "Compiler" -> "Xcov" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Xstrict" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="Strict compiler for the X class of circuits."]; "Compiler" -> "Xstrict" [arrowsize=0.5,style="setlinewidth(0.5)"]; "Xunitary" [color=lightskyblue1,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style=filled,tooltip="General interferometer or unitary compiler for the X class of circuits."]; "Compiler" -> "Xunitary" [arrowsize=0.5,style="setlinewidth(0.5)"]; }