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

Qubits, channels, and acquisition #1001

Merged
merged 79 commits into from
Sep 3, 2024
Merged

Qubits, channels, and acquisition #1001

merged 79 commits into from
Sep 3, 2024

Conversation

alecandido
Copy link
Member

@alecandido alecandido commented Aug 22, 2024

  • qubit holding references
  • instrument holding channels
  • drop channel IDs
    • we can distinguish the various instructions from the pulse-like type, and we do not need to distinguish a true Pulse from another one (not even a probe one, we look for Acquisition or Readout for their special needs)
    • Acquisition #970 (comment)
  • expose Readout and simplify its creation
  • remove internal name reference within objects (Channel and Qubit)
  • decide something for AcquisitionChannel.probe and IqChannel.acquisition
    • after dropping the current ChannelId, it could make sense to keep them, or not even
    • they may still be redundant because of Readout instructions (or probe Pulse separate from Acquisition in general)
    • Acquisition #970 (comment)
  • update QM

@alecandido alecandido added this to the Qibolab 0.2.0 milestone Aug 22, 2024
@alecandido alecandido mentioned this pull request Aug 22, 2024
6 tasks
Base automatically changed from py3.12 to 0.2 August 22, 2024 16:30
@alecandido
Copy link
Member Author

alecandido commented Aug 22, 2024

