AWS Builder Center
Entanglement on Amazon Braket: The CNOT Gate and Your First Bell State

Entanglement on Amazon Braket: The CNOT Gate and Your First Bell State

A hands-on guide to quantum entanglement on Amazon Braket. Build a Bell state with the CNOT gate, run it in 2 lines, and measure the correlation.

Series: Quantum Computing on AWS (8 articles)

  1. …
  2. 6
    Entanglement on Amazon Braket: The CNOT Gate and Your First Bell State This article
Founder & CEO of Altivum® Inc., Army Veteran, and 11x AWS Certified
In the previous article, we put a single qubit into superposition (Fault Tolerance: Quantum's Hardest Problem Has an End-Date ).
A single qubit in superposition is a good start, but by itself it behaves a lot like a very expensive spinning coin. The real power of quantum computing shows up when qubits start to interact. When 2 qubits become linked so that measuring one tells you something about the other. This is called "entanglement" and this is the property that enables a quantum computer to perform.
To create a state of entanglement between two qubits, we need a new tool: the controlled-NOT gate, usually written as CNOT. By the end of this article you will understand what entanglement is, what it is not, and you will have written and run a real entangling circuit on Amazon Braket.
As with the last article, some of the vocabulary here can feel foreign at first. I have linked references from the Quantum Learner glossary  throughout so you can go deeper on any concept that catches your attention.

A quick recap of the last article:
  • A qubit is the quantum version of a classical bit, and unlike a bit it can exist in a superposition of 0 and 1 at the same time.
  • The Bloch sphere is a globe that represents every possible state of a single qubit, with 0 at the North Pole and 1 at the South Pole.
  • Because a qubit in superposition is probabilistic, you run a circuit many times to see the statistics. Each run is called a shot.
Superposition gives you multiple possibilities out of one qubit. That alone does not beat a classical computer. The leap happens when you let qubits influence each other, and that requires a gate that acts on more than one qubit at a time.

What Entanglement Is

Entanglement is a shared state between qubits. When 2 or more qubits are entangled, they are described by a single combined state. The pair stops being "qubit A doing its thing and qubit B doing its thing". Instead, it becomes a single object with correlated outcomes. The implication here is that if you measure one qubit in an entangled pair, you immediately learn something about the other, no matter how the 2 are arranged. Their results are locked together.
A simple mental image is tends to be very helpful. Imagine 2 coins that are prepared together in a special way where what one coin lands on immediately tells you what the second coin lands on. Each individual flip of a single coin lands randomly, so you cannot predict any single result but seeing what one coin lands on (measuring) tells you exactly what the second coin landed on without having to look at it. Across many flips, the 2 coins always agree with each other. That agreement comes from how the pair was prepared as a single system. The two coins are entangled.
To describe 2 qubits, we list the 4 possible combined outcomes:
|00⟩
|01⟩
|10⟩
|11⟩
Note: this type of notation is know as Dirac notation. When you see "|x⟩" it is pronounced "ket 'x'". When you see "⟨x|", it is pronounced "bra 'x'". Not only do you now know how to speak in Dirac notation but you also know why Amazon named their quantum computing service "Braket".
A separable pair can be written as 2 independent qubits multiplied together. An entangled pair lives in a blend of those 4 states that refuses to factor into independent parts. Holding that idea in mind is enough to follow everything below.

What Entanglement Is Not

Entanglement attracts more myths than almost any topic in physics. Three of them are worth clearing up before we touch code.
1. Entanglement does not send messages faster than light
This is a very common misconception. When you measure a qubit, you get a random result that you cannot control. A colleague measuring the other qubit also gets a random result they cannot control. Neither of you can force a particular outcome.
The correlation only becomes visible when you bring the 2 sets of results together and compare them. Comparing requires a normal classical channel, such as a phone call, an email, or a packet sent over the internet, and that channel is limited by the speed of light. This is called the "no-communication theorem". Entanglement produces shared correlations, and it gives neither party a way to transmit a chosen message.
2. Entanglement is more than a "pair of gloves in 2 boxes"
A common way to downplay entanglement is the glove analogy. Put a left glove in one box and a right glove in another, ship them to different cities, and open one box. You instantly know what is in the other. That is ordinary correlation, and there is no quantum mystery in it at all. If entanglement were only this, it would not be worth a series of articles.
The difference appears in experiments built around Bell's theorem and the CHSH inequality. Quantum correlations violate a limit that every glove-style explanation must obey. In plain language, the measurement outcomes cannot be accounted for by each qubit secretly carrying a pre-set answer chosen at preparation time. The correlations are stronger than any pre-agreed classical strategy could ever produce. You do not need to prove this to build with it, but it is the reason entanglement counts as a genuine computational resource that will soon bring forth quantum advantages.
3. Measuring one qubit does not push the other where you want
Measurement reveals the shared state. It does not hand you a lever to force the far qubit into a value of your choosing. The randomness sits at the foundation of the physics, which is exactly why the faster-than-light shortcut in the first myth does not work.

The CNOT Gate

The controlled-NOT gate is a 2-qubit gate with a control qubit and a target qubit. Its rule is short:
  • If the control qubit is 1, flip the target qubit.
  • If the control qubit is 0, leave the target qubit alone.
Like every quantum gate, CNOT is reversible. Its matrix is a 4x4 unitary, and applying it twice brings you back to where you started. The diagram below shows the standard notation.
The solid dot marks the control qubit. The circle with the cross marks the target. The target flips only when the control is 1.
The full behavior fits in a truth table:
Control (in)Target (in)Control (out)Target (out)
0000
0101
1011
1110
Look closely at the bottom 2 rows. When the control is 1, the target value changes. When the control is 0, nothing happens to the target.
Now, if you run CNOT on plain 0s and 1s, all it does is copy or flip bits. Feed it definite classical inputs and you get definite classical outputs, with no entanglement anywhere. The interesting behavior only appears when the control qubit is itself in superposition. That is why the Hadamard gate from the last article is so incredibly important.

From CNOT to Entanglement: The Bell State

Entanglement comes from combining the 2 gates you now know:
  1. Apply a Hadamard gate to qubit 0 to put the control into superposition.
  2. Apply a CNOT gate with qubit 0 as the control and qubit 1 as the target.
Follow the state as it moves through the circuit:
  • Start with both qubits at 0. The system is |00⟩.
  • Apply H to qubit 0. Qubit 0 spreads into a superposition, so the pair becomes an equal mix of |00⟩ and |10⟩, written as (|00⟩ + |10⟩) / √2.
  • Apply CNOT. It flips qubit 1 wherever qubit 0 is 1. The |00⟩ term is left alone, and the |10⟩ term turns into |11⟩. The result is (|00⟩ + |11⟩) / √2.
That final state is a Bell state, the simplest and most famous entangled state in all of quantum computing.
A Hadamard on qubit 0 creates superposition, and the CNOT ties qubit 1 to it. The 2 measurement boxes on the right read out the result.

Writing the Circuit on Amazon Braket

The workload is 2 method calls in the Braket SDK. Gates are first-class objects, and you chain them onto a circuit.
1
2
3
4
5
6
from braket.circuits import Circuit

# Put qubit 0 in superposition, then entangle qubit 1 with a CNOT
circuit = Circuit().h(0).cnot(0, 1)

print(circuit)
The .h(0) call applies a Hadamard gate to qubit 0. The .cnot(0, 1) call applies a CNOT with qubit 0 as the control and qubit 1 as the target. Chaining them defines the whole Bell state circuit in a single line.
Because the outcome is probabilistic, you run many shots to see the pattern. Here is the circuit on the free Amazon Braket local simulator, which runs entirely on your own machine.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
from braket.devices import LocalSimulator
from braket.circuits import Circuit

# 1. Define the local simulator
device = LocalSimulator()

# 2. Build the Bell state circuit
circuit = Circuit().h(0).cnot(0, 1)

# 3. Run 1000 shots
task = device.run(circuit, shots=1000)

# 4. Fetch and print the measurement counts
result = task.result()
print(result.measurement_counts)
When you print the measurement counts, you see something close to {'00': 502, '11': 498}. 2 outcomes, each near 50%. Now look at what is missing. The results 01 and 10 never appear.

Why the Missing Outcomes are the Whole Point

The empty bars carry the meaning of the entire experiment. In a Bell state the 2 qubits always agree, so the outcomes 01 and 10 have zero probability. The data you get back is the correlation itself.
To see how special that is, compare it against a pair of qubits that are not entangled. Send each qubit through its own Hadamard gate:
1
2
# Two independent superpositions, no entanglement
circuit = Circuit().h(0).h(1)
Run 1,000 shots of that circuit and all 4 outcomes show up, each near 250:
1
{'00': 249, '01': 253, '10': 248, '11': 250}
Every combination appears because the qubits pay no attention to each other. Put the 2 circuits side by side and the contrast is clear:
  • The entangled circuit narrows 4 possible outcomes down to 2 that always match.
  • The independent circuit spreads evenly across all 4 outcomes.
That narrowing to correlated outcomes is measurable entanglement. You can watch it happen in the count with no advanced hardware and no cost.

From the Simulator to a Real QPU

The path to real quantum hardware is the same swap you learned last time. Replace LocalSimulator() with an AwsDevice pointed at a specific QPU, and the exact same circuit runs on physical qubits.
1
2
3
4
5
6
7
8
9
10
11
12
from braket.aws import AwsDevice
from braket.circuits import Circuit

# Gate-based trapped-ion QPU from IonQ. Check the Braket console
# Devices page for the current list of available hardware.
device = AwsDevice("arn:aws:braket:us-east-1::device/qpu/ionq/Forte-Enterprise-1")

circuit = Circuit().h(0).cnot(0, 1)
task = device.run(circuit, shots=1000)

result = task.result()
print(result.measurement_counts)
Results from real devices are stored in your S3 bucket and returned through the same task.result() call. Amazon Braket gives you gate-based QPUs from providers such as IonQ, Rigetti, and IQM, and the available devices change over time, so the console is the source of truth for what is live today.
One honest caveat about physical hardware. On a real QPU you will see a small number of 01 and 10 results that the simulator never produces. Those stray counts are what we refer to as noise, the fingerprint of every quantum computer built so far. Today's devices are not perfect, and learning to read that error is a skill of its own. It is a subject I will return to later in this series.

Why this matters for builders

Entanglement is the resource behind essentially every quantum algorithm that outruns a classical one.
  • Quantum teleportation and superdense coding are built directly on entangled pairs.
  • Quantum error correction, the thing that will eventually make large QPUs reliable, depends on entangling many qubits together.
  • The famous speedups from Grover's search and Shor's factoring come from entangling a register of qubits and then using interference to concentrate probability on the right answer.
Strip entanglement out and a quantum computer is just an expensive random number generator. Enable entanglement and the machine can represent and process correlations that a classical CPU cannot reach. For an AWS builder, going from a Hadamard gate to a Hadamard plus a CNOT is the moment Amazon Braket starts being hardware that does something fundamentally new.

Key Takeaways

  • Entanglement is a shared state. 2 or more qubits are described by one combined state that cannot be split into independent parts. Measure one and you learn about the others.
  • The CNOT gate is the entangler. It flips a target qubit only when the control qubit is 1. On plain classical inputs it merely copies or flips, but paired with a control in superposition it creates entanglement.
  • H then CNOT builds a Bell state. The 2-line recipe produces (|00⟩ + |11⟩) / √2, the simplest entangled state and the backbone of countless algorithms.
  • The proof is in the missing outcomes. Run 1,000 shots of a Bell state and you get only 00 and 11. The absence of 01 and 10 is entanglement you can measure.
  • Entanglement is not faster-than-light communication. You cannot send a chosen message with it. The correlation only appears once results are compared over a normal classical channel.
  • The same code reaches real hardware. Swap the local simulator for an AwsDevice ARN and your Bell state runs on a physical QPU, noise and all.

What comes next

You can now put qubits into superposition and lock them together with entanglement. The next question is how to steer results on purpose. That is the job of interference, where quantum states add and cancel to push probability toward the answer you want.
In the next article we will use interference to build a circuit that actually computes something, and we will start looking at how noise on real hardware shapes what you get back.

For runnable notebooks on Bell states and much more, sign up for Quantum Learner  and start building on Amazon Braket.

Series: Quantum Computing on AWS (8 articles)

  1. …
  2. 6
    Entanglement on Amazon Braket: The CNOT Gate and Your First Bell State This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article