Do not modify original schedule in qcompile

  • Quantify version: develop

Disclaimer: I am mocking up some things, apologies for not providing executable code.

@AdriaanRol @adamorangeqs @jvoven @kel85uk please mind this bug!!!

Description

Run this kind of cell twice (or more in the same python kernel)

_, progs = qcompile(
    schedule=sched_abs,
    device_cfg=ss.SPIN_DEVICE_CFG,
    hardware_mapping=ss.SPIN_HARDWARE_MAPPING
)

for seq_idx in range(2):
    fn = progs["qcm0"][f"seq{seq_idx}"]["seq_fn"]
    print(fn, ":\n")
    with open(fn, "r") as file:
        result = json.load(file)
        print(result["program"])

this will end up producing something like this the first time:

/Users/Victor/quantify-data/schedules/20210414-131320-554-b4e8bc/RP_baseband_sequencer_cfg.json :

          
          move          1,R0                                        
          wait_sync     4              #sync                        
  start:  set_mrk       1                                           
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,20                                      
          wait          8              #Sync with other sequencers  
                                                                    
          loop          R0,@start                                   
          stop                                                      

BUT the next time(s) you tun the same cel it will produce unexpected instructions:

/Users/Victor/quantify-data/schedules/20210414-130759-630-9dd3aa/RP_baseband_sequencer_cfg.json :

          
          move          1,R0                                        
          wait_sync     4              #sync                        
  start:  set_mrk       1                                           
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  -13107,-13107  #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  0,0            #Set gain                    
          play          0,1,20                                      
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,0                                       
                                                                    
          set_awg_gain  13107,13107    #Set gain                    
          play          0,1,20                                      
          wait          8              #Sync with other sequencers  
                                                                    
          loop          R0,@start                                   
          stop                                                   

What Was Expected

Running the qcompile repeated times would not modify the original schedule. Or would raise some kind of exception in the worse case (probably not desired for UX reasons)

What Actually Happened

It seems that the original dict holding the schedule information gets modified and this leads to very unexpected program output