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

VALID_TARGETS

connection

The connection object used by the engine.

target

The target device used by the engine.

DEFAULT_TARGETS = {'X12': 'X12_01', 'X8': 'X8_01'}
POLLING_INTERVAL_SECONDS = 1
VALID_TARGETS = ('X8_01', 'X12_01', 'X12_02')
connection

The connection object used by the engine.

Return type

Connection

Returns

strawberryfields.api.Connection

target

The target device used by the engine.

Returns

the name of the target

Return type

str

run(program, *[, compile_options])

Runs a blocking job.

run_async(program, *[, compile_options])

Runs a non-blocking remote job.

run(program, *, compile_options=None, **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

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