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

Define public API #1030

Merged
merged 38 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
98bd880
refactor: Start defining the public api through all module attribute
alecandido Sep 6, 2024
934e161
build: Add ruff and pycln configs, to treat init files consistently
alecandido Sep 6, 2024
9be1708
refactor: Drop pycln directive
alecandido Sep 6, 2024
54bdc74
test: Import qasm executor from defining module
alecandido Sep 6, 2024
2034813
docs: Import qasm executor from defining module
alecandido Sep 6, 2024
ad96503
fix: Import qasm executor from defining module
alecandido Sep 6, 2024
6896f75
refactor: Add pulses and sequence exports
alecandido Sep 6, 2024
ae2442c
feat!: Expose sweeeper API
alecandido Sep 16, 2024
2381c0e
feat!: Expose components API
alecandido Sep 16, 2024
a18449f
fix: Avoid exposing configs
alecandido Sep 16, 2024
3c26826
fix: Move qibolab content to private core subpackage
alecandido Sep 16, 2024
434088f
fix: Correct imports to adapt to core subpackage
alecandido Sep 16, 2024
9af9fd3
fix: Fix qm imports of other qibolab modules
alecandido Sep 16, 2024
aa87254
fix: Add instruments public subpackage
alecandido Sep 16, 2024
db71cc5
feat: Expose qm drivers
alecandido Sep 16, 2024
8d511af
feat: Expose era drivers
alecandido Sep 16, 2024
2885b6b
feat: Expose bluefors drivers
alecandido Sep 16, 2024
a087997
feat: Expose rohde & schwarz drivers
alecandido Sep 16, 2024
40186d6
feat: Expose drivers for the dummy instruments
alecandido Sep 16, 2024
8b594ca
fix: Fix import in C API
alecandido Sep 16, 2024
f22c164
fix: Remove unneeded scoped import
alecandido Sep 16, 2024
1b25fc7
fix: Remove further unneeded scoped import
alecandido Sep 16, 2024
af3a9e4
fix: Redirect leftover imports
alecandido Sep 16, 2024
a26812d
fix: Prevent circular imports
alecandido Sep 16, 2024
4bc5c50
test: Propagate imports redirect in tests
alecandido Sep 16, 2024
5894135
test: Fix imports in conf.py
alecandido Sep 16, 2024
3c036f9
build: Update pylint whitelist with new qualified path
alecandido Sep 16, 2024
d488702
feat: Expose dummy platform creation
alecandido Sep 16, 2024
9482e4a
docs: Redirect imports to use public api
alecandido Sep 16, 2024
f401521
feat: Expose config kinds and qubits
alecandido Sep 16, 2024
cbe8c77
feat: Expose dummy and bluefors directly in instruments
alecandido Sep 16, 2024
87277cc
feat: Expose dummy and bluefors directly in instruments
alecandido Sep 16, 2024
76c37e2
docs: Fix some references
alecandido Sep 17, 2024
a16d3cb
fix: Remove unused import
alecandido Sep 17, 2024
a08aaa4
refactor: Standardize import, imposing mild conventions
alecandido Sep 17, 2024
8daa663
docs: Remove mentions to the internal API in the lab tutorial
alecandido Sep 18, 2024
9a889b4
feat: Expose the platform locating function
alecandido Sep 18, 2024
26df7f2
test: Add test for platform localization
alecandido Sep 19, 2024
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
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ repos:
- id: pycln
args:
- --config=pyproject.toml
- --all
- repo: https://github.com/adamchainz/blacken-docs
rev: 1.18.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion capi/src/wrapper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is part of
from cqibolab import ffi

from qibolab import execute_qasm as py_execute_qasm
from qibolab._core.backends import execute_qasm as py_execute_qasm


@ffi.def_extern()
Expand Down
6 changes: 3 additions & 3 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
# TODO: the following is a workaround for Sphinx doctest, cf.
# - https://github.com/qiboteam/qibolab/commit/e04a6ab
# - https://github.com/pydantic/pydantic/discussions/7763
import qibolab.instruments.dummy
import qibolab.instruments.oscillator
import qibolab.instruments.zhinst
import qibolab._core.instruments.dummy
import qibolab._core.instruments.oscillator
import qibolab._core.instruments.zhinst

# -- Project information -----------------------------------------------------

Expand Down
34 changes: 19 additions & 15 deletions doc/source/getting-started/experiment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ although minimal changes are needed to use other devices.

import pathlib

from qibolab.components import AcquisitionChannel, Channel, DcChannel, IqChannel
from qibolab.identifier import ChannelId
from qibolab import (
AcquisitionChannel,
Channel,
ConfigKinds,
DcChannel,
IqChannel,
Platform,
Qubit,
)
from qibolab.instruments.qm import Octave, QmConfigs, QmController
from qibolab.parameters import ConfigKinds
from qibolab.platform import Platform
from qibolab.platform.platform import QubitMap
from qibolab.qubits import Qubit

