---
title: 'MAGICARP: Quantum Control for Gate Synthesis'
url: https://www.emergentmind.com/topics/magicarp
type: topic
---

# MAGICARP: Quantum Control for Gate Synthesis

MAGICARP is a specific quantum optimal control algorithm for synthesizing quantum gates. It combines the structure provided by Pontryagin’s Maximum Principle (PMP) with the robustness of gradient ascent techniques, and is formulated as a shooting technique that determines an initial adjoint momentum sufficient to realize a target gate. In its original formulation, MAGICARP merges PMP with gradient-based optimization by optimizing a single traceless Hermitian adjoint matrix \(g\), rather than optimizing thousands of discretized control amplitudes directly; in a later drift-aware extension, the same basic idea is generalized to closed systems with a constant drift Hamiltonian, including two exchange-coupled spins in an external magnetic field [2505.21203][2606.22212].

## 1. Conceptual position within quantum optimal control

In quantum optimal control, the objective is to design time-dependent fields that steer a unitary propagator \(U(t)\) according to
\[
\dot{U}(t) = -i H(t) U(t), \qquad U(0)=\mathbb{1},
\]
with
\[
H(t) = H_0 + \sum_k u_k(t)\,H_k,
\]
so that \(U(T)\) approximates a desired target gate \(U_{\mathrm{targ}}\in SU(d)\) at some final time \(T\). The standard objectives are gate fidelity and resource constraints such as total time, speed, energy, or amplitude [2505.21203].

MAGICARP was introduced against the background of methods such as GRAPE, which discretize time into \(N_{\text{steps}}\) slices, treat all amplitudes \(u_k[n]\) as optimization variables, and use analytic gradients with respect to those amplitudes. The original exposition identifies four resulting issues: dimensionality, local minima or landscape complexity, the difficulty of integrating time- or energy-optimality directly into the cost functional, and the absence of built-in analytic structure in the pulse ansatz [2505.21203].

The defining move in MAGICARP is therefore a reparameterization of the optimization problem. Instead of searching over the full space of discretized pulses, it searches over a finite-dimensional adjoint object whose dynamics determine the entire pulse shape through PMP. In the driftless formulation, this reduces the optimization variables from \(N_{\text{steps}}\times N_{\text{controls}}\) to \(d^2-1\), the number of real degrees of freedom in a traceless Hermitian \(d\times d\) matrix \(g\) [2505.21203].

| Algorithm | Number of optimization parameters |
|---|---|
| GRAPE | \(N_{\text{steps}}\times N_{\text{controls}}\) |
| MAGICARP | \(d^2 - 1\) |

This parameter reduction is not merely a numerical convenience. It encodes the claim that, for the cost functionals considered, optimal controls can be represented through a constant adjoint matrix whose conjugation by the evolving unitary specifies the control direction at every time. A plausible implication is that MAGICARP should be most advantageous when time discretization is fine and the control grid is large, but the physical Hilbert-space dimension remains moderate [2505.21203].

## 2. PMP formulation and the adjoint matrix \(g\)

The original derivation distinguishes Mayer, Lagrange, and Bolza cost functionals. For gate synthesis, the discussion centers on two Lagrange-type resource costs and a separate Mayer-type fidelity objective [2505.21203].

The time-optimal cost is written as
\[
\mathcal{J}[U,\vec{u}] = \int_0^T \sqrt{\sum_k u_k^2(t)}\,dt,
\]
while the quadratic energy cost is
\[
\mathcal{J}[U,\vec{u}] = \int_0^T \sum_k u_k^2(t)\,dt.
\]
The gate fidelity is defined as
\[
\mathcal{F}(U(T)) = \left| \mathrm{Tr}\left(U_{\mathrm{targ}^\dagger}U(T)\right)\right|^2.
\]
In practice, the paper also uses the gate cost
\[
\mathrm{Cost}_{\mathrm{gate}} = 1 - \frac{1}{d}\,\mathrm{Tr}\left(U_{\mathrm{targ}^\dagger}U(T)\right).
\]
These ingredients are combined by first deriving the PMP control structure from the resource functional and then optimizing fidelity over the adjoint parameter \(g\) [2505.21203].

Within PMP, the state is \(U(t)\in SU(d)\), the adjoint variable is a matrix \(\lambda(t)\), and for the chosen Lagrangians the adjoint equation simplifies to
\[
\dot{\lambda}(t) = -i H(t)\lambda(t).
\]
A central consequence is that one may write
\[
\lambda(t)=U(t)\lambda_0,
\]
where \(\lambda_0\) is a constant skew-Hermitian matrix, and then define
\[
g = -i\lambda_0,
\]
so that \(g\) is a constant traceless Hermitian matrix. This constant matrix is the shooting parameter that MAGICARP optimizes [2505.21203].

For the quadratic energy cost, the optimal controls take the explicit PMP form
\[
u_k^*(t)=\frac{1}{2}\operatorname{ReTr}\!\left(U(t)\,g\,U^\dagger(t)\,H_k\right).
\]
For the time-like cost, the controls are proportional to the same inner product but normalized by the control norm. The distinction is important: in the quadratic case the control is linear in the adjoint, whereas in the time-like case the control direction is fixed by the adjoint and the magnitude is normalized [2505.21203].

This induces a two-point boundary-value problem. One chooses \(g\), propagates \(U(t)\) forward under the PMP-structured controls, evaluates the final gate fidelity, and then updates \(g\) by gradient ascent. In control-theoretic language, this is a shooting method over the initial adjoint momentum [2505.21203].

## 3. Algorithmic realization as self-iterative pulse construction

MAGICARP is described as iteratively refining an adjoint matrix \(g\) to optimize the target quantum operation. In the driftless implementation, \(g\in\mathfrak{su}(d)\) is represented as a traceless Hermitian matrix, or equivalently as a real vector of length \(d^2-1\) on a basis of \(SU(d)\) generators [2505.21203].

For a given \(g\), the algorithm proceeds by computing initial controls from \(g\), propagating the unitary on a discrete time grid, and recomputing control amplitudes at each step through the conjugated adjoint \(U(t)gU^\dagger(t)\). In the energy-optimal variant used for the simplified implementation,
\[
u_k(0)=\frac{1}{2}\operatorname{ReTr}(gH_k),
\]
and at subsequent steps
\[
\tilde{u}_k(n\delta t)=\frac{1}{2}\operatorname{ReTr}\!\left(U(n\delta t)\,g\,U^\dagger(n\delta t)\,H_k\right).
\]
The propagator is updated piecewise-constantly as
\[
U((n+1)\delta t)=\exp\!\left(-i\delta t\sum_k u_k(n\delta t)H_k\right)U(n\delta t).
\]
After evolving to \(T=N\delta t\), the algorithm evaluates
\[
F(g)=\left|\mathrm{Tr}\left(U_{\mathrm{targ}^\dagger}U(T,g)\right)\right|^2,
\]
and updates \(g\) with a gradient-based optimizer [2505.21203].

The implementation is therefore hybrid in a precise sense. PMP provides a structured pulse ansatz, while gradient ascent supplies the outer optimization loop. In the original paper, gradients with respect to \(g\) are described as computable numerically by finite differences or via chain-rule-based derivations; in the later drift-aware formulation, gradients with respect to the generator parameters are evaluated by automatic differentiation in JAX, and L-BFGS-B is used under box constraints on those parameters [2505.21203][2606.22212].

No separate ODE for the costate is integrated in the basic MAGICARP realization, because the adjoint is implicit in the transported object \(U(t)\lambda_0\), or equivalently in the fixed matrix \(g\) conjugated by \(U(t)\). This is one of the reasons the method can be implemented as a self-iterative forward construction rather than as a simultaneous forward-backward scheme [2505.21203].

## 4. Pulse structure, constraints, and driftless numerical behavior

A notable feature of MAGICARP is that constraints are embedded in the pulse structure rather than imposed only through penalties. For time minimization, the controls are normalized versions of \(\operatorname{ReTr}(UgU^\dagger H_k)\), which naturally enforces maximal driving under the chosen norm. For energy minimization, the controls are linear in the same quantity. The original paper states that this tends to produce smooth, continuous pulses with a specific shape close to time- or energy-optimal trajectories under the specified norm and Hamiltonian set [2505.21203].

The physical interpretation given there is that the pulses are continuous functions of time, determined by how the adjoint matrix \(g\) is transported by the unitary evolution and projected onto the control Hamiltonians:
\[
u_k(t)=\frac{1}{2}\operatorname{ReTr}\!\left(U(t)gU^\dagger(t)H_k\right).
\]
They are explicitly characterized as not bang-bang in the strict sense. Rather, their shape is governed by the evolving projection of \(g\) under conjugation by \(U(t)\), which provides a controlled alternative to arbitrary piecewise-constant search over all time slices [2505.21203].

The initial numerical examples focus on constrained gate synthesis. For a single-qubit Hadamard gate with controls \(H_x=\sigma_x\) and \(H_y=\sigma_y\), the MAGICARP pulses are reported to be more continuous than the GRAPE-constrained pulses taken from previous work. The durations are given in units of the quantum speed limit \(\tau_{\text{QSL}}\): approximately \(1.33\tau_{\text{QSL}}\) for the GRAPE-constrained pulse and approximately \(1.25\tau_{\text{QSL}}\) for the MAGICARP-constrained pulse [2505.21203].

The method is also extended to \(d=2,\dots,6\) using \(2(d-1)\) generalized Pauli operators \(\sigma^x_{k,k+1}\) and \(\sigma^y_{k,k+1}\) as controls and the multi-level Hadamard or QFT gate as target. For each \(d\), the study reports 300 runs from random initial \(g\). The observed trend is that fidelity decreases on average with increasing dimension, the minimal duration achieving cost \(\le 10^{-7}\) increases, and the scatter of results becomes larger as local minima become more frequent. For \(d=2\), the minimal duration achieving cost \(\le 10^{-7}\) is approximately \(1.97\Omega_{\max}^{-1}\), or approximately \(1.25\tau_{\text{QSL}}\) [2505.21203].

These examples establish the main numerical profile of the method in the driftless setting: dimension reduction, structured smooth pulses, and competitive or shorter durations than constrained GRAPE in the cases considered. They also identify the main scaling caveat: while the search space is much smaller than a dense time-grid parameterization, it still grows as \(d^2-1\), which becomes large for systems where \(d=2^n\) [2505.21203].

## 5. Drift-aware generalization and transported-generator formalism

The 2026 extension reformulates MAGICARP for closed systems with a fixed, non-negligible drift Hamiltonian, and uses two exchange-coupled spins in an external magnetic field as the main testbed [2606.22212]. The drift Hamiltonian is
\[
H_0 = -\omega_1 Z_1 - \omega_2 Z_2 + J\,\mathbf{S}_1\cdot\mathbf{S}_2,
\qquad
\mathbf{S}_i=\frac{\boldsymbol{\sigma}_i}{2},
\]
with a single global transverse control
\[
H_{\mathrm{c}} = X_1 + X_2.
\]
The total lab-frame Hamiltonian is
\[
H_{\mathrm{lab}}(t)=H_0+u_{\mathrm{lab}}(t)\,H_{\mathrm{c}}.
\]
Because the drift is always on, the paper adopts the drift-aware target
\[
U_{\mathrm{target}}=U_{\mathrm{gate}}\,U_0(T),
\qquad
U_0(T)=e^{-iH_0T},
\]
so the gate is defined on top of the free drift evolution [2606.22212].

In this formulation, MAGICARP is written in terms of an anti-Hermitian generator
\[
G(\boldsymbol{\theta})=\sum_{a=1}^{N_\theta}\theta_a B_a,
\qquad
B_a^\dagger=-B_a,
\]
with real coefficients \(\theta_a\). The transported generator is
\[
M(t;\boldsymbol{\theta})=U(t)\,G(\boldsymbol{\theta})\,U^\dagger(t),
\]
and the control law is
\[
u_k(t;\boldsymbol{\theta})=\Im\,\mathrm{Tr}\!\left[H_k\,M(t;\boldsymbol{\theta})\right].
\]
This is explicitly identified as structurally analogous to a PMP costate transported along the trajectory [2606.22212].

The drift-aware method is implemented in two stages. First, the drift Hamiltonian is diagonalized to obtain dressed eigenstates and dressed transition frequencies \(\Omega_p\). For each transition \(p=(i,j)\), the one-way operator \(A_p=s_p|\varepsilon_j\rangle\langle\varepsilon_i|\) defines Hermitian quadratures
\[
H_{x,p}=A_p+A_p^\dagger,
\qquad
H_{y,p}=i(A_p^\dagger-A_p).
\]
Stage 1 then performs MAGICARP shooting in the rotating-wave frame, where the interaction-frame Hamiltonian is constructed from slowly varying quadratures on the retained dressed transitions. Stage 2 refines the same generator parameters in the exact laboratory frame, reconstructing the physical pulse as a sum of carriers at the dressed transition frequencies [2606.22212].

The extension also formalizes post-optimization control metrics. The integrated pulse energy is
\[
E_2=\int_0^T |u_{\mathrm{lab}}(t)|^2\,dt,
\]
the pulse area is
\[
E_1=\int_0^T |u_{\mathrm{lab}}(t)|\,dt,
\]
and the peak amplitude is \(\|u_{\mathrm{lab}}\|_\infty\). The paper emphasizes that the optimization objective itself is only gate infidelity; energy, area, spectral power concentration, and robustness are diagnostic quantities used for benchmarking and interpretation [2606.22212].

## 6. Benchmarks, weak-driving quantum speed limits, and open questions

The drift-aware study benchmarks MAGICARP against GRAPE and Krotov under a fair-halting protocol: same drift, same control Hamiltonian, same time grid, same dressed target gate, independent verified fidelity evaluation, and a common stopping rule at verified infidelity \(1-\mathcal{F}\le 10^{-5}\) or \(10^{-3}\) depending on the test [2606.22212].

For the moderate-coupling two-qubit QFT at \(T=50\,\mathrm{ns}\) and strict \(10^{-5}\) halt, the reported values are:
- MAGICARP: \(E_2 \approx 0.354\,\mathrm{rad}^2/\mathrm{ns}\), \(E_1 \approx 3.51\,\mathrm{rad}\), \(\|u\|_\infty\approx 0.19\,\mathrm{rad/ns}\);
- GRAPE: \(E_2 \approx 0.361\), \(E_1 \approx 3.52\), \(\|u\|_\infty\approx 0.22\);
- Krotov: \(E_2 \approx 5.0\), \(E_1 \approx 9.4\), \(\|u\|_\infty\approx 2.1\) [2606.22212].

| Method | \(T=50\,\mathrm{ns}\) QFT benchmark |
|---|---|
| MAGICARP | \(E_2 \approx 0.354\), \(E_1 \approx 3.51\), \(\|u\|_\infty\approx 0.19\) |
| GRAPE | \(E_2 \approx 0.361\), \(E_1 \approx 3.52\), \(\|u\|_\infty\approx 0.22\) |
| Krotov | \(E_2 \approx 5.0\), \(E_1 \approx 9.4\), \(\|u\|_\infty\approx 2.1\) |

The same comparison also shows strong differences in spectral concentration. For the QFT, MAGICARP places approximately \(93\%\) of spectral power on the four dressed transitions, GRAPE approximately \(99\%\), and Krotov approximately \(62\%\) [2606.22212]. The paper’s interpretation is explicit: GRAPE independently converges onto essentially the same low-energy, spectrally concentrated pulses that MAGICARP generates by design, whereas Krotov incurs an order-of-magnitude energy premium. A plausible implication is that the low-energy solution is a genuine feature of the control landscape rather than an artifact of the MAGICARP ansatz.

Robustness is examined through static fractional errors in the exchange coupling \(J\to(1+\varepsilon)J\). For the moderate-coupling QFT at \(T=50\,\mathrm{ns}\), MAGICARP and GRAPE are reported as the most robust; at \(-5\%\) error, the fidelities are approximately \(0.881\) for MAGICARP, \(0.854\) for GRAPE, and \(0.794\) for Krotov [2606.22212].

A major conceptual result of the drift-aware paper is the identification of a weak-driving quantum speed limit. A statistical sweep of \(100\times 4\times 24 = 9600\) MAGICARP runs over gate times \(T\in[5,25]\,\mathrm{ns}\) and four bounds on generator parameters is used to probe the existence of low-amplitude solutions for the dressed two-qubit QFT. A run is classified as converged if the verified infidelity is \(\le 10^{-7}\). The study reports that no run converges for \(T\lesssim 13.9\,\mathrm{ns}\), and the first converged run appears at \(T\approx 14.0\,\mathrm{ns}\) [2606.22212].

The minimum energy among converged runs is fitted by the two-parameter area-pole law
\[
E_2^{\mathrm{law}}(T)=\frac{A}{T}+\frac{B}{T-T^*},
\]
with fitted values
\[
A\approx 19.4\,\mathrm{rad}^2,\qquad
B\approx 0.23\,\mathrm{rad}^2,\qquad
T^*\approx 13.48\,\mathrm{ns}.
\]
The first term is identified as the time-optimal area cost, while the second is a pole at the weak-driving speed limit [2606.22212]. The same paper relates this threshold to a single-axis interaction bound of approximately \(12.6\,\mathrm{ns}\) derived from the QFT’s Cartan coordinates and the exchange rate \(J/4\).

The open questions are also stated with some precision across the two papers. The original formulation points to mapping stability of \(g\mapsto U(T,g)\), convergence as \(\delta t\to 0\), the cost of gradient computation with respect to \(g\), and the scaling of the \(d^2-1\) search space for large systems [2505.21203]. The drift-aware extension adds that the analysis is limited to closed systems, studies only static robustness to misspecified \(J\), and is demonstrated on a two-qubit setting even though the method is conceptually more general [2606.22212].

Taken together, these works define MAGICARP as a hybrid PMP-gradient family of shooting methods in which a single adjoint object generates the full control trajectory. In the driftless formulation, this yields a low-dimensional, resource-aware route to gate synthesis. In the drift-aware formulation, it becomes a transported-generator framework that produces smooth, low-energy, spectrally concentrated pulses and can expose a weak-driving quantum speed limit that is obscured by unconstrained high-amplitude optimization [2505.21203][2606.22212].

Source: https://www.emergentmind.com/topics/magicarp