Skip to content

Commit

Permalink
Merge branch 'david/qubit_tracking' of https://github.com/qiboteam/qi…
Browse files Browse the repository at this point in the history
…bolab into david/qubit_tracking
  • Loading branch information
DavidSarlle committed Sep 27, 2023
2 parents a79ea7d + 9bd0dd8 commit 603514e
Show file tree
Hide file tree
Showing 25 changed files with 819 additions and 795 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ repos:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: debug-statements
- repo: https://github.com/psf/black
rev: 23.9.1
Expand All @@ -20,7 +21,7 @@ repos:
- id: isort
args: ["--profile", "black"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.11.0
rev: v3.13.0
hooks:
- id: pyupgrade
- repo: https://github.com/hadialqattan/pycln
Expand Down
155 changes: 154 additions & 1 deletion doc/source/tutorials/lab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,11 @@ the above runcard:
# Create channel objects and assign to them the controller ports
channels = ChannelMap()
channels |= Channel("ch1out", port=instrument["o1"])
channels |= Channel("ch1in", port=instrument["i1"])
channels |= Channel("ch2", port=instrument["o2"])
channels |= Channel("ch3", port=instrument["o3"])
channels |= Channel("ch1in", port=instrument["i1"])
channels |= Channel("chf1", port=instrument["o4"])
channels |= Channel("chf2", port=instrument["o5"])
# create ``Qubit`` and ``QubitPair`` objects by loading the runcard
runcard = load_runcard(Path(__file__).parent / "my_platform.yml")
Expand All @@ -345,6 +347,7 @@ the above runcard:
qubits[q].readout = channels["ch1out"]
qubits[q].feedback = channels["ch1in"]
qubits[q].drive = channels[f"ch{q + 2}"]
qubits[q].flux = channels[f"chf{q + 1}"]
# create dictionary of instruments
instruments = {instrument.name: instrument}
Expand All @@ -356,3 +359,153 @@ the above runcard:
Note that this assumes that the runcard is saved as ``my_platform.yml`` in the
same directory with the Python file that contains ``create()``.


Instrument settings
^^^^^^^^^^^^^^^^^^^

The runcard of the previous example contains only parameters associated to the qubits
and their respective native gates. In some cases parameters associated to instruments
need to also be calibrated. An example is the frequency and the power of local oscillators,
such as the one used to pump a traveling wave parametric amplifier (TWPA).

The runcard can contain an ``instruments`` section that provides these parameters

.. code-block:: yaml
nqubits: 2
qubits: [0, 1]
settings:
nshots: 1024
sampling_rate: 1000000000
relaxation_time: 50_000
topology: [[0, 1]]
instruments:
twpa_pump:
frequency: 4_600_000_000
power: 5
native_gates:
single_qubit:
0: # qubit number
RX:
duration: 40
amplitude: 0.0484
frequency: 4_855_663_000
shape: Drag(5, -0.02)
type: qd # qubit drive
start: 0
phase: 0
MZ:
duration: 620
amplitude: 0.003575
frequency: 7_453_265_000
shape: Rectangular()
type: ro # readout
start: 0
phase: 0
1: # qubit number
RX:
duration: 40
amplitude: 0.05682
frequency: 5_800_563_000
shape: Drag(5, -0.04)
type: qd # qubit drive
start: 0
phase: 0
MZ:
duration: 960
amplitude: 0.00325
frequency: 7_655_107_000
shape: Rectangular()
type: ro # readout
start: 0
phase: 0
two_qubit:
0-1:
CZ:
- duration: 30
amplitude: 0.055
shape: Rectangular()
qubit: 1
relative_start: 0
type: qf
- type: virtual_z
phase: -1.5707963267948966
qubit: 0
- type: virtual_z
phase: -1.5707963267948966
qubit: 1
characterization:
single_qubit:
0:
readout_frequency: 7_453_265_000
drive_frequency: 4_855_663_000
T1: 0.0
T2: 0.0
sweetspot: -0.047
# parameters for single shot classification
threshold: 0.00028502261712637096
iq_angle: 1.283105298787488
1:
readout_frequency: 7_655_107_000
drive_frequency: 5_800_563_000
T1: 0.0
T2: 0.0
sweetspot: -0.045
# parameters for single shot classification
threshold: 0.0002694329123116206
iq_angle: 4.912447775569025
These settings are loaded when creating the platform using :meth:`qibolab.serialize.load_instrument_settings`.
Note that the key used in the runcard should be the same with the name used when instantiating the instrument,
in this case ``"twpa_pump"``.

.. code-block:: python
from pathlib import Path
from qibolab import Platform
from qibolab.channels import ChannelMap, Channel
from qibolab.serialize import load_runcard, load_qubits, load_settings, load_instrument_settings
from qibolab.instruments.dummy import DummyInstrument
from qibolab.instruments.oscillator import LocalOscillator
def create():
# Create a controller instrument
instrument = DummyInstrument("my_instrument", "0.0.0.0:0")
twpa = LocalOscillator("twpa_pump", "0.0.0.1")
# Create channel objects and assign to them the controller ports
channels = ChannelMap()
channels |= Channel("ch1out", port=instrument["o1"])
channels |= Channel("ch2", port=instrument["o2"])
channels |= Channel("ch3", port=instrument["o3"])
channels |= Channel("ch1in", port=instrument["i1"])
# create ``Qubit`` and ``QubitPair`` objects by loading the runcard
runcard = load_runcard(Path(__file__).parent / "my_platform.yml")
qubits, pairs = load_qubits(runcard)
# assign channels to the qubit
for q in range(2):
qubits[q].readout = channels["ch1out"]
qubits[q].feedback = channels["ch1in"]
qubits[q].drive = channels[f"ch{q + 2}"]
# create dictionary of instruments
instruments = {instrument.name: instrument, twpa.name: twpa}
# load instrument settings from the runcard
instruments = load_instrument_settings(runcard, instruments)
# load ``settings`` from the runcard
settings = load_settings(runcard)
return Platform(
"my_platform", qubits, pairs, instruments, settings, resonator_type="2D"
)
8 changes: 5 additions & 3 deletions doc/source/tutorials/pulses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ pulses (:class:`qibolab.pulses.Pulse`) through the
frequency=200000000,
amplitude=0.3,
duration=60,
phase=0,
relative_phase=0,
shape=Gaussian(5),
qubit=0,
)
)
sequence.add(
Expand All @@ -36,8 +37,9 @@ pulses (:class:`qibolab.pulses.Pulse`) through the
frequency=20000000.0,
amplitude=0.5,
duration=3000,
phase=0,
relative_phase=0,
shape=Rectangular(),
qubit=0,
)
)
Expand Down Expand Up @@ -72,7 +74,7 @@ pulse sequence according to the number of shots ``nshots`` specified.
# Executes a pulse sequence.
options = ExecutionParameters(nshots=1000, relaxation_time=100)
results = platform.execute_pulse_sequence(ps, options=options)
results = platform.execute_pulse_sequence(sequence, options=options)
# Turn off lab instruments
platform.stop()
Expand Down
Loading

0 comments on commit 603514e

Please sign in to comment.