filter_functions.gradient module

This module implements functions to calculate filter function and infidelity derivatives. Currently only auto-correlated noise (i.e. no cross-correlations) is implemented.

Throughout this documentation the following notation will be used:
  • n_dt denotes the number of time steps,

  • n_cops the number of all control operators,

  • n_ctrl the number of accessible control operators (if identifiers are provided, otherwise n_ctrl=n_cops),

  • n_nops the number of noise operators,

  • n_omega the number of frequency samples, and

  • d the dimension of the system.

Functions

calculate_derivative_of_control_matrix_from_scratch()

Calculate the derivative of the control matrix from scratch.

calculate_filter_function_derivative()

Compute the filter function derivative from the control matrix.

infidelity_derivative()

Calculate the infidelity derivative.

calculate_derivative_of_control_matrix_from_scratch(omega: Sequence[float], propagators: ndarray, eigvals: ndarray, eigvecs: ndarray, basis: Basis, t: Sequence[float], dt: Sequence[float], n_opers: Sequence[ndarray | Qobj], n_coeffs: Sequence[Sequence[float]], c_opers: Sequence[ndarray | Qobj], n_coeffs_deriv: Sequence[Sequence[float]] | None = None, intermediates: Dict[str, ndarray] | None = None) ndarray[source]

Calculate the derivative of the control matrix from scratch.

Parameters:
omega: array_like, shape (n_omega,)

Frequencies, at which the pulse control matrix is to be evaluated.

propagators: array_like, shape (n_dt+1, d, d)

The propagators \(Q_g = P_g P_{g-1}\cdots P_0\) as a (d, d) array with d the dimension of the Hilbert space.

eigvals: array_like, shape (n_dt, d)

Eigenvalue vectors for each time pulse segment g with the first axis counting the pulse segment, i.e. HD == array([D_0, D_1, ...]).

eigvecs: array_like, shape (n_dt, d, d)

Eigenvector matrices for each time pulse segment g with the first axis counting the pulse segment, i.e. HV == array([V_0, V_1, ...]).

basis: Basis, shape (d**2, d, d)

The basis elements, in which the pulse control matrix will be expanded.

t: array_like, shape (n_dt+1), optional

The absolute times of the different segments.

dt: array_like, shape (n_dt)

Sequence duration, i.e. for the \(g\)-th pulse \(t_g - t_{g-1}\).

n_opers: array_like, shape (n_nops, d, d)

Noise operators \(B_\alpha\).

n_coeffs: array_like, shape (n_nops, n_dt)

The sensitivities of the system to the noise operators given by n_opers at the given time step.

c_opers: array_like, shape (n_ctrl, d, d)

Control operators \(H_k\) with respect to which the derivative is computed.

n_coeffs_deriv: array_like, shape (n_nops, n_ctrl, n_dt)

The derivatives of the noise susceptibilities by the control amplitudes. Defaults to None.

intermediates: Dict[str, ndarray], optional

Optional dictionary containing intermediate results of the calculation of the control matrix.

Returns:
ctrlmat_deriv: ndarray, shape (n_ctrl, n_omega, n_dt, n_nops, d**2)

