QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
HomeLearnCatalogRanksPlaygroundDocs
01 · Measuring in the middle0%

You are reading without signing in. Sign in or continue as guest to take quizzes and climb the ranks.

Learn/QC 201Dynamic Circuits·Lesson 1 of 4

Measuring in the middle

What changes when a measurement is followed by more gates, and why statevector tools step aside.

Intermediate10 min read4 sections · 2 questions+45
By the end you will be able to
  1. 01Describe the state after a mid-circuit measurement as a branch, not a vector.
  2. 02Explain why QubitLab's State tab shows one statevector per branch.
  3. 03Reset and reuse a qubit.

Until now every measurement came last. Put one in the middle and the circuit splits: in the shots where the bit read 0 the remaining qubits are in one state, in the shots where it read 1 they are in another. There is no longer a single statevector for 'the circuit', only one per branch, weighted by how often that branch occurs.

Hands-on

One state per branch

Open the State tab. Two branch chips appear (c = 0 and c = 1, about 50% each); pick one to see the statevector of the untouched qubit for that branch.

OpenQASM 3
OPENQASM 3.0;
include "stdgates.inc";
qubit[2] q;
bit[2] c;
h q[0];
c[0] = measure q[0];
h q[1];
x q[0];
Sign in to run (nothing is saved)
Open in the IDE Open in the Playground

A measured qubit is not spent. `reset q[0];` returns it to |0⟩ whatever was read, so a short-lived helper qubit (an ancilla) can be used again and again. Many error-correction codes measure and reset the same ancillas thousands of times.

Knowledge check

2 questions · one try each counts

Question 1

After a mid-circuit measurement, the best description of the register is…

Sign in to answer and climb the ranks; you will come back to this lesson.

Question 2

Why can't the gate-by-gate debugger trace a dynamic circuit?

Sign in to answer and climb the ranks; you will come back to this lesson.

Key takeaway

A mid-circuit measurement splits the run into branches. Reason per branch, simulate with shots, and reuse qubits with reset.

Finished reading?

Knowledge check: 2 questions waiting above. Questions are optional. Mark it complete, or press Next: moving on marks it complete too.

Up next
Lesson 2 · 12 min
if / else on a measured bit
Feed-forward: apply a correction only when a bit says so. Build it from the palette and write it in both languages.
Further reading
  • Docs: dynamic circuits
More in Dynamic Circuits
  • Loops and switch
  • Teleportation with feed-forward
Two languages: OpenQASM 3 and Qiskitif / else on a measured bit
In this lesson0%
  1. Introduction
  2. Try it: One state per branch
  3. Knowledge check
  4. Key takeaway
QubitLab
IDELearnPlaygroundDocsCommunity
Log in
QubitLab
IDELearnPlaygroundDocsCommunity
Log in