# folder containing runcard with calibration parameters
FOLDER = pathlib.Path.cwd()
Expand All @@ -45,7 +48,7 @@ although minimal changes are needed to use other devices.

def create():
# Define qubit
qubits: QubitMap = {
qubits = {
0: Qubit(
drive="0/drive",
probe="0/probe",
Expand All @@ -54,7 +57,7 @@ although minimal changes are needed to use other devices.
}

# Create channels and connect to instrument ports
channels: dict[ChannelId, Channel] = {}
channels = {}
qubit = qubits[0]
# Readout
channels[qubit.probe] = IqChannel(
Expand Down Expand Up @@ -94,7 +97,7 @@ although minimal changes are needed to use other devices.
.. code-block:: python

import pathlib
from qibolab.platform import Platform
from qibolab import Platform


def create() -> Platform:
Expand Down Expand Up @@ -212,13 +215,14 @@ We leave to the dedicated tutorial a full explanation of the experiment, but her
import numpy as np
import matplotlib.pyplot as plt

from qibolab import create_platform
from qibolab.sequence import PulseSequence
from qibolab.sweeper import Sweeper, Parameter
from qibolab.execution_parameters import (
ExecutionParameters,
AveragingMode,
from qibolab import (
AcquisitionType,
AveragingMode,
ExecutionParameters,
Parameter,
PulseSequence,
Sweeper,
create_platform,
)

# load the platform from ``dummy.py`` and ``dummy.json``
Expand Down
105 changes: 51 additions & 54 deletions doc/source/main-documentation/qibolab.rst

Large diffs are not rendered by default.

37 changes: 20 additions & 17 deletions doc/source/tutorials/calibration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ This is done in the following script:

import numpy as np
import matplotlib.pyplot as plt
from qibolab import create_platform
from qibolab.sequence import PulseSequence
from qibolab.sweeper import Sweeper, Parameter
from qibolab.execution_parameters import (
ExecutionParameters,
AveragingMode,
from qibolab import (
AcquisitionType,
AveragingMode,
ExecutionParameters,
Parameter,
PulseSequence,
Sweeper,
create_platform,
)

# allocate platform
Expand Down Expand Up @@ -102,13 +103,14 @@ complex pulse sequence. Therefore with start with that:

import numpy as np
import matplotlib.pyplot as plt
from qibolab import create_platform
from qibolab.sequence import PulseSequence
from qibolab.sweeper import Sweeper, Parameter
from qibolab.execution_parameters import (
ExecutionParameters,
AveragingMode,
from qibolab import (
AcquisitionType,
AveragingMode,
ExecutionParameters,
Parameter,
PulseSequence,
Sweeper,
create_platform,
)

# allocate platform
Expand Down Expand Up @@ -193,12 +195,13 @@ and its impact on qubit states in the IQ plane.

import numpy as np
import matplotlib.pyplot as plt
from qibolab import create_platform
from qibolab.sweeper import Sweeper, Parameter
from qibolab.execution_parameters import (
ExecutionParameters,
AveragingMode,
from qibolab import (
AcquisitionType,
AveragingMode,
ExecutionParameters,
Parameter,
Sweeper,
create_platform,
)

# allocate platform
Expand Down
4 changes: 2 additions & 2 deletions doc/source/tutorials/circuits.rst
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ Qibolab also supports the execution of circuits starting from a QASM string. The
measure q[0] -> a[0];
measure q[2] -> a[1];"""

can be executed by passing it together with the platform name to the :func:`qibolab.execute_qasm` function:
can be executed by passing it together with the platform name to the :func:`qibolab._core.backends.execute_qasm` function:
stavros11 marked this conversation as resolved.
Show resolved Hide resolved

.. testcode::

from qibolab import execute_qasm
from qibolab._core.backends import execute_qasm

result = execute_qasm(circuit, platform="dummy")

Expand Down
4 changes: 2 additions & 2 deletions doc/source/tutorials/instrument.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ For example, a local oscillator is just an instrument, while Quantum Machines is
Add an instrument
-----------------

The base of an instrument is :class:`qibolab.instruments.abstract.Instrument`,
The base of an instrument is :class:`qibolab._core.instruments.abstract.Instrument`,
which is a pydantic ``Model``.
To accomodate different kind of instruments, a flexible interface is implemented
with two abstract methods (``connect()`` and ``disconnect()``) that are required
Expand Down Expand Up @@ -79,7 +79,7 @@ Add a controller

The controller is an instrument that has the additional method ``play``,
which allows it to execute arbitrary pulse sequences and perform sweeps.
Its abstract implementation can be found in :class:`qibolab.instruments.abstract.Controller`.
Its abstract implementation can be found in :class:`qibolab._core.instruments.abstract.Controller`.

Let's see a minimal example:

Expand Down
Loading