Tutorials
qcr:2608.26483.1

Analog Hamiltonian Simulation with the Local Simulator on Amazon Braket

This intermediate tutorial shows how to prototype and debug analog Hamiltonian simulation (AHS) programs on Amazon Braket's local simulator before submitting them to a neutral-atom QPU such as Aquila. Using a nine-atom three-by-three square lattice of Rydberg atoms, it assembles an atom arrangement and a time-dependent global driving field whose Rabi frequency and detuning are adiabatically tuned to prepare the antiferromagnetic 2D checkerboard phase, then runs the program on the local simulator with configurable shots and time steps. The notebook's main theme is performance tuning of the classical simulation. It demonstrates the blockade approximation, in which setting a blockade radius restricts the dynamics to a smaller effective Hilbert space by forbidding simultaneous excitation of atoms within each other's Rydberg blockade radius, cutting runtime by an order of magnitude while keeping the final Rydberg densities within about two percent as measured by a root-mean-square difference. It also explores reducing the number of integration steps and explains the underlying solvers, an implicit Runge-Kutta scheme in numpy for small systems and scipy's ODE integrator for larger ones. It matters by teaching practical techniques to iterate on Rydberg-atom simulations quickly and cheaply before incurring QPU costs.
Quantum Simulation
Qubit
Analog simulation
Uploaded 2 weeks ago
20
Views
GitHub587
Citing this entry? Use this QCR ID
Uploaded by
QL
QCR Librarian

Overview

amazon-braket/amazon-braket-examples
587262
In [ ]:
# --- Setup cell added by QCR (not part of the original tutorial) ---
# Source: amazon-braket/amazon-braket-examples @ 0c0818f315479aab9deebed7e7ed7533ac581923, Apache License 2.0.
# Installs the example's dependencies. If a later cell still reports a missing
# package, restart the runtime/kernel and run again from the top.
%pip install -q amazon-braket-sdk==1.117.3 matplotlib networkx

Running analog Hamiltonian simulation with local simulator

We recommend to test and debug an analog Hamiltonian simulation (AHS) program on the local simulator before submitting it to a QPU. In this notebook, we introduce several features of the local simulator that will be useful to streamline this testing process.

To begin, we import the necessary packages.

In [1]:
import time

import numpy as np
from ahs_utils import plot_avg_density_2D, show_global_drive, show_register

from braket.ahs.analog_hamiltonian_simulation import AnalogHamiltonianSimulation
from braket.ahs.atom_arrangement import AtomArrangement
from braket.ahs.driving_field import DrivingField
from braket.devices import LocalSimulator

2D checkerboard phase

We consider a square grid with 9 atoms. As shown in this notebook, we can realize the 2D checkerboard phase via adiabatically tuning the Rabi frequency and detuning.

In [25]:
register = AtomArrangement()
separation = 6.7e-6  # in meters

for k in range(3):
    for i in range(3):
        register.add((k * separation, i * separation))


time_points = [0, 2.5e-7, 2.75e-6, 3e-6]
amplitude_min = 0  # rad / s
amplitude_max = 1.57e7  # rad / s

detuning_min = -5.5e7  # rad / s
detuning_max = 5.5e7  # rad / s

amplitude_values = [amplitude_min, amplitude_max, amplitude_max, amplitude_min]  # piecewise linear
detuning_values = [detuning_min, detuning_min, detuning_max, detuning_max]  # piecewise linear
phase_values = [0, 0, 0, 0]  # piecewise constant


drive = DrivingField.from_lists(time_points, amplitude_values, detuning_values, phase_values)

show_register(register)
show_global_drive(drive)

The AHS program can be constructed by assembling the atomic register with the driving field.

In [26]:
ahs_program = AnalogHamiltonianSimulation(register=register, hamiltonian=drive)

We can then run the program on the local simulator.

In [27]:
device = LocalSimulator("braket_ahs")

Below we explicitly specify shots=10000 and steps=100 respectively.

In [28]:
start_time = time.time()
result_full = device.run(ahs_program, shots=10000, steps=100).result()
print(f"The elapsed time = {time.time() - start_time} seconds")
The elapsed time = 3.253291130065918 seconds
In [29]:
plot_avg_density_2D(result_full.get_avg_density(), register)

Run AHS program in the blockade subspace

The above simulation is performed using the full Hamiltonian with size . However, because of Rydberg blockade, if neighboring atoms are within each other's Rydberg blockade radius , they are very unlikely to be excited to the Rydberg states simultaneously. Given that (see this notebook)

