sf.DeviceSpec

class DeviceSpec(spec)[source]

Bases: object

The specifications for a specific remote device.

Parameters

spec (dict) –

dictionary representing the raw device specification. This dictionary must contain the following key-value pairs:

  • layout (str): string containing the Blackbird circuit layout or XIR manifest

  • modes (int): number of modes supported by the target

  • compiler (list): list of supported compilers

  • gate_parameters (dict): parameters for the circuit gates

compiler

A list of strings corresponding to Strawberry Fields compilers supported by the hardware device.

default_compiler

Specified default compiler

gate_parameters

A dictionary of gate parameters and allowed ranges.

layout

Returns a string containing the Blackbird circuit layout.

modes

Number of modes supported by the device.

target

The name of the target hardware device.

compiler

A list of strings corresponding to Strawberry Fields compilers supported by the hardware device.

Type

list[str]

Return type

Sequence[str]

default_compiler

Specified default compiler

Type

sf.compilers.Compiler

Return type

str

gate_parameters

A dictionary of gate parameters and allowed ranges.

The parameter names correspond to those present in the Blackbird circuit layout.

Example

>>> spec.gate_parameters
{'squeezing_amplitude_0': x=0, x=1, 'phase_0': x=0, 0≤x≤6.283185307179586}
Type

dict[str, strawberryfields.compilers.Ranges]

Return type

Mapping[str, Ranges]

layout

Returns a string containing the Blackbird circuit layout.

Type

str

Return type

str

modes

Number of modes supported by the device.

Type

int

Return type

int

target

The name of the target hardware device.

Type

str

Return type

str

create_program(**parameters)

Create a Strawberry Fields program matching the low-level Blackbird layout of the device.

validate_parameters(**parameters)

Validate gate parameters against the device spec.

create_program(**parameters)[source]

Create a Strawberry Fields program matching the low-level Blackbird layout of the device.

Gate arguments should be passed as keyword arguments, with names correspond to those present in the Blackbird circuit layout. Parameters not present will be assumed to have a value of 0.

Example

Device specifications can be retrieved from the API by using the xcc.Device and xcc.Connection classes:

>>> spec.create_program(squeezing_amplitude_0=0.43)
<strawberryfields.program.Program at 0x7fd37e27ff50>
Keyword Arguments

parameter values for the specific device (Supported) –

Returns

program compiled to the device

Return type

strawberryfields.program.Program

validate_parameters(**parameters)[source]

Validate gate parameters against the device spec.

Gate parameters should be passed as keyword arguments, with names corresponding to those present in the Blackbird circuit layout.

Raises

ValueError – if an invalid parameter is passed

Return type

None