Error handling
Compilation errors
Section titled “Compilation errors”At compilation several error might occur. In this notebook we describe the most common ones, show what are the typical error messages and how to interpret them and explain how to handle them.
Let us start by defining a simple quantum program:
# Or use built-in graph patternsfrom qoolqit import DataGraph, Register
graph = DataGraph.square(m=2, n=2)register = Register.from_graph(graph) # 2x2 square latticegraph.draw()from qoolqit import Drivefrom qoolqit.waveforms import Interpolated, Ramp
# Interpolated waveform: smooth curve through specified valuesomega_wf = Interpolated(duration=50, values=[0, 1, 0])# Ramp waveformdelta_wf = Ramp(duration=50, initial_value=-2, final_value=2)
# Combine into a Drivejupyter kernelspec listdrive = Drive( amplitude=omega_wf, detuning=delta_wf)
drive.draw()from qoolqit import AnalogDevice, QuantumProgram
program = QuantumProgram( register=register, drive=drive)
device=AnalogDevice()program.compile_to(device)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. First let us define a small function that output the quantum program we want to compile:
# Or use built-in graph patternsfrom qoolqit import DataGraph, Drive, QuantumProgram, Registerfrom qoolqit.waveforms import Interpolated, Ramp
def create_program(L,amp,det): graph = DataGraph.square(m=L, n=L) register = Register.from_graph(graph) # LxL square lattice
omega_wf = Interpolated(duration=50, values=[0, amp, 0]) delta_wf = Ramp(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)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 your program, set the maximum radial distance below 2.7547915763674697
What happened?
Section titled “What happened?”We selected an amplitude that is 100 times larger than the maximum atomic pair-wise interaction. The compilation routine automatically attempted to employ the maximum allowed amplitude and rescale the register accordingly: that is in such a way to have the a value of interaction at nearest neighobr that matches the value of the amplitude. In doing so, the register size increased, 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)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 your program, set the maximum absolute detuning below 10.000000000000139
What 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)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 your program, set the drive's duration below 7.5398223686154004
What happened?
Section titled “What happened?”The compilation routine 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, 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.
