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

Handling global backend for protocols involving circuits #1076

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

andrea-pasquale
Copy link
Contributor

@andrea-pasquale andrea-pasquale commented Feb 5, 2025

Closes #1065, by directly instatiating a local backend in each acquisition function.

Other changes implemented in this PR:

  • Drop noise models for RB
  • Adding to pytest the env variable QIBO_PLATFORM to properly run tests on the cluster
  • Small fixes related to other tests

Copy link

codecov bot commented Feb 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.29%. Comparing base (bc7a7ba) to head (59f95e3).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1076      +/-   ##
==========================================
- Coverage   97.30%   97.29%   -0.02%     
==========================================
  Files         124      123       -1     
  Lines        9884     9845      -39     
==========================================
- Hits         9618     9579      -39     
  Misses        266      266              
Flag Coverage Δ
unittests 97.29% <100.00%> (-0.02%) ⬇️

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

Files with missing lines Coverage Δ
src/qibocal/auto/transpile.py 90.90% <100.00%> (-0.76%) ⬇️
...l/protocols/randomized_benchmarking/standard_rb.py 98.50% <100.00%> (-0.09%) ⬇️
...qibocal/protocols/randomized_benchmarking/utils.py 96.01% <100.00%> (+0.21%) ⬆️
src/qibocal/protocols/readout_mitigation_matrix.py 100.00% <100.00%> (+2.50%) ⬆️
src/qibocal/protocols/state_tomography.py 98.64% <100.00%> (-0.01%) ⬇️
...l/protocols/two_qubit_interaction/chsh/protocol.py 97.07% <100.00%> (-0.60%) ⬇️
...rc/qibocal/protocols/two_qubit_state_tomography.py 99.28% <100.00%> (-0.01%) ⬇️

... and 1 file with indirect coverage changes

Copy link
Member

@alecandido alecandido left a comment

Choose a reason for hiding this comment

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

Just a couple of comments, but in general I agree with the overall idea (since we're now focusing on the platform, assuming the backend to be Qibolab, there is no need to require everywhere to create the entire backend)

"""Qibolab platforms."""
try:
platforms = list(MetaBackend().list_available())
except RuntimeError:
Copy link
Member

Choose a reason for hiding this comment

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

Not a comment on this PR, but just a point raised as a consequence.

Maybe we should actually drop this exception: if there is no path, we should already return an empty list.
It should be sufficient to do it here:
https://github.com/qiboteam/qibolab/blob/6b2a7b790e8d58d52be937c2f41b8606459a3bf1/src/qibolab/_core/platform/load.py#L23-L26

This should result in .list_available() returning an empty list, and .load() raising a different error.

@stavros11

qubit_maps[i] = list(qubit_map)
if backend.name == "qibolab":
platform_nqubits = backend.platform.nqubits
if platform.name in AVAILABLE_PLATFORMS:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe I just forgot, but in which case is this condition supposed to be false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it should be False when we transpile circuits that are executed on simultation so no transpilation at all.

Copy link
Member

Choose a reason for hiding this comment

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

I think it should be False when we transpile circuits that are executed on simultation so no transpilation at all.

Ah, I see. But in that case there should be no Platform at all, since it is the qibolab.Platform.

My advice would be to drop any simulation reference, and assume it is always Qibolab (possibly the emulator, but still Qibolab).
I would reintroduce the option for simulation as part of a larger refactor, taking into account #913. I'd expect there should be other as well not supporting a backend other than Qibolab.

src/qibocal/auto/transpile.py Outdated Show resolved Hide resolved
@andrea-pasquale
Copy link
Contributor Author

I realized that by properly dropping the possibility to run on simultation we don't need many shenaningans involving MetaBackend, for the time being I'm just creating the correct local backend passing the same Platform object.
Let me know if you agree with this solution.

Co-authored-by: Alessandro Candido <[email protected]>
@andrea-pasquale
Copy link
Contributor Author

@stavros11 I believe that with this approach we don't need anymore #1063, feel free to have a look and eventually we can just merge this PR if you agree.

@andrea-pasquale andrea-pasquale force-pushed the fix_backend branch 2 times, most recently from c2d5df9 to 29bc178 Compare February 6, 2025 16:14
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.

Circuit based protocols run only on simulation
2 participants