Partial derivatives of the total control matrix with respect to each control direction \(\frac{\partial\mathcal{B}_{\alpha k}(\omega)}{\partial u_h(t_{g'})}\).

See also

_liouville_derivative
_control_matrix_at_timestep_derivative

Notes

The derivative of the control matrix is calculated according to

\[\frac{\partial\mathcal{B}_{\alpha k}(\omega)}{\partial u_h(t_{g'})} = \sum_{g=1}^G \mathrm{e}^{\mathrm{i}\omega t_{g-1}}\cdot\left(\sum_j \left[\frac{\partial\mathcal{B}_{\alpha j}^{(g)}(\omega)} {\partial u_h(t_{g'})} \cdot \mathcal{Q}_{jk}^{(g-1)} + \mathcal{B}_{\alpha j}^{(g)}(\omega) \cdot\frac{\partial \mathcal{Q}_{jk}^{(g-1)}} {\partial u_h(t_{g'})} \right] \right)\]
calculate_filter_function_derivative(ctrlmat: ndarray, ctrlmat_deriv: ndarray) ndarray[source]

Compute the filter function derivative from the control matrix.

Parameters:
ctrlmat: array_like, shape (n_nops, d**2, n_omega)

The control matrix.

ctrlmat_deriv: array_like, shape (n_nops, d**2, n_t, n_ctrl, n_omega)

The derivative of the control matrix.

Returns:
filter_function_deriv: ndarray, shape (n_nops, n_dt, n_ctrl, n_omega)

The regular filter functions’ derivatives for variation in each control contribution \(\frac{\partial F_\alpha(\omega)}{\partial u_h(t_{g'})}\).

Notes

The filter function derivative is calculated according to

\[\frac{\partial F_\alpha(\omega)}{\partial u_h(t_{g'})} = 2 \mathrm{Re}\left(\sum_k \mathcal{B}_{\alpha k}^\ast(\omega) \frac{\partial\mathcal{B}_{\alpha k}(\omega)} {\partial u_h(t_{g'})} \right)\]
infidelity_derivative(pulse: PulseSequence, spectrum: Sequence[float], omega: Sequence[float], control_identifiers: Sequence[str] | None = None, n_oper_identifiers: Sequence[str] | None = None, n_coeffs_deriv: Sequence[Sequence[float]] | None = None) ndarray[source]

Calculate the entanglement infidelity derivative of the PulseSequence pulse.

Parameters:
pulse: PulseSequence

The PulseSequence instance for which to calculate the infidelity.

spectrum: array_like, shape ([[n_nops,] n_nops,] omega)

The two-sided noise power spectral density in units of inverse frequencies as an array of shape (n_omega,), (n_nops, n_omega), or (n_nops, n_nops, n_omega). In the first case, the same spectrum is taken for all noise operators, in the second, it is assumed that there are no correlations between different noise sources and thus there is one spectrum for each noise operator. In the third and most general case, there may be a spectrum for each pair of noise operators corresponding to the correlations between them. n_nops is the number of noise operators considered and should be equal to len(n_oper_identifiers).

omega: array_like, shape (n_omega,)

The frequencies at which the integration is to be carried out.

control_identifiers: Sequence[str], shape (n_ctrl,)

Sequence of strings with the control identifiers to distinguish between control and drift Hamiltonian. The default is None, in which case the derivative is computed for all known non-noise operators.

n_oper_identifiers: Sequence[str], shape (n_nops,)

Sequence of strings with the noise identifiers for which to compute the derivative contribution. The default is None, in which case it is computed for all known noise operators.

n_coeffs_deriv: array_like, shape (n_nops, n_ctrl, n_dt)

The derivatives of the noise susceptibilities by the control amplitudes. The rows and columns should be in the same order as the corresponding identifiers above. Defaults to None, in which case the coefficients are assumed to be constant and hence their derivative vanishing.

Warning

Internally, control and noise terms of the Hamiltonian are stored alphanumerically sorted by their identifiers. If the noise and/or control identifiers above are not explicitly given, the rows and/or columns of this parameter need to be sorted in the same fashion.

Returns:
infid_deriv: ndarray, shape (n_nops, n_dt, n_ctrl)

Array with the derivative of the infidelity for each noise source taken for each control direction at each time step \(\frac{\partial I_e}{\partial u_h(t_{g'})}\). Sorted in the same fashion as n_coeffs_deriv or, if not given, alphanumerically by the identifiers.

Raises:
ValueError

If the provided noise spectral density does not fit expected shape.

Notes

The infidelity’s derivative is given by

\[\frac{\partial I_e}{\partial u_h(t_{g'})} = \frac{1}{d} \int_{-\infty}^\infty \frac{d\omega}{2\pi} S_\alpha(\omega) \frac{\partial F_\alpha(\omega)} {\partial u_h(t_{g'})}\]

with \(S_{\alpha}(\omega)\) the noise spectral density and \(F_{\alpha}(\omega)\) the canonical filter function for noise source \(\alpha\).

To convert to the average gate infidelity, use the following relation given by Horodecki et al. [Hor99] and Nielsen [Nie02]:

\[\big\langle\mathcal{I}_\mathrm{avg}\big\rangle = \frac{d}{d+1} \big\langle\mathcal{I}_\mathrm{e}\big\rangle.\]

References

[Hor99]

Horodecki, M., Horodecki, P., & Horodecki, R. (1999). General teleportation channel, singlet fraction, and quasidistillation. Physical Review A - Atomic, Molecular, and Optical Physics, 60(3), 1888–1898. https://doi.org/10.1103/PhysRevA.60.1888

[Nie02]

Nielsen, M. A. (2002). A simple formula for the average gate fidelity of a quantum dynamical operation. Physics Letters, Section A: General, Atomic and Solid State Physics, 303(4), 249–252. https://doi.org/10.1016/S0375-9601(02)01272-0