-
Notifications
You must be signed in to change notification settings - Fork 7
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
Include update methods in all protocols #526
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing this @andrea-pasquale. It looks good to me, so I would say to go ahead with the rest of methods (after @alecandido's review).
The only thing that seems a bit annoying is that the for loop over qubits is repeated in all update methods. One way to solve this would be to lift it to Task.update_platform
but I am not sure if this will create problems in the longer term, maybe for two-qubit gate routines, etc. where we may need full flexibility when defining _update
.
I agree with @stavros11, this is mostly fine, in that the overall structure is perfect (at least I'd not have any better proposal right now). Please, keep going. And thanks for this :) |
Codecov Report
@@ Coverage Diff @@
## main #526 +/- ##
==========================================
+ Coverage 96.47% 96.59% +0.12%
==========================================
Files 66 67 +1
Lines 4846 4998 +152
==========================================
+ Hits 4675 4828 +153
+ Misses 171 170 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
In principle this is done, I think. |
src/qibocal/update.py
Outdated
for qubit, beta in results.items(): | ||
shape = platform.qubits[qubit].native_gates.RX.shape | ||
rel_sigma = re.findall(r"[\d]+[.\d]+|[\d]*[.][\d]+|[\d]+", shape)[0] | ||
drag_pulse = pulses.Drag(rel_sigma=rel_sigma, beta=beta) | ||
platform.qubits[qubit].native_gates.RX.shape = repr(drag_pulse) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stavros11 I had to these weird shenanigans since apparently native_gates.RX.shape
will give me the serial of the pulse shape and not the pulse shape object by itself.
Is there any reason to return the str and not the object itself?
I'm guessing that this is mostly related to the serialization of the native pulse
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @andrea-pasquale for this. To me, it's perfect (and it has been incredibly fast).
The problem of the loops (repeated operations for qubits and pairs) in a sense is a long-standing one, because it is related to the multi-qubit calibration, for which we never had a very clear plan.
The message is: if there is not already one, open a dedicated issue, and we will solve anyhow in a dedicated PR.
The only tiny remark is that you're mixing this relevant and general update with something specific to the Chevron, that maybe would have been worth to examine in a separate PR as well.
Actually I might be close to find a solution for this.
Yeah, I know. I just did it since #520 is ready to merge I just need a second approval and I already fixed a few things there. I didn't want to open a second PR just for the chevron. Finally, this PR does not tackle the update of the twpa parameters since the interface is currently being developed in qiboteam/qibolab#585 |
For loop implemented :) |
Saw it, that's definitely a possible solution. I wonder if it's worth to have the whole routines working just for individual qubit/pair. |
@@ -94,6 +94,11 @@ def update(self): | |||
"""Local update parameter.""" | |||
return self.action.update | |||
|
|||
def update_platform(self, results: Results, platform: Platform): | |||
if self.update: | |||
for qubit in self.qubits: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.qubits
are actually pairs for two-qubits routines, isn't it?
(btw, maybe a brief docstring for this function would be nice)
@andrea-pasquale since the Chevron might require slightly more time, would you consider removing it from here, such that we can immediately merge this in
Or is there any other limitation for which we need the Chevron to merge the update? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or is there any other limitation for which we need the Chevron to merge the update?
I think they are independent, so it should be possible to merge this before the Chevron fit. However, given that the Chevron fit is an enhancement and does not break any existing functionality, I am not sure if it is worth going through the trouble reversing the order now. The fit most likely won't be perfect but if it is on main it will be easier to test and improve.
The current PR also looks good to be merged.
I wonder if it's worth to have the whole routines working just for individual qubit/pair. I believe the case of the
fit
will be similar to theupdate
, but maybe it is convenient to make the acquisition in parallel (or maybe not, in which case we could really write the routines per qubit/pair, and keep the multi-thing at the level of the executor - in a separate PR, of course).
For fit
it may be possible, however for the acquisition it may be complex. With the current qibolab, if you want to take advantage of multiplex, you need to create a PulseSequence
that targets multiple qubits and send it in a single platform.execute_pulse_sequence
call. Lifting that to the executor will reduce our flexibility when writing routines, for example what if you want to execute two different sequences, on multiple qubits each. There may be a better design that allows this though.
src/qibocal/update.py
Outdated
shape = platform.qubits[qubit].native_gates.RX.shape | ||
rel_sigma = re.findall(r"[\d]+[.\d]+|[\d]*[.][\d]+|[\d]+", shape)[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not tested but this can probably be simplified using
shape = platform.qubits[qubit].native_gates.RX.shape | |
rel_sigma = re.findall(r"[\d]+[.\d]+|[\d]*[.][\d]+|[\d]+", shape)[0] | |
pulse = platform.qubits[qubit].native_gates.RX.pulse(start=0) | |
rel_sigma = pulse.shape.rel_sigma |
This will basically delegate the shenanigans to qibolab's pulse constructor, but better to have them in a single place instead of two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @stavros11, I'll give it a try.
In theory they are independent, I decided to make this PR point to
I agree with pretty much everything that @stavros11 said. |
I agree it is out of scope for the PR, but it is not even urgent right now in general. We can rediscuss when we'll have lifted the main bottlenecks for autocalibration (and this is not one of them). |
I'd like this to be merged asap, in order to:
So, if you want to merge #520 before, that's even fine. But if possible, let's do it soon. Otherwise, the proposal above is because I do not feel much pressure about merging #520, but I'd like to merge this soon. |
I'm about to push a few fixes here but in principle both this PR and #520 are ready to merge. I prefer to merge #520 first I don't think that it is necessary to merge this one and afterwards #520. |
As soon as CI passes I will merge also this one. |
Thank you very much :D |
This PR aims at removing the
platform.update
method in qibolab by delegating to qibocal the update of the platform.This is possible since qibocal has access to all the primitives in qibolab to peform this operation.
@alecandido @stavros11 I think that this is more or less what we discussed yesterday.
I'm encapsulating each parameter update in a function in update.py for two reasons:
qibocal/src/qibocal/update.py
Lines 8 to 16 in 36eeb5d
For now I implemented the new proposal only for resonator spectroscopy.
If you agree with it I will propagate the change for all protocols in qibocal.
Checklist:
master
main
main