---
title: Branch-Aware Quantum Constant Propagation
url: https://www.emergentmind.com/topics/branch-aware-quantum-constant-propagation-bqcp
type: topic
---

# Branch-Aware Quantum Constant Propagation

Branch-Aware Quantum Constant Propagation (BQCP) is a compile-time static analysis and optimization method for dynamic quantum circuits, i.e., circuits that mix quantum operations with real-time classical control. It extends Quantum Constant Propagation (QCP) by tracking the classical information produced by mid-circuit measurements together with the corresponding post-measurement quantum states across different execution branches. The defining objective is semantics-preserving simplification of dynamic circuits containing mid-circuit measurements, classical feedforward, resets, and if-then-else conditionals, while bounding both the size of the quantum-state representation and the number of tracked branches to keep the analysis scalable [2606.02018].

## 1. Origin, scope, and optimization target

BQCP was introduced in "Branch-Aware Quantum Constant Propagation for Dynamic Quantum Circuits" [2606.02018] as a response to a specific limitation of earlier quantum constant propagation methods: most prior methods target only unitary circuits and do not support dynamic circuits with mid-circuit measurements and classical feedforward. In dynamic circuits, optimization requires preserving the correlation between a measurement outcome and the corresponding post-measurement quantum state. BQCP addresses this by tracking a bounded set of abstract execution branches, each carrying both classical and quantum information, and then using that information for semantics-preserving simplification.

The problem setting is dynamic quantum circuits in which quantum and classical computation interleave during execution. Besides unitary gates, these circuits contain mid-circuit measurements, classical feedforward, conditional blocks typically of the form `if (φ) then Pt else Pf`, and often resets. These features are important in current NISQ and early fault-tolerant workflows, especially for quantum error correction, qubit reuse, and circuit cutting. They also introduce true dynamic control flow: after a measurement, different outcomes induce different reachable continuations [2606.02018].

The optimization goal is to reduce circuit size, gate count, and depth, especially expensive multi-qubit operations and dynamic overhead such as measurements and conditionals, while preserving the concrete classical–quantum semantics. This emphasis distinguishes BQCP from purely structural rewriting and from branch-insensitive state propagation. A common misconception is that BQCP is merely QCP plus classical bits; the paper explicitly frames the difference as a disjunctive, path-sensitive extension of QCP to dynamic control flow [2606.02018].

BQCP is closely related to the hybrid quantum-classical constant propagation framework of "Automatic De-Quantization of Quantum Programs Using Constant Propagation" [2605.22980]. That earlier work formalized hybrid quantum-classical constant propagation for dynamic circuits with measurement and classically guarded gates, but it remained essentially sequential and not branch-aware in the compiler-analysis sense. BQCP can therefore be situated as direct prior-work continuation: it preserves the same general objective of de-quantizing unnecessary quantum behavior, but introduces explicit branch sensitivity for if-then-else conditionals and branch-specific post-measurement reasoning [2605.22980].

## 2. Concrete semantics and program model

BQCP considers a dynamic circuit over a quantum register
\[
Q=\{q_0,\dots,q_{n-1}\},
\]
and a classical register
\[
C=\{c_0,\dots,c_{m-1}\}.
\]
Instructions include unitary gates \(U\), measurements \(M_{q_j \to c_i}\), resets \(R_{q_j}\), and conditionals of the form
\[
\mathbf{if}\ (\varphi)\ \mathbf{then}\ P_t\ \mathbf{else}\ P_f,
\]
where \(P_t\) and \(P_f\) are instruction sequences and \(\varphi\) is a guard over classical bits [2606.02018].

The concrete semantics is formulated over the Hilbert space
\[
\mathcal{H}_Q = (\mathbb{C}^2)^{\otimes n},
\]
with \(\mathcal{D}(\mathcal{H}_Q)\) denoting the set of density operators over \(\mathcal{H}_Q\). At a program point, the concrete state is not a single valuation but a finite set of classical–quantum branches:
\[
\mathfrak{S} \subseteq \{0,1\}^m \times \mathcal{D}(\mathcal{H}_Q).
\]
A branch \((c,\rho)\) means that the classical register has value \(c\) and the quantum register is in density state \(\rho\). Probabilities are intentionally ignored; only branch reachability matters for the static analysis [2606.02018].

The guard language is Boolean over classical bits:
\[
\varphi \;::=\; c_i \mid \neg\varphi \mid \varphi \land \varphi \mid \varphi \lor \varphi.
\]
This restriction is central to the method’s branch discipline. It supports structured conditionals driven by measurement outcomes, rather than arbitrary classical computation. This also clarifies the scope of BQCP: it is a dynamic-circuit analysis for guarded quantum programs, not a general-purpose control-flow analysis for unrestricted hybrid languages [2606.02018].

