The Boulder Opal Toolkits are currently in beta phase of development. Breaking changes may be introduced.

ms_optimize(drives, lamb_dicke_parameters, relative_detunings, duration, target_phases, sample_count=128, robust=False, optimization_count=4, max_iteration_count=None, cost_history=None)

Find optimal pulses to perform a target Mølmer–Sørensen-type operation on a system composed of ions.

  • drives (list[OptimizableDrive]) – A list of optimizable drives addressing the ions. Each ion can only be addressed by a single drive, but there may be ions not addressed by any drive.

  • lamb_dicke_parameters (np.ndarray) – A 3D array of shape (3, N, N), where \(N\) is the number of ions in the system, specifying the laser-ion coupling strength, \(\{\eta_{jkl}\}\). The three dimensions indicate, respectively, the axis, the collective mode number, and the ion.

  • relative_detunings (np.ndarray) – A 2D array of shape (3, N) specifying the difference, in Hz, between each motional mode frequency and the laser detuning (with respect to the qubit transition frequency \(\omega_0\)), \(\{\delta_{jk} = \nu_{jk} - \delta\}\). The two dimensions indicate, respectively, the axis and the collective mode number.

  • duration (float) – The duration, in seconds, of the dynamics to be optimized, \(T\). It must be greater than zero.

  • target_phases (np.ndarray) – A 2D array of shape (N, N) with the target relative phases between ion pairs, \(\{\Psi_{kl}\}\), as a strictly lower triangular matrix. Its \((k, l)\)-th element indicates the total relative phase target for ions \(k\) and \(l\), with \(k > l\).

  • sample_count (int, optional) – The number of times \(T\) between 0 and duration (included) at which the evolution is sampled. Defaults to 128.

  • robust (bool, optional) – Whether to obtain optimized drives robust against dephasing noise.

  • optimization_count (int, optional) – The number of independent randomly seeded optimizations to perform. The result from the best optimization (the one with the lowest cost) is returned. Defaults to 4.

  • max_iteration_count (int, optional) – The maximum number of optimizer iterations to perform. You can set this as an early stop condition for the optimizer. If provided, it must be greater than zero. Defaults to None, which means that the optimizer runs until it converges.

  • cost_history (str, optional) – String determining the output of the optimization cost history. If “BEST”, a single cost history for the best performing optimization is returned. If “ALL”, a list with the cost histories for all optimizations is returned. Defaults to None, in which case no cost history is returned.


A dictionary containing information about the evolution of the system. The dictionary keys are:


Dictionary containing the optimized drives values, whose keys are the names of the drives provided to the function, and whose values are an np.ndarray with the values of the piecewise-constant signal.


The final optimized cost. If robust is set to False, this corresponds to the infidelity at the end of the gate. If robust is set to True, it is the final infidelity plus the dephasing-robust cost term.


The times at which the evolution is sampled, as an array of shape (T,).


Acquired phases \(\{\Phi_{jk}(t_i) = \phi_{jk}(t_i) + \phi_{kj}(t_i)\}\) for each sample time and for all ion pairs, as a strictly lower triangular matrix of shape (T, N, N). \(\Phi_{jk}\) records the relative phase between ions \(j\) and \(k\); matrix elements where \(j \leq k\) are zero.


Displacements \(\{\eta_{pj}\alpha_{pj}(t_i)\}\) for all mode-ion combinations, as an array of shape (T, 3, N, N). The four dimensions indicate the sample time, the axis, the collective mode number, and the ion.


A 1D array of length T representing the operational infidelities of the Mølmer–Sørensen gate at each sample time, \(\mathcal{I}(t_i)\).


If cost_history is set to “BEST”, the cost history for the best performing optimization. If cost_history is set to “ALL”, a list of all the cost histories for each optimization.

Return type:


See also


Class describing a piecewise-constant complex-valued optimizable drive.


Class describing a piecewise-constant real-valued optimizable drive.


Simulate a Mølmer–Sørensen-type operation on a trapped ions system.


Calculate the properties of an ion chain.


The internal and motional Hamiltonian of \(N\) ions is

\[H_0 = \sum_{p = 1}^{3N} \hbar\nu_p \left(a_p^\dagger a_p + \frac{1}{2}\right) + \sum_{j = 1}^N \frac{\hbar \omega_0}{2} \sigma_{z,j} ,\]

where the axis dimension and collective mode dimension are combined into a single index \(p\) for simplicity, \(a_p\) is the annihilation operator for the mode \(p\), and \(\sigma_{z,j}\) is the Pauli \(Z\) operator for the ion \(j\). The interaction Hamiltonian for Mølmer–Sørensen-type operations in the rotating frame with respect to \(H_0\) is:

\[H_I(t) = i\hbar\sum_{j = 1}^N \sigma_{x, j} \sum_{p = 1}^{3N} (-\beta_{pj}^*(t)a_p + \beta_{pj}(t) a_p^\dagger) ,\]

where \(\sigma_{x, j}\) is the Pauli \(X\) operator for the ion \(j\) and \(\beta_{pj}(t) = \eta_{pj} \frac{\gamma_j(t)}{2} e^{i\delta_p t}\), indicating the coupling of the ion \(j\) to the motional mode \(p\), where \(\{\gamma_j\}\) is the total drive acting on ion \(j\).

The corresponding unitary operation is given by [1]

\[U(t) = \exp\left[ \sum_{j=1}^N \sigma_{x, j} B_j(t) + i\sum_{j=1}^N\sum_{k=1}^{j - 1} (\phi_{jk}(t) + \phi_{kj}(t)) \sigma_{x, j} \sigma_{x, k} \right] ,\]


\[ \begin{align}\begin{aligned}B_j(t) &\equiv \sum_{p = 1}^{3N} \left(\eta_{pj}\alpha_{pj}(t)a_p^\dagger - \eta_{pj}^{\ast}\alpha_{pj}^\ast(t)a_p \right) ,\\\phi_{jk}(t) &\equiv \mathrm{Im} \left[ \sum_{p=1}^{3N} \int_{0}^{t} d \tau_1 \int_{0}^{\tau_1} d \tau_2 \beta_{pj}(\tau_1)\beta_{pk}^{\ast}(\tau_2) \right] ,\end{aligned}\end{align} \]


\[\alpha_{pj}(t) = \int_0^t d\tau \frac{\gamma_j(\tau)}{2} e^{i \delta_p \tau} .\]

The operational infidelity of the Mølmer–Sørensen gate is defined as [1]:

\[\begin{split}\mathcal{I} = 1 - \left| \left( \prod_{\substack{k=1 \\ l<k}}^N \cos ( \phi_{kl} - \psi_{kl}) \right) \left( 1 - \sum_{j=1}^3 \sum_{k,l=1}^N \left[ |\eta_{jkl}|^2 |\alpha_{jkl}|^2 \left(\bar{n}_{jk}+\frac{1}{2} \right) \right] \right) \right|^2 .\end{split}\]

You can use the robust flag to construct a Mølmer–Sørensen gate that is robust against dephasing noise. This imposes a symmetry [1] in the optimizable ion drives and aims to minimize the time-averaged positions of the phase-space trajectories,

\[\langle \alpha_{pj} \rangle = \frac{1}{t_\text{gate}} \int_0^{t_\text{gate}} \alpha_{pj}(t) \mathrm{d} t ,\]

where the axis dimension and the collective mode dimension are combined into a single index \(p\) for simplicity.

This is achieved by adding an additional term to the cost function, consisting of the sum of the square moduli of the time-averaged positions multiplied by the corresponding Lamb–Dicke parameters. That is to say,

\[C_\text{robust} = \mathcal{I} + \sum_{p,j} \left| \eta_{pj} \langle \alpha_{pj} \rangle \right|^2 .\]