Closed hay-k closed 4 months ago
Thanks @hay-k for start polishing it, it was due since long.
I assigned @Jacfomg as a reviewer, because he's the original author of these drivers, so it's interesting to have his opinion already at an early stage (though I'm pretty sure you already discussed with him about the topic).
Btw, most likely the module could also be radically rearranged, so feel free to start simplifying things adiabatically, but also start thinking about how things could be better organized in case you started from scratch.
A further point, that I might have already remarked, is that laboneq
is doing many things that are also done by Qibolab. So, for as long as its abstractions match, and it's convenient, it is fine to keep using them. But as soon as the conversion from one to the other start being verbose and not that intuitive, we may move to the lower level Zurich drivers.
(Trivial comment: a file of >1k lines has to be splitted asap)
@hay-k what about this? https://github.com/qiboteam/qibolab/blob/0d27c8b1e47f22f7417c606070dcf3f308d4fec4/src/qibolab/instruments/zhinst.py#L78 (and the related lines below)
I'm not sure how it works: to my naive understanding, it should be a unique identifier of the pulse within the experiment, such that you construct your library of pulses to be played in a single batch, and then you download all the results in a single transaction.
I expected them to be overly specific, and that they should have been deduplicated. But this ID seems to me too generic, just specifying the pulse qubit and type (i.e. pulse.type.name.lower()
, corresponding to the channel type, in the 0.1 pulse style).
How is it possible that there is no clash?
@hay-k a few simple requests, before an actual review:
this file is still 1k lines, spanning everything that is required for ZI - would you try to split it in smaller ones
I was thinking to do it in a separate PR, so that the diff for this one looks a bit nicer. But if you think splitting already now helps for the review, I will do now.
tests are failing, could you fix them?
Sure, I am on it.
I was thinking to do it in a separate PR, so that the diff for this one looks a bit nicer. But if you think splitting already now helps for the review, I will do now.
I had the same thought, but after opening the Files changed tab I realized that I'm getting very little from this diff anyhow, since there are more changed lines than unchanged ones...
Attention: Patch coverage is 83.71041%
with 72 lines
in your changes are missing coverage. Please review.
Project coverage is 66.22%. Comparing base (
c19ca70
) to head (92f9640
). Report is 3 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@alecandido Most of the comments you have make sense, and I agree that a lot of things could still be improved. As I mentioned in the description of the PR, I did not attempt to perfect everything. I had to stop somewhere. The main purpose was to extract usage of Qubits and Couplers away from the driver code, and centralize the way sweeps are handled. This is pretty much preparation for the other upcoming refactor related to the introduction of logical channels. I would avoid refactoring more than this now, because most of the code will be refactored again soon. I will address selected comments that are more relevant to the main goal of this PR, but will leave the rest for future.
I would avoid refactoring more than this now, because most of the code will be refactored again soon. I will address selected comments that are more relevant to the main goal of this PR, but will leave the rest for future.
I agree, especially concerning aggressive refactoring, like the denesting.
I'm having my first dive into this code as a whole, so I'm annotating down ideas for improvements. It is perfectly fine to leave the comments that are sensible but not urgent where they are. Just apply solutions for the low-hanging fruits, and close those that you believe to be not suitable. Those left open could be used as a reference (i.e. a starting point) for further discussions, after this PR.
@hay-k should we try to calibrate a qubit with this driver as well ?
@hay-k should we try to calibrate a qubit with this driver as well ?
@Jacfomg We can try. So far I have tested the following experiments (i.e. checked that they produce the same results as main), but without a strict intention to calibrate the qubit:
@hay-k just to check, I found while closing https://github.com/qiboteam/qibolab_platforms_qrc/pull/121 some improvement that may be relevant here or on the following. Could we move power_range into the parameters.json
like QM ?
The ZI driver code is unnecessarily complicated and entangled, which makes it very fragile, hard to read and change, easy to introduce bugs. This PR is an attempt to untangle and simplify the code.
What is changed:
ProcessedSweeps
class, and theclassify_sweepers
function. This removes a lot of repetitive code scattered throughout the driver code, plus makes code more linear and easy to follow.ZhPulse
,ZhSweeper
, andZhSweeperLine
are combined into one. That lucky one is theZhPulse
. The other two are removed.find_subsequence_finish
, and weird phenomena likeself.sequence[f"readout{q}"]
returning non empty list of measurements whenq
is a coupler. Now all signal lines are split together and they are represented together with the measurements responsible for split via the newly introducedSubSequence
class.Qubit
andCoupler
object throughout the driver code is greatly reduced. This moves the driver towards a direction where it is easier to implement upcoming plans for logical channels.play_sweep_select_single
andplay_sweep_select_dual
are unified into the methodplay_sweep
and generalized - in principle the driver should be able to handle any number of sweeps, not only 1 and 2.fast_reset
functionality. Such functionality does not belong to the driver, and should be handled either in higher levels of qibolab, or even outside of it. I believe there is no known user of that functionality for now, hence I thought I could afford removing it for now and then later reintroducing it properly.Bugfixes:
There are still some things that could be polished, however I tried avoiding to touch everything as much as possible. The structure of the code is largely still the same. The goal was to rewrite the minimum possible as an intermediate step towards the upcoming introduction of logical channels in qibolab. Now it should be easier to adapt to those new concepts.
TODO: still need to fix the tests
Checklist: