# The Remote device¶

Pennylane’s Remote device gives access to remote backends from Strawberry Fields including hardware backends.

## Accounts and Tokens¶

By default, the strawberryfields.remote device will attempt to use an already active or stored Strawberry Fields account. If the device finds no account it will raise a warning:

'WARNING:strawberryfields.configuration:No Strawberry Fields configuration file found.'


It is recommended to use the strawberryfields.store_account() function to permanently store an account:

import strawberryfields as sf
sf.store_account("my_token")


Alternatively, you can use the Strawberry Fields command line interface for configuration. Please see the Strawberry Fields hardware details for more information.

Warning

Never publish code containing your token online.

## Usage¶

You can instantiate the Remote device in PennyLane as follows:

import pennylane as qml

dev = qml.device('strawberryfields.remote', backend="X8", shots=10, sf_token="XXX")


The device can then be used to create supported circuits to define and evaluate QNodes within PennyLane. Refer to the Strawberry Fields hardware page for more details on circuit structures, backends to use and getting an authentication token.

As an example, the following simple example defines a quantum_function circuit that first applies two-mode squeezing on the the vacuum state, followed by beamsplitters, and then returns the photon number expectation. This function is then converted into a QNode which is placed on the strawberryfields.remote device:

@qml.qnode(dev)
def quantum_function(theta, phi):
qml.TwoModeSqueezing(1.0, 0.0, wires=[0,4])
qml.TwoModeSqueezing(1.0, 0.0, wires=[1,5])
qml.Beamsplitter(theta, phi, wires=[0,1])
qml.Beamsplitter(theta, phi, wires=[4,5])
return qml.expval(qml.NumberOperator(0))


The strawberryfields.remote device also supports returning Fock basis probabilities:

@qml.qnode(dev)
def quantum_function(theta, x):
qml.TwoModeSqueezing(1.0, 0.0, wires=[0,4])
qml.TwoModeSqueezing(1.0, 0.0, wires=[1,5])
qml.Beamsplitter(theta, phi, wires=[0,1])
qml.Beamsplitter(theta, phi, wires=[4,5])
return qml.probs(wires=[0, 1, 2, 4])


The probabilities will be returned as a 1-dimensional NumPy array with length $$D^N$$, where $$N$$ is the number of wires, and $$D$$ is the Fock basis truncation (one greater than then number of photons detected).

in addition, Fock basis samples can returned from the device:

@qml.qnode(dev)
def quantum_function(theta, x):
qml.TwoModeSqueezing(1.0, 0.0, wires=[0,4])
qml.TwoModeSqueezing(1.0, 0.0, wires=[1,5])
qml.Beamsplitter(theta, phi, wires=[0,1])
qml.Beamsplitter(theta, phi, wires=[4,5])
return [qml.sample(qml.NumberOperator(i)) for i in [0, 1, 2, 4]]


This will return a NumPy array of shape (len(sampled_modes), shots).

## Device options¶

The Strawberry Fields Remote device accepts the following device arguments.

backend

The remote Strawberry Fields backend to use. Authentication is required for connection.

sf_token

The SF API token used for remote access.

shots=10

The number of circuit evaluations/random samples used to estimate expectation values and variances of observables.

hbar=2

The convention chosen in the canonical commutation relation $$[x, p] = i \hbar$$. Default value is $$\hbar=2$$.

wires

Iterable that contains unique labels for the modes as numbers or strings (i.e., ['m1', ..., 'm4', 'n1',...,'n4']). The number of labels must match the number of modes accessible on the backend. If not provided, modes are addressed as consecutive integers [0, 1, ...], and their number is inferred from the backend.

cutoff_dim

the Fock basis truncation to be applied when computing quantities in the Fock basis (such as probabilities)

## Supported operations¶

The Strawberry Fields Remote device supports a subset of continuous-variable (CV) operations and observables provided by PennyLane.

• Supported operations: The set of supported operations depends on the specific backend used. Please refer to the Strawberry Fields documentation for the chosen backend.

• Supported observables: This device only supports Fock-based measurements, including qml.probs(), qml.NumberOperator, and qml.TensorN. The qml.state and qml.density_matrix measurements are not supported.