# Optimization

Control optimization uses machine-learning algorithms to determine a control solution that minimizes a cost-function. In order to perform the optimization, we have to define a parameterization of the controls and an appropriate cost function to minimize.

## Pulse controls parametrization

The pulse controls are parameterized as piecewise constant functions as described in Control formats. To get the most efficient optimization, typically only the magnitude of each segment is optimized. The time steps are kept constant and are evenly divided in $m$ segments:

\[\begin{align} \tau_{i} = \tau_{op}/m, \hspace{1cm} i\in\{1,..,m\} \end{align}\]The full control operation is then determined by specifying the control pulses for each one of the $m$ segments. Each individual control pulse $k$ during segment $i$ is characterized by its modulus $\Omega_{k i}$ and phase $\phi_{k i}$, for complex controls, and simply by the amplitude $\alpha_{ki}$ for real pulses.

## Maximum modulus

The implementation of control operations in real systems imposes bounds on the control strength that can be applied. This bound is described by

\[\begin{align} \Omega_{k}(t) &\leq \Omega_{k,\text{max}}, \end{align}\]and

\[\begin{align} |{\alpha_{k}(t)}| &\leq \alpha_{k,\text{max}}, \end{align}\]where $\Omega_{k,\text{max}}$ and $\alpha_{k,\text{max}}$ are the maximum moduli for the $k$th complex and real pulses, respectively.

### Fixed modulus

For each complex pulse the modulus can be kept fixed to its maximum value over the course of the optimization so that

\[\begin{align} \Omega_{k}(t) &= \Omega_{k,\text{max}}. \end{align}\]In this case, only the phases of the complex pulse are optimized. This reduces the number of control parameters by $m$ for each fixed modulus.

### Cost

The optimizer iteratively searches over the control parameters $\boldsymbol{v}$ in order to minimize the cost function defined by

\[\begin{align} C(\boldsymbol{v}) = \mathcal{I}_{op}(\boldsymbol{v}) + \sum_{k=1}^{p} \mathcal{I}_{av,k}(\boldsymbol{v}) \end{align}\]where \(\mathcal{I}_{op}(\boldsymbol{v})\) and \(\mathcal{I}_{av,k}(\boldsymbol{v})\) are the noise-free infidelity and filter function infidelity respectively. Which terms of this cost function are used depends on the specific control problem at hand, as seen in the examples below.

#### Optimal control optimization

The optimal control optimization disregards any noise contribution and the cost function reduces to

\[\begin{align} C(\boldsymbol{v}) = \mathcal{I}_{op}(\boldsymbol{v}) = \frac{1}{D^2} \left|\text{Tr}[U_\text{target}^\dagger U_c(\boldsymbol{v})]\right|^2. \end{align}\]This function measures the deviation between the target operation $U_\text{target}$, and a perfectly implemented control operation $U_c(\boldsymbol{v})$ for the given control parameter configuration $\boldsymbol{v}$. Here, $D$ is the dimension of the quantum system (i.e. 2 for a 1 qubit operations).

#### Robust control optimization

For robust optimization the cost function includes the additional term of the 0 frequency components of the filter function:

\[\begin{align} C(\boldsymbol{v}) = \mathcal{I}_{op}(\boldsymbol{v}) + \mathcal{I}_{av,k}(\boldsymbol{v}), \\ \end{align}\]with

\[\begin{align} \mathcal{I}_{av,k}(\boldsymbol{v}) \approx \frac{1}{2\pi} F_{k}(\omega=0). \end{align}\]The reason for considering only the “0” frequency is that, in general, single-frequency optimizations provide robust solutions with much lower computational overhead.

## Single qubit driven control

In the case of single-qubit driven controls, the optimization follows the general description above but with an extra (optional) parameter, the detuning $\Delta_{i}$, in addition to the drive modulus $\Omega_{i}$ (the Rabi rate) and phase $\phi_{i}$.

The optimization is performed with appropriate constraints such that the maximum Rabi rate $\Omega_\text{max}$ (and optionally the maximum detuning $\Delta_\text{max}$) are never exceeded.

The complexity of the optimization scales with the increase in control flexibility such that it involves $2m$ variables if $z$-axis control is off, and $3m$ variables if $z$-axis control is on. To simplify the problem, the fixed-modulus option explained above can be used to provide solutions which only optimize over the values $\phi_{m}$ and $\Delta_{m}$.

### Cost

In the single qubit case, the cost function

\[\begin{align} C(\boldsymbol{v}) = \mathcal{I}_{op}(\boldsymbol{v}) + \mathcal{I}_{av,k}(\boldsymbol{v}) \\ \end{align}\]is not limited to use only the 0 frequency component of the filter function and $ \mathcal{I}_{av,k}(\boldsymbol{v})$ can assume more general forms, as described in the cases below.

### Fixed frequency

In this case, one is interested in reducing the effect of noise at a specific frequency and the noise infidelity entering the cost function is chosen to be

\[\begin{align} \mathcal{I}_{av,k}(\boldsymbol{v}) \approx \frac{1}{2\pi} F_{k}(\omega). \end{align}\]### Broadband

The broadband option calculates the cost using the full spectrum of the filter function to determine the infidelity

\[\begin{align} \mathcal{I}_{av,k}(\boldsymbol{v}) \approx \frac{1}{2\pi} \int_{-\infty}^{\infty} S_{k}(\omega) F_{k}(\omega) d\omega. \end{align}\]This quantity measures the average infidelity in implementing the resulting control operation $U_c(\boldsymbol{v})$ including noise interactions. Here $F_{k}(\omega)$ and $S_{k}(\omega)$ are the filter function and noise power spectral density, respectively, associated with the $k$th noise channel in the noise Hamiltonian. Once an optimized pulse is found, the average operation infidelity $\mathcal{I}_{op}(\boldsymbol{v})$ is not shown, this is because it is typically many orders of magnitude smaller than the noise infidelities.

In most common cases $C(\boldsymbol{v})$ is not a convex function, meaning it has multiple local minima, which furthermore do not have the same minimum value. Hence it can not be guaranteed after running an optimization that the optimal solution has been found. Nevertheless, with the default settings provided the optimization will typically find a solution that is better than a primitive pulse.

If the noise you have provided is particularly challenging to optimize you may receive a notification that the optimized pulse does not out-perform the equivalent primitive operation, in which case a primitive pulse is returned. In this case there are a few options:

- Increase the duration of the pulse. It is typically easier to find optimized solutions with controls that extend over a longer time.
- Run the optimization again with the same settings. Each optimization is run with randomized initial conditions. Hence there is always a chance that a better optimal solution will be found if an optimization is run again.

## Two-qubit parametric drive

In case of two-qubit parametric drive the optimization of two controls, the parametric drive (coupling rate) and a tunable qubit drive (Rabi rate), can be performed with concurrent drives or interleaved drives.

### Concurrent

Under this setting, the parametric and tunable qubit drives are applied simultaneously. The parametric and tunable qubit drives are split into $m$ segments with equal fixed duration. Both drives can be set to have fixed or variable moduli.

### Interleaved

Under this setting, the parametric drive and tunable qubit drive are applied one after the other, such that they are never on at the same time. The parametric drive is split into $m$ segments with equal fixed duration. The tunable qubit control is split into $n=m+1$ segments, that are placed in between the parametric drive segments. The parametric can be set to have variable or fixed moduli. The single qubit drive, on the other hand, always have a fixed total modulus, but can have a variable or fixed duration.