qiboteam / qibosoq

Qibo server for Qick
https://qibo.science
Apache License 2.0
11 stars 2 forks source link

Qibosoq improvements #109

Closed JavierSerranoGarcia closed 3 months ago

JavierSerranoGarcia commented 6 months ago

Hi @rodolfocarobene, we should work on some issues/improvements next week.

  1. Allow declared channels at full speed, multiplexed and interpolated at the same experiment.
  2. Move to PYNQ 3.0. I already created an SD card with it. Now we have to test it with qibosoq.
  3. Improve the duration estimation of the calibration experiments.
  4. Robustify qibosoq against small issues (buffer overflow, tproc not fast enough, running server,...) that happen "randomly".

and whatever we will come up with.

rodolfocarobene commented 6 months ago

Hi @JavierSerranoGarcia, thanks for the list!

Regarding (1), could you prepare some kind of notebook / example on how to use these channels with QICK (not qibosoq)? It would be very useful for me since I never used the interpolated channels

JavierSerranoGarcia commented 5 months ago

Hi @rodolfocarobene, as we talked last week we need to use ASAP the interpolated channel with qibosoq. Do you think you could do it in the weeks?

rodolfocarobene commented 5 months ago

Hi @JavierSerranoGarcia, yes I should be able to implement interpolated channels in this week (max the next one). But it would be really useful if you could share with me the working notebook you should me last week. I remember that I have to add the "mixer" parameter, but I am not sure where...

JavierSerranoGarcia commented 5 months ago

So @rodolfocarobene , here you are

from qick import *
from tqdm.notebook import tqdm

soc = QickSoc("../qick/firmware/qick_qibo_v2.bit")
soccfg = soc

# Setup configuration parameters
hw_cfg={"res_ch":6,
        "qubit_ch":9
       }
readout_cfg={
    "readout_length":soccfg.us2cycles(3.0, gen_ch=hw_cfg["res_ch"]), # [Clock ticks]
    "f_res": -200, # [MHz]
    "res_phase": 0,
    "adc_trig_offset": 175, # [Clock ticks]
    "res_gain":30000
    }
qubit_cfg={
    "sigma":soccfg.us2cycles(0.025, gen_ch=9),
    "pi_gain": 11500,
    "pi2_gain":11500//2, 
    "f_ge":4743.041802067813,
    "relax_delay":500
}
feedback_ch = 0 
mixer_f=7300

class SingleToneSpectroscopyProgram(AveragerProgram):
    def initialize(self):
        cfg=self.cfg   
        self.declare_gen(ch=cfg["res_ch"], nqz=2, mixer_freq=mixer_f, ro_ch=feedback_ch ) #Readout
        for ch in [feedback_ch]: #configure the readout lengths and downconversion frequencies
            self.declare_readout(ch=ch, length=cfg["readout_length"],
                                 freq=cfg["frequency"], gen_ch=cfg["res_ch"])

        freq=self.freq2reg(cfg["frequency"], gen_ch=cfg["res_ch"], ro_ch=feedback_ch)  # convert frequency to dac frequency (ensuring it is an available adc frequency)
        self.set_pulse_registers(ch=cfg["res_ch"], style="const", freq=freq, phase=0, gain=cfg["res_gain"],
                                length=cfg["readout_length"])

        self.synci(200)  # give processor some time to configure pulses

    def body(self):
        self.measure(pulse_ch=self.cfg["res_ch"], 
             adcs=[feedback_ch],
             adc_trig_offset=self.cfg["adc_trig_offset"],
             wait=True,
             syncdelay=self.us2cycles(self.cfg["relax_delay"])) 

expt_cfg={"reps":1000, "relax_delay":10,
          "start":7300-mixer_f, "step":1, "expts":200
         }
config={**hw_cfg,**readout_cfg,**qubit_cfg,**expt_cfg} #combine configs

fpts=expt_cfg["start"] + expt_cfg["step"]*np.arange(expt_cfg["expts"])

amps=[]
for f in tqdm(fpts):
    config["frequency"]=f

    rspec=SingleToneSpectroscopyProgram(soccfg, config)
    avgi,avgq=rspec.acquire(soc)
    amp=np.abs(avgi[0][0]+1j*avgq[0][0])
    amps.append(amp)
amps=np.array(amps)

plt.subplot(111,title="Resonator Spectroscopy", xlabel="Resonator Frequency (MHz)", ylabel="Amp. (adc level)")
plt.plot(fpts+mixer_f, amps,'o-')
max_freq=fpts[np.argmax(amps)]
plt.show()
rodolfocarobene commented 5 months ago

Thanks @JavierSerranoGarcia, I started to draft for supporting the interpolated channel.

However, I have some questions: from qibolab how do you want to specify the mixer frequency? Since it is not a standard parameter I see two options:

I have also other questions:

JavierSerranoGarcia commented 5 months ago

Hi @rodolfocarobene,

We should do the same as other instruments and set it in the platform (channel object) and in the runcard the parameter value port.lo_frequency.

The sweeper should sweep the frequency with a fixed mixer frequency. The interpolated channel frequencies must be between [-fs/2, fs/2] being fs in some channels 4915 and other 6881. So the bandwidth is quite large.

I am leaving on vacation for a couple of weeks so probably I will answer emails.