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

Channel api #885

Merged
merged 129 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
dc5e3d6
Define user facing Channel and various *ChannelConfig classes
hay-k Apr 5, 2024
6e544df
rename Channel to InstrumentChannel
hay-k Apr 5, 2024
9495b19
convert PulseSequence to dict and simplify
hay-k Apr 5, 2024
88642c1
accept channel configs as part of execution requests
hay-k Apr 5, 2024
69e5825
Instead of qubits and couplers, define sweepers in terms of channels
hay-k Apr 5, 2024
146e15c
separate channel from channel config
hay-k Apr 17, 2024
e880fd1
Update channel configs
hay-k Apr 17, 2024
235b028
remove channel.py
hay-k Apr 22, 2024
c3662b2
Revert "rename Channel to InstrumentChannel"
hay-k Apr 22, 2024
8997657
remove redundant port.py
hay-k Apr 22, 2024
8803f28
strip down Channel class
hay-k Apr 22, 2024
7be825e
move channels.py under instruments
hay-k Apr 22, 2024
5c9795b
introduce channel types
hay-k Apr 22, 2024
802487a
remove the ChannelMap class
hay-k Apr 23, 2024
d9ea4be
simple channel definition
hay-k Apr 23, 2024
ad20f5e
Introduce simple Channel type for type annotations
hay-k Apr 24, 2024
ba144e1
rename lo to laboneq to avoid confusion with local oscillator
hay-k Apr 24, 2024
ed17b90
remove ZhPort
hay-k Apr 24, 2024
9d6ee2f
don't use default values
hay-k Apr 24, 2024
f5dd7d2
propagate channel_config to instruments
hay-k Apr 24, 2024
07dffa7
ZI channels
hay-k Apr 24, 2024
bea6e25
Revert "propagate channel_config to instruments"
hay-k Apr 24, 2024
f4353a0
update platfrom according to new way of defining sequences
hay-k Apr 24, 2024
d2c2fc0
use OscillatorConfig for TWPA pump
hay-k Apr 26, 2024
36fac18
move channel and channel config definitions into dedicated subpackage
hay-k Apr 30, 2024
cea6292
remove channel and qubit properties from pulse
hay-k Apr 30, 2024
33ad2ad
implement appending sequence to a sequnece
hay-k Apr 30, 2024
16754d5
move channel and channel config definitions into dedicated subpackage
hay-k Apr 30, 2024
1653a14
remove load_instrument_settings since it is replaced by channel confi…
hay-k May 6, 2024
4d08935
ZI channels implementation
hay-k May 6, 2024
b4e87f2
fix incorrect call of function _load_pulse
hay-k May 6, 2024
72f9a82
parse two qubit gates represented as raw sequence dict
hay-k May 6, 2024
f67655d
define ZI acquisition channel config with power_range
hay-k May 6, 2024
77d3647
Revert "remove load_instrument_settings since it is replaced by chann…
hay-k May 7, 2024
4810c0c
update dumping 2qb natives to dump pulse sequence
hay-k May 7, 2024
949c645
remove redundant line
hay-k May 7, 2024
7bbd82e
adapt sweep processing to channels
hay-k May 8, 2024
72acb68
remove redundant function frequency_from_pulses
hay-k May 8, 2024
e95cf4e
introduce small mixin classes for channel definitions
hay-k May 14, 2024
6acad5a
add frequency to the list of channel related parameters
hay-k May 14, 2024
8ab64a4
implement function to load channel configs from serialized runcard
hay-k May 14, 2024
21d96d8
implement processing of channel sweeps; remove subsecuence splitting …
hay-k May 14, 2024
1737109
remove sweetspot from Qubit class
hay-k May 14, 2024
742b835
don't copy pulse
hay-k May 14, 2024
98cb18d
rename PulseSequence.append to extend
hay-k May 14, 2024
3313718
get rid of CHannelMap
hay-k May 14, 2024
daba9ff
shorten and normalize config class names
hay-k May 14, 2024
405f657
improve type annotation and docstring
hay-k May 14, 2024
3dcf4b0
get rid of ZhPulse
hay-k May 15, 2024
79fd8d8
get rid of SubSequence that was made redundant by 9dd355a643c2052e365…
hay-k May 15, 2024
255658b
move channel_cfg to ExecutionParameters
hay-k May 16, 2024
582d04d
set cfg for external/supplementary (to the main channel instrument) i…
hay-k May 20, 2024
eb611f9
get rid of redundant properties
hay-k May 20, 2024
014efcf
sweap measurement pulse amplitude in near-time instead of oscillator …
hay-k May 20, 2024
29fe61a
remove type from acquisition config
hay-k May 21, 2024
b2da266
remove import of removed ZhPulse class
hay-k May 21, 2024
12c1dae
don't use properties that were made redundant
hay-k May 21, 2024
a2b642b
convert single qubit natives from Pulse to PulseSequence
hay-k May 21, 2024
1feaa21
remove frequency from IqConfig
hay-k May 29, 2024
82479fa
Improve channel cfg deserialization
hay-k May 31, 2024
d8146ea
Revert "remove frequency from IqConfig"
hay-k May 31, 2024
b623e99
implement possibility for user to add aux IQ channels
hay-k Jun 3, 2024
bda8573
Revert "implement possibility for user to add aux IQ channels"
hay-k Jun 5, 2024
a4ae3b9
channels and components
hay-k Jun 12, 2024
7bd9b28
add config and components getters
hay-k Jun 26, 2024
7d38a88
do not refer to qubits in the driver
hay-k Jun 26, 2024
4b098a9
update ZI driver according to components
hay-k Jun 27, 2024
1cc1022
fix component config update
hay-k Jun 27, 2024
89ea40e
remove duplicate line
hay-k Jun 27, 2024
0a8f1a6
fix the extend implementation
hay-k Jul 1, 2024
4aa511c
sequence tests
hay-k Jul 1, 2024
534dc9e
fix pulse tests
hay-k Jul 1, 2024
6a931a8
remove frequency from pulse
hay-k Jul 2, 2024
528ce61
accept frequency explicitly as argument
hay-k Jul 2, 2024
188dab3
update plot tests
hay-k Jul 2, 2024
a349a4b
remove obsolete files
hay-k Jul 2, 2024
9ee329c
implement sequence copy
hay-k Jul 2, 2024
7562361
add channels dedicated to 12 transition and cross resonance gates
hay-k Jul 2, 2024
713bd7a
fix handling of native gates
hay-k Jul 2, 2024
f369dba
update dummy instrument and platform
hay-k Jul 2, 2024
b67356e
update dummy platform tests
hay-k Jul 2, 2024
33766a9
fix incorrect rebase
hay-k Jul 2, 2024
6450801
remove obsolete functions
hay-k Jul 3, 2024
a34b4e9
update unrolling tests
hay-k Jul 3, 2024
8d4ed27
improve error messages
hay-k Jul 3, 2024
7efd482
update sweeper tests
hay-k Jul 3, 2024
3d2b508
update result shape tests
hay-k Jul 3, 2024
48e4f8d
update platform tests
hay-k Jul 3, 2024
44dc29a
remove reference to Port
hay-k Jul 4, 2024
e272397
update to new pulse sequence format
hay-k Jul 12, 2024
6594d6b
introduce concept of gate factories
hay-k Jul 12, 2024
915bf1d
remove redundant methods
hay-k Jul 12, 2024
d224411
update compiler
hay-k Jul 12, 2024
bfe6adf
remove obsolete property _ports
hay-k Jul 15, 2024
4c74a30
temporarily disable pylint check
hay-k Jul 15, 2024
02a21a9
update zhinst tests
hay-k Jul 15, 2024
c32799e
fix import
hay-k Jul 15, 2024
09dbd11
make arguments optional
hay-k Jul 15, 2024
2d37e63
Update dummy platform tests
hay-k Jul 15, 2024
417a604
fix channel name
hay-k Jul 15, 2024
9ac5185
update compiler tests
hay-k Jul 15, 2024
626f812
fix dummy platform
hay-k Jul 16, 2024
35037a5
update unrolling function
hay-k Jul 16, 2024
6aa3056
update channel list
hay-k Jul 16, 2024
91257e1
update platform tests
hay-k Jul 16, 2024
15294bf
update looping over pulses
hay-k Jul 16, 2024
35dfcf1
update metabackend load test
hay-k Jul 16, 2024
73e5887
temporarily disable non 0.2 compatible platforms
hay-k Jul 16, 2024
9944e95
update unit test platform with ZI instruments
hay-k Jul 16, 2024
a67d222
change confusing name of platform
hay-k Jul 16, 2024
11f672b
recover function lost during rebase
hay-k Jul 17, 2024
5f1401c
improve type annotation
hay-k Jul 17, 2024
3b6b5f3
implement init from dict
hay-k Jul 22, 2024
8dceab7
update documentation
hay-k Jul 23, 2024
b406f31
some port tests
hay-k Jul 29, 2024
2189a90
rename component_configs to configs
hay-k Jul 29, 2024
3d24096
rename the sweep method to play for zi executor
hay-k Jul 30, 2024
bee7498
Some port tests
hay-k Jul 30, 2024
bfd7cc4
remove un-necessary method load_component_config
hay-k Jul 30, 2024
5006b74
revert accidental change in pyproject.toml
hay-k Jul 30, 2024
e237aee
rename measure to probe
hay-k Jul 31, 2024
5005f93
dump platform with updates
hay-k Jul 31, 2024
84dfaec
update documentation
hay-k Jul 31, 2024
efefe5d
chore: Fix rebase leftover
alecandido Aug 5, 2024
a14ff78
ci: Temporarily block automated run of Rust checks
alecandido Aug 5, 2024
3572165
ci: Replace rustup update with external installation action
alecandido Aug 5, 2024
4522fa7
ci: Update actions in local workflows
alecandido Aug 5, 2024
c1747ad
fix: Fix further rebase leftover
alecandido Aug 5, 2024
0eaf775
ci: Attempt switching back to macos latest
alecandido Aug 5, 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
6 changes: 3 additions & 3 deletions .github/workflows/capi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
- name: Prepare virtual environment
run: |
python -m venv env
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9, "3.10", "3.11"]
uses: qiboteam/workflows/.github/workflows/deploy-pip-poetry.yml@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-13, windows-latest]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.9, "3.10", "3.11"]
uses: qiboteam/workflows/.github/workflows/rules-poetry.yml@v1
with:
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/rustapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name: Rust API

