Skip to content

Commit

Permalink
Merge pull request #1050 from qiboteam/fix_backend
Browse files Browse the repository at this point in the history
Fix backend call
  • Loading branch information
scarrazza authored Nov 28, 2024
2 parents c280398 + 51ebc1e commit 4a1251a
Show file tree
Hide file tree
Showing 8 changed files with 387 additions and 349 deletions.
708 changes: 373 additions & 335 deletions poetry.lock

Large diffs are not rendered by default.

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 = { git = "https://github.com/qiboteam/qibolab.git" }
qibo = "^0.2.12"
qibo = "^0.2.13"
numpy = "^1.26.4"
scipy = "^1.10.1"
pandas = { version = "^2.2.2", extras = ["html"] }
Expand Down
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

Expand Down Expand Up @@ -351,7 +351,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 import PulseSequence
from scipy.sparse import lil_matrix
Expand Down Expand Up @@ -115,7 +115,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)

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 qibocal.auto.operation import DATAFILE, Data, Parameters, QubitId, Results, Routine
Expand Down Expand Up @@ -103,7 +103,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_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

Expand Down Expand Up @@ -105,7 +105,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
4 changes: 2 additions & 2 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 @@ -21,7 +21,7 @@
@pytest.fixture(scope="module")
def platform():
set_backend(backend="qibolab", platform="dummy")
return CalibrationPlatform.from_platform(GlobalBackend().platform)
return CalibrationPlatform.from_platform(get_backend().platform)


TARGETS = [0, 1, 2]
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 4a1251a

Please sign in to comment.