sf.RemoteEngine

class RemoteEngine(target, connection=None, backend_options=None)[source]

Bases: object

A quantum program executor engine that provides a simple interface for running remote jobs in a blocking or non-blocking manner.

Example:

The following examples instantiate an engine with the default configuration, and run both blocking and non-blocking jobs.

Run a blocking job:

>>> engine = RemoteEngine("X8_01")
>>> result = engine.run(program, shots=1) # blocking call
>>> result
[[0 1 0 2 1 0 0 0]]

Run a non-blocking job:

>>> job = engine.run_async(program, shots=1)
>>> job.status
"queued"
>>> job.result
InvalidJobOperationError
>>> job.refresh()
>>> job.status
"complete"
>>> job.result
[[0 1 0 2 1 0 0 0]]
Parameters
  • target (str) – the target device

  • connection (strawberryfields.api.Connection) – a connection to the remote job execution platform

  • backend_options (Dict[str, Any]) – keyword arguments for the backend

DEFAULT_TARGETS

POLLING_INTERVAL_SECONDS

connection

The connection object used by the engine.

device_spec

The device specifications for target device

target

The target device used by the engine.

DEFAULT_TARGETS = {'X12': 'X12_01', 'X8': 'X8_01'}
POLLING_INTERVAL_SECONDS = 1
connection

The connection object used by the engine.

Return type

Connection

Returns

strawberryfields.api.Connection

device_spec

The device specifications for target device

target

The target device used by the engine.

Returns

the name of the target

Return type

str

run(program, *[, compile_options, recompile])

Runs a blocking job.

run_async(program, *[, compile_options, …])

Runs a non-blocking remote job.

run(program, *, compile_options=None, recompile=False, **kwargs)[source]

Runs a blocking job.

In the blocking mode, the engine blocks until the job is completed, failed, or cancelled. A job in progress can be cancelled with a keyboard interrupt (ctrl+c).

If the job completes successfully, the result is returned; if the job fails or is cancelled, None is returned.

Parameters
  • program (strawberryfields.Program) – the quantum circuit

  • compile_options (None, Dict[str, Any]) – keyword arguments for Program.compile()

  • recompile (bool) – Specifies if program should be recompiled using compile_options, or if not provided, the default compilation options.

Keyword Arguments

shots (Optional[int]) – The number of shots for which to run the job. If this argument is not provided, the shots are derived from the given program.

Returns

the job result if successful, and None otherwise

Return type

strawberryfields.api.Result, None

run_async(program, *, compile_options=None, recompile=False, **kwargs)[source]

Runs a non-blocking remote job.

In the non-blocking mode, a Job object is returned immediately, and the user can manually refresh the status and check for updated results of the job.

Parameters
  • program (strawberryfields.Program) – the quantum circuit

  • compile_options (None, Dict[str, Any]) – keyword arguments for Program.compile()

  • recompile (bool) – Specifies if program should be recompiled using compile_options, or if not provided, the default compilation options.

Keyword Arguments

shots (Optional[int]) – The number of shots for which to run the job. If this argument is not provided, the shots are derived from the given program.

Returns

the created remote job

Return type

strawberryfields.api.Job