on:
push:
workflow_dispatch:

jobs:
Expand All @@ -13,18 +12,15 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: "3.11"
- name: Prepare virtual environment
run: |
pip install .
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: dtolnay/rust-toolchain@stable
- name: Check and lint
working-directory: crate
run: |
Expand Down
147 changes: 106 additions & 41 deletions doc/source/getting-started/experiment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,87 @@ file with additional calibration parameters.
More information about defining platforms is provided in :doc:`../tutorials/lab` and several examples can be found at `TII dedicated repository <https://github.com/qiboteam/qibolab_platforms_qrc>`_.

For a first experiment, let's define a single qubit platform at the path previously specified.
For simplicity, the qubit will be controlled by a RFSoC-based system, althought minimal changes are needed to use other devices.
In this example, the qubit is controlled by a Zurich Instruments' SHFQC instrument, although minimal changes are needed to use other devices.

.. testcode:: python

# my_platform/platform.py

import pathlib

from qibolab.channels import Channel, ChannelMap
from qibolab.instruments.rfsoc import RFSoC
from qibolab.instruments.rohde_schwarz import SGS100A as LocalOscillator
from laboneq.simple import DeviceSetup, SHFQC
from qibolab.components import (
AcquireChannel,
IqChannel,
IqConfig,
AcquisitionConfig,
OscillatorConfig,
)
from qibolab.instruments.zhinst import ZiChannel, Zurich
from qibolab.platform import Platform
from qibolab.serialize import load_qubits, load_runcard, load_settings
from qibolab.serialize import (
load_instrument_settings,
load_qubits,
load_runcard,
load_settings,
)

NAME = "my_platform" # name of the platform
ADDRESS = "192.168.0.1" # ip address of the controller
PORT = 6000 # port of the controller
ADDRESS = "localhost" # ip address of the ZI data server
PORT = 8004 # port of the ZI data server

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


def create():
# Instantiate controller instruments
controller = RFSoC(NAME, ADDRESS, PORT)
# Define available instruments
device_setup = DeviceSetup()
device_setup.add_dataserver(host=ADDRESS, port=PORT)
device_setup.add_instruments(SHFQC("device_shfqc", address="DEV12146"))

# Create channel objects and port assignment
channels = ChannelMap()
channels |= Channel("readout", port=controller[1])
channels |= Channel("feedback", port=controller[0])
channels |= Channel("drive", port=controller[0])

# create qubit objects
# Load and parse the runcard (i.e. parameters.json)
runcard = load_runcard(FOLDER)
qubits, pairs = load_qubits(runcard)
# assign channels to qubits
qubits[0].readout = channels["L3-22_ro"]
qubits[0].feedback = channels["L1-2-RO"]
qubits[0].drive = channels["L3-22_qd"]
qubits, _, pairs = load_qubits(runcard)
qubit = qubits[0]

instruments = {controller.name: controller}
# define component names, and load their configurations
drive, probe, acquire = "q0/drive", "q0/probe", "q0/acquire"
drive_lo, readout_lo = "q0/drive/lo", "q0/readout/lo"

# assign channels to qubits
qubit.drive = IqChannel(name=drive, lo=drive_lo, mixer=None)
qubit.probe = IqChannel(name=probe, lo=readout_lo, mixer=None, acquisition=acquire)
qubit.acquisition = AcquireChannel(name=acquire, probe=probe, twpa_pump=None)

configs = {}
component_params = runcard["components"]
configs[drive] = IqConfig(**component_params[drive])
configs[probe] = IqConfig(**component_params[probe])
configs[acquire] = AcquisitionConfig(**component_params[acquire])
configs[drive_lo] = OscillatorConfig(**component_params[drive_lo])
configs[readout_lo] = OscillatorConfig(**component_params[readout_lo])

zi_channels = [
ZiChannel(qubit.drive, device="device_shfqc", path="SGCHANNELS/0/OUTPUT"),
ZiChannel(qubit.probe, device="device_shfqc", path="QACHANNELS/0/OUTPUT"),
ZiChannel(qubit.acquisition, device="device_shfqc", path="QACHANNELS/0/INPUT"),
]

controller = Zurich(NAME, device_setup=device_setup, channels=zi_channels)

instruments = load_instrument_settings(runcard, {controller.name: controller})
settings = load_settings(runcard)
return Platform(NAME, qubits, pairs, instruments, settings, resonator_type="3D")
return Platform(
NAME,
qubits,
pairs,
configs,
instruments,
settings,
resonator_type="3D",
)


.. note::

Expand Down Expand Up @@ -93,22 +131,51 @@ And the we can define the runcard ``my_platform/parameters.json``:
"relaxation_time": 70000,
"sampling_rate": 9830400000
},
"components": {
"qubit_0/drive": {
"frequency": 4833726197,
"power_range": 5
},
"qubit_0/drive/lo": {
"frequency": 5200000000,
"power": null
},
"qubit_0/probe": {
"frequency": 7320000000,
"power_range": 1
},
"qubit_0/readout/lo": {
"frequency": 7300000000,
"power": null
},
"qubit_0/acquire": {
"delay": 0,
"smearing": 0,
"power_range": 10
}
}
"native_gates": {
"single_qubit": {
"0": {
"RX": {
"duration": 40,
"amplitude": 0.5,
"frequency": 5500000000,
"shape": "Gaussian(3)",
"type": "qd",
"qubit_0/drive": [
{
"duration": 40,
"amplitude": 0.5,
"envelope": { "kind": "gaussian", "rel_sigma": 3.0 },
"type": "qd"
}
]
},
"MZ": {
"duration": 2000,
"amplitude": 0.02,
"frequency": 7370000000,
"shape": "Rectangular()",
"type": "ro",
"qubit_0/probe": [
{
"duration": 2000,
"amplitude": 0.02,
"envelope": { "kind": "rectangular" },
"type": "ro"
}
]
}
}
},
Expand All @@ -117,8 +184,6 @@ And the we can define the runcard ``my_platform/parameters.json``:
"characterization": {
"single_qubit": {
"0": {
"readout_frequency": 7370000000,
"drive_frequency": 5500000000,
"anharmonicity": 0,
"Ec": 0,
"Ej": 0,
Expand Down Expand Up @@ -187,16 +252,15 @@ We leave to the dedicated tutorial a full explanation of the experiment, but her
# load the platform from ``dummy.py`` and ``dummy.json``
platform = create_platform("dummy")

qubit = platform.qubits[0]
# define the pulse sequence
sequence = PulseSequence()
ro_pulse = platform.create_MZ_pulse(qubit=0)
sequence.append(ro_pulse)
sequence = qubit.native_gates.MZ.create_sequence()

# define a sweeper for a frequency scan
sweeper = Sweeper(
parameter=Parameter.frequency,
values=np.arange(-2e8, +2e8, 1e6),
pulses=[ro_pulse],
channels=[qubit.probe.name],
type=SweeperType.OFFSET,
)

Expand All @@ -209,10 +273,11 @@ We leave to the dedicated tutorial a full explanation of the experiment, but her
)

results = platform.execute([sequence], options, [[sweeper]])
probe_pulse = next(iter(sequence.probe_pulses))

# plot the results
amplitudes = results[ro_pulse.id][0].magnitude
frequencies = np.arange(-2e8, +2e8, 1e6) + ro_pulse.frequency
amplitudes = results[probe_pulse.id][0].magnitude
frequencies = np.arange(-2e8, +2e8, 1e6) + platform.config(qubit.probe.name).frequency

plt.title("Resonator Spectroscopy")
plt.xlabel("Frequencies [Hz]")
Expand Down
Loading