qilimanjaro-tech/qililab

[BUG] QProgram avg causing QRM timeout

visagim opened this issue · 3 comments

Expected behavior

I'm running the following code

import numpy as np
import qililab as ql
from qililab.waveforms import DragPair
from qililab.qprogram import Domain
 
ql.logger.setLevel(40)
 
# Loops parameters
PHASE_LOOP_VALUES = np.linspace(0, 2 * np.pi, 21)
REPETITION_DURATION = 200_000
 
# Set the platform from runcard
PLATFORM_PATH = os.path.expanduser("~/LabScripts/QuantumPainHackathon/runcards/soprano_RF.yml")
partition = "galadriel_lab"
platform_qp = ql.build_platform(runcard=os.path.expanduser("~/LabScripts/QuantumPainHackathon/runcards/soprano_RF_qprogram.yml"))
 
CONTROL_QUBIT = 0
TARGET_QUBIT = 2
 
# Amplitude parameters
AMP = platform.get_parameter(alias=f"CZ({CONTROL_QUBIT},{TARGET_QUBIT})", parameter=ql.Parameter.AMPLITUDE)
AMP_STEP = 0.02 # this should be big enough to calibrate, small enough to prevent going over the 2nd minima
AMP_LOOP_VALUES = np.linspace(AMP - AMP_STEP, AMP + AMP_STEP, 40)
B_LOOP_VALUES = np.linspace(0,1,40) # B/A
 
# Define gates
def qpDrag(qp, qubit, amp, phase):
    drag = DragPair(
        amplitude=platform.get_parameter(parameter = ql.Parameter.AMPLITUDE, alias=f"Drag({qubit})"),
        duration=platform.get_parameter(parameter = ql.Parameter.DURATION, alias=f"Drag({qubit})"),
        num_sigmas=platform.get_parameter(parameter = ql.Parameter.NUM_SIGMAS, alias=f"Drag({qubit})"),
        drag_coefficient=platform.get_parameter(parameter = ql.Parameter.DRAG_COEFFICIENT, alias=f"Drag({qubit})"))
    qp.set_gain(bus=f"drive_q{qubit}_bus",
        gain=amp/np.pi * platform.get_parameter(parameter =ql.Parameter.AMPLITUDE, alias=f"Drag({qubit})"))
    qp.set_phase(bus=f"drive_q{qubit}_bus",
        phase=phase)
    qp.play(bus=f"drive_q{qubit}_bus",
        waveform=drag)
     
def qpM(qp, qubit):
    t = platform.get_parameter(parameter=ql.Parameter.DURATION, alias=f"M({qubit})")
    weights = ql.Square(amplitude=1, duration=t)
    qp.play(bus=f"readout_q{qubit}_bus", waveform=ql.Square(
        amplitude=platform.get_parameter(parameter=ql.Parameter.AMPLITUDE, alias=f"M({qubit})"),
        duration=t))
    qp.acquire(bus=f"readout_q{qubit}_bus", weights=ql.IQPair(I=weights, Q=weights))
    qp.wait(bus=f"drive_q{qubit}_bus",duration=REPETITION_DURATION)
 
 
# first try amp loop only
q0 = CONTROL_QUBIT
q1 = TARGET_QUBIT
 
qp = ql.QProgram()
amplitude = qp.variable(ql.Domain.Voltage)
phase = qp.variable(ql.Domain.Phase)
nshots = qp.variable(Domain.Scalar, type=int)
 
with qp.average(1000):
    with qp.for_loop(variable=amplitude, start=AMP_LOOP_VALUES[0], stop=AMP_LOOP_VALUES[-1], step=AMP_LOOP_VALUES[1]-AMP_LOOP_VALUES[0]):
        with qp.for_loop(variable=phase, start=PHASE_LOOP_VALUES[0], stop=PHASE_LOOP_VALUES[-1], step=PHASE_LOOP_VALUES[1]-PHASE_LOOP_VALUES[0]):
         
            qpDrag(qp, qubit=q0, amp=np.pi, phase=0) # control qubit on 0
            qpDrag(qp, qubit=q1, amp=np.pi/2, phase=0) # target qubit on |-i>
 
            qp.sync()
            qpM(qp, qubit=q0)
            qpM(qp, qubit=q1)
 
 
