  The use of mid-circuit measurement and qubit reset within quantum programs
has been introduced recently and several applications demonstrated that perform
conditional branching based on these measurements. In this work, we go a step
further and describe a next-generation implementation of classical computation
embedded within quantum programs that enables the real-time calculation and
adjustment of program variables based on the mid-circuit state of measured
qubits. A full-featured Quantum Intermediate Representation (QIR) model is used
to describe the quantum circuit including its embedded classical computation.
This integrated approach eliminates the need to evaluate and store a
potentially prohibitive volume of classical data within the quantum program in
order to explore multiple solution paths. It enables a new type of quantum
algorithm that requires fewer round-trips between an external classical driver
program and the execution of the quantum program, significantly reducing
computational latency, as much of the classical computation can be performed
during the coherence time of quantum program execution. We review practical
challenges to implementing this approach along with developments underway to
address these challenges. An implementation of this novel and powerful quantum
programming pattern, a random walk phase estimation algorithm, is demonstrated
on a physical quantum computer with an analysis of its benefits and feasibility
as compared to existing quantum computing methods.
