Skip to content

Commit

Permalink
change GlobalBackends() with get_backend() for compatibility with qib…
Browse files Browse the repository at this point in the history
…o v0.2.13
  • Loading branch information
ElStabilini committed Nov 28, 2024
1 parent 40926fd commit cbf4933
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/qibocal/protocols/randomized_benchmarking/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np
import numpy.typing as npt
from qibo import gates
from qibo.backends import GlobalBackend
from qibo.backends import get_backend
from qibo.config import raise_error
from qibo.models import Circuit
from qibolab.platform import Platform
Expand Down Expand Up @@ -352,7 +352,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
4 changes: 2 additions & 2 deletions src/qibocal/protocols/readout_mitigation_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy.typing as npt
import plotly.express as px
from qibo import gates
from qibo.backends import GlobalBackend
from qibo.backends import get_backend
from qibo.models import Circuit
from qibolab.platform import Platform
from qibolab.qubits import QubitId
Expand Down Expand Up @@ -61,7 +61,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
4 changes: 2 additions & 2 deletions src/qibocal/protocols/state_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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.backends import NumpyBackend, get_backend, 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
4 changes: 2 additions & 2 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.backends import get_backend
from qibolab import ExecutionParameters
from qibolab.platform import Platform
from qibolab.qubits import QubitId, QubitPairId
Expand Down Expand Up @@ -222,7 +222,7 @@ def _acquisition_circuits(
bell_states=params.bell_states,
thetas=thetas.tolist(),
)
backend = GlobalBackend()
backend = get_backend()
backend.platform = platform
transpiler = dummy_transpiler(backend)
if params.apply_error_mitigation:
Expand Down
4 changes: 2 additions & 2 deletions src/qibocal/protocols/two_qubit_state_tomography.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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.backends import NumpyBackend, get_backend
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.backends 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
6 changes: 3 additions & 3 deletions tests/test_transpile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from qibo import Circuit, gates, set_backend
from qibo.backends import GlobalBackend
from qibo.backends import get_backend

from qibocal.auto.transpile import (
dummy_transpiler,
Expand Down Expand Up @@ -30,7 +30,7 @@ def test_execute_transpiled_circuit():
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 @@ -52,7 +52,7 @@ def test_execute_transpiled_circuits():
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

0 comments on commit cbf4933

Please sign in to comment.