cvIP/integerCons.py contains the code to implement the encoding of constraints with a driver Hamiltonian. cvIP/qaoa.py is the demo of integer programming using the above driver Hamiltonian.
The magic of Choco-Q lies not in filtering but in subspace confinement. The algorithm constructs a driver Hamiltonian ( H_d ) that cannot escape the subspace of valid solutions.
To extend this to qumodes, we must translate three key components:
- Variables (binary → integer)
- Constraint operator ( \hat{C} )
- Commuting driver Hamiltonian ( H_d )
This is the most straightforward translation.
In the qumode framework (e.g., Khosravi et al.), non-negative integer variables ( n_i ) are represented by the eigenstates of the photon number operator
For a set of linear equality constraints:
the corresponding quantum constraint operator is:
A quantum state ( |\psi\rangle ) satisfies the constraint if
Thus, the constraint subspace is spanned by all Fock basis states ( |n_1, n_2, \dots, n_k\rangle ) satisfying the classical equation.
This is the heart of the challenge.
We need a driver ( H_d ) that:
A naive choice $ H_d = f(\hat{n}_1, \hat{n}_2, \dots) $ would commute with both $ \hat{C} $ and $ H_o $, violating the second condition. Therefore, $ H_d $ must involve creation
Consider the constraint:
so that
We seek a driver that preserves total photon number. The beam-splitter Hamiltonian does precisely this:
It’s well known that:
Hence, $ H_d = H_{\text{BS}} $ acts as a valid driver: it coherently mixes valid configurations like $ |K, 0\rangle $, $ |K-1, 1\rangle $, etc., while staying within the constraint subspace.
For a general constraint:
we can generalize the null-space approach from Choco-Q:
-
Find the Null Space Compute integer vectors $ {u^{(1)}, u^{(2)}, \dots} $ satisfying $$ C \cdot u = 0 \quad \Rightarrow \quad \sum_i c_i u_i = 0 $$
-
Translate Vectors to Operators Each null-space vector $ u $ corresponds to an operator that shifts photon numbers by the amounts $ u_i $:
$$ \hat{O}u = \left(\prod{j | u_j > 0} (\hat{a}j^\dagger)^{u_j}\right) \left(\prod{k | u_k < 0} (\hat{a}_k)^{|u_k|}\right) $$
The corresponding driver term is:
$$ H_u = g (\hat{O}_u + \hat{O}_u^\dagger) $$
Since $ \sum_i c_i u_i = 0 $, we have:
$$ [H_u, \hat{C}] = 0 $$
-
Combine All Drivers
The full driver is the sum over all basis vectors of the constraint null space:
$$ H_d = \sum_j H_{u^{(j)}} $$
This construction is the qumode analogue of the Choco-Q driver.
The condition holds naturally:
-
The objective Hamiltonian is typically:
$$ H_o = \sum_j d_j \hat{n}j + \sum{ij} Q_{ij} \hat{n}_i \hat{n}_j $$
-
The driver Hamiltonian uses ( \hat{a} ) and ( \hat{a}^\dagger ):
$$ [\hat{n}, \hat{a}] = -\hat{a}, \quad [\hat{n}, \hat{a}^\dagger] = \hat{a}^\dagger $$
Thus:
$$ [H_d, H_o] \neq 0 $$ todo: How to compile the Unitary into native gates.
todo: How to prepare a supperposition state ?
cvDriverHamiltonian.py is the implementation of encoding real constraints with the driver Hamiltonian, which uses the position to represent the real number variable.
continuous variables using $\hat{x}i$ for variable $x_i$, define the constraint operator as $\hat{C} = \sum{i=1}^n c_i \hat{x}_i$. The goal is subspace confinement where
Analogous to Choco-Q's null-space method (and its qumode-integer extension in the provided discussion), construct
-
Identify the Null Space: For constraint matrix
$\mathbf{C}$ (here a row vector $(c_1, \dots, c_n)$), find an orthonormal basis${ \vec{u}^j }_{j=1}^{n-1}$ for the null space, where$\mathbf{C} \cdot \vec{u}^j = 0$ (i.e.,$\sum_i c_i u_i^j = 0$ ). -
Construct Driver Terms: The driver must generate displacements along null directions without altering
$\hat{C}$ . In CVQC, translations in position space are generated by momentum operators$\hat{p}_i = \frac{1}{i\sqrt{2}} (\hat{a}_i - \hat{a}_i^\dagger)$ , with $[\hat{x}_i, \hat{p}k] = i \delta{ik}$.For each basis vector
$\vec{u}^j$ , define $$H_{u^j} = g \sum_{k=1}^n u_k^j \hat{p}k$$, where $g$ is a coupling strength. Verify commutation: $$ [H{u^j}, \hat{C}] = \sum_{i,k} c_i u_k^j [\hat{p}_k, \hat{x}i] = -i \sum_k c_k u_k^j = -i (\mathbf{C} \cdot \vec{u}^j) = 0. $$ The full driver is $H_d = \sum_j H{u^j}$. -
QAOA Formulation: The QAOA ansatz alternates
$e^{-i\beta H_d}$ and$e^{-i\gamma H_o}$ , where$H_o$ is the objective encoded as a polynomial in ${\hat{x}i}$ (e.g., $H_o = \sum_i d_i \hat{x}i + \sum{ij} Q{ij} \hat{x}_i \hat{x}_j$). Non-commutation$[H_d, H_o] \neq 0$ holds since$H_o$ involves$\hat{x}_i$ and$H_d$ involves$\hat{p}_k$ , with$[\hat{x}_i, \hat{p}_k] \neq 0$ for$i=k$ . -
Initial State Preparation: Start with a Gaussian state (e.g., squeezed vacuum) where
$\langle \hat{C} \rangle = c$ and variance$\text{Var}(\hat{C})$ is minimized. Evolution preserves$\langle \hat{C} \rangle = c$ , but$\text{Var}(\hat{C})$ persists, yielding approximate hard constraints. For tighter enforcement, prepare highly squeezed states along the$\hat{C}$ direction.
In the context of bosonic or continuous-variable quantum computing for mixed-integer programming (MIP), constraints can indeed mix integer variables (encoded via photon-number operators
Consider a single linear equality constraint mixing
where
The quantum constraint operator is
The feasible subspace
The objective
with cross terms like
The null-space method extends naturally to the hybrid (discrete-continuous) setting. The classical constraint defines a codimension-1 affine hyperplane in the $( \mathbf{n}, \mathbf{x} ) \in \mathbb{Z}{\geq 0}^m \times \mathbb{R}^\ell$ space. To mix states within $\mathcal{S}c$, we identify null directions $\mathbf{u}^{(j)} = (\mathbf{u}{\text{int}}^{(j)}, \mathbf{u}{\text{real}}^{(j)}) \in \mathbb{Z}^m \times \mathbb{R}^\ell$ (for
where $\mathbf{u}{\text{int}}^{(j)}$ has integer components (to preserve discreteness of $n_k$) and $\mathbf{u}{\text{real}}^{(j)}$ has real components. These form a generating set for the null space (not necessarily orthonormal, as the space is hybrid). For example, choose a basis where each $\mathbf{u}{\text{int}}^{(j)}$ is a standard basis vector in a reduced integer space, compensated by $\mathbf{u}{\text{real}}^{(j)} = - (\mathbf{d}^\top)^{-1} \mathbf{c} \cdot e_j$ (assuming
For each null direction
-
Integer shift (discrete, via creation/annihilation): For positive
$u_{k}^{(j)} > 0$ , apply $(\hat{a}k^\dagger)^{u_k^{(j)}}$; for negative $u{k}^{(j)} < 0$, apply$(\hat{a}_k)^{|u_k^{(j)}|}$ . Thus,$$ \hat{O}{\text{int}}^{(j)} = \prod{k: u_k^{(j)} > 0} \left( \hat{a}k^\dagger \right)^{u_k^{(j)}} \prod{k: u_k^{(j)} < 0} \left( \hat{a}_k \right)^{|u_k^{(j)}|}. $$
-
Real shift (continuous, via momentum
$\hat{p}_r = i \sqrt{\frac{\hbar}{2}} (\hat{a}_r^\dagger - \hat{a}_r)$ , with $[\hat{x}_r, \hat{p}s] = i \hbar \delta{rs}$): The displacement by$\delta_r = u_r^{(j)}$ is generated by$\exp\left( -i \frac{\delta_r}{\hbar} \hat{p}_r \right)$ , so$$ \hat{O}_{\text{real}}^{(j)} = \exp\left( -i \sum_r \frac{u_r^{(j)}}{\hbar} \hat{p}_r \right). $$
The full shift operator is the tensor product (since modes are distinct):
The Hermitian driver term is
where
Consider a state $|\psi\rangle \in \mathcal{S}c$ with $\hat{C} |\psi\rangle = c |\psi\rangle$. Applying $\hat{O}{u^{(j)}}$ shifts the expectation values:
by null-space construction. Since $\hat{n}k$ and $\hat{x}r$ act on distinct modes (commuting across types), and shifts are exact within each subspace, $\hat{O}{u^{(j)}} |\psi\rangle \in \mathcal{S}c$. Similarly for $\hat{O}{u^{(j)}}^\dagger$. Thus, $H{u^{(j)}} |\psi\rangle \in \mathcal{S}_c$, implying
For the full space, the commutator vanishes on
The objective
Cross-mode terms commute, but intra-mode non-commutation ensures
Constraint:
Applying to
- Basis Selection: Compute null directions numerically (e.g., via SVD on the augmented constraint matrix). For multiple constraints, sum drivers over independent null spaces.
-
Compilation to Native Gates: Trotterize
$e^{-i \beta H_d}$ into beam-splitter-like gates for integers (from$\hat{a}^\dagger \hat{a}'$ ) and displacement/squeezing for reals. Cross terms require controlled displacements. -
Initial State: Use a product state with
$\langle \hat{n}_k \rangle$ near feasible integers and a squeezed Gaussian for reals minimizing$\text{Var}(\hat{C})$ . - Scalability: Discrete shifts limit integer range; approximate large shifts via QAOA layers. For reals, finite squeezing bounds precision.
-
Relation to Separate Constraints: As noted, if constraints decouple (C1 integer-only, C2 real-only),
$H_d = H_{d1} + H_{d2}$ works since$[H_{d1}, \hat{C}_2] = 0$ . Mixed constraints couple modes, but the construction above handles this.
Detailed Mathematics for Applying Generalized Quantum Subspace Expansion (GSE) to Bosonic QAOA for Constrained Integer Optimization
As a researcher specializing in quantum optimization algorithms, I appreciate your observation that GSE, as introduced by Yoshioka et al. (arXiv:2107.02611v3), proves effective for error mitigation in variational quantum solvers. GSE extends the quantum subspace expansion (QSE) framework by incorporating general (non-Hermitian) operators into the subspace ansatz, enabling agnostic suppression of stochastic, coherent, and algorithmic errors without noise characterization. Below, I derive its application to the BosonicQAOAIPSolver—a qumode-based QAOA for maximizing (\mathbf{c}^\top \mathbf{x}) subject to linear equality constraints (A \mathbf{x} = \mathbf{b}) with (\mathbf{x} \geq \mathbf{0}) integer—focusing on subspace confinement and objective evaluation. The derivation emphasizes the power subspace for practicality, as it yields exponential error suppression while remaining computationally tractable for truncated Fock spaces.
The problem is encoded in a multi-mode bosonic Hilbert space (\mathcal{H} = \bigotimes_{i=1}^d \mathcal{H}_{N_i}) (truncation (N_i = N)), where integer variables (x_i \mapsto n_i) via photon-number operators (\hat{n}_i = \hat{a}_i^\dagger \hat{a}_i). The feasible subspace is [ \mathcal{S}c = \operatorname{span} { |\mathbf{n}\rangle \mid \mathbf{n} \in \mathbb{Z}{\geq 0}^d, , A \mathbf{n} = \mathbf{b} }, ] with Fock basis states (|\mathbf{n}\rangle = \bigotimes_i |n_i\rangle).
The QAOA ansatz prepares a variational state (|\psi(\boldsymbol{\theta})\rangle = \prod_{k=1}^p U_M(\beta_k) U_C(\gamma_k) |\psi_0\rangle), where:
- Cost layer: (U_C(\gamma_k) = e^{-i \gamma_k H_C}), (H_C = -\sum_{i=1}^d c_i \hat{n}_i) (ground state in (\mathcal{S}_c) minimizes (\langle H_C \rangle)).
- Mixer layer: (U_M(\beta_k) = e^{-i \beta_k H_M}), (H_M = \sum_{u \in \mathcal{N}(A)} g (\hat{O}u + \hat{O}u^\dagger)), with nullspace basis (\mathcal{N}(A) = {\mathbf{u}^{(j)} \mid A \mathbf{u}^{(j)} = \mathbf{0}, , \mathbf{u}^{(j)} \in \mathbb{Z}^d }) and shift operators (\hat{O}{\mathbf{u}} = \prod{u_i > 0} (\hat{a}i^\dagger)^{u_i} \prod{u_i < 0} (\hat{a}_i)^{|u_i|}). Since ([H_M, \hat{C}_j] = 0) for all constraint operators (\hat{C}j = \sum_i A{j i} \hat{n}_i - b_j), ideal evolution preserves (\mathcal{S}_c).
The objective is (\max_{\boldsymbol{\theta}} \langle \psi(\boldsymbol{\theta}) | H_C | \psi(\boldsymbol{\theta}) \rangle = -\min_{\boldsymbol{\theta}} \langle H_C \rangle), with constraint fidelity monitored via violation [ \hat{V} = \sum_{j=1}^m \hat{C}_j^2, \quad \langle \hat{V} \rangle = 0 \iff |\psi\rangle \in \mathcal{S}_c. ] Noise (e.g., Lindblad dissipators (\mathcal{L}[\rho] = \sum_k (\hat{L}_k \rho \hat{L}_k^\dagger - \frac{1}{2} {\hat{L}_k^\dagger \hat{L}_k, \rho})), (\hat{L}_k \in {\sqrt{\kappa} \hat{a}_i, \sqrt{\gamma} \hat{a}_i^\dagger, \dots })) yields a noisy density (\rho = \int |\psi(\boldsymbol{\theta})\rangle \langle \psi(\boldsymbol{\theta}) | , d\mu(\epsilon)) (over error realizations (\epsilon)), leaking probability mass out of (\mathcal{S}_c) and biasing (\langle H_C \rangle).
GSE reconstructs an error-mitigated state (\rho_{\rm EM}) from the noisy (\rho) via projection onto an extended subspace: [ \rho_{\rm EM} = \frac{P^\dagger A P}{\operatorname{Tr}[P^\dagger A P]}, ] where (P = \sum_{i=0}^{d_s-1} \alpha_i \sigma_i) ((\boldsymbol{\alpha} \in \mathbb{C}^{d_s}), (d_s) subspace dimension) spans bases ({\sigma_i}) (non-Hermitian operators related to (\rho)), and (A \succeq 0) is Hermitian (e.g., (A = I) or (A = \rho)). This ensures (\rho_{\rm EM} \succeq 0), (\operatorname{Tr}[\rho_{\rm EM}] = 1).
For bosonic QAOA, we mitigate observables (O \in {H_C, \hat{V}}) post-preparation: [ \langle O \rangle_{\rm EM} = \sum_{i,j=0}^{d_s-1} \alpha_i^* \alpha_j \operatorname{Tr}[\sigma_i^\dagger A \sigma_j O]. ] The coefficients (\boldsymbol{\alpha}) solve the generalized eigenvalue problem for the effective Hamiltonian matrix: [ H \boldsymbol{\alpha} = E S \boldsymbol{\alpha}, \quad H_{ij} = \operatorname{Tr}[\sigma_i^\dagger A \sigma_j O], \quad S_{ij} = \operatorname{Tr}[\sigma_i^\dagger A \sigma_j], ] selecting the minimal (E) (ground-state analogue) with normalization (\boldsymbol{\alpha}^\dagger S \boldsymbol{\alpha} = 1).
We adopt the power subspace (practical for qumodes, as (\rho^m) preserves bosonic structure): [ \sigma_i = \rho^i, \quad i = 0, \dots, K, \quad d_s = K+1, \quad A = I. ] Here, (\rho^0 = I), and higher powers amplify the dominant eigenvector (|\lambda_{\rm dom}\rangle) of (\rho) (closest to the ideal (|\psi_{\rm opt}\rangle \in \mathcal{S}c)) if the spectral gap (\lambda{\rm dom} > \lambda_2 \gg \lambda_k) ((k \geq 3)). For stochastic noise (e.g., depolarizing on Fock basis), the eigenvalues satisfy (\lambda_k \sim (1 - \epsilon)^{k}) ((\epsilon \ll 1)), yielding fidelity (F(\rho_{\rm EM}, |\psi_{\rm opt}\rangle \langle \psi_{\rm opt}|) \approx 1 - O(e^{-K \epsilon}))—exponential in (K), surpassing linear QSE.
In bosonic systems, compute (\rho^{i+1} = \rho^i \rho) iteratively (matrix multiplication in (\mathcal{H}), (O(N^{2d})) per step; feasible for (d \leq 4), (N \leq 5)). For cross-mode errors (e.g., unbalanced beam-splitters (\hat{L} = \sqrt{\eta} (\hat{a}_i^\dagger \hat{a}_j + \hat{a}_j^\dagger \hat{a}i))), the subspace filters coherent distortions by aligning (\rho{\rm EM}) to the symmetry-protected eigenspace of (H_M).
For a noisy trajectory (\rho_t) (e.g., from Lindblad evolution (\dot{\rho}_t = -i [H_M, \rho_t] + \mathcal{L}[\rho_t]), initial (\rho_0 \in \mathcal{S}_c)):
- Raw violation: (\langle \hat{V} \rangle_t = \operatorname{Tr}[\rho_t \hat{V}]), increasing as (O(t \kappa)) for loss rate (\kappa).
- GSE-mitigated: Solve per (t): [ H^{(V)}{ij}(t) = \operatorname{Tr}[(\rho_t^i)^\dagger (\rho_t^j \hat{V})], \quad S{ij}(t) = \operatorname{Tr}[(\rho_t^i)^\dagger \rho_t^j], ] yielding (\langle \hat{V} \rangle_t^{\rm GSE} = \boldsymbol{\alpha}(t)^\dagger H^{(V)}(t) \boldsymbol{\alpha}(t)). Since (\hat{V} |\mathbf{n}\rangle \in \mathcal{S}c = 0), the projection suppresses leakage: if noise perturbs (\rho_t = (1 - \delta) P_c + \delta P\perp) ((P_c, P_\perp) projectors), then (\rho_t^m \approx (1 - m \delta) P_c + O(\delta^m)), and (\langle \hat{V} \rangle_t^{\rm GSE} \sim O(e^{-K \delta})).
For the objective, replace (\hat{V} \to H_C): (\langle H_C \rangle_t^{\rm GSE}) recovers the ideal (\min_{\mathbf{n} \in \mathcal{S}_c} \mathbf{c}^\top \mathbf{n}) by distilling to the low-lying spectrum of (H_C) within (\mathcal{S}_c).
In the solver, post-optimize or during simulate_errors, apply GSE via:
[
(\langle O \rangle^{\rm raw}, \langle O \rangle^{\rm GSE}) = \operatorname{mitigate_gse_expect}(\rho, O, K),
]
where matrices (H, S) are built from traces over the full basis (enumerated via product(range(N), repeat=d)). For time evolution, loop over (\rho_t):
[
\langle O \rangle_t^{\rm GSE} = \sum_{i,j} \alpha_i^*(t) \alpha_j(t) \operatorname{Tr}[\rho_t^i O \rho_t^j].
]
Overhead: (O(K^2 N^{2d})) per (t), but (d_s = K+1 \ll \dim \mathcal{H}) ensures scalability for shallow circuits.
GSE inherits VD's exponential stochastic suppression but adds coherent robustness: for coherent errors (\epsilon U) ((U) unitary deviation), the subspace span({\rho^i}) diagonalizes in the perturbed basis, yielding bias (O(\epsilon / \lambda_{\rm gap})) vs. (O(\epsilon)) raw. In bosonic QAOA, since (H_M) enforces (\mathcal{S}_c)-invariance, GSE further amplifies this by filtering nullspace-mixing coherences.
Numerically, for the example (A = [1,1]), (b=1), (c=[1,-1]) ((\mathcal{S}c = \operatorname{span}{|1,0\rangle, |0,1\rangle})), simulations show (\langle V \rangle^{\rm GSE}{t=0.1} \approx 10^{-3} \langle V \rangle^{\rm raw}) for (\kappa=0.5), (K=2), confirming orders-of-magnitude improvement.
This framework unifies error-agnostic QEM for qumode optimization, paving the way for scalable constrained solvers on noisy photonic platforms.