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

0.2 update #996

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion doc/source/protocols/signal/time_of_flight.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Acquisition
.. testcode::
:hide:

from qibolab.execution_parameters import AcquisitionType
from qibolab import AcquisitionType

It is important to note that this experiment makes use of the RAW acquisition mode (see `Qibolab documentation <https://qibo.science/qibolab/stable/api-reference/qibolab.html#qibolab.execution_parameters.AcquisitionType>`_), which may require some specific care depending on the instrument employed (for some devices demodulation could be used, or this mode could be available for just a single qubit at a time).

Expand Down
12 changes: 6 additions & 6 deletions doc/source/tutorials/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ In the acquisition function we are going to perform the experiment.

.. code-block:: python

from qibolab.platform import Platform
from qibolab.qubits import QubitId, QubitPairId
from qibolab import Platform
from qibocal.auto.operation import QubitId, QubitPairId
from typing import Union

def acquisition(params: RoutineParameters, platform: Platform, targets: Union[list[QubitId], list[QubitPairId], list[list[QubitId]]]) -> RoutineData
Expand All @@ -200,8 +200,8 @@ In the acquisition function we are going to perform the experiment.

.. code-block:: python

from qibolab.platform import Platform
from qibolab.qubits import QubitId
from qibolab import Platform
from qibocal.auto.operation import QubitId

