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

Unify execution interface #861

Merged
merged 17 commits into from
Jul 23, 2024
Merged

Unify execution interface #861

merged 17 commits into from
Jul 23, 2024

Conversation

alecandido
Copy link
Member

@alecandido alecandido commented Mar 31, 2024

Close #755

  • propagate to Controller.play()
  • drop Controller.sweep()
  • fix tests

@alecandido alecandido changed the base branch from 0.2 to vectorize-shapes March 31, 2024 14:52
@alecandido
Copy link
Member Author

Currently, it is at the stage of just an interface proposal, but it would require to propagate the sweeper usage to all the Controller.play() definitions, and drop the .sweep() (on top of fixing tests).

@stavros11 stavros11 added this to the Qibolab 0.2.0 milestone Apr 1, 2024
@alecandido alecandido force-pushed the vectorize-shapes branch 2 times, most recently from 8d74b7f to 6f4c84b Compare April 17, 2024 06:37
Base automatically changed from vectorize-shapes to 0.2 April 17, 2024 07:24
@alecandido alecandido linked an issue Apr 23, 2024 that may be closed by this pull request
@alecandido alecandido mentioned this pull request May 14, 2024
This was referenced Jun 11, 2024
@alecandido alecandido marked this pull request as ready for review July 16, 2024 16:30
@alecandido alecandido requested review from stavros11 and hay-k July 16, 2024 16:30
@alecandido
Copy link
Member Author

@stavros11 @hay-k the biggest change is (of course) in qibolab.platform.platform, where the previous methods have been replaced by the unique Platform.execute(), and in qibolab.instruments.abstract, where Controller.sweep() has been suppressed.

Everything else is just a matter of propagating these changes and fixing the tests.

Copy link

codecov bot commented Jul 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 44.93%. Comparing base (673425d) to head (79b5c14).

Additional details and impacted files
@@            Coverage Diff             @@
##              0.2     #861      +/-   ##
==========================================
- Coverage   45.17%   44.93%   -0.25%     
==========================================
  Files          70       70              
  Lines        6255     6224      -31     
==========================================
- Hits         2826     2797      -29     
+ Misses       3429     3427       -2     
Flag Coverage Δ
unittests 44.93% <100.00%> (-0.25%) ⬇️

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.

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. Looks good to me and I think the faster we merge this, the better for other ongoing developers (drivers).

options: ExecutionParameters,
*sweepers: Sweeper,
) -> dict[Any, list]:
"""Execute a pulse sequences.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe in this docstring, most likely in the Returns: part (but I cannot comment directly there), we could add a more detailed sentence about what exactly is returned. For example a dict from readout pulse ids to ExecuteResult objects.

That reminds me that at some point we need to finalize the output of this function for 0.2, since this is also user facing. Certainly not for this PR, but currently, I am not sure about the following:

  • Should we keep the dict and with what keys? Currently we are using serial (replaced by id) and also qubit name. Personally, I think we should keep the dict but only with ids, not qubits.
  • Should we keep separate objects for different averaging/acquisition modes, or just replace everything with array?
  • Unrolling: I think id is still sufficient and we don't need lists, if all readouts in the given sequences have distinct ids.
  • Sweepers: I think here the same id is associated to multiple measurements so maybe we need multi-dimensional arrays (as we have now), however I could think some complicated cases (eg. we are sweeping something on the readout pulse).

Copy link
Member Author

Choose a reason for hiding this comment

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

Should we keep the dict and with what keys? Currently we are using serial (replaced by id) and also qubit name. Personally, I think we should keep the dict but only with ids, not qubits.

Agreed

Should we keep separate objects for different averaging/acquisition modes, or just replace everything with array?

Replace with arrays. #809 #899 are both listed for 0.2

Unrolling: I think id is still sufficient and we don't need lists, if all readouts in the given sequences have distinct ids.

That is fine by me. It would keep the return object flat (less nested)

Sweepers: I think here the same id is associated to multiple measurements so maybe we need multi-dimensional arrays (as we have now), however I could think some complicated cases (eg. we are sweeping something on the readout pulse).

Sweepers are for loops, by definition. We should collect them within multidimensional arrays, since each iteration is homogeneous with the others.
Possibly, we should identify results with just the id of the original pulse, if newer readout pulses are introduced in the process. But this should be fully internal to the drivers, despite non-trivial

assert pulse.id and pulse.qubit in results
shape = results[pulse.qubit].magnitude.shape
shape = results[pulse.qubit][0].magnitude.shape
Copy link
Member

Choose a reason for hiding this comment

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

Following the above comment, why do we need to index using [0] here? This is probably a patch for tests to pass, however do we actually want the results to be a dict with list values now?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is just a patch, let's provide a better solution with #809 and #899

@alecandido
Copy link
Member Author

@stavros11 thanks for your comments: I would avoid implementing both, even the docstring, because the current result is not here to stay.

Current patches are there because it's useful to have tests passing, even for a work-in-progress 0.2 version, but they will also change as a consequence of new developments concerning the results.

I would close this as it is, unless you or @hay-k have any other comments.
To move forward, if no other feedback will be collected, I will merge on Monday/Tuesday (in this case approvals are only informal, since we're not merging to main), and then start working asap on #809 and #899. @stavros11 if you can provide some support, we could even prototype the results' generation in QM. I will start defining the interface and implementing for dummy.

@alecandido alecandido mentioned this pull request Jul 19, 2024
@stavros11
Copy link
Member

I would close this as it is, unless you or @hay-k have any other comments. To move forward, if no other feedback will be collected, I will merge on Monday/Tuesday (in this case approvals are only informal, since we're not merging to main), and then start working asap on #809 and #899.

No comments from my side, I agree with the plan and merging this as it is. I also agree with the summary in the issues.

@stavros11 if you can provide some support, we could even prototype the results' generation in QM. I will start defining the interface and implementing for dummy.

Sure, when you define the interface I will propagate it to QM.

@alecandido
Copy link
Member Author

As previously announced, I'm merging this, and keep going with #809 and #899.

Thanks @stavros11 for your review. I will keep into account in those issues (I'm going to directly cite it in there)

@alecandido alecandido merged commit e95b2e8 into 0.2 Jul 23, 2024
24 checks passed
@alecandido alecandido deleted the unify-execution branch July 23, 2024 09:52
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.

General execution interface
2 participants