Skip to content

Commit

Permalink
Merge pull request #1030 from qiboteam/public-api
Browse files Browse the repository at this point in the history
Define public API
  • Loading branch information
alecandido authored Sep 19, 2024
2 parents d07eb62 + 26df7f2 commit dff7479
Show file tree
Hide file tree
Showing 105 changed files with 1,679 additions and 1,728 deletions.
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:

.. 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

0 comments on commit dff7479

Please sign in to comment.