sf.circuitspecs.Chip0Specs

class Chip0Specs[source]

Bases: strawberryfields.circuitspecs.circuit_specs.CircuitSpecs

Circuit specifications for the chip0 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

circuit = 'name template_2x2_chip0\nversion 1.0\ntarget chip0 (shots=10)\n\n# for n spatial degrees, first n signal modes, then n idler modes, phase zero\nS2gate({squeezing_amplitude_0}, 0.0) | [0, 2]\nS2gate({squeezing_amplitude_1}, 0.0) | [1, 3]\n\n# standard 2x2 interferometer for the signal modes (the lower ones in frequency)\nRgate({external_phase_0}) | [0]\nBSgate(pi/4, pi/2) | [0, 1]\nRgate({internal_phase_0}) | [0]\nBSgate(pi/4, pi/2) | [0, 1]\n\n#duplicate the interferometer for the idler modes (the higher ones in frequency)\nRgate({external_phase_0}) | [2]\nBSgate(pi/4, pi/2) | [2, 3]\nRgate({internal_phase_0}) | [2]\nBSgate(pi/4, pi/2) | [2, 3]\n\n# final local phases\nRgate({final_phase_0}) | 0\nRgate({final_phase_1}) | 1\nRgate({final_phase_2}) | 2\nRgate({final_phase_3}) | 3\n\n# Measurement in Fock basis\nMeasureFock() | [0, 1, 2, 3]\n'
decompositions = {'BipartiteGraphEmbed': {'drop_identity': False, 'mesh': 'rectangular_symmetric'}, 'Interferometer': {'drop_identity': False, 'mesh': 'rectangular_symmetric'}, 'MZgate': {}}
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 = True
local = True
modes = 4
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', 'MeasureFock', 'Rgate', 'S2gate'}
remote = True
short_name = 'chip0'

compile(seq, registers)

Try to arrange a quantum circuit into a form suitable for Chip0.

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 Chip0.

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 Chip0

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

list[strawberryfields.program_utils.Command]