sf.compilers.Borealis¶
-
class
Borealis
[source]¶ Bases:
strawberryfields.compilers.tdm.TDM
Compiler for 3-loop time-domain circuits with Fock measurements.
Attributes
A rigid circuit template that defines this circuit specification.
delay applied by each loop in time bins
The allowed circuit topologies or connectivity of the class, modelled as a directed acyclic graph.
range of phase shift accessible to the Borealis phase modulators
-
circuit
¶ A rigid circuit template that defines this circuit specification.
If arbitrary topologies are allowed in the circuit class, this function will simply return
None
.If a backend device expects a specific template for the received Blackbird script, this method will return the serialized Blackbird circuit in string form.
- Returns
Blackbird circuit or template representing the circuit
- Return type
Union[str, None]
-
decompositions
= {}¶
-
delays
= [1, 6, 36]¶ delay applied by each loop in time bins
-
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
= False¶
-
phi_range
= [-1.5707963267948966, 1.5707963267948966]¶ range of phase shift accessible to the Borealis phase modulators
-
primitives
= {'BSgate', 'MeasureFock', 'Rgate', 'Sgate'}¶
-
short_name
= 'borealis'¶
Methods
add_loss
(program, device)Adds realistic Borealis loss to circuit.
compile
(seq, registers)Compiles the Borealis circuit by inserting missing phase gates due to loop offsets.
decompose
(seq)Recursively decompose all gates in a given sequence, as allowed by the circuit specification.
init_circuit
(layout)Sets the circuit in the compiler class.
Resets the
circuit
andgraph
class attributes.update_params
(program, device)Compensates for the loop offsets in the rotation gates.
-
compile
(seq, registers)[source]¶ Compiles the Borealis circuit by inserting missing phase gates due to loop offsets.
- Parameters
seq (Sequence[Command]) – quantum circuit to modify
registers (Sequence[RegRefs]) – quantum registers
- Returns
modified circuit
- Return type
List[Command]
- Raises
CircuitError – the given circuit cannot be validated to belong to this circuit class
-
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
-
classmethod
init_circuit
(layout)¶ Sets the circuit in the compiler class.
- Parameters
layout (str) – the circuit layout for the target device
- Return type
None
-
classmethod
reset_circuit
()¶ Resets the
circuit
andgraph
class attributes.- Return type
None
-
update_params
(program, device)[source]¶ Compensates for the loop offsets in the rotation gates.
Note
About 50% of the applied phase-shift parameter values for the rotation gates in each loop will lay beyond the range of the Borealis phase modulators, and will be offset by pi. This is due to hardware limitations and is unfortunately unavoidable. It is possible to avoid this warning by manually inserting the correct loop phase offsets obtainable via the device certificate:
>>> eng = RemoteEngine("borealis") >>> eng.device.certificate["loop_phases"] [0.10124, -0.15121, 3.54901]
Alternatively, the utility function
strawberryfields.tdm.utils.full_compile()
orstrawberryfields.tdm.utils.make_phases_compatible()
can be used to compile the gate arguments into hardware applicable ones.- Parameters
program (tdm.TDMProgram) – TDMProgram containing the circuit and gate parameters device
device (Device) – device containing the certificate with the loop offsets
-