qiboteam / qibocal

Quantum calibration, characterization and validation module for Qibo.
https://qibo.science
Apache License 2.0
30 stars 7 forks source link

Simplified calibration scripts #869

Closed alecandido closed 2 months ago

alecandido commented 4 months ago

Here (there will be) the implementation of the rant syntax of #865.

It seems that it is actually possible, and it should result in simple and nice scripts.

Plugins (i.e. protocols set extensions) will also be supported, though we now have the option of avoiding auto-discovery, since there will be room for explicit registration (that seems more intuitive and transparent).

Further proposals

This PR

Beyond

codecov[bot] commented 4 months ago

Codecov Report

Attention: Patch coverage is 98.55072% with 1 line in your changes missing coverage. Please review.

Project coverage is 97.23%. Comparing base (92e775b) to head (e640670).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/qiboteam/qibocal/pull/869/graphs/tree.svg?width=650&height=150&src=pr&token=3EA9ZUNKUY&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam)](https://app.codecov.io/gh/qiboteam/qibocal/pull/869?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam) ```diff @@ Coverage Diff @@ ## main #869 +/- ## ======================================= Coverage 97.23% 97.23% ======================================= Files 118 118 Lines 8963 9014 +51 ======================================= + Hits 8715 8765 +50 - Misses 248 249 +1 ``` | [Flag](https://app.codecov.io/gh/qiboteam/qibocal/pull/869/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/qibocal/pull/869/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam) | `97.23% <98.55%> (+<0.01%)` | :arrow_up: | 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. | [Files](https://app.codecov.io/gh/qiboteam/qibocal/pull/869?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam) | Coverage Δ | | |---|---|---| | [src/qibocal/\_\_init\_\_.py](https://app.codecov.io/gh/qiboteam/qibocal/pull/869?src=pr&el=tree&filepath=src%2Fqibocal%2F__init__.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam#diff-c3JjL3FpYm9jYWwvX19pbml0X18ucHk=) | `100.00% <100.00%> (ø)` | | | [src/qibocal/auto/output.py](https://app.codecov.io/gh/qiboteam/qibocal/pull/869?src=pr&el=tree&filepath=src%2Fqibocal%2Fauto%2Foutput.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam#diff-c3JjL3FpYm9jYWwvYXV0by9vdXRwdXQucHk=) | `100.00% <100.00%> (ø)` | | | [src/qibocal/auto/task.py](https://app.codecov.io/gh/qiboteam/qibocal/pull/869?src=pr&el=tree&filepath=src%2Fqibocal%2Fauto%2Ftask.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam#diff-c3JjL3FpYm9jYWwvYXV0by90YXNrLnB5) | `98.05% <100.00%> (+0.01%)` | :arrow_up: | | [src/qibocal/cli/acquisition.py](https://app.codecov.io/gh/qiboteam/qibocal/pull/869?src=pr&el=tree&filepath=src%2Fqibocal%2Fcli%2Facquisition.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam#diff-c3JjL3FpYm9jYWwvY2xpL2FjcXVpc2l0aW9uLnB5) | `95.83% <100.00%> (+0.18%)` | :arrow_up: | | [src/qibocal/cli/autocalibration.py](https://app.codecov.io/gh/qiboteam/qibocal/pull/869?src=pr&el=tree&filepath=src%2Fqibocal%2Fcli%2Fautocalibration.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam#diff-c3JjL3FpYm9jYWwvY2xpL2F1dG9jYWxpYnJhdGlvbi5weQ==) | `96.15% <100.00%> (+0.15%)` | :arrow_up: | | [src/qibocal/cli/report.py](https://app.codecov.io/gh/qiboteam/qibocal/pull/869?src=pr&el=tree&filepath=src%2Fqibocal%2Fcli%2Freport.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam#diff-c3JjL3FpYm9jYWwvY2xpL3JlcG9ydC5weQ==) | `100.00% <ø> (ø)` | | | [src/qibocal/web/report.py](https://app.codecov.io/gh/qiboteam/qibocal/pull/869?src=pr&el=tree&filepath=src%2Fqibocal%2Fweb%2Freport.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam#diff-c3JjL3FpYm9jYWwvd2ViL3JlcG9ydC5weQ==) | `100.00% <100.00%> (ø)` | | | [src/qibocal/auto/execute.py](https://app.codecov.io/gh/qiboteam/qibocal/pull/869?src=pr&el=tree&filepath=src%2Fqibocal%2Fauto%2Fexecute.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=qiboteam#diff-c3JjL3FpYm9jYWwvYXV0by9leGVjdXRlLnB5) | `98.79% <98.18%> (-1.21%)` | :arrow_down: |
alecandido commented 2 months ago

I added the call simplification: now it is possible to use the names of the parameters as keyword arguments.

There are three semi-reserved names: id, mode, and parameters itself. These can not be used as keyword arguments for parameter names, as they are interpreted as other routine attributes. However, the parameters argument can still be used to pass a dictionary, that will be updated with the further explicit keyword arguments. In that dictionary, there is no reserved key (but using id, mode, and parameters as names for routines' parameters is discouraged anyhow, as it would be confusing, despite being possible).

https://github.com/qiboteam/qibocal/blob/d63bc73efd189cf316c7bd31bde6341af6151a3c/src/qibocal/auto/execute.py#L46-L49

alecandido commented 2 months ago

The main point of the PR is implemented, and vaguely tested.

However, I'm asking for review to have an actual feedback, not necessarily to merge immediately (and in any case, this is pointing #909, which is pointing #921). Moreover, the script support is not completed, since, to fully reproduce runcards, we need other basic functionalities like those described in #922.

But with a bit of boilerplate scripts could be already used, reimplementing in each and every script the saving operations in https://github.com/qiboteam/qibocal/blob/manage-output/src/qibocal/cli/autocalibration.py and the other commands. So, I'm inclined to merge this with this feature alone, and introduce further features in further PRs, to avoid super-huge PRs and consequently more complicated reviews.

alecandido commented 2 months ago

In b03665e I added a new (small) feature: positional arguments. Now, it should be also possible to omit the name of the parameters, and rely on the order they are listed in the Parameters class.

I checked with the RX calibration script that nothing is broken.

I'm not dedicating a huge effort to properly test all these features, also because they are experimental. As soon as we will improve a bit these scripts (and start using them), I will also expand the testing infrastructure, to make them even more reliable.

alecandido commented 2 months ago

Sorry, I didn't see the review. I'll reply to your comments asap

alecandido commented 2 months ago

Nothing new wrt @andrea-pasquale review, I just rebased on top of the current main.