Level Up Coding

Coding tutorials and news. The developer homepage gitconnected.com && skilled.dev && levelup.dev

Follow publication

https://pixabay.com/photos/recycling-bins-recycle-environment-373156/

Member-only story

Dynamic Quantum Circuits, Lesson 7

Brian N. Siegelwax
Level Up Coding
Published in
2 min readDec 26, 2022

--

Reusable Classical Registers

Dynamic quantum circuits were announced at IBM Quantum Summit 2022 and presented in some detail at the IBM Quantum Practitioners Forum the next day. In a nutshell, whereas you design static quantum circuits in their entirety before you queue them up to run, you use classical logic to generate dynamic circuits after they queue and during their actual runtime.

A major part of dynamic circuits is taking mid-circuit measurements, and then applying conditional logic to those measurement results. If we care what those mid-circuit measurements are, we need to assign each set of measurements to its own classical register. We can then retrieve one very long bitstring at the end, and then parse it to determine what each measurement was.

But, what if we don’t care about the mid-circuit measurements? Besides measuring, resetting, and reusing qubits, it turns out we can reuse our classical bits, as well.

qr = QuantumRegister(1)
cr = ClassicalRegister(1, name="cr")
qc = QuantumCircuit(qr, cr)
qc.x(0)
qc.measure(0, cr)
with qc_reset.if_test((cr, 1)):
qc.x(0)
qc.measure(0, cr)

Above is a very simple test, but it works on real hardware. Line 2 initializes only one classical bit. Line 5 measures qubit 0 to that bit. And then line 8 measures qubit 0…

--

--

No responses yet