The paper denotes transfer along an instruction or program \(P\) by \(T\llbracket P \rrbracket\). For conditional blocks,
\[
P_t = (I^t_1,\dots,I^t_{L_t}),\qquad P_f = (I^f_1,\dots,I^f_{L_f}),
\]
the effect is given by composition of instruction transfer functions. This structured formulation gives BQCP the character of an abstract interpretation over an imperative intermediate representation for dynamic circuits [2606.02018].

## 3. Abstract state: disjunctive branches with bounded quantum tracking

The core abstraction in BQCP is branch-disjunctive. Each classical bit is abstracted by the flat lattice
\[
\mathcal{C} \triangleq \{0,1,\top\},
\]
where \(0\) means definitely 0, \(1\) means definitely 1, and \(\top\) means unknown. The order is
\[
0 \sqsubseteq_{\mathcal C} \top,\qquad 1 \sqsubseteq_{\mathcal C} \top,
\]
with \(0\) and \(1\) incomparable. For the full classical register,
\[
\mathcal{C}_C \triangleq \prod_{i=0}^{m-1}\mathcal{C}.
\]
An abstract classical state is written \(\gamma_C \in \mathcal{C}_C\), with bitwise update notation \(\gamma_C[c_i \mapsto v]\) [2606.02018].

The quantum abstraction is inherited from refined QCP and is organized around exact tracking of small entanglement groups. A partition \(\mathcal{G}\) of \(Q\) records entanglement groups, with two qubits in the same group iff they are entangled in the refined variant cited by the paper. For each group \(G\in\mathcal{G}\), the concrete pure state is represented sparsely as a partial map from basis strings to amplitudes, bounded by a threshold \(n_{\max}\) on support size. Formally,
\[
\mathcal{Q}(G) \triangleq \left\{ s:\{0,1\}^{|G|}\rightharpoonup \mathbb{C} \;\middle|\; |\operatorname{dom}(s)| \le n_{\max} \right\} \cup \{\top_Q\}.
\]
Then
\[
\mathcal{Q}(\mathcal{G}) \triangleq \prod_{G\in\mathcal G}\mathcal Q(G), \qquad
\mathcal Q_Q \triangleq \{\,(\mathcal G,\gamma_Q)\mid \gamma_Q\in\mathcal Q(\mathcal G)\,\}.
\]
If applying an operation would increase the number of nonzero amplitudes beyond \(n_{\max}\), the group becomes untracked [2606.02018].

A single abstract branch is a pair
\[
(\gamma_C,\eta_Q)\in \mathcal C_C \times \mathcal Q_Q.
\]
The full abstract state is a finite set of such branches:
\[
\mathcal{B} \triangleq \{(\gamma_C^1,\eta_Q^1),\dots,(\gamma_C^k,\eta_Q^k)\} \subseteq \mathcal C_C \times \mathcal Q_Q.
\]
This finite disjunction of branch-specific classical–quantum states is the defining innovation of BQCP. Unlike branch-insensitive analyses that collapse all post-measurement possibilities into one coarse abstraction, BQCP explicitly preserves multiple abstract continuations as long as the branch budget allows [2606.02018].

Two bounds control scalability. The quantum-state bound \(n_{\max}\) limits support size per entanglement group, and the branch bound \(b_{\max}\) limits how many branches are represented explicitly:
\[
|\mathcal B| \le b_{\max}.
\]
A plausible implication is that BQCP’s precision is jointly constrained by entanglement growth and control-flow branching; the paper makes this explicit by tying quantum imprecision to \(n_{\max}\) and branch imprecision to \(b_{\max}\) [2606.02018].

## 4. Transfer functions, guard evaluation, and branch management

Guard evaluation uses three-valued logic
\[
\mathbb{B}_3 \triangleq \{\mathsf t,\mathsf f,\mathsf u\},
\]
with abstract evaluation function
\[
\llbracket \varphi \rrbracket^\sharp : \mathcal C_C \to \mathbb B_3.
\]
For a classical bit \(c_i\),
\[
\llbracket c_i \rrbracket^\sharp(\gamma_C)=
\begin{cases}
\mathsf t,& \gamma_C(c_i)=1,\\
\mathsf f,& \gamma_C(c_i)=0,\\
\mathsf u,& \gamma_C(c_i)=\top.
\end{cases}
\]
Negation and Boolean connectives are interpreted compositionally over \(\mathbb B_3\), using Kleene-style three-valued logic. This is what makes conditionals branch-sensitive: each branch’s guard can be definitely true, definitely false, or unknown [2606.02018].

