AWS Quantum Technologies Blog
Introducing Local Device Emulator for Verbatim Circuits on Amazon Braket
Today, we’re excited to announce the launch of local device emulator on Amazon Braket. This feature enables developers to emulate their verbatim circuits based on device calibration data. Local device emulation helps accelerate the development cycle by providing early feedback on circuit compatibility and expected behavior in the presence of noise.
In this post, we show you how the local emulator helps catch potential issues early, by validating and testing your verbatim circuits before running them on actual quantum hardware. We also compare the emulation and quantum hardware results, showing how local emulation can facilitate developing noise-aware algorithms, such as error mitigation algorithms for the targeted hardware. By the end of this post, you will understand how to incorporate local device emulation into your quantum computing workflow.
Overview
The local device emulator leverages the existing Braket SDK to accelerate quantum software development with verbatim circuits. Verbatim circuits are quantum circuits that use a quantum processor’s native gate set for direct execution and no intervening compiler passes. When developing a quantum program, developers currently face difficulties in validating device compatibility and predicting the result in the presence of noise. Without proper validation tools, the only way to verify if a program can run on a specific QPU is to submit it to the hardware and cancel immediately, risking unnecessary costs. Additionally, developers must take time to build a noise model to predict a noisy result. The local device emulator mitigates these challenges by emulating the circuit on the target QPU. This includes validating the circuit based on the given calibration data, applying depolarizing noise to each gate in the circuit based on the calibration data, and simulating the noisy circuit using the local density matrix simulator. One of the benefits of using the local emulator is that it enables developers to streamline the development process by catching compatibility issues and predicting program behavior without the need to manually construct the noise model.
Instantiating a local device emulator
A device emulator can be instantiated either directly from an AWS device or a set of device properties. For instance, if we are interested in emulating the Rigetti Ankaa-3 device, its emulator can be instantiated as follows:
from braket.aws import AwsDevice
from braket.devices import Devices
ankaa3 = AwsDevice(Devices.Rigetti.Ankaa3)
ankaa3_emulator = ankaa3.emulator()
The Rigetti Ankaa-3 local emulator was created based on the up-to-date calibration data extracted from the Ankaa-3 device. Alternatively, you could create a local emulator with a set of device properties in JSON format, as seen below.
from braket.emulation.local_emulator import LocalEmulator
ankaa3_device_property_json = ankaa3.properties.json()
ankaa3_emulator = LocalEmulator.from_json(ankaa3_device_property_json)
Each method to instantiate a device emulator is tailored toward a unique use case. The first approach is suitable for testing your circuits with real-time calibration data. The second approach is useful for emulation with custom device properties or historical calibration data previously recorded from quantum hardware.
Validation with a local emulator
After you have set up a local emulator, it can be used to test if a given verbatim circuit satisfies the constraints of the device, including:
- If the qubit indices used in the circuit exist on the QPU.
- If the circuit is comprised of a QPU’s native gates.
- If the two-qubit gates are applied to qubits that are not connected in the device’s topology graph.
Let’s consider three examples using Ankaa-3 as our target quantum hardware, whose topology is shown in Figure 1, and examine why they will fail.
Example 1: The following circuit will return an error because it contains a gate operation on qubit with index 84 while the device has only qubit indices from 0 to 83.
from braket.circuits import Circuit
invalid_circuit = Circuit().add_verbatim_box(Circuit().rx(84, 0))
ankaa3_emulator.run(invalid_circuit, shots=10)
Example 2: The following circuit will return an error because it contains the gate H although the device only supports the native gates RX, RZ, and iSWAP.
invalid_circuit = Circuit().add_verbatim_box(Circuit().h(0))
ankaa3_emulator.run(invalid_circuit, shots=10)
Example 3: The following circuit will result in an error because the two-qubit gate, although supported natively, is applied to qubits 0 and 2 which are not connected on the device.
invalid_circuit = Circuit().add_verbatim_box(Circuit().iswap(0,2))
ankaa3_emulator.run(invalid_circuit, shots=10)

Figure 1 – The device topology graph for the Rigetti Ankaa-3 device where qubits are indexed from 0 to 83 and neighboring qubits that support two-qubit gates are connected by an edge.
Comparing emulator results to the hardware results
After verifying the validity of the input circuit, the local emulator applies depolarizing noise to each of the gates in the circuit to mimic the noise in the target QPU. The noise model is constructed based on the provided device calibration data. The noisy circuit is then simulated using the local density matrix simulator. As an example, let’s use Ankaa-3 as the target hardware and create a valid verbatim circuit.
from numpy import pi as pi
valid_circuit = Circuit().add_verbatim_box(
Circuit().rx(0, pi/2).rz(1, pi).iswap(0, 1).rx(2, -pi/2).rz(3, pi/2).iswap(2, 3).iswap(1, 2).rx(0, -pi/2).rz(3, -pi)
)
Let’s then run this circuit on both the noiseless local state-vector simulator and the local emulator.
from braket.devices import LocalSimulator
local_sim_task = LocalSimulator().run(valid_circuit, shots=1000)
local_sim_result = local_sim_task.result()
local_sim_counts = local_sim_result.measurement_counts
emulator_task = ankaa3_emulator.run(valid_circuit, shots=1000)
emulator_result = emulator_task.result()
emulator_counts = emulator_result.measurement_counts
The local emulator applies a depolarizing noise to each of the gates in the circuit. It is constructed based on the calibration data for the specific qubit or edge, to mimic the noise in the target QPU. Then, the emulator uses the local density-matrix simulator to simulate the noisy circuit. You can inspect the noisy circuit run on the local emulator using the following code:
noisy_circ = ankaa3_emulator.transform(valid_circuit)
print(noisy_circ)

Figure 2 – The noisy circuit run on the local emulator for the Ankaa-3 device, where a depolarizing channel is applied to each one or two-qubit gate in the circuit and bit-flip channels are applied before the measurements.
In an actual workflow of developing quantum algorithms, you could inspect and iterate on the results from the emulator before submitting to the quantum hardware. For example, you could vary the parameters in the circuit and see how the result changes in the noisy setting. In the following example, we run the same verbatim circuit on the device and compare the results.
device_run = ankaa3.run(valid_circuit, shots=1000)
device_result = device_run.result()
device_counts = device_result.measurement_counts
For comparison of the noiseless and noisy simulations to the actual quantum task on the Ankaa-3 device, we present the bitstring distributions obtained from the measurement results.

Figure 3 – The comparison of the results from the noiseless simulator (green), local emulator (blue) and the Ankaa-3 device (orange).
To quantify the discrepancy between the results from different devices, we define the following fidelity.
Here pi and qi are two arrays of bit-string probabilities. We find that the fidelity between results from Ankaa-3 and the state-vector simulation without device noise is 0.956, whereas the fidelity between the results from Ankaa-3 and the density-matrix simulation with the noise model provided by the local emulator is 0.982. The local emulator provides results closer to the actual quantum hardware indicates that it serves as a better tool to develop noise-aware algorithms for the target hardware.
Conclusion
With the introduction of a local emulator, we aim to facilitate quantum software development on Amazon Braket. To learn more and get started with local emulation, see our developer guide and example notebook.