Skip to content

Commit

Permalink
Drop path from create signature
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros11 committed Jan 26, 2024
1 parent b861009 commit da23ea1
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
8 changes: 4 additions & 4 deletions doc/source/getting-started/experiment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ For simplicity, the qubit will be controlled by a RFSoC-based system, althought
PORT = 6000 # port of the controller

# folder containing runcard with calibration parameters
FOLDER = pathlib.Path.cwd()
FOLDER = pathlib.Path(__file__)


def create(folder=FOLDER):
def create():
# Instantiate controller instruments
controller = RFSoC(NAME, ADDRESS, PORT)

Expand All @@ -54,7 +54,7 @@ For simplicity, the qubit will be controlled by a RFSoC-based system, althought
channels |= Channel("drive", port=controller[0])

# create qubit objects
runcard = load_runcard(folder)
runcard = load_runcard(FOLDER)
qubits, pairs = load_qubits(runcard)
# assign channels to qubits
qubits[0].readout = channels["L3-22_ro"]
Expand All @@ -75,7 +75,7 @@ For simplicity, the qubit will be controlled by a RFSoC-based system, althought
from qibolab.platform import Platform


def create(folder: Path) -> Platform:
def create() -> Platform:
"""Function that generates Qibolab platform."""

And the we can define the runcard ``my_platform/parameters.yml``:
Expand Down
41 changes: 30 additions & 11 deletions doc/source/tutorials/lab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,17 @@ platform available as

.. code-block:: python

from qibolab import Platform
from qibolab import create_platform

# Define platform and load specific runcard
platform = Platform("my_platform")
platform = create_platform("my_platform")


To do so, ``create()`` needs to be saved in a module called ``my_platform.py``
and the environment flag ``QIBOLAB_PLATFORMS`` needs to point to the directory
that contains this module. Examples of advanced platforms are available at `this
To do so, ``create()`` needs to be saved in a module called ``platform.py`` inside
a folder with the name of this platform (in this case ``my_platform``).
Moreover, the environment flag ``QIBOLAB_PLATFORMS`` needs to point to the directory
that contains this folder.
Examples of advanced platforms are available at `this
repository <https://github.com/qiboteam/qibolab_platforms_qrc>`_.

.. _using_runcards:
Expand All @@ -257,6 +259,8 @@ a two-qubit system:

.. code-block:: yaml

# my_platform / parameters.yml

nqubits: 2

qubits: [0, 1]
Expand Down Expand Up @@ -396,19 +400,25 @@ should be a subset of :class:`qibolab.qubits.Qubit` attributes.
Providing the above runcard is not sufficient to instantiate a
:class:`qibolab.platform.Platform`. This should still be done using a
``create()`` method, however this is significantly simplified by
``qibolab.serialize``. Here is the ``create()`` method that loads the parameters of
``qibolab.serialize``. The ``create()`` method should be put
Here is the ``create()`` method that loads the parameters of
the above runcard:

.. testcode:: python

# my_platform / platform.py

from pathlib import Path
from qibolab import Platform
from qibolab.channels import ChannelMap, Channel
from qibolab.serialize import load_runcard, load_qubits, load_settings
from qibolab.instruments.dummy import DummyInstrument

FOLDER = Path(__file__).parent
# assumes runcard is storred in the same folder as platform.py


def create(folder: Path):
def create():
# Create a controller instrument
instrument = DummyInstrument("my_instrument", "0.0.0.0:0")

Expand Down Expand Up @@ -444,7 +454,10 @@ With the following additions for coupler architectures:

.. testcode:: python

def create(folder):
# my_platform / platform.py


def create():
# Create a controller instrument
instrument = DummyInstrument("my_instrument", "0.0.0.0:0")

Expand All @@ -459,7 +472,7 @@ With the following additions for coupler architectures:
channels |= Channel("chfc0", port=instrument["o6"])

# create ``Qubit`` and ``QubitPair`` objects by loading the runcard
runcard = load_runcard(folder)
runcard = load_runcard(FOLDER)
qubits, couplers, pairs = load_qubits(runcard)

# assign channels to the qubit
Expand Down Expand Up @@ -502,6 +515,8 @@ The runcard can contain an ``instruments`` section that provides these parameter

.. code-block:: yaml

# my_platform / parameters.yml

nqubits: 2

qubits: [0, 1]
Expand Down Expand Up @@ -599,6 +614,8 @@ in this case ``"twpa_pump"``.

.. testcode:: python

# my_platform / platform.py

from pathlib import Path
from qibolab import Platform
from qibolab.channels import ChannelMap, Channel
Expand All @@ -611,8 +628,10 @@ in this case ``"twpa_pump"``.
from qibolab.instruments.dummy import DummyInstrument
from qibolab.instruments.oscillator import LocalOscillator

FOLDER = Path(__file__).parent

def create(folder: Path):

def create():
# Create a controller instrument
instrument = DummyInstrument("my_instrument", "0.0.0.0:0")
twpa = LocalOscillator("twpa_pump", "0.0.0.1")
Expand All @@ -625,7 +644,7 @@ in this case ``"twpa_pump"``.
channels |= Channel("ch1in", port=instrument["i1"])

# create ``Qubit`` and ``QubitPair`` objects by loading the runcard
runcard = load_runcard(folder)
runcard = load_runcard(FOLDER)
qubits, pairs = load_qubits(runcard)

# assign channels to the qubit
Expand Down
7 changes: 2 additions & 5 deletions src/qibolab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_platforms_path():
return Path(profiles)


def create_platform(name, path: Path = None) -> Platform:
def create_platform(name) -> Platform:
"""A platform for executing quantum algorithms.

It consists of a quantum processor QPU and a set of controlling instruments.
Expand All @@ -53,10 +53,7 @@ def create_platform(name, path: Path = None) -> Platform:
spec = importlib.util.spec_from_file_location("platform", platform / PLATFORM)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)

if path is None:
return module.create()
return module.create(path)
return module.create()


def execute_qasm(circuit: str, platform, runcard=None, initial_state=None, nshots=1000):
Expand Down

0 comments on commit da23ea1

Please sign in to comment.