@stavros11 I still need to:

  • fix the doctests (just annoying, but I'm confident I can do quickly)
  • add a convenience constructor for Readout
  • (I also want to translate the MZ natives to Readouts, as they will be more supported)

Other than these points, this PR is almost ready, but there will be two points left.

The trivial one is the one that makes the C API failing (and potentially any similar situation): I'm now type hinting the base LO class with qcodes. This implies that, if you import the LO module, qcodes has to be available. But that is also used by DummyLocalOscillator, which in turn is used by the dummy platform.
Should we make a DummyLocalOscillator not inheriting from the base class? Or make an empty (and useless) base class independent of qcodes? Or just give up on the DummyLocalOscillator? Or keep it, but split from the dummy controller in a separate module?

Then the non-trivial point, that I still want to address in this same PR is QM: I'm making some arbitrary choices about how to handle channels, and the only two places that are giving me some feedback are the dummy platform and the compiler. Which are both pretty limited.
Thus, I want to update QM in this same PR, to possibly iterate.
If you want to do something on your own, feel free to push here. But I can also do it myself.

Copy link

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 40.77381% with 199 lines in your changes missing coverage. Please review.

Project coverage is 51.45%. Comparing base (cd6dcd6) to head (585eb0b).
Report is 81 commits behind head on 0.2.

Files with missing lines Patch % Lines
src/qibolab/instruments/qm/controller.py 0.00% 92 Missing ⚠️
src/qibolab/instruments/qm/program/sweepers.py 0.00% 41 Missing ⚠️
src/qibolab/instruments/qm/config/config.py 0.00% 14 Missing ⚠️
src/qibolab/instruments/qm/config/devices.py 0.00% 13 Missing ⚠️
src/qibolab/instruments/qm/program/instructions.py 0.00% 12 Missing ⚠️
src/qibolab/instruments/qm/program/arguments.py 0.00% 9 Missing ⚠️
src/qibolab/instruments/qm/components/__init__.py 0.00% 4 Missing ⚠️
src/qibolab/instruments/qm/config/elements.py 0.00% 4 Missing ⚠️
src/qibolab/instruments/qm/config/pulses.py 0.00% 3 Missing ⚠️
src/qibolab/components/channels.py 87.50% 1 Missing ⚠️
... and 6 more
Additional details and impacted files
@@            Coverage Diff             @@
##              0.2    #1001      +/-   ##
==========================================
- Coverage   51.86%   51.45%   -0.41%     
==========================================
  Files          58       57       -1     
  Lines        2765     2740      -25     
==========================================
- Hits         1434     1410      -24     
+ Misses       1331     1330       -1     
Flag Coverage Δ
unittests 51.45% <40.77%> (-0.41%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alecandido alecandido changed the base branch from 0.2 to qm-duration-sweeps August 23, 2024 17:05
@alecandido
Copy link
Member Author

alecandido commented Aug 23, 2024

The usual upgrading script, to convert MZ gates to Readout operations:

import sys
import json
from pathlib import Path
from typing import Optional

path = Path(sys.argv[1])
run = json.loads(path.read_text())


def upgrade(
    gate: str, seq: Optional[list[tuple[str, dict]]]
) -> Optional[list[tuple[str, dict]]]:
    """Upgrade sequence layout.

    From https://github.com/qiboteam/qibolab/pull/971 to
    https://github.com/qiboteam/qibolab/pull/970
    """
    if seq is None or gate != "MZ":
        return seq
    return [
        (seq[1][0], {"kind": "readout", "acquisition": seq[1][1], "probe": seq[0][1]})
    ]


for section in run["native_gates"].values():
    for qubit, gates in section.items():
        for gate, sequence in gates.items():
            gates[gate] = upgrade(gate, sequence)


path.write_text(json.dumps(run, indent=2))

@alecandido alecandido marked this pull request as ready for review August 23, 2024 17:20
@alecandido alecandido requested a review from stavros11 August 23, 2024 17:20
@alecandido
Copy link
Member Author

alecandido commented Aug 23, 2024

I'm missing the QM update, which will be a review on its own. But other than that the features should be all there, so a first look and early opinion could be already useful :)

(both of the points here, #1001 (comment), are still relevant - that's why the C API is still failing)

Copy link
Member

@stavros11 stavros11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alecandido. I had a quick look and it generally looks better than the previous acquisition PR. ChannelId should be simpler to handle as a string (although for this I may be a bit biased from QM) and dropping the names from channels should also be a simplification. My only concern so far is about Readout and generally the measurement interface (last comment below).

The trivial one is the one that makes the C API failing (and potentially any similar situation): I'm now type hinting the base LO class with qcodes. This implies that, if you import the LO module, qcodes has to be available. But that is also used by DummyLocalOscillator, which in turn is used by the dummy platform. Should we make a DummyLocalOscillator not inheriting from the base class? Or make an empty (and useless) base class independent of qcodes? Or just give up on the DummyLocalOscillator? Or keep it, but split from the dummy controller in a separate module?

The DummyLocalOscillator should now be used only by the dummy platform. I think before the ZI platform was also using it to set internal LOs, but since we now have the channel configs, it shouldn't be needed there anymore. So dropping could be possible, but we may still want to keep for the dummy to have an LO so that it is closer to real platforms.

If we keep it, it should certainly be free of optional dependencies such as qcodes. I don't think moving the dummy controller to a separate module would help, as if the dummy is still using DummyLocalOscillator directly, we don't want it to depend on qcodes. Rearranging the inheritance should work, for example

graph TD;
    Base-->Dummy;
    Base-->Real;
    Real-->R&S;
    Real-->EraSynth;
Loading

where Base and Dummy are qcodes-free. In that scheme I would try to move shared methods as upwards as possible (to avoid repetition), but I am not sure to what extent this is possible.

Then the non-trivial point, that I still want to address in this same PR is QM: I'm making some arbitrary choices about how to handle channels, and the only two places that are giving me some feedback are the dummy platform and the compiler. Which are both pretty limited. Thus, I want to update QM in this same PR, to possibly iterate. If you want to do something on your own, feel free to push here. But I can also do it myself.

Usually, I also get a better feeling of how everything works when I try to implement it for QM and update the real platform and some qibocal routines. I think we should do that before merging. Let me know if you are planning to do it yourself in case you also want to have a look, otherwise I can also do it (just let me know to avoid doing in parallel). From my side, I was planning to add the missing QM features starting from the working branch (#979), which is pretty much indepedent and I can rebase to this later. Most likely after tomorrow, though.

src/qibolab/identifier.py Outdated Show resolved Hide resolved
Comment on lines +20 to +24
drive_qudits: dict[TransitionId, ChannelId] = Field(default_factory=dict)
"""Output channels collection, to drive non-qubit transitions."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that this is a generalization of the previous drive12. I am not sure how useful are higher order transitions in practice, but should be fine, why not provide support anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looked to me more polished to have the general object.

Moreover, the other more subtle reason for doing this is to keep some "flexible space" for channels, to be abused.
It doesn't sound great, and if not needed it should not be used, but there might be occasions where it could be handy to associate extra channels to qubits in Qibocal. To avoid any possible breaking change in the short term, I left some room here, such that it could be used as a workaround (e.g., you can use the transition 0-1000, 0-1001, ... with a custom Qibocal encoding).
If any of these patterns will arise, we should then stabilize it with proper support. But possibly in 0.3. So, some extra wiggle room for such a huge change as 0.2 doesn't hurt.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume there were no actual requests, just a comment. In case I misinterpreted, please reopen the conversation.

Copy link
Member

@stavros11 stavros11 Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Providing some flexible space sounds like a good idea. If that is the case, we could even make it more apparent that this is such a thing. For example, instead of the tuple (TransitionId) type, we could use just str for the keys and even have a less descriptive name, such as additional, instead of drive_qudits.

That being said, I am not sure if there are any "additional" channels that are not associated to some transition that could be relevant for some actual application, to motivate relaxing the TransitionId structure. One example could be that we can do the 0->2 using one or two photons (with half the frequency) but I think that single photon 0->2 frequency cannot be reached by our electronics so it's probably not useful anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly related to this discussion: what was implemented in #907 could be an example of an "additional" pulse that is not strictly associated to a drive to an excited state.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, for that we should augment even the probe channels.

But I'd still keep as it is, for the time being. We're lacking person power for the full qudits project, and scheduling for 0.3 should not be that limiting.
The extra wiggle room here would still allow doing something like that, e.g. using the 0-1001 encoding for that is an option for the probe, since it's still an IqChannel (though you will lack a channel for the acquisition...).

src/qibolab/dummy/platform.py Outdated Show resolved Hide resolved
src/qibolab/pulses/pulse.py Show resolved Hide resolved
Base automatically changed from qm-duration-sweeps to 0.2 August 24, 2024 11:33
@alecandido
Copy link
Member Author

Let me know if you are planning to do it yourself in case you also want to have a look, otherwise I can also do it (just let me know to avoid doing in parallel). From my side, I was planning to add the missing QM features starting from the working branch (#979), which is pretty much indepedent and I can rebase to this later. Most likely after tomorrow, though.

@stavros11 please, keep going with the other features, as I won't touch those. I will now try to update QM here by myself (just because I'd like to have a more direct feedback). In case of troubles, or lack of time, I'll get back to ask your help.

@alecandido
Copy link
Member Author

@stavros11 I'm still waiting qiboteam/qibolab_platforms_qrc#170 for testing, but most of the changes I made to QM should be a trivial consequence of the main one: I discarded QmChannel in favor of direct usage of general Channel and its direct subclasses.

The reason I made this is that, in the previous commits, I started requiring the general channels to be stored in the instruments themselves (specifically, in the Controllers). The rationale was explained in previous discussions in recent PRs (in summary, they are needed to play, so they are useful if they are available to drivers, in the easiest possible way).

Another bunch of changes are triggered by the removal of the name within the channels. If needed, now it has to be passed separately.

The only bit about which I'm unsure is within QmController.configure_channel(): before you were not registering the acquisition channels, instead delegating it to probe. Now, I'm doing the opposite: the acquisition channel has a reference to the probe, but not conversely (and Readout and Acquisition events are both supposed to be played on the acquisition channel).
Moreover, the probe channels are perfectly indistinguishable from any other IqChannel, so I'm registering them anyway. I'm not sure whether this is a problem. If it is, and they have no other role in the QM driver, we could try to "unregister" them (i.e. listing them in a sort of "unregister" record during acquisition registration, and undo their registration at the end of the all-channels operation, within QmControllr.configure_channels()); I really hope it won't be needed.

@alecandido alecandido force-pushed the qubits branch 2 times, most recently from d0f6354 to fee41c7 Compare August 26, 2024 10:37
@stavros11
Copy link
Member

I discarded QmChannel in favor of direct usage of general Channel and its direct subclasses.

That's great. I have not checked the details of the implementation, but I guess that at some point you'll have to cast the path: str to the previous port: int when you generate the QmConfig.

The only bit about which I'm unsure is within QmController.configure_channel(): before you were not registering the acquisition channels, instead delegating it to probe. Now, I'm doing the opposite: the acquisition channel has a reference to the probe, but not conversely (and Readout and Acquisition events are both supposed to be played on the acquisition channel). Moreover, the probe channels are perfectly indistinguishable from any other IqChannel, so I'm registering them anyway. I'm not sure whether this is a problem. If it is, and they have no other role in the QM driver, we could try to "unregister" them (i.e. listing them in a sort of "unregister" record during acquisition registration, and undo their registration at the end of the all-channels operation, within QmControllr.configure_channels()); I really hope it won't be needed.

If we are using qua.measure to perform measurements, it is handling both probe and acquisition and it is running on the single element which looks like:

"D2/probe": {
            "digitalInputs": {
                "output_switch": {
                    "delay": 57,
                    "buffer": 18,
                    "port": ('con6', 1),
                },
            },
            "digitalOutputs": {},
            "outputs": {
                "out1": ('con6', 1),
                "out2": ('con6', 2),
            },
            "time_of_flight": 224,
            "smearing": 0,
            "intermediate_frequency": -70432000.0,
            "operations": {
                "-6192737274986805398": "-6192737274986805398_D2/probe",
            },
            "mixInputs": {
                "I": ('con6', 1),
                "Q": ('con6', 2),
                "mixer": "D2/probe_mixer_18b",
                "lo_frequency": 7450000000.0,
            },
        },

Its name doesn't really matter, as long as we are consistent between the config and the program. However it should contain all this information, which in qibolab is spread in two different channels: for example frequency is on the probe channel, while time of flight and smearing are on the acquisition channel. Therefore, I would guess that you need to process both channels at the same time to properly generate this.

Registering additional elements in the config that are not used in the program is fine, as in there will be no errors and everything will run as expected. You may just end up uploading more stuff than needed in the device, which may cause some overhead, but most likely negligible. I am not sure why you need to go through this process of registering and unregistering though, instead of just registering only the elements we really need in the first place, but I have not looked at the code in detail yet.

@alecandido
Copy link
Member Author

That's great. I have not checked the details of the implementation, but I guess that at some point you'll have to cast the path: str to the previous port: int when you generate the QmConfig.

There is now a port property, that's still an int. Initially, I called the attribute itself port, but it made more sense that the port keeps being an int.

@alecandido
Copy link
Member Author

Its name doesn't really matter, as long as we are consistent between the config and the program. However it should contain all this information, which in qibolab is spread in two different channels: for example frequency is on the probe channel, while time of flight and smearing are on the acquisition channel. Therefore, I would guess that you need to process both channels at the same time to properly generate this.

This is feasible, as AcquireChannel still holds the name of the probe, so I can retrieve it.

Registering additional elements in the config that are not used in the program is fine, as in there will be no errors and everything will run as expected. You may just end up uploading more stuff than needed in the device, which may cause some overhead, but most likely negligible. I am not sure why you need to go through this process of registering and unregistering though, instead of just registering only the elements we really need in the first place, but I have not looked at the code in detail yet.

Here the problem is that I can not distinguish a probe channel from a drive one any longer. They are both IqChannel, and there is no IqChannel.acquire any longer. So, they are just the same, other than the name (which is arbitrary, and we're deciding not to attribute to it any special meaning).

https://github.com/qiboteam/qibolab_platforms_qrc/blob/aae486cf3cc73c5379561191e96ef69bfd3c955c/qw11qD/platform.py#L40-L44
vs
https://github.com/qiboteam/qibolab_platforms_qrc/blob/aae486cf3cc73c5379561191e96ef69bfd3c955c/qw11qD/platform.py#L52-L56

@stavros11
Copy link
Member

stavros11 commented Aug 26, 2024

Here the problem is that I can not distinguish a probe channel from a drive one any longer. They are both IqChannel, and there is no IqChannel.acquire any longer. So, they are just the same, other than the name (which is arbitrary, and we're deciding not to attribute to it any special meaning).

https://github.com/qiboteam/qibolab_platforms_qrc/blob/aae486cf3cc73c5379561191e96ef69bfd3c955c/qw11qD/platform.py#L40-L44 vs https://github.com/qiboteam/qibolab_platforms_qrc/blob/aae486cf3cc73c5379561191e96ef69bfd3c955c/qw11qD/platform.py#L52-L56

Thanks for the explanation. I guess the only way to distinguish them now is that probes will be referenced by some acquisition channel. We could probably use that to avoid registering them as drives.

Unrelated, but looking at the platforms, path also sounds a bit weird as terminology but I'm fine with it over having to maintain multiple instrument specific channels.

@alecandido
Copy link
Member Author

Thanks for the explanation. I guess the only way to distinguish them now is that probes will be referenced by some acquisition channel. We could probably use that to avoid registering them as drives.

Yes, but if you follow the current strategy, you should sort all the AcquireChannel before all the IqChannel.
Since in general you don't know (and it's even false), that's the motivation of unregistering.
Of course, we could split at a higher level, filtering just one kind of channel, and iterating the full list multiple times.
For the time being, I didn't care that much, and I just hoped it's only overhead.

Unrelated, but looking at the platforms, path also sounds a bit weird as terminology but I'm fine with it over having to maintain multiple instrument specific channels.

I was missing a better name, so I kept the Zurich one. I'm fully open to proposals.

@alecandido
Copy link
Member Author

Ok, now I have a report for single shot, using this PR and
qiboteam/qibolab_platforms_qrc#172
qiboteam/qibocal#973
(or, slightly more accurate, https://github.com/alecandido/qrc/tree/bd332625bba1c7739c4d1442887ab6abc91a5906, part of https://github.com/alecandido/qrc/tree/0.2-qubits)

Here the report:
http://login.qrccluster.com:9000/p21X1CbHSrOtEY4vmnqvig==/

Now, we need to test routines including sweepers.

@stavros11
Copy link
Member

Thanks @alecandido. With d5b7c6f and the latest push in qiboteam/qibocal#973 I managed to run the Rabi routines, which use amplitude and duration sweepers.

I will try to do a more detailed review tomorrow or Monday.

@stavros11
Copy link
Member

stavros11 commented Aug 31, 2024

One issue I see, is that when I add the measurement delay in the probe channel, I get the usual QM error, while if I use acquisition everything works. From the user (who has no idea how QM works) point of view, this may be a bit confusing, as they would probably expect that a delay in the probe only delays the probe etc.. I get that in this case the delay should be added in the acquisition, because the Readout instruction from MZ.create_sequence() also appears in acquisition, but I would probably raise a better error in the QM driver if anything appears in the probe channel (which in practice is useless channel for QM).

Regarding the QM error in this particular case, I did not explore it in detail, but could it be because you are defining two elements (D*/probe, D*/acquisition) with the same input/output ports and the exact same frequency in the config? I would probably try to change the frequency for probe and see if we can execute it. Of course, this is mostly curiosity, it doesn't really matter for qibolab.

@stavros11
Copy link
Member

stavros11 commented Sep 1, 2024

I get that in this case the delay should be added in the acquisition, because the Readout instruction from MZ.create_sequence() also appears in acquisition, but I would probably raise a better error in the QM driver if anything appears in the probe channel (which in practice is useless channel for QM).

Another point about this, not directly related to this PR, is that we should be a bit careful with what we advertise as the measurement API, particularly for qibocal purposes.

If qibocal is using pulses/delays on probe, independently of acquisition, hoping that some instrument (not the current QM) will support them, then all these routines won't be supported by QM. On the other hand, if we stick to using Readout and acquisition channels only in qibocal, we keep compatibility with QM, but we can also never take advantage of the more flexible measurement API introduced here (and the previous acquisition PR) and any instruments that support it.

I remember there were discussions about how to advertise what each instrument supports, but eventually the goal of qibolab-qibocal is to run the same routines on as many different platforms as possible, and to achieve this we probably have to limit ourselves to the subset of features supported by all instruments.

@alecandido alecandido marked this pull request as ready for review September 2, 2024 09:15
@alecandido
Copy link
Member Author

If qibocal is using pulses/delays on probe, independently of acquisition, hoping that some instrument (not the current QM) will support them, then all these routines won't be supported by QM. On the other hand, if we stick to using Readout and acquisition channels only in qibocal, we keep compatibility with QM, but we can also never take advantage of the more flexible measurement API introduced here (and the previous acquisition PR) and any instruments that support it.

At this point, my advice is to keep Readout as the default API for measurement operations, and translate measurement gates to Readout. It preserves more information.

I remember there were discussions about how to advertise what each instrument supports, but eventually the goal of qibolab-qibocal is to run the same routines on as many different platforms as possible, and to achieve this we probably have to limit ourselves to the subset of features supported by all instruments.

Yes, but here is the point where I want to make a step forward wrt the previous aim: before we were trying to support all routines everywhere. And thus, we were exposing a minimal Qibolab API, that should have worked on all the instruments (or almost all).
In a sense, before Qibolab was aiming for the intersection of features.

Instead, I'd like to move Qibolab towards the union of features, but somehow declaring which is the intersection (e.g. you can compare to the compatibility tables on MDN).
So, if there are relevant features, even for a single instrument, we should try to expose it to the user (in a Qibolab-compatible way), but then the people writing the routines will be aware that making use of advanced features will restrict the routines' compatibility. So, it will still be possible to make universally compatible routines, but it's a choice.

@alecandido alecandido requested a review from stavros11 September 2, 2024 10:01
Copy link
Member

@stavros11 stavros11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alecandido. The only significant issue I found is one about the channel sweepers (offset and frequency) in QM which should be broken (comments below). However, I can fix it myself if you agree, I will push here. The rest are minor comments and some suggestions.

One other point, mentioned somewhere else before, is about drive_qudits and whether we would like to convert it to something more flexible, such as a dict with str keys instead of TransitionId. Personally, I don't have a strong opinion, I suggested the str because it is more open to other uses that we may not be aware right now, however I see the advantages of having something more structured for transitions. Whatever we decide will be fixed for all 0.2.* releases as it is certainly in the public interface.

doc/source/getting-started/experiment.rst Outdated Show resolved Hide resolved
doc/source/tutorials/calibration.rst Outdated Show resolved Hide resolved
doc/source/tutorials/calibration.rst Outdated Show resolved Hide resolved
doc/source/tutorials/lab.rst Outdated Show resolved Hide resolved
doc/source/tutorials/lab.rst Outdated Show resolved Hide resolved
src/qibolab/instruments/qm/config/config.py Show resolved Hide resolved
src/qibolab/instruments/qm/program/sweepers.py Outdated Show resolved Hide resolved
src/qibolab/instruments/qm/program/sweepers.py Outdated Show resolved Hide resolved
tests/test_identifier.py Outdated Show resolved Hide resolved
src/qibolab/dummy/platform.py Show resolved Hide resolved
@alecandido
Copy link
Member Author

One other point, mentioned somewhere else before, is about drive_qudits and whether we would like to convert it to something more flexible, such as a dict with str keys instead of TransitionId. Personally, I don't have a strong opinion, I suggested the str because it is more open to other uses that we may not be aware right now, however I see the advantages of having something more structured for transitions. Whatever we decide will be fixed for all 0.2.* releases as it is certainly in the public interface.

Yes, for this I don't have any definitive answer.

The usage of TransitionId was motivated by the fact that it should be used mainly for that purpose, and the flexibility is just a safety option.
On a practical level, int (and tuple[int, int]) is as much unlimited as str, so it could fit whatever you wish.
But one or the other could be more convenient according to the main use, which I'm unsure which it will be...

alecandido and others added 4 commits September 2, 2024 18:50
Co-authored-by: Stavros Efthymiou <[email protected]>
As they are now embedded in the parameters.json
As they are already in the sweepers
@alecandido
Copy link
Member Author

@stavros11 I fixed all the simple issues, and left you with the channels in the sweepers.

@alecandido alecandido requested a review from stavros11 September 2, 2024 17:01
Copy link
Member

@stavros11 stavros11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QM sweeper issues should be fixed by 585eb0b. Frequency sweeper works locally, I have not tested on hardware. Maybe it is worth updating the resonator spectroscopy and flux routines to test on hardware, but I need to do this in qibocal.

Other than that, this is fine to merge from my side. @alecandido maybe you want to review the last commit because I tried to also simplify a bit (instead of just converting to tuple as I would need to propagate this to several places. If you agree, feel free to merge.

The usage of TransitionId was motivated by the fact that it should be used mainly for that purpose, and the flexibility is just a safety option. On a practical level, int (and tuple[int, int]) is as much unlimited as str, so it could fit whatever you wish. But one or the other could be more convenient according to the main use, which I'm unsure which it will be...

I am not sure either. We could ask others if they have any idea what additional channels could be useful and if they all fall under the transitions regime. But I would say the best option for now is to leave as it is and move to an issue/question to potentially address in later releases. It is not really interface breaking. If there is really need for additional channels and the tuple is not convenient to define them, we could just add an additional attribute in some 0.2.* and leave its better refactoring for 0.3.

Comment on lines +37 to +39
@property
def port(self) -> int:
return int(self.path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this would work for all instruments, at least probably not for ZI, so we could even "downgrade" internally to QM. It could be useful for other instruments though, which could justify keeping it here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZI will use the .path, and most of the others will also use .path directly.

I would say that it makes a bit of sense, since int and str are the only general types we can accommodate for, using str to represent both. If any driver needs anything more structured, it will make more sense to write the custom (de)serialization (from)to str in the driver itself, and treat it as str in the channel.
We could follow this logic for int as well, but that's the minimally structured one, so we can even afford (it's just a compromise).

@alecandido
Copy link
Member Author

alecandido commented Sep 3, 2024

I am not sure either. We could ask others if they have any idea what additional channels could be useful and if they all fall under the transitions regime. But I would say the best option for now is to leave as it is and move to an issue/question to potentially address in later releases. It is not really interface breaking. If there is really need for additional channels and the tuple is not convenient to define them, we could just add an additional attribute in some 0.2.* and leave its better refactoring for 0.3.

Yes, that's also another good reason: the structured str -> plain str is a backward compatible change, as it will be a superset. Let's keep it as it is.
Also, adding further fields with default initialization is backward compatible.

QM sweeper issues should be fixed by 585eb0b. Frequency sweeper works locally, I have not tested on hardware. Maybe it is worth updating the resonator spectroscopy and flux routines to test on hardware, but I need to do this in qibocal.

Other than that, this is fine to merge from my side. @alecandido maybe you want to review the last commit because I tried to also simplify a bit (instead of just converting to tuple as I would need to propagate this to several places. If you agree, feel free to merge.

I'm checking and merging right after. It is worth to test more with Qibocal, but it's also quite time-consuming. If some routine breaks, the fix will be most likely internal to the driver, so it's worth to keep going.

@alecandido
Copy link
Member Author

Other than that, this is fine to merge from my side. @alecandido maybe you want to review the last commit because I tried to also simplify a bit (instead of just converting to tuple as I would need to propagate this to several places. If you agree, feel free to merge.

It seems simpler to me as well, I'm merging.

@alecandido alecandido merged commit 9ad9c1a into 0.2 Sep 3, 2024
27 of 28 checks passed
@alecandido alecandido deleted the qubits branch September 3, 2024 09:35
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.

Unify instrument specific components
2 participants