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.



Abstract base class for describing circuit compilation.

Ranges(*args[, variable_name])

Lightweight class for representing a set of ranges of floats.


Compiler for general Fock backends.


Compiler for general Gaussian backends.


Compiler for the general GBS class of circuits.


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


General state compiler for the X class of circuits.


Strict compiler for the X class of circuits.


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



Map from compiler name to the corresponding class.

Class Inheritance Diagram

Inheritance diagram of strawberryfields.compilers.compiler.Compiler, strawberryfields.compilers.compiler.Ranges, strawberryfields.compilers.fock.Fock, strawberryfields.compilers.gaussian.Gaussian, strawberryfields.compilers.gbs.GBS, strawberryfields.compilers.gaussian_unitary.GaussianUnitary, strawberryfields.compilers.xcov.Xcov, strawberryfields.compilers.xstrict.Xstrict, strawberryfields.compilers.xunitary.Xunitary