Cross Resonance calibration - #1414
Conversation
6b72310 to
20a7155
Compare
|
@alecandido in this PR I think we can delete the following files, which were inherited from #1131:
then maybe we can move all files from src/qibocal/protocols/two_qubit_interaction/cross_resonance/hamiltonian_tomography in the upstream folder, and eventually merge the two |
|
What were the two files doing? And where is it done now? |
They were simply doing the CR calibration by either sweeping CR pulse duration or CR amplitude, but there was not implemented Hamiltonian Tomography, simply evaluating the 'distance' of the two trajectories (i.e. when control in 0 or in 1) only along Z. |
Ok, I agree. We definitely have a better option. It's true that the better option requires some more measurements, but it is still always affordable, and it's a fair price to pay for the accuracy. |
def830e to
9cdb9d3
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1414 +/- ##
==========================================
- Coverage 94.41% 92.02% -2.40%
==========================================
Files 136 145 +9
Lines 10636 11569 +933
==========================================
+ Hits 10042 10646 +604
- Misses 594 923 +329
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
8e1b543 to
7dac201
Compare
alecandido
left a comment
There was a problem hiding this comment.
Very first batch.
Still missing all the protocols and Quinn-Fernandes
There was a problem hiding this comment.
Given this is more a "protocol suite" than a single protocol, we should put some care in documenting it properly, to avoid confusion about the roles of the various protocols.
In this sense, this page is quite fundamental.
There was a problem hiding this comment.
I agree, I'll keep doc updating as last fix.
| Sweeping the duration of the CR pulse | ||
| ------------------------------------- | ||
|
|
||
| In a first experiment we can sweep the duration of the CR pulse and measure both the | ||
| target and control qubit. The measurement is performed while preparing the control | ||
| qubit in state :math:`\ket{0}` and :math:`\ket{1}`. | ||
|
|
||
| Parameters | ||
| ^^^^^^^^^^ | ||
|
|
||
| .. autoclass:: qibocal.protocols.two_qubit_interaction.cross_resonance.length.CrossResonanceLengthParameters | ||
| :noindex: | ||
|
|
||
| Example | ||
| ^^^^^^^ | ||
|
|
||
| A possible runcard to launch the experiment could be the following: | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| - id: CR length | ||
| operation: cross_resonance_length | ||
| parameters: | ||
| targets: [[0,1]] | ||
| pulse_duration_start: 10 | ||
| pulse_duration_end: 200 | ||
| pulse_duration_step: 10 | ||
| flux_pulse_amplitude: 0.1 | ||
| nshots: 2000 | ||
| relaxation_time: 50000 | ||
|
|
||
|
|
||
| The expected output is the following: | ||
|
|
||
| .. image:: length.png | ||
|
|
||
| Post-processing | ||
| ^^^^^^^^^^^^^^^ | ||
|
|
||
| The probability of the target qubit is fitted in both cases to a dumped cosine functions. | ||
| It is possible to extract the effective coupling as | ||
|
|
||
| .. math:: | ||
|
|
||
| \text{J}_\text{eff}/ 2 \pi = \frac{f^{\pi}_\text{Rabi} - f_\text{Rabi}}{2} | ||
|
|
||
|
|
||
| where :math:`f^{\pi}_\text{Rabi}` and :math:`f_\text{Rabi}` are the frequencies of the | ||
| fitted Rabi oscillations on the target qubit. |
There was a problem hiding this comment.
This protocol does not exist any longer (to the best of my knowledge) since it has been replaced by hamiltonian_tomography_cr_length (unless it is cr_crosstalk_length, I'm still confused about that).
There was a problem hiding this comment.
actually there was already a first implementation of the hamiltonian tomography, but yeah we are no longer relying on that. I think documentation will be the last thing I'll fix before merging.
| Sweeping amplitude of the CR pulse | ||
| ---------------------------------- | ||
|
|
||
| Similarly it is possible to sweep the amplitude of the CR pulse and measure both the | ||
| target and control qubit. | ||
|
|
||
|
|
||
| Parameters | ||
| ^^^^^^^^^^ | ||
|
|
||
| .. autoclass:: qibocal.protocols.two_qubit_interaction.cross_resonance.length.CrossResonanceLengthParameters | ||
| :noindex: | ||
|
|
||
| Example | ||
| ^^^^^^^ | ||
|
|
||
| A possible runcard to launch the experiment could be the following: | ||
|
|
||
| .. code-block:: yaml | ||
|
|
||
| - id: CR amplitude | ||
| operation: cross_resonance_amplitude | ||
| parameters: | ||
| targets: [[0,1]] | ||
| max_amp: 0.05 | ||
| min_amp: 0.01 | ||
| step_amp: 0.005 | ||
| pulse_duration: 100 | ||
| nshots: 2000 | ||
| relaxation_time: 50000 | ||
|
|
||
|
|
||
| The expected output is the following: | ||
|
|
||
| .. image:: amplitude.png | ||
|
|
||
| Post-processing | ||
| ^^^^^^^^^^^^^^^ | ||
|
|
||
| The probability of the target qubit is fitted in both cases to a cosine function. |
| "hamiltonian_tomography_cr_amplitude", | ||
| "hamiltonian_tomography_cr_length", | ||
| "hamiltonian_tomography_canc_phase", | ||
| "hamiltonian_tomography_canc_amplitude", |
There was a problem hiding this comment.
If we decide to only provide the Hamiltonian tomography variant of these protocols, prepending them by hamiltonian_tomography_ is just redundant.
There was a problem hiding this comment.
Moreover, we may consider to disable the X and Y components in the basic amplitude and length, for a faster calibration (not sure if useful at any time). However, it may still be more convenient to have them as flags limiting the full protocol (seen as a performance tradeoff), rather than fully separate protocols.
Even if agreed, this would be just a performance improvement, and it should be addressed in a separate PR (in case, let's just open an issue).
There was a problem hiding this comment.
If we do only Z we cannot then tune the cancellation pulse, then we are essentially doing the Cross Rabi experiment.
We could create a wrapper protocol calling the general rabi protocols.
There was a problem hiding this comment.
Indeed, you're right. It would be just cross-Rabi, but a conditional one, i.e. with the extra feature of toggling the qubit related to the drive channel, producing two series of data.
So, it is somewhere in between cross-Rabi and an actual CR
| .. code-block:: yaml | ||
|
|
||
| - id: Hamiltonian tomography CR | ||
| operation: cross_resonance_amplitude | ||
| parameters: | ||
| targets: [[0,1]] | ||
| nshots: 2000 | ||
| pulse_amplitude: 0.1 | ||
| pulse_duration_end: 400 | ||
| pulse_duration_start: 10 | ||
| pulse_duration_step: 20 | ||
|
|
||
|
|
||
| The expected output is the following: | ||
|
|
||
| .. image:: tomography_length.png |
There was a problem hiding this comment.
This is definitely inconsistent. If nothing else, at least the operation: key
There was a problem hiding this comment.
why is it inconsistent?
There was a problem hiding this comment.
Maybe inconsistent was misleading, as a word. Let's say outdated
alecandido
left a comment
There was a problem hiding this comment.
Still missing 5 protocols and 3 utils files.
Not even sure why we have 5 protocols, since I only expected 4 (amplitude, length, cancellation phase, cancellation amplitude). But I already wrote this somewhere else, and I will eventually figure out what are the off_res* ones
|
|
||
| pi_pulse_parameter = popt[2] / 2 * period_correction_factor(phase=popt[3]) | ||
| return popt, perr, pi_pulse_parameter | ||
| return popt.tolist(), perr.tolist(), pi_pulse_parameter |
There was a problem hiding this comment.
popt seems to be a list if coming from the if branch. In which case, it would raise an error for .tolist(). The LSP should tell you about this
There was a problem hiding this comment.
you're right, silly error
There was a problem hiding this comment.
Btw do you know why perr is manipulated only for signal==False?
There was a problem hiding this comment.
To be fair, that's a good point. It doesn't seem meaningful, since we want to extract the variances.
However, even that is wrong: we care about covariances, since we are not just using popt, but we are actually turning it into another popt (which is shadowing, and changing the meaning of the variable - we truly need a different name for the variable assigned with the if: ... else: ... branch). So, we need error propagation, and the distributions of popt are not at all independent.
Right now, perr is just outright wrong
There was a problem hiding this comment.
ok, so do you have any plan for that?
| control_phase: float = 0.0 | ||
| """Phase of the CR pulse on the control qubit""" | ||
| target_phase: float = 0.0 | ||
| """Phase of the Cancellation pulse on the target qubit""" |
There was a problem hiding this comment.
In a sense, better more parameters than less. But... what do we need these for?
There was a problem hiding this comment.
I think it depend how do you interpret these package of experiments...
In fact, if we consider them as Hamiltonian Tomography, where then we estimate the contributions of each Hamiltonian term, then we should be as most flexible in the parameters as possible. Otherwise, if we only consider them for calibrating from scratch the CR pulse, then I agree with you and can be deleted, also with target_amplitude I would say.
Or maybe can be used in maintaining the calibration?
92bdf88 to
998bae6
Compare
…f cancellation amplitude calibration protocol
…mplitude calibration
…g) - succeeding tests plus refactoring of parameters extraction
…still to be tested
…older. Also creating Parent sharedf classed for Data, Results and Parametrers used for each Hamiltonian Tomography experiment.
7f39c41 to
6319a26
Compare
This PR contains the whole calibration of the Cross Resonance gate as described by the CR IBM paper.
The main method exploited is the so called
Hamltonian Tomography, defined as the process of inferring a quantum system’s Hamiltonian from observed dynamics. The algorithm is quite simple: after preparing known states, we let them evolve, then measure outcomes, and fit a model to estimate the terms in the theoretical Hamiltonian model.This PR gives the freedom of the user to calibrate the CR in different levels of accuracy:
Simple CR calibration: by simply sweeping over time (or control qubit amplitude) we determine the pulse parameters; the sequence is composed by simply one pulse applied on the control qubit with the frequency of the target one.
Echo CR sequence calibration: simply in this case the pulse sequence is more convoluted, since it consists on two CR pulses out-of-phase interleaved by two$\pi$ -pulses on the control qubit; this pulse sequence improves the performances of the whole gate since it refocuses specific sources of noise.
CR with Cancellation calibration: we add to the echo sequence two out-of phase pulses to the target qubit which are synched to the CR pulses; this calibration refocuses the remaining sources of noise, but additional parameters (i.e. cancellation and CR pulses phases and cancellation amplitude) have to be calibrated.
Here is a scheme of the different calibrations:
this is a followup of PR #1131.
In addition, this PR requires a new emulator version from Qibolab #1416, Qibolab #1412 and Qibolab #1401.
Some suggestions for eventual improvements: