Introduction to Mid-Circuit Measurements in PennyLane
Overview
Introduction to Mid-Circuit Measurements in PennyLane
This PennyLane tutorial introduces mid-circuit measurements (MCMs), the capability to measure qubits partway through a circuit and use the outcomes to influence the rest of the computation, a feature central to dynamic circuits, quantum error correction, and many modern protocols. In a conventional circuit all measurements happen at the end, but MCMs let a circuit branch on intermediate results: measuring a qubit, optionally resetting it, and conditioning later operations on what was observed (feedforward). The tutorial shows PennyLane's syntax for mid-circuit measurements, how to apply gates conditioned on a measurement result, how to reuse measured qubits, and the different ways to collect statistics over MCM outcomes (such as sampling, expectation values, and counts) across the various supported measurement-handling methods. It explains how PennyLane simulates these stochastic, branch-dependent circuits and the subtleties of post-selection versus deferred measurement. By establishing the MCM primitives clearly, the tutorial gives the foundation for dynamic circuits, teleportation, and error-correction demos. It is a practical, beginner-friendly entry point to measurement-driven quantum programming in PennyLane.
Run it
pip install -r requirements.txt
python demo.py
Source and license
Imported from demonstrations_v2/tutorial_mcm_introduction/demo.py in PennyLaneAI/demos at c52c0abeb5122218aa96b38eea848864cce7323f, under the Apache License 2.0. Original authors: Xanadu and the PennyLane community. The upstream LICENSE is included alongside this example.
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
Cite all versions? Use the base QCR ID to always reference the latest version of this entry.
Join the Discussion
Comments (0)
No comments yet. Be the first to share your thoughts!