The local Braket device

The local device of the PennyLane-Braket plugin runs quantum computations on the local Braket SDK. This could be either utilizing the processors of your own PC, or those of a Braket notebook instance hosted on AWS.

This device is useful for small-scale simulations in which the time of sending a job to a remote service would add an unnecessary overhead. It can also be used for rapid prototyping before running a computation on a paid-for remote service.

Usage

After the Braket SDK and the plugin are installed you immediately have access to the local Braket device in PennyLane.

To instantiate the local Braket simulator, simply use:

import pennylane as qml
device_local = qml.device("braket.local.qubit", wires=2) # local state vector simulator
# device_local = qml.device("braket.local.qubit", backend="default", wires=2) # local state vector simulator
# device_local = qml.device("braket.local.qubit", backend="braket_sv", wires=2) # local state vector simulator
# device_local = qml.device("braket.local.qubit", backend="braket_dm", wires=2) # local state vector simulator

You can define and evaluate quantum nodes with these devices just as you would with any other PennyLane device.

For example:

@qml.qnode(device_local)
def circuit(x, y, z):
    qml.RZ(z, wires=[0])
    qml.RY(y, wires=[0])
    qml.RX(x, wires=[0])
    qml.CNOT(wires=[0, 1])
    return qml.expval(qml.PauliZ(0)), var(qml.PauliZ(1))

When executed, the circuit will perform the computation on the local machine.

>>> circuit(0.2, 0.1, 0.3)
array([0.97517033, 0.04904283])

Device options

You can set shots to None (default) to get exact results instead of results calculated from samples.

Supported operations

The device supports all PennyLane operations and observables.

The PennyLane-Braket plugin provides the following framework-specific operations for PennyLane, which can be imported from braket.pennylane_plugin.ops:

braket.pennylane_plugin.CPhaseShift00(phi, wires)

Controlled phase shift gate phasing the \(| 00 \rangle\) state.

braket.pennylane_plugin.CPhaseShift01(phi, wires)

Controlled phase shift gate phasing the \(| 01 \rangle\) state.

braket.pennylane_plugin.CPhaseShift10(phi, wires)

Controlled phase shift gate phasing the \(| 10 \rangle\) state.

braket.pennylane_plugin.PSWAP(phi, wires)

Phase-SWAP gate.

braket.pennylane_plugin.XY(phi, wires)

Parameterized ISWAP gate: https://arxiv.org/abs/1912.04424v1