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

Time-Optimal Gate

First, we aim to find the fastest possible pulse realizing a CZ gate on two atoms in the perfect Rydberg blockade regime (for a fixed number of 4 pulse parameters). For this, we perform many random initializations of pulse parameters, optimize the pulses, and identify the fastest pulse that realizes the gate with a fidelity better than our target fidelity.

[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 object and the pulse ansatz. The Rydberg decay strength is set to zero.

[2]:
gate = ro.gates.TwoQubitGate(phi=None, theta=np.pi, Vnn=float("inf"), decay=0.0)
pulse_ansatz = ro.pulses.PulseAnsatz(
    detuning_ansatz=ro.pulses.const, phase_ansatz=ro.pulses.sin_crab
)

Then we specify upper and lower bounds for the random initialization of pulse parameters.

[3]:
min_initial_params = (1, [-1], [-1, -1], [])
max_initial_params = (15, [1], [1, 1], [])

We perform 60 random parameter initializations, running in parallel on 4 CPU cores. We decide to return the optimization history of all runs.

[4]:
opt_result = ro.optimization.multi_start_optimize(
    gate,
    pulse_ansatz,
    min_initial_params,
    max_initial_params,
    num_steps=300,
    tol=1e-8,
    num_initializations=60,
    num_processes=4,
    return_history=True,
    return_all=True,
)

Started optimization using 4 processes


=== Optimization finished using multi-start Adam ===

Runtime: 28.725 seconds
Gates with infidelity below tol=1.0e-08: 37

Slowest gate:
> infidelity <= tol
> parameters = (16.655961125100387, [0.35633379], [ 0.08006122 -1.30342051], [])
> duration = 16.655961125100387

Fastest gate:
> infidelity <= tol
> parameters = (7.611413531684982, [0.07764845], [1.75254238 0.61844757], [])
> duration = 7.611413531684982
> one-sided bootstrap error on duration: 0.0004

Finally, we plot the history of all optimization runs.

[5]:
ro.characterization.plot_optimization_history(opt_result);
../_images/examples_multi_start_optimization_10_0.png

Now, we aim to find a gate pulse that minimizes the Rydberg time for a CZ gate on two atoms in the perfect Rydberg blockade regime (for a fixed number of 4 pulse parameters). Again, we perform many random initializations of pulse parameters, optimize the pulses in the presence of Rydberg-state decay, and identify the pulse that performs best.

Specify the target gate with decay

[6]:
gate_with_decay = ro.gates.TwoQubitGate(
    phi=None, theta=np.pi, Vnn=float("inf"), decay=0.0001
)

Perform 60 random parameter initializations, running in parallel on 4 CPU cores.

[7]:
opt_result_with_decay = ro.optimization.multi_start_optimize(
    gate_with_decay,
    pulse_ansatz,
    min_initial_params,
    max_initial_params,
    num_steps=300,
    tol=1e-8,
    num_initializations=60,
    num_processes=4,
)

Started optimization using 4 processes


=== Optimization finished using multi-start Adam ===

Runtime: 31.390 seconds
Gates with infidelity below tol=1.0e-08: 0

Best gate:
> infidelity = 2.937532e-04
> parameters = (7.6995993881854226, [0.11585392], [0.17406893 0.8953095 ], [])
> duration = 7.6995993881854226

Finally, we analyze the best performing gate.

[8]:
optimized_params_with_decay = opt_result_with_decay.params
infidelity, infidelity_nodecay, ryd_time = ro.characterization.analyze_gate(
    gate_with_decay, pulse_ansatz, optimized_params_with_decay
)

print(f"Gate infidelity:             {infidelity:.4e}")
print(f"Gate infidelity (no decay):  {infidelity_nodecay:.4e}")
print(f"Rydberg time:                {ryd_time:.4f}")
Gate infidelity:             2.9375e-04
Gate infidelity (no decay):  4.3007e-09
Rydberg time:                2.9380