For a unitary instruction \(U\), the classical state is unchanged, and the quantum abstraction is updated branchwise using the QCP transformer \(\tau_U^\sharp\):
\[
T\llbracket U \rrbracket(\mathcal B) = \{\,(\gamma_C,\tau_U^\sharp(\eta_Q)) \mid (\gamma_C,\eta_Q)\in\mathcal B\,\}.
\]
Measurements are the crucial extension. If the measured qubit is a tracked singleton group \(\{q_j\}\) in an exact basis state \(\ket b\), the measurement is deterministic and only the classical bit is updated. Otherwise, the analysis may generate two successor branches, one for each outcome \(b\in\{0,1\}\), updating the classical state, setting the singleton measured qubit to \(\ket b\), and conditioning the residual state of the remaining qubits when that information is tracked [2606.02018].

When a non-deterministic measurement would exceed the global branch budget, BQCP applies a conservative fallback:
\[
\mathsf{FB}^{\sharp}(\gamma_C,(\mathcal{G},\gamma_Q)) \triangleq \{(\gamma_C[c_i\mapsto \top],\ (\mathcal{G},\gamma_Q[G\mapsto \top_Q]))\}.
\]
If there is no room to split, the measured classical bit becomes unknown and the entire group containing the measured qubit is forgotten. This is the main branch-bounding approximation [2606.02018].

Reset transfer preserves the classical state. If \(q_j\) is already a singleton group, its abstract state is overwritten with \(s_0\), representing \(\ket 0\). If it belongs to a larger entangled group, reset breaks entanglement, places \(q_j\) in its own singleton group set to \(s_0\), and conservatively discards information about the remainder by marking it untracked [2606.02018].

Conditionals are handled by partitioning incoming branches according to guard evaluation:
\[
\mathcal B_{\mathsf t} \triangleq \{\,(\gamma_C,\eta_Q)\in\mathcal B \mid \llbracket \varphi \rrbracket^\sharp(\gamma_C)\in\{\mathsf t,\mathsf u\}\,\},
\]
\[
\mathcal B_{\mathsf f} \triangleq \{\,(\gamma_C,\eta_Q)\in\mathcal B \mid \llbracket \varphi \rrbracket^\sharp(\gamma_C)\in\{\mathsf f,\mathsf u\}\,\}.
\]
Definitely true branches go only to the then-block, definitely false branches go only to the else-block, and unknown branches go to both. The two sides are propagated independently and then rejoined conservatively under a reduction operator \(\mathsf{RD}_{b_{\max}}\) that repeatedly merges branches until at most \(b_{\max}\) remain [2606.02018].

For branches
\[
A=(\gamma_C^A,\eta_Q^A),\qquad B=(\gamma_C^B,\eta_Q^B),
\]
their merge is
\[
A\sqcup B \triangleq (\gamma_C^{A\sqcup B},\eta_Q^{A\sqcup B}).
\]
The classical part uses bitwise join,
\[
\gamma_C^{A\sqcup B}(c_i) \triangleq \gamma_C^A(c_i)\sqcup_{\mathcal C}\gamma_C^B(c_i),
\qquad
v\sqcup_{\mathcal C} w =
\begin{cases}
v,& v=w,\\
\top,& \text{otherwise},
\end{cases}
\]
while the quantum part preserves only groups appearing identically in both partitions and keeps exact information only when the tracked state agrees; otherwise it degrades to \(\top_Q\) or to a residual untracked group. This deliberately conservative design retains only information common to both branches [2606.02018].

## 5. Semantics-preserving simplifications and formal soundness

BQCP computes abstract states at program points and uses them to simplify circuits. The paper presents all rewrites as semantics-preserving [2606.02018].

The first family is control reduction under branching. A control can be dropped only if it is redundant in every branch in the current abstract state \(\mathcal B\), and a controlled gate can be removed if its control condition is unsatisfiable in every branch. This branchwise universal condition is central: it preserves soundness under disjunctive abstract states while enabling branch-local reasoning inside conditionals [2606.02018].

The second family is elimination of redundant unitary gates. Let \(U\) act on qubits \(S\subseteq Q\). For each branch,
\[
(\gamma_C,(\mathcal G,\gamma_Q))\in\mathcal B,
\]
let
\[
(\mathcal G',\gamma_Q') \triangleq \tau_U^\sharp((\mathcal G,\gamma_Q)).
\]
A sufficient condition for \(U\) to be redundant under \(\mathcal B\) is:
\[
\forall\,G\in\mathcal G,\ G\cap S\neq\emptyset.\; G\in\mathcal G' \wedge \gamma_Q(G)\neq \top_Q \wedge \gamma_Q'(G)=\gamma_Q(G).
\]
If this holds in every branch, the operation is deleted [2606.02018].

