Skip to content

Commit

Permalink
fix: Fix doctests and import
Browse files Browse the repository at this point in the history
  • Loading branch information
alecandido committed Aug 16, 2024
1 parent 4aeee57 commit 3a8b20b
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 40 deletions.
4 changes: 3 additions & 1 deletion doc/source/getting-started/experiment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ We leave to the dedicated tutorial a full explanation of the experiment, but her

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

plt.title("Resonator Spectroscopy")
plt.xlabel("Frequencies [Hz]")
Expand Down
17 changes: 9 additions & 8 deletions doc/source/main-documentation/qibolab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ We can easily access the names of channels and other components, and based on th

drive_channel = platform.qubits[0].drive
print(f"Drive channel name: {drive_channel.name}")
print(f"Drive frequency: {platform.config(drive_channel.name).frequency}")
print(f"Drive frequency: {platform.config(str(drive_channel.name)).frequency}")

drive_lo = drive_channel.lo
if drive_lo is None:
print(f"Drive channel {drive_channel.name} does not use an LO.")
else:
print(f"Name of LO for channel {drive_channel.name} is {drive_lo}")
print(f"LO frequency: {platform.config(drive_lo).frequency}")
print(f"LO frequency: {platform.config(str(drive_lo)).frequency}")

.. testoutput:: python
:hide:
Expand Down Expand Up @@ -304,12 +304,12 @@ To organize pulses into sequences, Qibolab provides the :class:`qibolab.pulses.P
relative_phase=0, # phases are in radians
envelope=Rectangular(),
)
sequence = PulseSequence(
sequence = PulseSequence.load(
[
("channel", pulse1),
("channel", pulse2),
("channel", pulse3),
("channel", pulse4),
("qubit/drive", pulse1),
("qubit/drive", pulse2),
("qubit/drive", pulse3),
("qubit/drive", pulse4),
],
)

Expand All @@ -336,13 +336,14 @@ Typical experiments may include both pre-defined pulses and new ones:
.. testcode:: python

from qibolab.pulses import Rectangular
from qibolab.identifier import ChannelId

natives = platform.parameters.native_gates.single_qubit[0]
sequence = PulseSequence()
sequence.concatenate(natives.RX.create_sequence())
sequence.append(
(
"some_channel",
ChannelId.load("some/drive"),
Pulse(duration=10, amplitude=0.5, relative_phase=0, envelope=Rectangular()),
)
)
Expand Down
8 changes: 6 additions & 2 deletions doc/source/tutorials/calibration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ In few seconds, the experiment will be finished and we can proceed to plot it.

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

plt.title("Resonator Spectroscopy")
plt.xlabel("Frequencies [Hz]")
Expand Down Expand Up @@ -166,7 +168,9 @@ We can now proceed to launch on hardware:

probe_pulse = next(iter(sequence.probe_pulses))
amplitudes = magnitude(results[probe_pulse.id][0])
frequencies = np.arange(-2e8, +2e8, 1e6) + platform.config(qubit.drive.name).frequency
frequencies = (
np.arange(-2e8, +2e8, 1e6) + platform.config(str(qubit.drive.name)).frequency
)

plt.title("Resonator Spectroscopy")
plt.xlabel("Frequencies [Hz]")
Expand Down
60 changes: 36 additions & 24 deletions doc/source/tutorials/lab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@ using different Qibolab primitives.
qubit = Qubit(name=0)

# assign channels to the qubit
qubit.probe = IqChannel(name="probe", mixer=None, lo=None, acquisition="acquire")
qubit.acquisition = AcquireChannel(name="acquire", twpa_pump=None, probe="probe")
qubit.drive = Iqchannel(name="drive", mixer=None, lo=None)
qubit.probe = IqChannel(
name="0/probe", mixer=None, lo=None, acquisition="0/acquisition"
)
qubit.acquisition = AcquireChannel(
name="0/acquisition", twpa_pump=None, probe="probe"
)
qubit.drive = Iqchannel(name="0/drive", mixer=None, lo=None)

# define configuration for channels
configs = {}
configs[qubit.drive.name] = IqConfig(frequency=3e9)
configs[qubit.probe.name] = IqConfig(frequency=7e9)
configs[str(qubit.drive.name)] = IqConfig(frequency=3e9)
configs[str(qubit.probe.name)] = IqConfig(frequency=7e9)

# create sequence that drives qubit from state 0 to 1
drive_seq = PulseSequence(
Expand Down Expand Up @@ -120,13 +124,21 @@ the native gates, but separately from the single-qubit ones.
qubit1 = Qubit(name=1)

# assign channels to the qubits
qubit0.probe = IqChannel(name="probe_0", mixer=None, lo=None, acquisition="acquire_0")
qubit0.acquisition = AcquireChannel(name="acquire_0", twpa_pump=None, probe="probe_0")
qubit0.drive = IqChannel(name="drive_0", mixer=None, lo=None)
qubit0.flux = DcChannel(name="flux_0")
qubit1.probe = IqChannel(name="probe_1", mixer=None, lo=None, acquisition="acquire_1")
qubit1.acquisition = AcquireChannel(name="acquire_1", twpa_pump=None, probe="probe_1")
qubit1.drive = IqChannel(name="drive_1", mixer=None, lo=None)
qubit0.probe = IqChannel(
name="0/probe", mixer=None, lo=None, acquisition="0/acquisition"
)
qubit0.acquisition = AcquireChannel(
name="0/acquisition", twpa_pump=None, probe="probe_0"
)
qubit0.drive = IqChannel(name="0/drive", mixer=None, lo=None)
qubit0.flux = DcChannel(name="0/flux")
qubit1.probe = IqChannel(
name="1/probe", mixer=None, lo=None, acquisition="1/acquisition"
)
qubit1.acquisition = AcquireChannel(
name="1/acquisition", twpa_pump=None, probe="probe_1"
)
qubit1.drive = IqChannel(name="1/drive", mixer=None, lo=None)

# assign single-qubit native gates to each qubit
single_qubit = {}
Expand Down Expand Up @@ -219,10 +231,10 @@ will take them into account when calling :class:`qibolab.native.TwoQubitNatives`
# create the qubit and coupler objects
qubit0 = Qubit(name=0)
qubit1 = Qubit(name=1)
coupler_01 = Qubit(name=100)
coupler_01 = Qubit(name="c01")

# assign channel(s) to the coupler
coupler_01.flux = DcChannel(name="flux_coupler_01")
coupler_01.flux = DcChannel(name="c01/flux")

# assign single-qubit native gates to each qubit
# Look above example
Expand Down Expand Up @@ -295,26 +307,26 @@ a two-qubit system:
"relaxation_time": 50000
},
"components": {
"drive_0": {
"0/drive": {
"frequency": 4855663000
},
"drive_1": {
"1/drive": {
"frequency": 5800563000
},
"flux_0": {
"0/flux": {
"bias": 0.0
},
"probe_0": {
"0/probe": {
"frequency": 7453265000
},
"probe_1": {
"1/probe": {
"frequency": 7655107000
},
"acquire_0": {
"0/acquisition": {
"delay": 0,
"smearing": 0
},
"acquire_1": {
"1/acquisition": {
"delay": 0,
"smearing": 0
}
Expand Down Expand Up @@ -510,7 +522,7 @@ the above runcard:
# define channels and load component configs
qubits = {}
for q in range(2):
probe_name, acquire_name = f"qubit_{q}/probe", f"qubit_{q}/acquire"
probe_name, acquire_name = f"qubit_{q}/probe", f"qubit_{q}/acquisition"
qubits[q] = Qubit(
name=q,
drive=IqChannel(f"qubit_{q}/drive", mixer=None, lo=None),
Expand Down Expand Up @@ -540,7 +552,7 @@ With the following additions for coupler architectures:
qubits = {}
# define channels and load component configs
for q in range(2):
probe_name, acquire_name = f"qubit_{q}/probe", f"qubit_{q}/acquire"
probe_name, acquire_name = f"qubit_{q}/probe", f"qubit_{q}/acquisition"
qubits[q] = Qubit(
name=q,
drive=IqChannel(f"qubit_{q}/drive", mixer=None, lo=None),
Expand Down Expand Up @@ -622,7 +634,7 @@ in this case ``"twpa_pump"``.
# define channels and load component configs
qubits = {}
for q in range(2):
probe_name, acquire_name = f"qubit_{q}/probe", f"qubit_{q}/acquire"
probe_name, acquire_name = f"qubit_{q}/probe", f"qubit_{q}/acquisition"
qubits[q] = Qubit(
name=q,
drive=IqChannel(f"qubit_{q}/drive", mixer=None, lo=None),
Expand Down
8 changes: 4 additions & 4 deletions doc/source/tutorials/pulses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ pulses (:class:`qibolab.pulses.Pulse`) through the
from qibolab.sequence import PulseSequence

# Define PulseSequence
sequence = PulseSequence(
sequence = PulseSequence.load(
[
(
"channel_0",
"0/drive",
Pulse(
amplitude=0.3,
duration=60,
relative_phase=0,
envelope=Gaussian(rel_sigma=0.2),
),
),
("channel_1", Delay(duration=100)),
("1/drive", Delay(duration=100)),
(
"channel_1",
"1/drive",
Pulse(
amplitude=0.5, duration=3000, relative_phase=0, envelope=Rectangular()
),
Expand Down
2 changes: 1 addition & 1 deletion src/qibolab/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from pydantic import TypeAdapter
from pydantic_core import core_schema

from .identifier import ChannelId
from .identifier import ChannelId, ChannelType
from .pulses import Delay, Pulse, PulseLike

__all__ = ["PulseSequence"]
Expand Down

0 comments on commit 3a8b20b

Please sign in to comment.