-
Notifications
You must be signed in to change notification settings - Fork 15
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
Serialization interface #971
Conversation
00bc864
to
63e094f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 0.2 #971 +/- ##
==========================================
- Coverage 42.93% 41.71% -1.23%
==========================================
Files 80 79 -1
Lines 5524 5442 -82
==========================================
- Hits 2372 2270 -102
- Misses 3152 3172 +20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
473da20
to
93a5bf6
Compare
@stavros11 I now introduced the It seems reasonable to me to have this object in the What do you think about this plan? P.S.: I'd like to have a better name than |
Thanks for the summary. Sure, sounds good to me as well, as long as we are not duplicating the information (eg. copying from the
|
Let's try.
I also thought about something like that, but I felt guilty wrt #972 :P |
3088f0d
to
af0d7f9
Compare
@stavros11 as you'll observe, there is a bit of additional mess in the sequence class: qibolab/src/qibolab/pulses/sequence.py Lines 19 to 48 in 42572a8
I just wanted to tell you in advance that, despite working, this is only needed because I'm trying to keep This is a trade-off, and I'm not fully satisfied myself. If things will change, we may switch decision (e.g. keep it simple, and alias some methods manually, like |
42572a8
to
97596ca
Compare
Another annoying point is about the qubits, since they contain two things, with two different sources:
This leads to this mess: qibolab/src/qibolab/platform/platform.py Lines 118 to 161 in 2f1683f
Is it acceptable to give up on the |
I actually forgot it, but |
@stavros11 I still want to check whether I can elegantly split the channels from their configs, and to remove the cumbersome qubit/coupler/pair properties and attributes (and I have one Zurich doctest to fix). However, the PR is already pretty big, and the main features are implemented. |
3cdf01b should not be needed at all, is somewhat like a Pydantic bug (or a bad interaction with Sphinx dynamic imports). It could not happen as a standalone script. However, this particular instance is happening because Zurich is not reached by the bare Anyhow, this could also be solved by avoiding driver-specific components. |
The last item remaining was big enough to be worth a separate PR, even for the advantage of the review. This is now ready as it is, and it could be used to upgrade QM and its platforms. (the remaining changes won't affect that much the platform-creation interface, which is the true name of the serialization interface mentioned in this PR's title) |
I.e. - strict typing, respecting those specified for the attributes - strict attributes, no extra silently allowed or ignored
Otherwise it seems to be impossible to even generate a schema. To be investigated...
Remove extra ignored attributes from Pydantic-based classes
And also platform creation, which is actually untested, though running
Best effort, cf. #984
@@ -31,9 +32,11 @@ class Qubit: | |||
send flux pulses to the qubit. | |||
""" | |||
|
|||
model_config = ConfigDict(frozen=False) |
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 the impression that Qubit
can be frozen. If not in this PR, since it still contains the native gates which may need to be updated (eg. by qibocal) then in #983. It only contains the logical channels (not their configs), which I believe never change.
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.
In principle, it could: already in #983 it should be created in the platform, and never touched again...
Almost. For as long as the frequencies are in the channels, we need to leave Qibocal (and any user) the freedom to change that even during the execution (i.e. between two of them).
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.
Almost. For as long as the frequencies are in the channels, we need to leave Qibocal (and any user) the freedom to change that even during the execution (i.e. between two of them).
I think the frequencies are in the configs, not the channels. The configs are inheriting the default Model
from qibolab.serialize
which I believe is frozen(?). Therefore, the user already cannot change the frequency directly but they can
- pass a different config when executing something or,
- change the default config in the
Platform
which I believe are acceptable solutions.
The Qubit
seems to be frozen anyway now. It only has a name (frozen) and channels and the channels only have str
attributes, all of which I believe are frozen. That's why I think we don't need to "unfreeze" it.
While looking on that, I realized that the Qubit
also has a mixer_frequencies
property, which I believe is broken as it tries to access attributes that don't exist anymore (not confirmed though, as I have not tried to use it). We should probably drop this.
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 think the frequencies are in the configs, not the channels.
Correct
The configs are inheriting the default
Model
fromqibolab.serialize
which I believe is frozen(?).
Also correct
which I believe are acceptable solutions.
The problem is what you would if you need more frequencies. In that case, you will have to add new channels.
The
Qubit
seems to be frozen anyway now. It only has a name (frozen) and channels and the channels only havestr
attributes, all of which I believe are frozen. That's why I think we don't need to "unfreeze" it.
All correct. But one of the channels is actually a dictionary (cross resonances), which is a mutable object (opposite to strings).
In principle, this is not preventing Qubit
from being frozen (which was only needed for natives), but it would be a bit fake: the address of the dictionary won't change, and that's going to make it possible to freeze the object. But the dictionary items would be conceptually part of the Qubit
, and they can change at will.
We can choose what we prefer. Freeze or unfreeze shouldn't matter that much in this case.
While looking on that, I realized that the
Qubit
also has amixer_frequencies
property, which I believe is broken as it tries to access attributes that don't exist anymore (not confirmed though, as I have not tried to use it). We should probably drop this.
Agreed.
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.
All correct. But one of the channels is actually a dictionary (cross resonances), which is a mutable object (opposite to strings). In principle, this is not preventing
Qubit
from being frozen (which was only needed for natives), but it would be a bit fake: the address of the dictionary won't change, and that's going to make it possible to freeze the object. But the dictionary items would be conceptually part of theQubit
, and they can change at will.
You are right, I missed this dict
. In that case, I am also fine with leaving it as not frozen.
However, I have the impression that allowing users to attach new channels to qubits is not very useful. To execute pulses on these channels they would also have to create the corresponding instrument channel to provide the port information and also register this to the instrument. QM, which is the only working driver, does not provide any interface for this. Of course it's Python so you can still access the QmController
from the Platform
and attach the channel there. This would work, however it requires so much knowledge of the internals that I wouldn't call you a "user" anymore.
Not for this PR, but regarding the channel creation business, we should probably decide: we either drop completely and in that case I think we can safely freeze Qubit
, or we provide a more user-friendly way to do it. Even if we drop, users could still attach new channels in the platform creation if needed, during Qubit
creation, so that there is no need to mutate them.
Separate channels from natives
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 think the things I would like to have fixed before merging this are the helper property to access native gates and potentially make the Qubit
frozen and drop mixer_frequencies
, since this is very simple. Everything else I would leave for the future and may even be debatable.
@@ -31,9 +32,11 @@ class Qubit: | |||
send flux pulses to the qubit. | |||
""" | |||
|
|||
model_config = ConfigDict(frozen=False) |
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.
Almost. For as long as the frequencies are in the channels, we need to leave Qibocal (and any user) the freedom to change that even during the execution (i.e. between two of them).
I think the frequencies are in the configs, not the channels. The configs are inheriting the default Model
from qibolab.serialize
which I believe is frozen(?). Therefore, the user already cannot change the frequency directly but they can
- pass a different config when executing something or,
- change the default config in the
Platform
which I believe are acceptable solutions.
The Qubit
seems to be frozen anyway now. It only has a name (frozen) and channels and the channels only have str
attributes, all of which I believe are frozen. That's why I think we don't need to "unfreeze" it.
While looking on that, I realized that the Qubit
also has a mixer_frequencies
property, which I believe is broken as it tries to access attributes that don't exist anymore (not confirmed though, as I have not tried to use it). We should probably drop this.
d7a372b
to
4f4e6fc
Compare
Ok, all the comments should be addressed, but the last two still open (which are not for this PR, in principle). I could provide some more tests, but I'd prefer to finish first all the other features, and then review the tests altogether (there are choices to be made and simplifications to be applied). |
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 the updates @alecandido. I believe we can now merge this, right? It was also tested and working with the QM driver (using #989).
Closes #946
arbitrary_types_allowed
, cf. 6105cb3load_instrument_settings
with componentsRuncard
into platformadd methods for template creationcf. Parameters templates and handling #978check whether it's possible to separate runcardSeparate channels from natives #982configs
from those defined inplatform.py
Just in case anyone will look at this later on: it definitely went beyond the interface.