AWS Quantum Technologies Blog

Fundamental Physics Simulations with Amazon Braket

This post was contributed by Emilie Huffman from Perimeter Institute along with Sebastian Stern and Sebastian Hassinger from AWS.

Quantum computing promises new approaches to the ways in which we simulate fundamental physics, potentially solving problems that are intractable for classical computers. In this post, we demonstrate how to use Amazon Braket to find the ground state energy for a model relevant to quantum chromodynamics, the fundamental theory of quarks and gluons. For physicists, quantum computing is an attractive idea because it is intrinsically suited to be a platform for simulating quantum systems, as anticipated by physicist Richard Feynman:

“Can you do it with a new kind of computer — a quantum computer? Now it turns out, as far as I can tell, that you can simulate this with a quantum system, with quantum computer elements. It’s not a Turing machine, but a machine of a different kind.”

Being able to simulate quantum systems means being able to simulate the fundamental laws of nature, and classical computers cannot efficiently perform these simulations due to an exponential scaling problem. But because the fundamental elements of quantum computers are themselves quantum, they can sometimes be used to transform the simulation problem into a polynomial one, making it much more tractable.

We will cover a simplified, yet nontrivial, model and show step-by-step how we used Braket tools and features to build the experiments. We have used the constructs and primitives available in the Amazon Braket SDK for implementing the quantum circuit subroutine of the algorithm and to interact with the service to run the entire hybrid workflow in the cloud using Hybrid Jobs. Using these same techniques, researchers from the Perimeter Institute for Theoretical Physics, Saha Institute of Nuclear Physics, and University of Southampton were able to simulate larger, more challenging systems on both circuit simulators and real quantum hardware in a paper – Spontaneous symmetry breaking in a SO(3) non-Abelian lattice gauge theory in 2+1D with quantum algorithms – recently published in Physical Review Research.

Physics Background

Our simulation focuses on a model with SO(3) symmetry (or rotational group symmetry) – the mathematical group that describes three-dimensional rotations in space. The model is built from “quantum links,” fundamental building blocks that we can represent using individual qubits. SO(3)-symmetric lattice models are interesting as toy models with similarities to the model for Quantum Chromodynamics (QCD). This symmetry allows for models that can accommodate the three color charges that quarks and gluons may have. The advantage for SO(3) models (which are a simplification of the full SU(3) symmetry of QCD), is that it is possible to obtain this symmetry with a very small number of qubits. These experiments can provide insights that may guide the development of quantum simulations of the full SU(3) gauge theory on larger systems in the future. The image that follows is a representation of the building blocks that make up our model: each white circle (which we will represent with a qubit) is on a quantum link, and there is a square lattice geometry to the model that makes some quantum links closer to each other than others. Each intersection dark circle represents a point in space.

Figure 1: Each link in this lattice has two circles, and each circle represents one qubit.

Figure 1: Each link in this lattice has two circles, and each circle represents one qubit.

Mathematically, this model is defined by a Hamiltonian, which is an expression of its energy and is given by

with

The first line is the full model, and the lines that follow it give the definitions for “operators” (quantum gates) that will make up the model. In the second line, the square symbol “□” on the operator O is for a “plaquette,” which corresponds to the links that make up a square in the lattice.

Each “O” in the product for that operator on the right-hand side of the equation then corresponds to each one of the four links in a plaquette. In the third line, these link operators are then defined using the two qubits on the link, represented by the white circles in the figure.

The first σ operator corresponds to the circle on the left side of the link, with the second σ operator corresponding to the circle on the right side of the link. The same holds true for the last two “L” (left) and “R” (right) operator definitions, with one qubit (the left or the right) having a nontrivial , and the other qubit having the identity operator (represented as a “ǁ,” which means to do nothing to the qubit).

As seen in the equations, ultimately all the operators boil down to σ operators with superscripts (a,b =1,2,3). They correspond to the Pauli X, Y, and Z matrices, respectively. These are then very natural for quantum circuits, which are often built from single-qubit Pauli gates X, Y, and Z.

We find the SO(3) symmetry through this operator, which commutes with the Hamiltonian:

The vector α in the exponent of V again has three components (a = 1,2,3), which make up the generators of SO(3).

Because of the three components, this model can be extended to include three flavors of fermions (the quarks) which live on the sites. This is interesting from the QCD perspective because it allows for the simulation of baryons, which are made up of three quarks.

For our simulation on real hardware, we will be looking at a simpler lattice than the one with the square plaquettes. In fact, we will be looking at only a single plaquette with two links instead of four:

Figure 2: Bubble, or cirquette: a plaquette with two links. As in the larger lattice, each link still has two qubits.

Figure 2: Bubble, or cirquette: a plaquette with two links. As in the larger lattice, each link still has two qubits.

This plaquette with two links is sometimes called a “cirquette”. Here we will call it a bubble. This simulation only needs four qubits, and it is the smallest system size possible that still preserves the SO(3) symmetry. Its Hamiltonian is a special case of the general Hamiltonian and is given by

We sum over the repeated indices, so a and b are each summed over 1, 2, and 3. Our goal will be to find the ground state energy of this system.

Defining the Ansatz and the Model

In the previous section, we explored the theoretical foundation of our SO(3) symmetric model and its connection to quantum chromodynamics. Now we’ll transform this mathematical framework into something we can run on actual quantum hardware. Our goal remains straightforward: find the ground state energy of our bubble model—the lowest possible energy state of our system. This task, while mathematically well-defined, requires us to bridge the gap between abstract physics and practical quantum computing. We’ll accomplish this using a hybrid approach that combines the quantum advantages we discussed earlier with classical optimization techniques.

To tackle this challenge, we’ll implement a Quantum Variational Eigensolver (VQE)—an algorithm specifically designed to find ground state energies of quantum systems. This approach leverages both quantum and classical resources: the quantum hardware handles the state preparation and energy measurements, while classical optimization guides us toward the solution. We’ll use Amazon Braket’s development framework to implement this algorithm, testing it on both quantum simulators and real quantum processors to understand how theoretical predictions match experimental reality.

Quantum variational eigensolvers make use of the variational principle, which says that for any state |ψ⟩, we always have

where EGS is the ground state energy and GS⟩ is the ground state. We can thus explore a state space of ‘guesses’ for what the ground state could be, and run a minimization algorithm within this space. If it includes the ground state, then the minimizer will find it and we will learn the value of EGS. The space of possible ground states is called the variational ansatz.

For the bubble model in particular, the system is small enough that we can exactly diagonalize it and find that the ground state is

We will now see if the eigensolver can also find this state within a larger state space. Here we define the ansatz to be

This form is exactly equal to the ground state when the θ parameter is equal to π. In addition to inputting this ansatz into the eigensolver, we will also need to input the Hamiltonian itself for the bubble.

Let’s review how we implemented the algorithm using primitives provided by the Amazon Braket SDK.

Because we will need four qubits, we go ahead and define qubit indices (these could be in a different order if we wanted to optimize for the connectivity of the hardware, which would be important for superconducting qubits in particular):

qubits = [0,1,2,3]
PI = np.pi

And we define our variational ansatz:

from braket.circuits import Circuit, FreeParameter

def ansatz_init():
  theta = FreeParameter(“theta”)
  ansatz = Circuit().h(qubits[0]).rz(qubits[0], theta).x(qubits[1]).cnot(qubits[0], qubits[1])
  ansatz = ansatz.h(qubits[2]).rz(qubits[2], theta).x(qubits[3]).cnot(qubits[2], qubits[3])
  return ansatz

This function creates the following circuit:

We are now ready to define the Hamiltonian for the bubble. Its form ends up being very simple in terms of Pauli matrices:

where each of the four operators in each term acts on a different one of the four qubits in the system. We can define this Hamiltonian in the following way:

from braket.circuits import Observable

from braket.circuits import Observable

Hbub = [
    Observable.X(0) @ Observable.X(1) @ Observable.X(2) @ Observable.X(3),
    Observable.X(0) @ Observable.X(1) @ Observable.Y(2) @ Observable.Y(3),
    Observable.X(0) @ Observable.X(1) @ Observable.Z(2) @ Observable.Z(3),
    Observable.Y(0) @ Observable.Y(1) @ Observable.X(2) @ Observable.X(3),
    Observable.Y(0) @ Observable.Y(1) @ Observable.Y(2) @ Observable.Y(3),
    Observable.Y(0) @ Observable.Y(1) @ Observable.Z(2) @ Observable.Z(3),
    Observable.Z(0) @ Observable.Z(1) @ Observable.X(2) @ Observable.X(3),
    Observable.Z(0) @ Observable.Z(1) @ Observable.Y(2) @ Observable.Y(3),
    Observable.Z(0) @ Observable.Z(1) @ Observable.Z(2) @ Observable.Z(3),
] 

Variational Eigensolver

For the variational eigensolver to find the minimum energy of our Hamiltonian, we need to measure the expectation value for the respective term in Hbub:

n_tasks = 0
def expec_value(theta, term, device, shots):
    global n_tasks
    circuit = ansatz_init()
    circuit.expectation(observable=term, target=qubits)
    
    # execute the circuit
    task = device.run(circuit, shots=shots, inputs={“theta”: theta})
    n_tasks +=1
    
    # retrieve the result
    return task.result().result_types[0].value

We feed these measurements into an objective function summing the expectation value of the individual terms in Hbub:

from braket.jobs.metrics import log_metric 

n_fevs = 0
def objective(parameter, *args):
    global n_fevs
    global n_tasks
    n_fevs += 1
    device = args[0]
    shots = args[1]
    print(f"--- function evaluation {n_fevs} ---")
    if isinstance(parameter, np.ndarray):
        parameter = parameter[0]
    exp_vals = [expec_value(parameter, term, device, shots) for term in Hbub]
    J = 1.
    sum = -J * np.sum(exp_vals)
    log_metric(metric_name="energy_vs_fev", value=sum_result, iteration_number=n_fevs)
    log_metric(metric_name="parameter_vs_fev", value=parameter, iteration_number=n_fevs)
    log_metric(metric_name="tasks_vs_fev", value=n_tasks, iteration_number=n_fevs)
    return sum

Finally, we have what we need to find the optimal parameter for our ansatz that minimizes the energy. This is a hybrid quantum-classical workflow with the workload going back and forth between a classical and a quantum computer: we feed the measurements obtained on a quantum computer into a classical optimizer which iteratively updates the variational parameters in order to find a minimum of the objective function. We use the Braket Hybrid Jobs feature to run the entire algorithm in the cloud.

from braket.jobs import hybrid_job
from braket.jobs.environment_variables import get_job_name, get_job_device_arn
from braket.aws import AwsDevice
from braket.devices import LocalSimulator, Devices
from scipy.optimize import minimize

  
@hybrid_job(job_name="so3bubble-vqe-test", device=“local:aws/braket_sv”)
def vqe_job(x0=1, tol=1e-6, shots=4000):
    print(f"Start job {get_job_name()}")
    
    # instantiate quantum device
    device_arn = get_job_device_arn()
    if device_arn.startswith('arn:aws:braket:'):
        device = AwsDevice(device_arn)
    else:
        device = LocalSimulator()
    print(device)
    
    #Inject the objective function inside the minimizer function
    result = minimize(objective, x0, method="Powell", tol=tol, options={'disp': True}, args=(device, shots,))
  
    print("The estimated ground state energy using VQE algorithm is: {}".format(result.fun))
    print("\nThe optimal parameter theta is : {} ".format(result.x[0]))
     
    return {
        "parameter": result.x[0],
        "energy": result.fun,
        "nfev": result.nfev,
        "nit": result.nit,
    }
  
job = vqe_job()
print(job)  

Results

First, we present the results for a circuit simulator. With the local simulator of the Braket SDK running embedded in the job container we achieve a minimum energy close to -9.0. The value -9.0 is indeed the exact minimum energy, and can be understood from there being nine terms each of which would have a minimum of -1.0 and a maximum of 1.0.

Figure 3: The convergence of the energy for the Bubble ground state with the number of function evaluations (denoted as nfev on the x axis) using the state vector simulator of the Braket SDK.

Figure 3: The convergence of the energy for the Bubble ground state with the number of function evaluations (denoted as nfev on the x axis) using the state vector simulator of the Braket SDK.

Next, we present the results for running the job on real quantum hardware. For that, we have used the IonQ Aria QPU by simply changing the line device=“local:aws/braket_sv” to device=Devices.IonQ.Aria1 in the preceding code cell. The QPU simulation produces a higher energy of about -8.0.

Figure 4: The convergence of the energy for the Bubble ground state with the number of function evaluations using the IonQ Aria QPU.

Figure 4: The convergence of the energy for the Bubble ground state with the number of function evaluations using the IonQ Aria QPU.

The reason the QPU does not give a low enough energy is that noise prevents the states from being in the exact ground state. However, we see that the real hardware-based optimizer is indeed able to find the correct ground state angle, θ = π, just as the simulator could.

Figure 5: The estimate of the variational parameter  at each step of the optimizer using the IonQ Aria QPU for which the variational eigensolver also managed to converge to .

Figure 5: The estimate of the variational parameter θ at each step of the optimizer using the IonQ Aria QPU for which the variational eigensolver also managed to converge to π.

This works because all of the states suffer from noise, so the state for θ = π still has the lowest energy of all possible ansatz options. Thus, we are able to find the ground state energy for the bubble plaquette with real quantum hardware.

Summary

In this post, we’ve demonstrated how Amazon Braket enables practical quantum simulations of fundamental physics systems. We successfully implemented a quantum chromodynamics model across quantum hardware and simulators, showcasing how Braket allows seamless transitions between different quantum platforms. Despite current hardware limitations, we achieved meaningful results and validated our approach through careful comparison of simulator and hardware implementations, using Braket’s ability to easily change the backend that executes a circuit and using Hybrid Jobs to support a hybrid quantum-classical algorithm, the Variational Quantum Eigensolver. With on-demand access to a variety of different quantum computers and classical circuit simulators available through Braket, we were able to run the experiments independently, self-paced and with no upfront commitment required.

While our demonstration focused on a simplified system with specific entanglement patterns between qubit pairs (0-1 and 2-3), it serves as a crucial proof-of-concept for more complex quantum simulations. The successful optimization of a single-parameter system on real quantum hardware establishes a solid foundation for tackling more sophisticated problems.

For researchers interested in extending this work, our companion paper in Physical Review Research explores more expressive ansatz implementations and energy spectra calculations for larger 2D systems. The paper delves deeper into advanced quantum algorithms for field theory simulations and presents strategies for scaling to more complex quantum systems.