rydopt.characterization

analyze_gate(gate, pulse, params, tol=1e-15)[source]

Function that analyzes the performance of a gate pulse using JAX.

It determines the gate infidelity, the gate infidelity in the absence of Rydberg state decay, and the Rydberg time.

Example

>>> import rydopt as ro
>>> import numpy as np
>>> gate = ro.gates.TwoQubitGate(
...     phi=None,
...     theta=np.pi,
...     Vnn=float("inf"),
...     decay=0.0001,
... )
>>> pulse = ro.pulses.PulseAnsatz(
...     detuning_ansatz=ro.pulses.Const(),
...     phase_ansatz=ro.pulses.SinCrab(2),
... )
>>> params = ro.pulses.PulseParams(7.61140652, [0.07842706], [1.80300902, -0.61792703], [])
>>> infid, infid_no_decay, ryd_time = analyze_gate(gate, pulse, params)
Parameters:
  • gate (GateSystem) – Target gate.

  • pulse (PulseAnsatzLike) – Ansatz of the gate pulse.

  • params (ParamsFloatLike) – Pulse parameters.

  • tol (float) – Precision of the ODE solver, default is 1e-15.

Returns:

Gate infidelity, Gate infidelity without decay, Rydberg time.

Return type:

tuple[float | None, float | None, float | None]

analyze_gate_qutip(gate, pulse, params)[source]

Function that analyzes the performance of a gate pulse using QuTiP.

It determines the gate infidelity, the gate infidelity in the absence of Rydberg state decay, and the Rydberg time.

Example

>>> import rydopt as ro
>>> import numpy as np
>>> gate = ro.gates.TwoQubitGate(
...     phi=None,
...     theta=np.pi,
...     Vnn=float("inf"),
...     decay=0.0001,
... )
>>> pulse = ro.pulses.PulseAnsatz(
...     detuning_ansatz=ro.pulses.Const(),
...     phase_ansatz=ro.pulses.SinCrab(2),
... )
>>> params = ro.pulses.PulseParams(7.61140652, [0.07842706], [1.80300902, -0.61792703], [])
>>> infid, infid_no_decay, ryd_time = analyze_gate_qutip(gate, pulse, params)
Parameters:
Returns:

Gate infidelity, Gate infidelity without decay, Rydberg time.

Return type:

tuple[float | None, float | None, float | None]

plot_pulse(pulse, params, *, plot_detuning=True, plot_phase=True, plot_rabi=True, subtract_phase_offset=False, num_points=1024, ax=None)[source]

Function that plots a pulse, given the pulse ansatz and the pulse parameters.

Example

>>> import rydopt as ro
>>> pulse = ro.pulses.PulseAnsatz(
...     detuning_ansatz=ro.pulses.Const(),
...     phase_ansatz=ro.pulses.SinCrab(2),
... )
>>> params = ro.pulses.PulseParams(7.6, [-0.1], [1.8, -0.6], [])
>>> ro.characterization.plot_pulse(pulse, params)
(<Figure ...
Parameters:
  • pulse (PulseAnsatzLike) – Ansatz of the gate pulse.

  • params (ParamsFloatLike) – Pulse parameters.

  • plot_detuning (bool) – Whether to plot the detuning pulse, default is True.

  • plot_phase (bool) – Whether to plot the phase pulse, default is True.

  • plot_rabi (bool) – Whether to plot the rabi pulse, default is True.

  • subtract_phase_offset (bool) – Whether the phase pulse begins at 0, default is False.

  • num_points (int) – Number of sampling points in the time interval.

  • ax (Axes | None) – Optional matplotlib.axes.Axes to draw on; if None, a new one is created.

Returns:

A tuple of (fig, ax) where ax is the axes used for the pulse plot.

Return type:

tuple[Figure, Axes]

plot_spectrum(pulse, params, *, plot_detuning=True, plot_phase=True, plot_rabi=True, num_points=256, pad_factor=1024, tapered=True, xlim=None, ylim=None, ax=None)[source]

Function that plots the spectrum of a pulse, given the pulse ansatz and the pulse parameters.

Example

>>> import rydopt as ro
>>> pulse = ro.pulses.PulseAnsatz(
...     detuning_ansatz=ro.pulses.Const(),
...     phase_ansatz=ro.pulses.SinCrab(2),
... )
>>> params = ro.pulses.PulseParams(7.6, [-0.1], [1.8, -0.6], [])
>>> ro.characterization.plot_spectrum(pulse, params)
(<Figure ...
Parameters:
  • pulse (PulseAnsatzLike) – Ansatz of the gate pulse.

  • params (ParamsFloatLike) – Pulse parameters.

  • plot_detuning (bool) – Whether to plot the detuning pulse, default is True.

  • plot_phase (bool) – Whether to plot the phase pulse, default is True.

  • plot_rabi (bool) – Whether to plot the rabi pulse, default is True.

  • num_points (int) – Number of sampling points in the time interval.

  • pad_factor (int) – Factor by which the time array is padded.

  • tapered (bool) – If True, applies a Tukey window in the padded region.

  • xlim (tuple[float, float] | None) – Optional x-axis (frequency) limits; if None, chosen automatically.

  • ylim (tuple[float, float] | None) – Optional y-axis (dB) limits; if None, chosen automatically.

  • ax (Axes | None) – Optional matplotlib.axes.Axes to draw on; if None, a new one is created.

Returns:

A tuple of (fig, ax) where ax is the axes used for the spectrum plot.

Return type:

tuple[Figure, Axes]

plot_optimization_history(optimization_result, *, xlim_step=None, xlim_duration=None, ylim=None, ax1=None, ax2=None)[source]

Function that plots the optimization history.

Example

>>> import rydopt as ro
>>> import numpy as np
>>> gate = ro.gates.TwoQubitGate(
...     phi=None,
...     theta=np.pi,
...     Vnn=float("inf"),
...     decay=0,
... )
>>> pulse = ro.pulses.PulseAnsatz(
...     detuning_ansatz=ro.pulses.Const(),
...     phase_ansatz=ro.pulses.SinCrab(2),
... )
>>> initial_params = ro.pulses.PulseParams(7.6, [-0.1], [1.8, -0.6], [])
>>> result = ro.optimization.optimize(
...     gate,
...     pulse,
...     initial_params,
...     num_steps=200,
...     tol=1e-7,
...     return_history=True,
... )
Started optimization ...
>>> plot_optimization_history(result)
(<Figure ...
Parameters:
  • optimization_result (OptimizationResult) – OptimizationResult object.

  • xlim_step (tuple[float, float] | None) – Optional x-axis (optimization steps) limits; if None, chosen automatically.

  • xlim_duration (tuple[float, float] | None) – Optional x-axis (gate duration) limits; if None, chosen automatically.

  • ylim (tuple[float, float] | None) – Optional y-axis (infidelity) limits; if None, chosen automatically.

  • ax1 (Axes | None) – Optional matplotlib.axes.Axes to draw the infidelity as a function of the optimization step; if None and ax2 is also None, a new one is created.

  • ax2 (Axes | None) – Optional matplotlib.axes.Axes to draw the infidelity as a function of the gate duration; if None and ax1 is also None, a new one is created.

Returns:

A tuple (fig, (ax1, ax2)) where ax1 and ax2 are the axes used for the two plots.

Return type:

tuple[Figure, tuple[Axes | None, Axes | None]]