Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cryoscope post-processing #1064

Draft
wants to merge 16 commits into
base: test_cryoscope
Choose a base branch
from

Conversation

ElStabilini
Copy link
Contributor

I added the first post-processing routines to the cryoscope protocol described in #974:

  • Added the flux_coefficients attribute to the Qubit class to store the output of flux_amplitude_frequency
  • Added update method for flux_amplitude_frequency
  • Apply single exponential correction to the flux signal
  • Update filters values in parameters.json

It's still a work in progress as I still need to figure out how to determine more precisely the filters and add the FIR filters

@alecandido alecandido changed the base branch from main to test_cryoscope January 13, 2025 17:17
Copy link

codecov bot commented Jan 14, 2025

Codecov Report

Attention: Patch coverage is 96.42857% with 3 lines in your changes missing coverage. Please review.

Project coverage is 96.97%. Comparing base (5544539) to head (2e705ad).
Report is 136 commits behind head on test_cryoscope.

Files with missing lines Patch % Lines
...bocal/protocols/two_qubit_interaction/cryoscope.py 97.22% 2 Missing ⚠️
src/qibocal/update.py 83.33% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##           test_cryoscope    #1064      +/-   ##
==================================================
- Coverage           97.11%   96.97%   -0.15%     
==================================================
  Files                 101      101              
  Lines                8178     8255      +77     
==================================================
+ Hits                 7942     8005      +63     
- Misses                236      250      +14     
Flag Coverage Δ
unittests 96.97% <96.42%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/qibocal/calibration/calibration.py 96.49% <100.00%> (+0.06%) ⬆️
src/qibocal/protocols/flux_amplitude_frequency.py 100.00% <100.00%> (ø)
src/qibocal/update.py 94.84% <83.33%> (-0.76%) ⬇️
...bocal/protocols/two_qubit_interaction/cryoscope.py 97.82% <97.22%> (-0.48%) ⬇️

... and 5 files with indirect coverage changes

@ElStabilini
Copy link
Contributor Author

ElStabilini commented Jan 16, 2025

TO DO:

  • add limitation on filters values
  • increase number of exponential correction
  • implement method to get the correct flux pulse amplitude (& add call in cryoscope _acquisition)
  • add FIR correction
  • Insert control on waveform

@ElStabilini
Copy link
Contributor Author

ElStabilini commented Jan 16, 2025