def acquisition(
params: RotationParameters,
Expand Down Expand Up @@ -252,7 +252,7 @@ parameters for each qubit.

.. code-block:: python

from qibolab.qubits import QubitId
from qibocal.auto.operation import QubitId

@dataclass
class RotationResults(Results):
Expand Down Expand Up @@ -344,7 +344,7 @@ Here is the plotting function for the protocol that we are coding:
.. code-block:: python

import plotly.graph_objects as go
from qibolab.qubits import QubitId
from qibocal.auto.operation import QubitId

def plot(data: RotationData, fit: RotationResults, target: QubitId):
"""Plotting function for rotation."""
Expand Down
540 changes: 271 additions & 269 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 @@ -17,7 +17,7 @@ classifiers = [

[tool.poetry.dependencies]
python = ">=3.9,<3.12"
qibolab = "^0.1.8"
qibolab = ">=0.2.0"
qibo = "^0.2.6"
numpy = "^1.26.4"
scipy = "^1.10.1"
Expand Down
3 changes: 1 addition & 2 deletions src/qibocal/auto/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
from typing import Optional, Union

from qibo.backends import construct_backend
from qibolab import create_platform
from qibolab.platform import Platform
from qibolab import Platform, create_platform

from qibocal import protocols
from qibocal.config import log
Expand Down
11 changes: 6 additions & 5 deletions src/qibocal/auto/operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@

import numpy as np
import numpy.typing as npt
from qibolab import AcquisitionType, AveragingMode, ExecutionParameters
from qibolab.platform import Platform
from qibolab.qubits import Qubit, QubitId, QubitPair, QubitPairId
from qibolab import AcquisitionType, AveragingMode, Platform, Qubit

from qibocal.config import log

from .serialize import deserialize, load, serialize

QubitId = Union[str, int]
QubitPairId = tuple[QubitId, QubitId]
ChannelId = str

OperationId = NewType("OperationId", str)
"""Identifier for a calibration routine."""
ParameterValue = Union[float, int]
"""Valid value for a routine and runcard parameter."""
Qubits = dict[QubitId, Qubit]
"""Convenient way of passing qubit pairs in the routines."""
QubitsPairs = dict[tuple[QubitId, QubitId], QubitPair]


DATAFILE = "data"
Expand Down Expand Up @@ -112,7 +113,7 @@ def execution_parameters(self):
if self.classify
else AcquisitionType.INTEGRATION
)
return ExecutionParameters(
return dict(
nshots=self.nshots,
relaxation_time=self.relaxation_time,
acquisition_type=acquisition_type,
Expand Down
3 changes: 1 addition & 2 deletions src/qibocal/auto/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from qibo.backends import construct_backend
from qibolab import Platform
from qibolab.serialize import dump_platform

from ..config import log
from ..version import __version__
Expand Down Expand Up @@ -213,7 +212,7 @@ def update_platform(platform: Platform, path: Path):
platpath = path / UPDATED_PLATFORM

platpath.mkdir(parents=True, exist_ok=True)
dump_platform(platform, platpath)
platform.dump(platpath)

def _export_stats(self):
"""Export task statistics.
Expand Down
2 changes: 1 addition & 1 deletion src/qibocal/auto/runcard.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import yaml
from pydantic.dataclasses import dataclass
from qibolab.platform import Platform
from qibolab import Platform

from .. import protocols
from .execute import Executor
Expand Down
5 changes: 3 additions & 2 deletions src/qibocal/auto/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

import yaml
from qibo import Circuit
from qibolab.platform import Platform
from qibolab.qubits import QubitId, QubitPairId
from qibolab import Platform

from qibocal.auto.operation import QubitId, QubitPairId

from .. import protocols
from ..config import log
Expand Down
3 changes: 2 additions & 1 deletion src/qibocal/auto/transpile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from qibo.backends.abstract import Backend
from qibo.transpiler.pipeline import Passes
from qibo.transpiler.unroller import NativeGates, Unroller
from qibolab.qubits import QubitId

from qibocal.auto.operation import QubitId


def transpile_circuits(
Expand Down
2 changes: 1 addition & 1 deletion src/qibocal/cli/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import plotly.graph_objects as go
from jinja2 import Environment, FileSystemLoader
from qibolab.qubits import QubitId, QubitPairId

from qibocal.auto.history import History
from qibocal.auto.operation import QubitId, QubitPairId
from qibocal.auto.output import Output
from qibocal.auto.task import Completed
from qibocal.config import log
Expand Down
3 changes: 2 additions & 1 deletion src/qibocal/fitting/classifier/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

import numpy as np
import pandas as pd
from qibolab.qubits import QubitId
from sklearn.metrics import accuracy_score

from qibocal.auto.operation import QubitId

from . import data

CLS_MODULES = [
Expand Down
110 changes: 29 additions & 81 deletions src/qibocal/protocols/allxy/allxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
import numpy as np
import numpy.typing as npt
import plotly.graph_objects as go
from qibolab import AveragingMode, ExecutionParameters
from qibolab.platform import Platform
from qibolab.pulses import PulseSequence
from qibolab.qubits import QubitId
from qibolab import AveragingMode, Delay, Platform, PulseSequence

from qibocal.auto.operation import Data, Parameters, Results, Routine
from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine


@dataclass
Expand Down Expand Up @@ -93,27 +90,19 @@ def _acquisition(
)

# execute the pulse sequence
options = ExecutionParameters(
nshots=params.nshots, averaging_mode=AveragingMode.CYCLIC
)
options = dict(nshots=params.nshots, averaging_mode=AveragingMode.CYCLIC)
if params.unrolling:
results = platform.execute_pulse_sequences(sequences, options)
results = platform.execute(sequences, **options)
else:
results = [
platform.execute_pulse_sequence(sequence, options) for sequence in sequences
]
results = {}
for sequence in sequences:
results.update(platform.execute([sequence], **options))

for ig, (gates, ro_pulses) in enumerate(zip(gatelist, all_ro_pulses)):
for gates, ro_pulses in zip(gatelist, all_ro_pulses):
gate = "-".join(gates)
for qubit in targets:
serial = ro_pulses[qubit].serial
if params.unrolling:
prob = results[serial][ig].probability(0)
z_proj = 2 * prob - 1
else:
prob = results[ig][serial].probability(0)
z_proj = 2 * prob - 1

prob = 1 - results[ro_pulses[qubit].id]
z_proj = 2 * prob - 1
errors = 2 * np.sqrt(prob * (1 - prob) / params.nshots)
data.register_qubit(
AllXYType,
Expand All @@ -138,85 +127,44 @@ def add_gate_pair_pulses_to_sequence(
readout_delay=0,
beta_param=None,
):
pulse_duration = platform.create_RX_pulse(qubit, start=0).duration
# All gates have equal pulse duration

sequence_duration = sequence.get_qubit_pulses(qubit).duration + sequence_delay
pulse_start = sequence.get_qubit_pulses(qubit).duration + sequence_delay

natives = platform.natives.single_qubit[qubit]
for gate in gates:
if gate == "I":
pass

if gate == "Xp":
if beta_param == None:
RX_pulse = platform.create_RX_pulse(
qubit,
start=pulse_start,
)
if beta_param is None:
rx_sequence = natives.RX()
else:
RX_pulse = platform.create_RX_drag_pulse(
qubit,
start=pulse_start,
beta=beta_param,
)
sequence.add(RX_pulse)
raise NotImplementedError
sequence += rx_sequence

if gate == "X9":
if beta_param == None:
RX90_pulse = platform.create_RX90_pulse(
qubit,
start=pulse_start,
)
if beta_param is None:
rx90_sequence = natives.R(theta=np.pi / 2)
else:
RX90_pulse = platform.create_RX90_drag_pulse(
qubit,
start=pulse_start,
beta=beta_param,
)
sequence.add(RX90_pulse)
raise NotImplementedError
sequence += rx90_sequence

if gate == "Yp":
if beta_param == None:
RY_pulse = platform.create_RX_pulse(
qubit,
start=pulse_start,
relative_phase=np.pi / 2,
)
ry_sequence = natives.R(phi=np.pi / 2)
else:
RY_pulse = platform.create_RX_drag_pulse(
qubit,
start=pulse_start,
relative_phase=np.pi / 2,
beta=beta_param,
)
sequence.add(RY_pulse)
raise NotImplementedError
sequence += ry_sequence

if gate == "Y9":
if beta_param == None:
RY90_pulse = platform.create_RX90_pulse(
qubit,
start=pulse_start,
relative_phase=np.pi / 2,
)
ry90_sequence = natives.R(theta=np.pi / 2, phi=np.pi / 2)
else:
RY90_pulse = platform.create_RX90_drag_pulse(
qubit,
start=pulse_start,
relative_phase=np.pi / 2,
beta=beta_param,
)
sequence.add(RY90_pulse)

sequence_duration += pulse_duration
pulse_start = sequence_duration
raise NotImplementedError
sequence += ry90_sequence

# RO pulse starting just after pair of gates
ro_pulse = platform.create_qubit_readout_pulse(
qubit, start=sequence_duration + readout_delay
)

sequence.add(ro_pulse)
qd_channel = platform.qubits[qubit].drive
ro_channel, ro_pulse = natives.MZ()[0]
sequence.append((ro_channel, Delay(duration=sequence.channel_duration(qd_channel))))
sequence.append((ro_channel, ro_pulse))
return sequence, ro_pulse


Expand Down
7 changes: 2 additions & 5 deletions src/qibocal/protocols/allxy/allxy_drag_pulse_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
import numpy as np
import numpy.typing as npt
import plotly.graph_objects as go
from qibolab import AveragingMode, ExecutionParameters
from qibolab.platform import Platform
from qibolab.pulses import PulseSequence
from qibolab.qubits import QubitId
from qibolab import AveragingMode, Platform, PulseSequence

from qibocal.auto.operation import Data, Parameters, Results, Routine
from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine

from . import allxy

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@
import numpy as np
import numpy.typing as npt
import plotly.graph_objects as go
from qibolab import AveragingMode, ExecutionParameters
from qibolab.platform import Platform
from qibolab.pulses import PulseSequence
from qibolab.qubits import QubitId
from qibolab import AveragingMode, Platform, PulseSequence

from qibocal.auto.operation import Data, Parameters, Results, Routine
from qibocal.auto.operation import Data, Parameters, QubitId, Results, Routine

from . import allxy

Expand Down
Loading
Loading