we have 6.752 < < 6.796 throughout the program, which is always larger than , the distances between neighboring atoms. Hence we can approximate the full Hamiltonian of the system with a smaller effective Hamiltonian. We can take advantage of this fact to speed up the simulation by setting the parameter blockade_radius as shown below.

In [30]:
start_time = time.time()
result_blockade = device.run(ahs_program, shots=10000, blockade_radius=6.796e-6, steps=100).result()
print(f"The elapsed time = {time.time() - start_time} seconds")
The elapsed time = 0.199995756149292 seconds

Indeed, the runtime for the simulation with the effective Hamiltonian is one magnitude less than the one with the original Hamiltonian. We can visually confirm that the checkerboard phase is created successfully using the Rydberg blockade approximation.

In [31]:
plot_avg_density_2D(result_blockade.get_avg_density(), register)

In order to quantify the difference in the final average Rydberg densities from the two simulations, we can calculate the root-mean-square difference (RMS) defined as Here and are the final Rydberg density at the -th site for the simulation with the full Hamiltonian and the effective Hamiltonian respectively.

In [32]:
n_full = result_full.get_avg_density()
n_blockade = result_blockade.get_avg_density()

RMS_blockade = np.sqrt(np.mean((np.array(n_full) - np.array(n_blockade)) ** 2))
print(f"The RMS_blockade for the final Rydberg densities = {RMS_blockade}")
The RMS_blockade for the final Rydberg densities = 0.024428330547406077

Since the RMS is only around 2%, we are assured that the simulation with the effective Hamiltonian of smaller size gives quantitatively the same results as the one with the full Hamiltonian.

Tuning other parameters in the local simulator

Another way to speed up the simulation, without using the blockade approximation, is to adjust other parameters of the local simulator, such as steps, the number of time points in the simulation. Previously, we have set steps=100, but it can be adjusted to be 40 as shown below. We expect that the less time point used in the simulation, the faster it will finish.

In [33]:
start_time = time.time()
result_reduced_nsteps = device.run(ahs_program, shots=10000, steps=40).result()
print(f"The elapsed time = {time.time() - start_time} seconds")
The elapsed time = 1.4084961414337158 seconds

This indeed speed up the simulation as expected. We can confirm that the simulation produces result that is close to our expectation.

In [34]:
plot_avg_density_2D(result_reduced_nsteps.get_avg_density(), register)
In [35]:
n_reduced_nsteps = result_reduced_nsteps.get_avg_density()

RMS_reduced_nsteps = np.sqrt(np.mean((np.array(n_full) - np.array(n_reduced_nsteps)) ** 2))
print(f"The RMS_reduced_nsteps for the final Rydberg densities = {RMS_reduced_nsteps}")
The RMS_reduced_nsteps for the final Rydberg densities = 0.08276531076886416

We note that if the Hamiltonian is almost constant throughout the AHS program, simulation with smaller steps, such as 80 or 50, is likely sufficient to give qualitatively good result, as demonstrated here. On the other hand, if the Hamiltonian is varying drastically throughout the program, one may need to have higher steps around 200 or more.

We see that although the runtime is reduced compared to the simulation with default parameters, it is still much longer than the simulation performed with the effective Hamiltonian that uses blockade approximation. The reason is that the local simulator will need to construct Hamiltonian used for the simulation, and this takes majority part of the runtime.

We also note that when the dimension of the Hamiltonian is larger than , the AHS local simulator use scipy.integrate.ode as the backend solver and support the following arguments: atol, rtol, solver_method, order, nsteps, first_step, max_step and min_step. For more information, please refer to the following documentation page.

When the dimension of the Hamiltonian is less than or equal to , we use a solver based on the implicit Runge-Kutta method written in numpy, which is more efficient than the scipy.integrate.ode solver in this case. The solver based on numpy does not support the arguments listed above.

In [ ]:

Join the Discussion

Comments (0)

No comments yet. Be the first to share your thoughts!

Indexed by QCR Librarian

This entry was created automatically from publicly available records. QCR links to public sources and only stores repository content where the license permits redistribution.

Versions

v1 Latest
Aug 16, 2026
qcr:2608.26483.1

Cite all versions? Use the base QCR ID to always reference the latest version of this entry.

Tools used

Amazon Braket SDK

Keywords

braket
analog-hamiltonian-simulation
rydberg-atoms
neutral-atoms
local-simulator
rydberg-blockade
quantum-simulation

You may also like5