sf.Device

class Device(spec, cert=None)[source]

Bases: object

The representation of 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

  • cert (dict, optional) – dictionary representing the device certificate

certificate

A device certificate containing the current operating conditions of the device.

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

A string containing the Blackbird circuit layout.

modes

The number of modes supported by the device.

target

The name of the target hardware device.

certificate

A device certificate containing the current operating conditions of the device.

Type

dict[str, Any]

Return type

Optional[Mapping[str, Any]]

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

Optional[Mapping[str, Ranges]]

layout

A string containing the Blackbird circuit layout.

Type

str

Return type

Optional[str]

modes

The 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 the gate parameters against the device specification.

validate_target(spec)

Check that the target in the specification is equal to the layout target.

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 the gate parameters against the device specification.

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

static validate_target(spec)[source]

Check that the target in the specification is equal to the layout target.

Returns

dictionary representing the raw device specification.

Return type

dict