# sf.circuitspecs.X8Specs¶

class X8Specs[source]

Bases: strawberryfields.circuitspecs.circuit_specs.CircuitSpecs

Circuit specifications for the X8 class of circuits.

 circuit decompositions graph The allowed circuit topologies or connectivity of the class, modelled as a directed acyclic graph. interactive local modes parameter_ranges Allowed parameter ranges for supported quantum operations. primitives remote short_name sq_amplitude
circuit = 'name template_4x2_X8\nversion 1.0\ntarget X8 (shots=1)\n\n# for n spatial degrees, first n signal modes, then n idler modes, all phases zero\nS2gate({squeezing_amplitude_0}, 0.0) | [0, 4]\nS2gate({squeezing_amplitude_1}, 0.0) | [1, 5]\nS2gate({squeezing_amplitude_2}, 0.0) | [2, 6]\nS2gate({squeezing_amplitude_3}, 0.0) | [3, 7]\n\n# standard 4x4 interferometer for the signal modes (the lower ones in frequency)\n# even phase indices correspond to internal Mach-Zehnder interferometer phases\n# odd phase indices correspond to external Mach-Zehnder interferometer phases\nMZgate({phase_0}, {phase_1}) | [0, 1]\nMZgate({phase_2}, {phase_3}) | [2, 3]\nMZgate({phase_4}, {phase_5}) | [1, 2]\nMZgate({phase_6}, {phase_7}) | [0, 1]\nMZgate({phase_8}, {phase_9}) | [2, 3]\nMZgate({phase_10}, {phase_11}) | [1, 2]\n\n# duplicate the interferometer for the idler modes (the higher ones in frequency)\nMZgate({phase_0}, {phase_1}) | [4, 5]\nMZgate({phase_2}, {phase_3}) | [6, 7]\nMZgate({phase_4}, {phase_5}) | [5, 6]\nMZgate({phase_6}, {phase_7}) | [4, 5]\nMZgate({phase_8}, {phase_9}) | [6, 7]\nMZgate({phase_10}, {phase_11}) | [5, 6]\n\n# add final dummy phases to allow mapping any unitary to this template (these do not\n# affect the photon number measurement)\nRgate({final_phase_0}) | [0]\nRgate({final_phase_1}) | [1]\nRgate({final_phase_2}) | [2]\nRgate({final_phase_3}) | [3]\nRgate({final_phase_4}) | [4]\nRgate({final_phase_5}) | [5]\nRgate({final_phase_6}) | [6]\nRgate({final_phase_7}) | [7]\n\n# measurement in Fock basis\nMeasureFock() | [0, 1, 2, 3, 4, 5, 6, 7]\n'
decompositions = {'BipartiteGraphEmbed': {'drop_identity': False, 'mesh': 'rectangular_symmetric'}, 'Interferometer': {'drop_identity': False, 'mesh': 'rectangular_symmetric'}}
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
local = True
modes = 8
parameter_ranges

Allowed parameter ranges for supported quantum operations.

This property is optional.

Returns

a dictionary mapping an allowed quantum operation to a nested list of the form [[p0_min, p0_max], [p1_min, p0_max], ...]. where pi corresponds to the i th gate parameter

Return type

dict[str, list]

primitives = {'BSgate', 'MZgate', 'MeasureFock', 'Rgate', 'S2gate'}
remote = True
short_name = 'X8'
sq_amplitude = 1.0
 compile(seq, registers) Try to arrange a quantum circuit into a form suitable for X8. 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 X8.

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 X8

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 and decompositions class attributes to determine whether a command should be decomposed.

The order of precedence to determine whether decomposition should be applied is as follows.

1. 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 the CircuitSpecs).

2. 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 CircuitSpecs).

• 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