The waveform sent with cryoscope routine is defined (https://github.com/qiboteam/qibocal/blob/0fd56c283c3e99db23ca54799c69e3027bdc8f28/src/qibocal/protocols/two_qubit_interaction/cryoscope.py#L27C1-L27C60) if in the runcard the duration > len(FULL_WAVEFORM) then the code will raise the following error:

Error

Traceback (most recent call last):
  File "/nfs/users/elisa.stabilini/calibration/bin/qq", line 8, in <module>
    sys.exit(command())
  File "/nfs/users/elisa.stabilini/calibration/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/nfs/users/elisa.stabilini/calibration/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/nfs/users/elisa.stabilini/calibration/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/nfs/users/elisa.stabilini/calibration/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/nfs/users/elisa.stabilini/calibration/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/nfs/users/elisa.stabilini/qibocal/src/qibocal/cli/_base.py", line 75, in run
    protocols_execution(runcard, folder, force, update)
  File "/nfs/users/elisa.stabilini/qibocal/src/qibocal/cli/run.py", line 44, in protocols_execution
    history = runcard.run(
  File "/nfs/users/elisa.stabilini/qibocal/src/qibocal/auto/runcard.py", line 63, in run
    instance.run_protocol(
  File "/nfs/users/elisa.stabilini/qibocal/src/qibocal/auto/execute.py", line 130, in run_protocol
    completed = task.run(platform=self.platform, targets=self.targets, mode=mode)
  File "/nfs/users/elisa.stabilini/qibocal/src/qibocal/auto/task.py", line 159, in run
    completed.data, completed.data_time = operation.acquisition(
  File "/nfs/users/elisa.stabilini/qibocal/src/qibocal/auto/operation.py", line 40, in wrapper
    out = func(*args, **kwds)
  File "/nfs/users/elisa.stabilini/qibocal/src/qibocal/protocols/two_qubit_interaction/cryoscope.py", line 187, in _acquisition
    results_x = platform.execute(sequences_x, **options)
  File "/nfs/users/elisa.stabilini/qibolab/src/qibolab/_core/platform/platform.py", line 290, in execute
    results |= self._execute(b, options, configs, sweepers)
  File "/nfs/users/elisa.stabilini/qibolab/src/qibolab/_core/platform/platform.py", line 224, in _execute
    new_result = instrument.play(configs, sequences, options, sweepers)
  File "/nfs/users/elisa.stabilini/qibolab/src/qibolab/_core/instruments/qm/controller.py", line 512, in play
    self.register_pulses(configs, sequence)
  File "/nfs/users/elisa.stabilini/qibolab/src/qibolab/_core/instruments/qm/controller.py", line 342, in register_pulses
    self.register_pulse(id, configs[id], pulse)
  File "/nfs/users/elisa.stabilini/qibolab/src/qibolab/_core/instruments/qm/controller.py", line 319, in register_pulse
    return self.config.register_dc_pulse(channel, pulse, max_voltage)
  File "/nfs/users/elisa.stabilini/qibolab/src/qibolab/_core/instruments/qm/config/config.py", line 167, in register_dc_pulse
    self.pulses[op] = self.register_waveforms(pulse, max_voltage, dc=True)
  File "/nfs/users/elisa.stabilini/qibolab/src/qibolab/_core/instruments/qm/config/config.py", line 149, in register_waveforms
    waveforms = waveforms_from_pulse(pulse, max_voltage)
  File "/nfs/users/elisa.stabilini/qibolab/src/qibolab/_core/instruments/qm/config/pulses.py", line 82, in waveforms_from_pulse
    return wvtype.from_pulse(pulse, max_voltage)
  File "/nfs/users/elisa.stabilini/qibolab/src/qibolab/_core/instruments/qm/config/pulses.py", line 60, in from_pulse
    original_waveforms = pulse.envelopes(SAMPLING_RATE) * max_voltage
  File "/nfs/users/elisa.stabilini/qibolab/src/qibolab/_core/pulses/pulse.py", line 69, in envelopes
    return np.array([self.i(sampling_rate), self.q(sampling_rate)])
  File "/nfs/users/elisa.stabilini/qibolab/src/qibolab/_core/pulses/pulse.py", line 60, in i
    return self.amplitude * self.envelope.i(samples)
  File "/nfs/users/elisa.stabilini/qibolab/src/qibolab/_core/pulses/envelope.py", line 351, in i
    raise ValueError
ValueError

@alecandido
Copy link
Member

alecandido commented Jan 16, 2025

Ok, it's true that I've been lazy, and didn't fill all the exception messages. But what is happening here is not that obscure...

https://github.com/qiboteam/qibolab/blob/01f18860ad80b8f981e0be32fe60193a27fccb40/src/qibolab/_core/pulses/envelope.py#L350-L351

If you define a Custom pulse with a certain amount of samples, and then you ask for a pulse with that envelope, but with an incompatible duration (i.e. requiring a different number of samples), the envelope is raising an exception, instead of computing the samples.

This is one of the limitations of using Custom. In principle, we could interpolate the samples (it's one SciPy function call). But I deemed this as an unexpected behavior by the Custom user, which would assume to have complete control over the samples, without any kind of approximation.

@ElStabilini
Copy link
Contributor Author

Ok, it's true that I've been lazy, and didn't fill all the exception messages. But what is happening here is not that obscure...

https://github.com/qiboteam/qibolab/blob/01f18860ad80b8f981e0be32fe60193a27fccb40/src/qibolab/_core/pulses/envelope.py#L350-L351

If you define a Custom pulse with a certain amount of samples, and then you ask for a pulse with that envelope, but with an incompatible duration (i.e. requiring a different number of samples), the envelope is raising an exception, instead of computing the samples.

This is one of the limitations of using Custom. In principle, we could interpolate the samples (it's one SciPy function call). But I deemed this as an unexpected behavior by the Custom user, which would assume to have complete control over the samples, without any kind of approximation.

Thank you @alecandido, today @andrea-pasquale helped me understanding that! I posted it here also as a reminder for me to add a control on the duration or change the waveform (I also added it to the TO-DO list :) )

@alecandido
Copy link
Member

@ElStabilini perfect. Even posting known issues is welcome, since they may be a nice reference.

If you already know the solution, so much the better. But at that point, you may post even that, for the future reader looking for the same problem :)

@andrea-pasquale
Copy link
Contributor

Thank you @alecandido, today @andrea-pasquale helped me understanding that! I posted it here also as a reminder for me to add a control on the duration or change the waveform (I also added it to the TO-DO list :) )

Given what we are doing I suggest to just stick with a Rectangular waveform to simplify the calculation of the filters :)

@ElStabilini
Copy link
Contributor Author

I tried to add limitations to the filter values following QM documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants