sf.api.DeviceSpec

class DeviceSpec(target, spec, connection)[source]

Bases: object

The specifications for a specific hardware device.

Parameters
  • target (str) – name of the target hardware device

  • spec (dict) –

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

    • layout (str): string containing the Blackbird circuit layout

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

    • compiler (list): list of supported compilers

    • gate_parameters (dict): parameters for the circuit gates

  • connection (strawberryfields.api.Connection) – connection over which the job is managed

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]

default_compiler

Specified default compiler

Type

sf.compilers.Compiler

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]

layout

Returns a string containing the Blackbird circuit layout.

Type

str

modes

Number of modes supported by the device.

Type

int

target

The name of the target hardware device.

Type

str

create_program(**parameters)

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

refresh()

Refreshes the device specifications

validate_parameters(**parameters)

Validate gate parameters against the device spec.

create_program(**parameters)[source]

Create a Strawberry Fields program matching the low-level 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 Connection class:

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

refresh()[source]

Refreshes the device specifications

validate_parameters(**parameters)[source]

Validate gate parameters against the device spec.

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