%%submit_job -o job_data -p galadriel_lab -n hwl_snz -t 15
 
platform_qp.connect()
platform_qp.initial_setup()
platform_qp.turn_on_instruments()
 
result = platform_qp.execute_qprogram(qp)
job_data = result
 
platform.disconnect()
 
data = job_data.result()

where I merged all of the several cells I run this notebook in.

Actual behavior

When avg=1 the above works, but on avg=1000 this fails
Error log:
when doing

with qp.average(1):
    with qp.for_loop(variable=amplitude, start=AMP_LOOP_VALUES[0], stop=AMP_LOOP_VALUES[-1], step=AMP_LOOP_VALUES[1]-AMP_LOOP_VALUES[0]):
        with qp.for_loop(variable=phase, start=PHASE_LOOP_VALUES[0], stop=PHASE_LOOP_VALUES[-1], step=PHASE_LOOP_VALUES[1]-PHASE_LOOP_VALUES[0]):
        
            qpDrag(qp, qubit=q0, amp=np.pi, phase=0)  # control qubit on 0
            qpDrag(qp, qubit=q1, amp=np.pi/2, phase=0)  # target qubit on |-i>

            qp.sync()
            qpM(qp, qubit=q0)
            qpM(qp, qubit=q1)
[qililab] [0.22.2|INFO|2024-02-07 16:39:35]: Connecting to instrument cluster_controller_0.
[qililab] [0.22.2|INFO|2024-02-07 16:39:39]: Connecting to instrument rohde_schwarz_controller_0.
[qililab] [0.22.2|INFO|2024-02-07 16:39:39]: Reset instrument rs_1.
[qililab] [0.22.2|INFO|2024-02-07 16:39:39]: Connecting to instrument rohde_schwarz_controller_2.
[qililab] [0.22.2|INFO|2024-02-07 16:39:39]: Reset instrument rs_3.
[qililab] [0.22.2|INFO|2024-02-07 16:39:39]: Connecting to instrument rohde_schwarz_controller_3.
[qililab] [0.22.2|INFO|2024-02-07 16:39:39]: Reset instrument rs_4.
[qililab] [0.22.2|INFO|2024-02-07 16:39:39]: Connecting to instrument attenuator_controller_0.
[qililab] [0.22.2|INFO|2024-02-07 16:39:39]: Reset instrument attenuator.
[qililab] [0.22.2|INFO|2024-02-07 16:39:39]: Connected to the instruments
[qililab] [0.22.2|INFO|2024-02-07 16:39:39]: Initial setup to instrument QRM1.
[qililab] [0.22.2|INFO|2024-02-07 16:39:40]: Initial setup to instrument QCM-RF1.
[qililab] [0.22.2|INFO|2024-02-07 16:39:40]: Initial setup to instrument QCM2.
[qililab] [0.22.2|INFO|2024-02-07 16:39:40]: Initial setup to instrument QCM3.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Initial setup to instrument QCM4.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Initial setup to instrument rs_1.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Initial setup to instrument rs_3.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Initial setup to instrument rs_4.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Initial setup to instrument attenuator.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Initial setup applied to the instruments
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Turn on instrument QRM1.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Turn on instrument QCM-RF1.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Turn on instrument QCM2.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Turn on instrument QCM3.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Turn on instrument QCM4.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Turn on instrument rs_1.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Turn on instrument rs_3.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Turn on instrument rs_4.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Turn on instrument attenuator.
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Instruments turned on
[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Sequence program: 
 setup:
                wait_sync        4              

main:
                move             1, R0          
avg_0:
                move             0, R1          
                move             40, R2         
                move             0, R3          
loop_0:
                move             21, R4         
                move             0, R5          
loop_1:
                wait             40             
                play             0, 1, 2500     
                acquire          0, R1, 2500    
                add              R1, 1, R1      
                wait             65532          
                wait             65532          
                wait             63936          
                loop             R4, @loop_1    
                loop             R2, @loop_0    
                loop             R0, @avg_0     
                stop                            


[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Sequence program: 
 setup:
                wait_sync        4              

main:
                move             1, R0          
avg_0:
                move             0, R1          
                move             40, R2         
                move             0, R3          
loop_0:
                move             21, R4         
                move             0, R5          
loop_1:
                wait             40             
                play             0, 1, 1200     
                acquire          0, R1, 1200    
                add              R1, 1, R1      
                wait             65532          
                wait             65532          
                wait             65532          
                wait             1004           
                loop             R4, @loop_1    
                loop             R2, @loop_0    
                loop             R0, @avg_0     
                stop                            


[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Sequence program: 
 setup:
                wait_sync        4              

main:
                move             1, R0          
avg_0:
                move             40, R1         
                move             0, R2          
loop_0:
                move             21, R3         
                move             0, R4          
loop_1:
                set_awg_gain     2566, 2566     
                set_ph           0              
                play             0, 1, 40       
                wait             65532          
                wait             65532          
                wait             65532          
                wait             3404           
                loop             R3, @loop_1    
                loop             R1, @loop_0    
                loop             R0, @avg_0     
                stop                            


[qililab] [0.22.2|INFO|2024-02-07 16:39:41]: Sequence program: 
 setup:
                wait_sync        4              

main:
                move             1, R0          
avg_0:
                move             40, R1         
                move             0, R2          
loop_0:
                move             21, R3         
                move             0, R4          
loop_1:
                set_awg_gain     4293, 4293     
                set_ph           0              
                play             0, 1, 40       
                wait             65532          
                wait             65532          
                wait             65532          
                wait             3404           
                loop             R3, @loop_1    
                loop             R1, @loop_0    
                loop             R0, @avg_0     
                stop                            


[qililab] [0.22.2|INFO|2024-02-07 16:39:42]: Already disconnected from the instruments

when doing

with qp.average(1000):
    with qp.for_loop(variable=amplitude, start=AMP_LOOP_VALUES[0], stop=AMP_LOOP_VALUES[-1], step=AMP_LOOP_VALUES[1]-AMP_LOOP_VALUES[0]):
        with qp.for_loop(variable=phase, start=PHASE_LOOP_VALUES[0], stop=PHASE_LOOP_VALUES[-1], step=PHASE_LOOP_VALUES[1]-PHASE_LOOP_VALUES[0]):
         
            qpDrag(qp, qubit=q0, amp=np.pi, phase=0) # control qubit on 0
            qpDrag(qp, qubit=q1, amp=np.pi/2, phase=0) # target qubit on |-i>
 
            qp.sync()
            qpM(qp, qubit=q0)
            qpM(qp, qubit=q1)

note that the only variable I changed w.r.t. the above is the number of averages from 1 to 1000

[qililab] [0.22.2|INFO|2024-02-07 16:19:05]: Connecting to instrument cluster_controller_0.
[qililab] [0.22.2|INFO|2024-02-07 16:19:08]: Connecting to instrument rohde_schwarz_controller_0.
[qililab] [0.22.2|INFO|2024-02-07 16:19:08]: Reset instrument rs_1.
[qililab] [0.22.2|INFO|2024-02-07 16:19:08]: Connecting to instrument rohde_schwarz_controller_2.
[qililab] [0.22.2|INFO|2024-02-07 16:19:08]: Reset instrument rs_3.
[qililab] [0.22.2|INFO|2024-02-07 16:19:08]: Connecting to instrument rohde_schwarz_controller_3.
[qililab] [0.22.2|INFO|2024-02-07 16:19:08]: Reset instrument rs_4.
[qililab] [0.22.2|INFO|2024-02-07 16:19:08]: Connecting to instrument attenuator_controller_0.
[qililab] [0.22.2|INFO|2024-02-07 16:19:08]: Reset instrument attenuator.
[qililab] [0.22.2|INFO|2024-02-07 16:19:08]: Connected to the instruments
[qililab] [0.22.2|INFO|2024-02-07 16:19:08]: Initial setup to instrument QRM1.
[qililab] [0.22.2|INFO|2024-02-07 16:19:09]: Initial setup to instrument QCM-RF1.
[qililab] [0.22.2|INFO|2024-02-07 16:19:09]: Initial setup to instrument QCM2.
[qililab] [0.22.2|INFO|2024-02-07 16:19:10]: Initial setup to instrument QCM3.
[qililab] [0.22.2|INFO|2024-02-07 16:19:10]: Initial setup to instrument QCM4.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Initial setup to instrument rs_1.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Initial setup to instrument rs_3.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Initial setup to instrument rs_4.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Initial setup to instrument attenuator.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Initial setup applied to the instruments
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Turn on instrument QRM1.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Turn on instrument QCM-RF1.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Turn on instrument QCM2.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Turn on instrument QCM3.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Turn on instrument QCM4.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Turn on instrument rs_1.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Turn on instrument rs_3.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Turn on instrument rs_4.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Turn on instrument attenuator.
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Instruments turned on
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Sequence program:
 setup:
                wait_sync 4
 
main:
                move 1000, R0
avg_0:
                move 0, R1
                wait_sync 4
                move 40, R2
                move 0, R3
loop_0:
                move 21, R4
                move 0, R5
loop_1:
                wait 40
                play 0, 1, 1200
                acquire 0, R1, 1200
                add R1, 1, R1
                wait 65532
                wait 65532
                wait 65532
                wait 1004
                loop R4, @loop_1
                loop R2, @loop_0
                loop R0, @avg_0
                stop
 
 
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Sequence program:
 setup:
                wait_sync 4
 
main:
                move 1000, R0
avg_0:
                wait_sync 4
                move 40, R1
                move 0, R2
loop_0:
                move 21, R3
                move 0, R4
loop_1:
                set_awg_gain 4293, 4293
                set_ph 0
                play 0, 1, 40
                wait 65532
                wait 65532
                wait 65532
                wait 3404
                loop R3, @loop_1
                loop R1, @loop_0
                loop R0, @avg_0
                stop
 
 
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Sequence program:
 setup:
                wait_sync 4
 
main:
                move 1000, R0
avg_0:
                wait_sync 4
                move 40, R1
                move 0, R2
loop_0:
                move 21, R3
                move 0, R4
loop_1:
                set_awg_gain 2566, 2566
                set_ph 0
                play 0, 1, 40
                wait 65532
                wait 65532
                wait 65532
                wait 3404
                loop R3, @loop_1
                loop R1, @loop_0
                loop R0, @avg_0
                stop
 
 
[qililab] [0.22.2|INFO|2024-02-07 16:19:11]: Sequence program:
 setup:
                wait_sync 4
 
main:
                move 1000, R0
avg_0:
                move 0, R1
                wait_sync 4
                move 40, R2
                move 0, R3
loop_0:
                move 21, R4
                move 0, R5
loop_1:
                wait 40
                play 0, 1, 2500
                acquire 0, R1, 2500
                add R1, 1, R1
                wait 65532
                wait 65532
                wait 63936
                loop R4, @loop_1
                loop R2, @loop_0
                loop R0, @avg_0
                stop
 
 
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/submitit/core/_submit.py", line 11, in
    submitit_main()
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/submitit/core/submission.py", line 76, in submitit_main
    process_job(args.folder)
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/submitit/core/submission.py", line 69, in process_job
    raise error
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/submitit/core/submission.py", line 55, in process_job
    result = delayed.result()
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/submitit/core/utils.py", line 133, in result
    self._result = self.function(*self.args, **self.kwargs)
  File "/home/vsanchez/qililab/src/qililab/slurm.py", line 117, in function
    exec(code, variables) # pylint: disable=exec-used # nosec
  File "", line 27, in
  File "/home/vsanchez/qililab/src/qililab/platform/platform.py", line 620, in execute_qprogram
    return self._execute_qprogram_with_qblox(qprogram=qprogram, bus_mapping=bus_mapping, debug=debug)
  File "/home/vsanchez/qililab/src/qililab/platform/platform.py", line 663, in _execute_qprogram_with_qblox
    bus_results = buses[bus_alias].acquire_qprogram_results(acquisitions=acquisitions)
  File "/home/vsanchez/qililab/src/qililab/platform/components/bus.py", line 235, in acquire_qprogram_results
    return self.system_control.acquire_qprogram_results(acquisitions=acquisitions)
  File "/home/vsanchez/qililab/src/qililab/system_control/readout_system_control.py", line 59, in acquire_qprogram_results
    instrument_results = instrument.acquire_qprogram_results(acquisitions=acquisitions)
  File "/home/vsanchez/qililab/src/qililab/instruments/qblox/qblox_qrm.py", line 130, in acquire_qprogram_results
    return self._get_qprogram_acquisitions(acquisitions=acquisitions)
  File "/home/vsanchez/qililab/src/qililab/instruments/instrument.py", line 152, in __call__
    return self._method(ref, *args, **kwargs) if hasattr(ref, "device") else self._method(*args, **kwargs)
  File "/home/vsanchez/qililab/src/qililab/instruments/qblox/qblox_qrm.py", line 138, in _get_qprogram_acquisitions
    self.device.get_acquisition_state(
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/qblox_instruments/native/generic_func.py", line 539, in decorator_wrapper
    return func(*args, **kwargs)
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/qblox_instruments/native/cluster.py", line 540, in get_acquisition_state
    return gf.get_acquisition_state(funcs, sequencer, timeout, timeout_poll_res)
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/qblox_instruments/native/generic_func.py", line 2155, in get_acquisition_state
    seq_state = get_sequencer_state(
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/qblox_instruments/native/generic_func.py", line 1440, in get_sequencer_state
    raise TimeoutError(
TimeoutError: Sequencer 0 did not stop in timeout period of 1 minutes.
srun: error: galadriel: task 0: Exited with exit code 1

Additional information

I modified the _handle_acquire from qprogram.qblox_compiler so that it does normal acquisitions instead of weighted ones to avoid overflowing the number of registers but this might not be relevant

    def _handle_acquire(self, element: Acquire):
        loops = [
            (i, loop)
            for i, loop in enumerate(self._buses[element.bus].qpy_block_stack)
            if isinstance(loop, QPyProgram.IterativeLoop) and not loop.name.startswith("avg")
        ]
        num_bins = math.prod(loop[1].iterations for loop in loops)
        self._buses[element.bus].qpy_sequence._acquisitions.add(
            name=f"acquisition_{self._buses[element.bus].next_acquisition_index}",
            num_bins=num_bins,
            index=self._buses[element.bus].next_acquisition_index,
        )

        index_I, index_Q, integration_length = self._append_to_weights_of_bus(element.bus, weights=element.weights)

        if num_bins == 1:
            self._buses[element.bus].qpy_block_stack[-1].append_component(
                component=QPyInstructions.AcquireWeighed(
                    acq_index=self._buses[element.bus].next_acquisition_index,
                    bin_index=self._buses[element.bus].next_bin_index,
                    weight_index_0=index_I,
                    weight_index_1=index_Q,
                    wait_time=integration_length,
                )
            )
        else:
            bin_register = QPyProgram.Register()
            block_index_for_move_instruction = loops[0][0] - 1 if loops else -2
            block_index_for_add_instruction = loops[-1][0] if loops else -1
            self._buses[element.bus].qpy_block_stack[block_index_for_move_instruction].append_component(
                component=QPyInstructions.Move(var=self._buses[element.bus].next_bin_index, register=bin_register),
                bot_position=len(self._buses[element.bus].qpy_block_stack[block_index_for_move_instruction].components),
            )
            # register_I, register_Q = QPyProgram.Register(), QPyProgram.Register()
            # self._buses[element.bus].qpy_block_stack[block_index_for_move_instruction].append_component(
            #     component=QPyInstructions.Move(var=index_I, register=register_I),
            #     bot_position=len(self._buses[element.bus].qpy_block_stack[block_index_for_move_instruction].components),
            # )
            # self._buses[element.bus].qpy_block_stack[block_index_for_move_instruction].append_component(
            #     component=QPyInstructions.Move(var=index_Q, register=register_Q),
            #     bot_position=len(self._buses[element.bus].qpy_block_stack[block_index_for_move_instruction].components),
            # )
            # self._buses[element.bus].qpy_block_stack[-1].append_component(
            #     component=QPyInstructions.AcquireWeighed(
            #         acq_index=self._buses[element.bus].next_acquisition_index,
            #         bin_index=bin_register,
            #         weight_index_0=register_I,
            #         weight_index_1=register_Q,
            #         wait_time=integration_length,
            #     )
            # )
            # TODO: test
            self._buses[element.bus].qpy_block_stack[-1].append_component(
                component=QPyInstructions.Acquire(
                    acq_index=self._buses[element.bus].next_acquisition_index,
                    bin_index=bin_register,
                    wait_time=integration_length,
                )
            )
            self._buses[element.bus].qpy_block_stack[block_index_for_add_instruction].append_component(
                component=QPyInstructions.Add(origin=bin_register, var=1, destination=bin_register)
            )
        self._buses[element.bus].static_duration += integration_length
        self._buses[element.bus].next_bin_index = 0  # maybe this counter can be removed completely
        self._buses[element.bus].next_acquisition_index += 1
        self._buses[element.bus].marked_for_sync = True

Source code

No response

Tracebacks

No response

System Information

Name: qililab
Version: 0.21.1
Summary: Fundamental package for fast characterization and calibration of quantum chips.
Home-page: https://github.com/qilimanjaro-tech/qililab
Author: Qilimanjaro Quantum Tech
Author-email: info@qilimanjaro.tech
License: Apache License 2.0
Location: /home/vsanchez/envs/qililab/lib/python3.10/site-packages
Requires: h5py, lmfit, networkx, pandas, papermill, PyVISA-py, PyYAML, qblox-instruments, qcodes, qcodes-contrib-drivers, qibo, qiboconnection, qm-qua, qpysequence, qualang-tools, ruamel.yaml, rustworkx, tqdm, urllib3
Required-by:
 
Platform info: Linux-6.2.0-39-generic-x86_64-with-glibc2.35
Python version: 3.10.12
PyVISA version: 0.5.2
QCodes version: 0.38.1
QCodes Contrib version: 0.18.0
Qblox Instrument version: 0.10.1
Qpysequence version: 0.10.0
Quantum Machines version: 1.1.4
Qibo version: 0.1.12.dev0
 
 
### Existing GitHub issues
 
- [X] I have searched existing GitHub issues to make sure the issue does not already exist.

Minimal working example

import numpy as np
import qililab as ql
import os
from qililab import Domain

# Loops parameters
PHASE_LOOP_VALUES = np.linspace(0, 2 * np.pi, 21)
REPETITION_DURATION = 200_000

# Set the platform from runcard
PLATFORM_PATH = os.path.expanduser("~/LabScripts/QuantumPainHackathon/runcards/soprano_RF.yml")
partition = "galadriel_lab"


platform_qp = ql.build_platform(runcard=os.path.expanduser("~/LabScripts/QuantumPainHackathon/runcards/soprano_RF_qprogram.yml"))

CONTROL_QUBIT = 0
TARGET_QUBIT = 2

# Amplitude parameters
print(f"CZ({CONTROL_QUBIT},{TARGET_QUBIT})")
AMP = platform_qp.get_parameter(alias=f"CZ({CONTROL_QUBIT},{TARGET_QUBIT})", parameter=ql.Parameter.AMPLITUDE)
AMP_STEP = 0.02 # this should be big enough to calibrate, small enough to prevent going over the 2nd minima
AMP_LOOP_VALUES = np.linspace(AMP - AMP_STEP, AMP + AMP_STEP, 40)
B_LOOP_VALUES = np.linspace(0,1,40)  # B/A

qp = ql.QProgram()
amplitude = qp.variable(ql.Domain.Voltage)
phase = qp.variable(ql.Domain.Phase)
nshots = qp.variable(Domain.Scalar, type=int)
qubit = 0

with qp.average(1000):
    with qp.for_loop(variable=amplitude, start=AMP_LOOP_VALUES[0], stop=AMP_LOOP_VALUES[-1], step=AMP_LOOP_VALUES[1]-AMP_LOOP_VALUES[0]):
        with qp.for_loop(variable=phase, start=PHASE_LOOP_VALUES[0], stop=PHASE_LOOP_VALUES[-1], step=PHASE_LOOP_VALUES[1]-PHASE_LOOP_VALUES[0]):
            t = platform_qp.get_parameter(parameter=ql.Parameter.DURATION, alias=f"M({qubit})")
            weights = ql.Square(amplitude=1, duration=t)
            qp.play(bus=f"readout_q{qubit}_bus", waveform=ql.Square(
                amplitude=platform_qp.get_parameter(parameter=ql.Parameter.AMPLITUDE, alias=f"M({qubit})"),
                duration=t))
            qp.acquire(bus=f"readout_q{qubit}_bus", weights=ql.IQPair(I=weights, Q=weights))
            qp.wait(bus=f"readout_q{qubit}_bus",duration=REPETITION_DURATION)


%%submit_job -o job_data -p galadriel_lab -n hwl_snz -t 15

platform_qp.connect()
platform_qp.initial_setup()
platform_qp.turn_on_instruments()

result = platform_qp.execute_qprogram(qp)
job_data = result

platform_qp.disconnect()

data = job_data.result()

outs:

[qililab] [0.22.2|INFO|2024-02-07 17:00:28]: Connecting to instrument cluster_controller_0.
[qililab] [0.22.2|INFO|2024-02-07 17:00:32]: Connecting to instrument rohde_schwarz_controller_0.
[qililab] [0.22.2|INFO|2024-02-07 17:00:32]: Reset instrument rs_1.
[qililab] [0.22.2|INFO|2024-02-07 17:00:32]: Connecting to instrument rohde_schwarz_controller_2.
[qililab] [0.22.2|INFO|2024-02-07 17:00:32]: Reset instrument rs_3.
[qililab] [0.22.2|INFO|2024-02-07 17:00:32]: Connecting to instrument rohde_schwarz_controller_3.
[qililab] [0.22.2|INFO|2024-02-07 17:00:32]: Reset instrument rs_4.
[qililab] [0.22.2|INFO|2024-02-07 17:00:32]: Connecting to instrument attenuator_controller_0.
[qililab] [0.22.2|INFO|2024-02-07 17:00:32]: Reset instrument attenuator.
[qililab] [0.22.2|INFO|2024-02-07 17:00:32]: Connected to the instruments
[qililab] [0.22.2|INFO|2024-02-07 17:00:32]: Initial setup to instrument QRM1.
[qililab] [0.22.2|INFO|2024-02-07 17:00:33]: Initial setup to instrument QCM-RF1.
[qililab] [0.22.2|INFO|2024-02-07 17:00:33]: Initial setup to instrument QCM2.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Initial setup to instrument QCM3.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Initial setup to instrument QCM4.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Initial setup to instrument rs_1.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Initial setup to instrument rs_3.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Initial setup to instrument rs_4.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Initial setup to instrument attenuator.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Initial setup applied to the instruments
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Turn on instrument QRM1.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Turn on instrument QCM-RF1.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Turn on instrument QCM2.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Turn on instrument QCM3.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Turn on instrument QCM4.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Turn on instrument rs_1.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Turn on instrument rs_3.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Turn on instrument rs_4.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Turn on instrument attenuator.
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Instruments turned on
[qililab] [0.22.2|INFO|2024-02-07 17:00:34]: Sequence program: 
 setup:
                wait_sync        4              

main:
                move             1000, R0       
avg_0:
                move             0, R1          
                move             40, R2         
                move             0, R3          
loop_0:
                move             21, R4         
                move             0, R5          
loop_1:
                play             0, 1, 2500     
                acquire          0, R1, 2500    
                add              R1, 1, R1      
                wait             65532          
                wait             65532          
                wait             65532          
                wait             3404           
                loop             R4, @loop_1    
                loop             R2, @loop_0    
                loop             R0, @avg_0     
                stop                            


Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/submitit/core/_submit.py", line 11, in <module>
    submitit_main()
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/submitit/core/submission.py", line 76, in submitit_main
    process_job(args.folder)
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/submitit/core/submission.py", line 69, in process_job
    raise error
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/submitit/core/submission.py", line 55, in process_job
    result = delayed.result()
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/submitit/core/utils.py", line 133, in result
    self._result = self.function(*self.args, **self.kwargs)
  File "/home/vsanchez/qililab/src/qililab/slurm.py", line 117, in function
    exec(code, variables)  # pylint: disable=exec-used # nosec
  File "<string>", line 10, in <module>
  File "/home/vsanchez/qililab/src/qililab/platform/platform.py", line 620, in execute_qprogram
    return self._execute_qprogram_with_qblox(qprogram=qprogram, bus_mapping=bus_mapping, debug=debug)
  File "/home/vsanchez/qililab/src/qililab/platform/platform.py", line 663, in _execute_qprogram_with_qblox
    bus_results = buses[bus_alias].acquire_qprogram_results(acquisitions=acquisitions)
  File "/home/vsanchez/qililab/src/qililab/platform/components/bus.py", line 235, in acquire_qprogram_results
    return self.system_control.acquire_qprogram_results(acquisitions=acquisitions)
  File "/home/vsanchez/qililab/src/qililab/system_control/readout_system_control.py", line 59, in acquire_qprogram_results
    instrument_results = instrument.acquire_qprogram_results(acquisitions=acquisitions)
  File "/home/vsanchez/qililab/src/qililab/instruments/qblox/qblox_qrm.py", line 130, in acquire_qprogram_results
    return self._get_qprogram_acquisitions(acquisitions=acquisitions)
  File "/home/vsanchez/qililab/src/qililab/instruments/instrument.py", line 152, in __call__
    return self._method(ref, *args, **kwargs) if hasattr(ref, "device") else self._method(*args, **kwargs)
  File "/home/vsanchez/qililab/src/qililab/instruments/qblox/qblox_qrm.py", line 138, in _get_qprogram_acquisitions
    self.device.get_acquisition_state(
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/qblox_instruments/native/generic_func.py", line 539, in decorator_wrapper
    return func(*args, **kwargs)
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/qblox_instruments/native/cluster.py", line 540, in get_acquisition_state
    return gf.get_acquisition_state(funcs, sequencer, timeout, timeout_poll_res)
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/qblox_instruments/native/generic_func.py", line 2155, in get_acquisition_state
    seq_state = get_sequencer_state(
  File "/home/vsanchez/envs/qililab/lib/python3.10/site-packages/qblox_instruments/native/generic_func.py", line 1440, in get_sequencer_state
    raise TimeoutError(
TimeoutError: Sequencer 0 did not stop in timeout period of 1 minutes.
srun: error: galadriel: task 0: Exited with exit code 1

Thanks to @4dri8 for pointing out that this is an issue with the sequencer's timeout being too short for this kind of program and once can just increase the value in the runcard!