The third and fourth families eliminate redundant resets and redundant measurements. Reset \(R_{q_j}\) is removed if, in every branch, \(q_j\) is a singleton group and its state is exactly \(s_0\), representing \(\ket 0\). Measurement \(M_{q_j\to c_i}\) is removed if, in every branch, \(q_j\) is a singleton group, \(q_j\) is exactly \(\ket b\) for some \(b\in\{0,1\}\), and \(\gamma_C(c_i)=b\). In those cases, the operation changes neither the quantum nor the classical state [2606.02018].

The fifth family simplifies conditionals themselves. Given abstract branch sets \(\mathcal B_{\mathsf t}\) and \(\mathcal B_{\mathsf f}\), if
\[
\mathcal B_{\mathsf f}=\emptyset,
\]
the conditional is replaced by \(P_t\); if
\[
\mathcal B_{\mathsf t}=\emptyset,
\]
it is replaced by \(P_f\). Even when both sides remain reachable, the then- and else-blocks are analyzed under restricted branch sets, enabling distinct simplifications on the two sides [2606.02018].

The formal soundness argument is built on an explicit representation relation. The concrete classical configurations compatible with \(\gamma_C\) are
\[
\Gamma_C(\gamma_C) \triangleq \{\, c\in\{0,1\}^m \mid \forall i.\ \gamma_C(c_i)\neq \top \Rightarrow c_i=\gamma_C(c_i) \,\}.
\]
For a quantum abstract state \(\eta_Q=(\mathcal G,\gamma_Q)\),
\[
\Gamma_Q(\eta_Q) \triangleq \{ \rho\in\mathcal D(\mathcal H_Q)\mid \forall G\in\mathcal G.\ \gamma_Q(G)=s \Rightarrow \mathfrak t_G(\rho)=\rho_s \},
\]
where
\[
\mathfrak t_G(\rho)\triangleq \operatorname{Tr}_{Q\setminus G}(\rho).
\]
A single abstract branch represents
\[
\Gamma_{CQ}(\gamma_C,\eta_Q) \triangleq \{\, (c,\rho)\mid c\in\Gamma_C(\gamma_C)\wedge \rho\in\Gamma_Q(\eta_Q)\,\},
\]
and an abstract state represents
\[
\Gamma(\mathcal B) \triangleq \bigcup_{(\gamma_C,\eta_Q)\in\mathcal B}\Gamma_{CQ}(\gamma_C,\eta_Q).
\]
The representation relation is
\[
\mathfrak S \models \mathcal B \quad\Longleftrightarrow\quad \mathfrak S\subseteq \Gamma(\mathcal B).
\]
On this basis, the paper proves soundness of abstract guard evaluation, soundness of branch merge, soundness of branch reduction, soundness of instruction transfer functions, and the main theorem:
\[
\mathfrak S_0 \models \mathcal B_0 \;\Rightarrow\; T\llbracket P\rrbracket(\mathfrak S_0)\models T\llbracket P\rrbracket(\mathcal B_0).
\]
It also gives a soundness criterion for rewrites:
\[
T\llbracket P\rrbracket(\mathfrak S)=T\llbracket P'\rrbracket(\mathfrak S)
\]
for every concrete \(\mathfrak S\) represented by the abstract state under which the rewrite is applied [2606.02018].

## 6. Empirical results, complexity, and relation to prior methods

The paper evaluates BQCP on an application-driven circuit-cutting case study and on synthetic random dynamic circuits [2606.02018].

In the circuit-cutting case study, Qdislib’s gate-cutting procedure generates dynamic subcircuits with measurements and conditionals from three input circuits: GHZ-4, QAOA-6, and BV-7. The compared methods are Qiskit HoareOptimizer, QCP with \(n_{\max}=512\), and BQCP with \(n_{\max}=512,\ b_{\max}=4\). Reported aggregated operation counts across all subcircuits are:

- **GHZ-4**: 1-qubit gates \(164 / 228 / 116\), 2-qubit gates \(12 / 12 / 0\), measurements \(48 / 48 / 16\), conditionals \(48 / 48 / 12\).
- **QAOA-6**: 1-qubit gates \(840 / 840 / 756\), 2-qubit gates \(360 / 360 / 192\), measurements \(48 / 48 / 48\), conditionals \(48 / 48 / 40\).
- **BV-7**: 1-qubit gates \(744 / 768 / 688\), 2-qubit gates \(180 / 180 / 160\), measurements \(48 / 48 / 44\), conditionals \(48 / 48 / 24\).

