This page was generated from the Jupyter notebook quick_start.ipynb. Open in Google Colab.

Quick Start

Let us create a pulse that implements a CZ gate on two atoms in the perfect Rydberg blockade regime.

[1]:
# %pip install -q --progress-bar off rydopt # Uncomment for installation on Colab

import rydopt as ro
import numpy as np

First, we create the target gate, by specifying the gate phases, the interaction between the atoms and the Rydberg-state decay rate.

[2]:
gate = ro.gates.TwoQubitGate(phi=None, theta=np.pi, Vnn=float("inf"), decay=0.0)

Then we choose a pulse ansatz that consists of a constant detuning and a sweep of the laser phase. The Rabi frequency amplitude is constant and fixed.

[3]:
pulse_ansatz = ro.pulses.PulseAnsatz(
    detuning_ansatz=ro.pulses.Const(), phase_ansatz=ro.pulses.SinCrab(2)
)

A guess of pulse parameters can serve as input for the optimization. Here, we choose to optimize four pulse parameters and package them as ro.pulses.PulseParams(...).

[7]:
initial_params = ro.pulses.PulseParams(7.0, [0.0], [0.0, 0.0], [])

Now, we perform the optimization, specifying a target gate infidelity (which also serves as tolerance for the differential equation solver).

[8]:
opt_result = ro.optimization.optimize(gate, pulse_ansatz, initial_params, tol=1e-10)
optimized_params = opt_result.params
Started optimization using 1 process


=== Optimization finished using Adam ===

Runtime: 8.395 seconds
Gates with infidelity below tol=1.0e-10: 1

Optimized gate:
> infidelity <= tol
> parameters = (7.626643597908443, -0.031259443394905904, 0.8197775118421416, 0.6638904306444476)
> duration = 7.626643597908443

Finally, we can plot the resulting pulse.

[9]:
ro.characterization.plot_pulse(pulse_ansatz, optimized_params);
../_images/examples_quick_start_12_0.png