qiboteam / qibolab

Quantum hardware module and drivers for Qibo.
https://qibo.science
Apache License 2.0
40 stars 10 forks source link

Disconnect after circuit execution #838

Closed stavros11 closed 3 months ago

stavros11 commented 3 months ago

This PR addresses two small issues related to the usage of local oscillators when executing circuits (using the QibolabBackend).

First, I get a weird exception warning from qblox after executing a circuit on a platform that contains a Rohde Scharz LO (in my case the qw5q_platinum platform from qiboteam/qibolab_platforms_qrc#125). I didn't copy the exact thing but should be easy to reproduce by running any circuit, ie

from qibo import Circuit, gates
from qibolab.backends import QibolabBackend

c = Circuit(5)
c.add(gates.GPI2(3, theta=0)) # using qubit 3 because it is calibrated
c.add(gates.M(3))

backend = QibolabBackend("qw5q_platinum")
result = backend.execute_circuit(c, nshots=1000)

This issue is fixed by removing the __del__ methods from the LO drivers. I don't think these are needed since Python/qcodes should already take care of destructing the objects.

Second, I added an explicit platform.disconnect() after executing circuits because otherwise LOs stay on forever after execution (this happens even with the destructor).

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 66.56%. Comparing base (0bd68b0) to head (af91db9).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #838 +/- ## ========================================== - Coverage 66.57% 66.56% -0.02% ========================================== Files 50 50 Lines 6079 6077 -2 ========================================== - Hits 4047 4045 -2 Misses 2032 2032 ``` | [Flag](https://app.codecov.io/gh/qiboteam/qibolab/pull/838/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/qiboteam/qibolab/pull/838/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam) | `66.56% <100.00%> (-0.02%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

stavros11 commented 3 months ago

Fine by me. But I wonder if (for 0.2) we should avoid auto-connection (and disconnection) at all.

Thanks. One potential issue with this is that QibolabBackend is geared towards higher-level execution from Qibo and these kind of users may not want to know the specifics of connection/disconnection, etc. That's why it's currently done automatically.

alecandido commented 3 months ago

Thanks. One potential issue with this is that QibolabBackend is geared towards higher-level execution from Qibo and these kind of users may not want to know the specifics of connection/disconnection, etc. That's why it's currently done automatically.

Yes, that's why I said opt-out.

In particular:

But auto-mode should only be a feature to the user, and drivers should not rely on it until it's really needed (i.e. actual execution, not program/experiment preparation). In particular, unless you want to reuse the same connection (that we could support by allowing manual connection), the driver should only connect at the very end, and avoid checking it before.

If that will be the case, I might be able to run Qibocal without a connection, and receive an error only when I can not send my program to anyone.