The format is HoareOptimizer / QCP / BQCP. The paper’s stated conclusion is that BQCP achieves the strongest reductions overall and is the only method among those compared that also removes measurements and conditionals [2606.02018].

For random dynamic circuits, the authors extend Qiskit’s random circuit generator to produce circuits with random subsets of qubits measured, conditional blocks with up to 10 operations in then and optionally 10 in else, and random resets. The size parameter is
\[
\mathit{dim}\in\{1,\dots,8\},
\]
with \(10\cdot \mathit{dim}\) qubits, depth \(50\cdot \mathit{dim}\) excluding measurements and conditional contents, and 10 independent circuits per \(\mathit{dim}\). They compare original circuits, QCP \((n_{\max}=512)\), and BQCP \((n_{\max}=512,\ b_{\max}=8)\), and report that BQCP consistently outperforms QCP in total operation reduction across all tested circuit sizes [2606.02018].

The paper also reports mean multi-qubit gate counts for QCP versus BQCP, shown with \(b_{\max}=4\):

- **\(dim=2\)**: 2-qubit \(336.7 / 321.0\), 3-qubit \(206.9 / 188.6\), 4-qubit \(91.9 / 79.5\).
- **\(dim=4\)**: 2-qubit \(1254.3 / 1192.9\), 3-qubit \(788.6 / 732.6\), 4-qubit \(345.7 / 311.8\).
- **\(dim=6\)**: 2-qubit \(2765.0 / 2662.3\), 3-qubit \(1706.9 / 1608.2\), 4-qubit \(794.1 / 733.4\).
- **\(dim=8\)**: 2-qubit \(4799.5 / 4619.7\), 3-qubit \(2956.5 / 2786.5\), 4-qubit \(1408.3 / 1293.2\).

Again, the format is QCP / BQCP. This suggests that BQCP’s path-sensitive reasoning remains useful even under bounded branch tracking, although the paper also notes that highly entangled random circuits often quickly reduce the usefulness of larger \(b_{\max}\), since the quantum information may become too imprecise to enable many more simplifications [2606.02018].

The stated complexity is
\[
O(b_{\max}\cdot g\cdot (n+m+\ell))
\]
time and
\[
O(b_{\max}\cdot (n\cdot n_{\max}+m))
\]
space, where \(g\) is the number of instructions, \(n\) the number of qubits, \(m\) the number of classical bits, and \(\ell\) the maximum guard size. If \(b_{\max}\) and \(n_{\max}\) are treated as constants, overall complexity is linear in program size:
\[
O(g\cdot (n+m+\ell))
\]
time and
\[
O(n+m)
\]
space. Runtime increases with circuit size and \(b_{\max}\); moderate \(b_{\max}\) values are reported to provide a good tradeoff [2606.02018].

Relative to prior work, BQCP extends rather than replaces earlier hybrid constant propagation. "Automatic De-Quantization of Quantum Programs Using Constant Propagation" [2605.22980] formalized a hybrid machine state
\[
\rho : \Phi \to [0,1]
\]
over hybrid states \((|\psi\rangle,\beta)\), supported classically guarded unitary application, measurement into registers, reset, and semantics-preserving rewrites such as removing impossible controls, removing always-true controls, replacing qubit controls with classical controls, exploiting implications among controls, and deleting diagonal gates that contribute only a global phase. Its method was flow-sensitive over a sequential instruction list, but not path-sensitive in the compiler-analysis sense: measurement outcomes coexisted in one distribution, there was no explicit branch-local abstract environment, and no predicate domain or symbolic guard tracking. BQCP’s principal advance is therefore not merely hybridization, but explicit representation of different execution branches and branch-restricted propagation through conditionals [2605.22980].

The limitations stated by the BQCP paper are correspondingly specific. It handles if-then-else constructs, but not richer dynamic control flow like loops or function calls; probabilities are ignored; branch selection and reduction use a fixed deterministic order rather than an optimization-aware heuristic; branch precision is bounded by \(b_{\max}\); and quantum precision is bounded by \(n_{\max}\) and degrades when entanglement causes support growth beyond the tracked threshold [2606.02018]. These limitations define the current boundary of the method rather than a contradiction of its goals: BQCP is a branch-disjunctive, path-sensitive constant propagation pass for structured dynamic circuits, not a general analysis for arbitrary hybrid quantum-classical programs.

Source: https://www.emergentmind.com/topics/branch-aware-quantum-constant-propagation-bqcp