optimize

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

optimize(transmons, cavities, interactions, gate_duration, initial_state=None, target_state=None, target_operation=None, sample_count=128, cutoff_frequency=None, target_cost=None, optimization_count=4, max_iteration_count=None, cost_history=None)

Find optimal pulses or parameters for a system composed of transmons and cavities, in order to achieve a target state or implement a target operation.

At least one of the terms in the transmon, cavities, or interaction Hamiltonians must be optimizable.

To optimize a state transfer, you need to provide an initial and a target state. To optimize a target gate/unitary, you need to provide a target operation.

Parameters
  • transmons (list[Transmon]) – List of objects containing the physical information about the transmons. It can be an empty list, but at least one transmon or cavity must be provided.

  • cavities (list[Cavity]) – List of objects containing the physical information about the cavities. It can be an empty list, but at least one transmon or cavity must be provided.

  • interactions (list[TransmonTransmonInteraction or TransmonCavityInteraction or CavityCavityInteraction]) – List of objects containing the physical information about the interactions in the system. It can be an empty list.

  • gate_duration (float) – The duration of the gate to be optimized, \(t_\mathrm{gate}\). It must be greater than zero.

  • initial_state (np.ndarray, optional) – The initial state of the system, \(|\Psi_\mathrm{initial}\rangle\), as a 1D array of length D = np.prod([system.dimension for system in transmon + cavities]). If provided, the function also returns its time evolution. This is a required parameter if you pass a target_state.

  • target_state (np.ndarray, optional) – The target state of the optimization, \(|\Psi_\mathrm{target}\rangle\), as a 1D array of length D. You must provide exactly one of target_state or target_operation.

  • target_operation (np.ndarray, optional) – The target operation of the optimization, \(U_\mathrm{target}\), as a 2D array of shape (D, D). You must provide exactly one of target_state or target_operation.

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

  • cutoff_frequency (float, optional) – The cutoff frequency of a linear sinc filter to be applied to the piecewise-constant signals you provide for the coefficients. If not provided, the signals are not filtered. If the signals are filtered, a larger sample count leads to a more accurate numerical integration. If the signals are not filtered, the sample count has no effect on the numerical precision of the integration.

  • target_cost (float, optional) – A target value of the cost that you can set as an early stop condition for the optimizer. If not provided, the optimizer runs until it converges.

  • 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.

Returns

A dictionary containing the optimized coefficients and information about the time evolution of the system, with keys

optimized_values

Dictionary containing the requested optimized Hamiltonian coefficients, under keys such as [transmon_1_name].drive, [cavity_2_name].frequency, [transmon_2_name]_[cavity_1_name]_interaction.dispersive_shift, and [cavity_1_name]_[cavity_2_name]_interaction.cross_kerr_coefficient (where [transmon_n_name] and [cavity_n_name] are the names assigned to the respective transmons or cavities). The values are float/complex for constant coefficients and np.ndarray for piecewise-constant signals. If you pass a cutoff_frequency, the filtered versions of the piecewise-constant coefficients are also included with keys such as [transmon_2_name].drive_filtered.

infidelity

The state/operational infidelity of the optimized evolution.

sample_times

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

unitaries

The system’s unitary time-evolution operators at each sample time, as an array of shape (T, D, D).

state_evolution

The time evolution of the initial state at each sample time, as an array of shape (T, D). This is only returned if you provide an initial state.

cost_history

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

dict

See also

superconducting.simulate()

Simulate a system composed of transmons and cavities.

Notes

The Hamiltonian of the system is of the form

\[H = \sum_i H_{\mathrm{transmon}_i} + \sum_i H_{\mathrm{cavity}_i} + \sum_{i,j} H_{\mathrm{transmon}_i-\mathrm{transmon}_j} + \sum_{i,j} H_{\mathrm{transmon}_i-\mathrm{cavity}_j} + \sum_{i,j} H_{\mathrm{cavity}_i-\mathrm{cavity}_j}\]

where i and j mark the i-th and j-th transmon or cavity. For their definition of each Hamiltonian term, see its respective class.

The Hilbert space of the system is defined as the outer product of all the transmon Hilbert spaces (in the order they’re provided in transmons) with the cavity Hilbert spaces (in the order they’re provided in cavities), that is:

\[\mathcal{H} = \mathcal{H}_{\mathrm{transmon}_1} \otimes \mathcal{H}_{\mathrm{transmon}_2} \otimes \ldots \otimes \mathcal{H}_{\mathrm{cavity}_1} \otimes \mathcal{H}_{\mathrm{cavity}_2} \otimes \ldots\]

The system dimension D is then the product of all transmon and cavity dimensions.

If you provide an initial_state and a target_state, the optimization cost is defined as the infidelity of the state transfer process,

\[\mathcal{I} = 1 - \left| \langle \Psi_\mathrm{target} | U(t_\mathrm{gate}) | \Psi_\mathrm{initial} \rangle \right|^2 ,\]

where \(U(t)\) is the unitary time-evolution operator generated by the Hamiltonian.

If you provide a target_operation, the optimization cost is defined as the operational infidelity,

\[\mathcal{I} = 1 - \left| \frac {\mathrm{Tr} (U_\mathrm{target}^\dagger U(t_\mathrm{gate}))} {\mathrm{Tr} (U_\mathrm{target}^\dagger U_\mathrm{target})} \right|^2 .\]

See the superconducting systems namespace classes for a list of the relevant objects to describe subsystems and optimizable coefficients.