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

Inheritance diagram of strawberryfields.compilers.compiler.Compiler, strawberryfields.compilers.compiler.Ranges, strawberryfields.compilers.fock.Fock, strawberryfields.compilers.gaussian.Gaussian, strawberryfields.compilers.bosonic.Bosonic, strawberryfields.compilers.gbs.GBS, strawberryfields.compilers.gaussian_unitary.GaussianUnitary, strawberryfields.compilers.xcov.Xcov, strawberryfields.compilers.xstrict.Xstrict, strawberryfields.compilers.xunitary.Xunitary, strawberryfields.compilers.gaussian_merge.GaussianMerge, strawberryfields.compilers.passive.Passive, strawberryfields.compilers.tdm.TDM, strawberryfields.compilers.tdm.TD2, strawberryfields.compilers.tdm.Borealis