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

Compatibility with the new Qibo global backend handling #1022

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ classifiers = [
[tool.poetry.dependencies]
python = ">=3.9,<3.12"
qibolab = "^0.1.8"
qibo = "^0.2.12"
qibo = { git = "https://github.com/qiboteam/qibo" }
numpy = "^1.26.4"
scipy = "^1.10.1"
pandas = { version = "^2.2.2", extras = ["html"] }
Expand Down
8 changes: 2 additions & 6 deletions src/qibocal/protocols/randomized_benchmarking/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

import numpy as np
import numpy.typing as npt
from qibo import gates
from qibo.backends import GlobalBackend
from qibo import gates, get_backend
from qibo.config import raise_error
from qibo.models import Circuit
from qibolab.platform import Platform
Expand Down Expand Up @@ -69,7 +68,6 @@
}

NPULSES_PER_CLIFFORD = 1.875

"""
Global phases that could appear in the Clifford group we defined in the "2q_cliffords.json" file
due to the gates we selected to generate the Clifford group.
Expand Down Expand Up @@ -352,7 +350,7 @@ def setup(
tuple: A tuple containing the experiment data, noise model, and backend.
"""

backend = GlobalBackend()
backend = get_backend()
backend.platform = platform
# For simulations, a noise model can be added.
noise_model = None
Expand Down Expand Up @@ -402,7 +400,6 @@ def get_circuits(
- circuits (list): List of generated circuits.
- indexes (dict): Dictionary containing the random indexes for each qubit and depth.
- npulses_per_clifford (float): Number of pulses per Clifford.

"""
circuits = []
indexes = {}
Expand Down Expand Up @@ -452,7 +449,6 @@ def execute_circuits(circuits, targets, params, backend, single_qubit=True):

Returns:
list: List of executed circuits.

"""
# Execute the circuits
transpiler = dummy_transpiler(backend)
Expand Down
5 changes: 2 additions & 3 deletions src/qibocal/protocols/readout_mitigation_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import numpy as np
import numpy.typing as npt
import plotly.express as px
from qibo import gates
from qibo.backends import GlobalBackend
from qibo import gates, get_backend
from qibo.models import Circuit
from qibolab import ExecutionParameters
from qibolab.platform import Platform
Expand Down Expand Up @@ -97,7 +96,7 @@ def _acquisition(
data = ReadoutMitigationMatrixData(
nshots=params.nshots, qubit_list=[list(qq) for qq in targets]
)
backend = GlobalBackend()
backend = get_backend()
backend.platform = platform
transpiler = dummy_transpiler(backend)
qubit_map = [i for i in range(platform.nqubits)]
Expand Down
6 changes: 3 additions & 3 deletions src/qibocal/protocols/state_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import numpy as np
import plotly.graph_objects as go
from plotly.subplots import make_subplots
from qibo import Circuit, gates
from qibo.backends import GlobalBackend, NumpyBackend, matrices
from qibo import Circuit, gates, get_backend
from qibo.backends import NumpyBackend, matrices
from qibo.quantum_info import fidelity, partial_trace
from qibolab.platform import Platform
from qibolab.qubits import QubitId
Expand Down Expand Up @@ -102,7 +102,7 @@ def _acquisition(
if params.circuit is None:
params.circuit = Circuit(len(targets))

backend = GlobalBackend()
backend = get_backend()
backend.platform = platform
transpiler = dummy_transpiler(backend)

Expand Down
6 changes: 3 additions & 3 deletions src/qibocal/protocols/two_qubit_interaction/chsh/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
import numpy.typing as npt
import plotly.graph_objects as go
from qibo.backends import GlobalBackend
from qibo import get_backend
from qibolab import ExecutionParameters
from qibolab.platform import Platform
from qibolab.qubits import QubitId, QubitPairId
Expand Down Expand Up @@ -45,6 +45,7 @@ class CHSHParameters(Parameters):

bell_states: list
"""List with Bell states to compute CHSH.

The following notation it is used:
0 -> |00>+|11>
1 -> |00>-|11>
Expand Down Expand Up @@ -157,7 +158,6 @@ def __contains__(self, key: QubitPairId):

While key is a QubitPairId both chsh and chsh_mitigated contain
an additional key which represents the basis chosen.

"""

return key in [(target, control) for target, control, _ in self.chsh]
Expand Down Expand Up @@ -220,7 +220,7 @@ def _acquisition_circuits(
bell_states=params.bell_states,
thetas=thetas.tolist(),
)
backend = GlobalBackend()
backend = get_backend()
backend.platform = platform
transpiler = dummy_transpiler(backend)
qubit_map = [i for i in range(platform.nqubits)]
Expand Down
6 changes: 3 additions & 3 deletions src/qibocal/protocols/two_qubit_state_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import numpy as np
import plotly.graph_objects as go
from plotly.subplots import make_subplots
from qibo import Circuit, gates
from qibo.backends import GlobalBackend, NumpyBackend
from qibo import Circuit, gates, get_backend
from qibo.backends import NumpyBackend
from qibo.quantum_info import fidelity, partial_trace
from qibo.result import QuantumState
from qibolab.platform import Platform
Expand Down Expand Up @@ -97,7 +97,7 @@ def _acquisition(
if params.circuit is None:
params.circuit = Circuit(len(qubits))

backend = GlobalBackend()
backend = get_backend()
backend.platform = platform
simulator = NumpyBackend()
transpiler = dummy_transpiler(backend)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_task_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from pytest import approx
from qibo.backends import GlobalBackend, set_backend
from qibo import get_backend, set_backend

from qibocal import protocols
from qibocal.auto.mode import AUTOCALIBRATION, ExecutionMode
Expand All @@ -20,7 +20,7 @@
@pytest.fixture(scope="module")
def platform():
set_backend(backend="qibolab", platform="dummy")
return GlobalBackend().platform
return get_backend().platform


TARGETS = [0, 1, 2]
Expand Down Expand Up @@ -107,7 +107,7 @@ def test_update_argument(platform, global_update, local_update, tmp_path):
NEW_CARD = modify_card(
UPDATE_CARD, local_update=local_update, global_update=global_update
)
# platform = deepcopy(GlobalBackend().platform)
# platform = deepcopy(get_backend().platform)
old_readout_frequency = platform.qubits[0].readout_frequency
old_iq_angle = platform.qubits[1].iq_angle
Runcard.load(NEW_CARD).run(
Expand Down
9 changes: 3 additions & 6 deletions tests/test_transpile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import numpy as np
from qibo import Circuit, gates, set_backend
from qibo.backends import GlobalBackend
from qibo import Circuit, gates, get_backend, set_backend

from qibocal.auto.transpile import (
dummy_transpiler,
Expand All @@ -24,13 +23,12 @@ def test_padd_circuit():


def test_execute_transpiled_circuit():

circuit = Circuit(2)
circuit.add(gates.X(0))
circuit.add(gates.X(1))
qubit_map = [1, 2]
set_backend("qibolab", platform="dummy")
backend = GlobalBackend()
backend = get_backend()
transpiler = dummy_transpiler(backend)
transpiled_circuit, _ = execute_transpiled_circuit(
circuit, qubit_map, backend, transpiler=transpiler
Expand All @@ -46,13 +44,12 @@ def test_execute_transpiled_circuit():


def test_execute_transpiled_circuits():

circuit = Circuit(2)
circuit.add(gates.X(0))
circuit.add(gates.X(1))
qubit_map = [1, 2]
set_backend("qibolab", platform="dummy")
backend = GlobalBackend()
backend = get_backend()
transpiler = dummy_transpiler(backend)
transpiled_circuits, _ = execute_transpiled_circuits(
[circuit], [qubit_map], backend, transpiler=transpiler
Expand Down