Error handling
Compilation errors with max_energy profile
Section titled “Compilation errors with max_energy profile”At compilation, several errors might occur. In this notebook we describe the most common ones, show what the typical error messages are and how to interpret them, and explain how to handle them.
Let us start by defining a simple quantum program:
from qoolqit import Register
# create a square Registerregister = Register.square(2,spacing=1.0)register.draw()from qoolqit import Drivefrom qoolqit.waveforms import InterpolatedWaveform, RampWaveform
# Interpolated waveform: smooth curve through specified valuesomega_wf = InterpolatedWaveform(duration=50, values=[0, 1, 0])# Ramp waveformdelta_wf = RampWaveform(duration=50, initial_value=-2, final_value=2)
# Combine into a Drivedrive = Drive( amplitude=omega_wf, detuning=delta_wf)
drive.draw()from qoolqit import AnalogDevice, QuantumProgram
# initialize the quantum programprogram = QuantumProgram( register=register, drive=drive)
# compile the quantum program to a selected devicedevice=AnalogDevice()program.compile_to(device, profile="max_energy")We observe there that the compilation was successful and we can access the compiled sequence.
program.draw()program.compiled_sequence.draw()Let us now explore different cases where different error messages might arise. First let us define a small function that outputs the quantum program we want to compile:
# Or use built-in graph patternsfrom qoolqit import Drive, QuantumProgram, Registerfrom qoolqit.graphs import DataGraphfrom qoolqit.waveforms import RampWaveform
def create_program(L,amp,det): graph = DataGraph.square(m=L, n=L) register = Register.from_graph(graph) # LxL square lattice
omega_wf = InterpolatedWaveform(duration=50, values=[0, amp, 0]) delta_wf = RampWaveform(duration=50, initial_value=-det, final_value=det)
drive = Drive(amplitude=omega_wf, detuning=delta_wf)
return QuantumProgram(register=register,drive=drive)Error 1: Amplitude too large
Section titled “Error 1: Amplitude too large”In this case the compilation routine will try to rescale the register in such a way to maintain the same relative amplitudes of the drive. If the amplitude of the drive is too large, the register may become too large, leading to an overflow error.
from qoolqit.exceptions import CompilationError
L=4amp=100det=2program=create_program(L,amp,det)try: compiled_sequence = program.compile_to(device, profile="max_energy")except CompilationError as err: print(err)After rescaling the input program to the maximum energy scale available for the selected device, the following exception was raised:
The register's maximum radial distance went over the maximum value allowed.To compile this program on the selected device `AnalogDevice`, the maximum radial distance must be below 2.7547915763674697What happened?
Section titled “What happened?”We selected an amplitude that is 100 times larger than the maximum atomic pair-wise interaction. The compilation profile set the amplitude to the maximum allowed value and rescaled the register to keep the ratio between drive strength and interaction energy. As a result, the register grew too large, leading to an overflow error.
Error 2: detuning too large
Section titled “Error 2: detuning too large”L=4amp=1det=20program=create_program(L,amp,det)try: compiled_sequence = program.compile_to(device, profile="max_energy")except CompilationError as err: print(err)After rescaling the input program to the maximum energy scale available for the selected device, the following exception was raised:
The drive's maximum absolute detuning went over the maximum value allowed.To compile this program on the selected device `AnalogDevice`, set the maximum absolute detuning below 10.000000000000139What happened?
Section titled “What happened?”We selected a detuning that is 20 times larger than the maximum atomic pair-wise interaction. The compilation routine automatically rescales the amplitude to the maximum allowed value and all the other quantities accordingly. Hence, it rescaled the register and the detuning. This time the register is fitting the device but the detuning value goes beyond the allowed bounds.
Error 3: duration too long
Section titled “Error 3: duration too long”L=2amp=10det=1program=create_program(L,amp,det)try: compiled_sequence = program.compile_to(device, profile="max_energy")except CompilationError as err: print(err)After rescaling the input program to the maximum energy scale available for the selected device, the following exception was raised:
The drive's duration went over the maximum value allowed.To compile this program on the selected device `AnalogDevice`, set the drive's duration below 7.5398223686154004What happened?
Section titled “What happened?”The compilation profile max_energy automatically rescales the amplitude to the maximum allowed value and all the other quantities accordingly. This means that also the time is rescaled. In particular, as explained in Adimensionalization and Compilation, when the amplitude is too large to fit the device and it has to be decreased and everything rescaled accordingly, then time is increased. In this case the total duration ended up being longer than the allowed value.
