Skip to content

Commit

Permalink
Merge pull request #818 from qiboteam/vectorize-shapes
Browse files Browse the repository at this point in the history
Trim pulse's `Shape` to envelopes
  • Loading branch information
alecandido committed Apr 17, 2024
2 parents 6790872 + 6f4c84b commit f829e8f
Show file tree
Hide file tree
Showing 49 changed files with 3,926 additions and 3,409 deletions.
4 changes: 2 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi

nix_direnv_watch_file flake.nix
nix_direnv_watch_file flake.lock
watch_file flake.nix
watch_file flake.lock
if ! use flake . --impure; then
echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2
fi
22 changes: 12 additions & 10 deletions doc/source/main-documentation/qibolab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Now we can create a simple sequence (again, without explicitly giving any qubit
ps = PulseSequence()
ps.append(platform.create_RX_pulse(qubit=0))
ps.append(platform.create_RX_pulse(qubit=0))
ps.append(Delay(200, platform.qubits[0].readout.name))
ps.append(Delay(duration=200, channel=platform.qubits[0].readout.name))
ps.append(platform.create_MZ_pulse(qubit=0))

Now we can execute the sequence on hardware:
Expand Down Expand Up @@ -274,7 +274,7 @@ To illustrate, here are some examples of single pulses using the Qibolab API:
amplitude=0.5, # Amplitude relative to instrument range
frequency=1e8, # Frequency in Hz
relative_phase=0, # Phase in radians
shape=Rectangular(),
envelope=Rectangular(),
channel="channel",
type="qd", # Enum type: :class:`qibolab.pulses.PulseType`
qubit=0,
Expand All @@ -292,7 +292,7 @@ Alternatively, you can achieve the same result using the dedicated :class:`qibol
amplitude=0.5, # this amplitude is relative to the range of the instrument
frequency=1e8, # frequency are in Hz
relative_phase=0, # phases are in radians
shape=Rectangular(),
envelope=Rectangular(),
channel="channel",
qubit=0,
)
Expand All @@ -312,7 +312,7 @@ To organize pulses into sequences, Qibolab provides the :class:`qibolab.pulses.P
amplitude=0.5, # this amplitude is relative to the range of the instrument
frequency=1e8, # frequency are in Hz
relative_phase=0, # phases are in radians
shape=Rectangular(),
envelope=Rectangular(),
channel="channel",
qubit=0,
)
Expand All @@ -321,7 +321,7 @@ To organize pulses into sequences, Qibolab provides the :class:`qibolab.pulses.P
amplitude=0.5, # this amplitude is relative to the range of the instrument
frequency=1e8, # frequency are in Hz
relative_phase=0, # phases are in radians
shape=Rectangular(),
envelope=Rectangular(),
channel="channel",
qubit=0,
)
Expand All @@ -330,7 +330,7 @@ To organize pulses into sequences, Qibolab provides the :class:`qibolab.pulses.P
amplitude=0.5, # this amplitude is relative to the range of the instrument
frequency=1e8, # frequency are in Hz
relative_phase=0, # phases are in radians
shape=Rectangular(),
envelope=Rectangular(),
channel="channel",
qubit=0,
)
Expand All @@ -339,7 +339,7 @@ To organize pulses into sequences, Qibolab provides the :class:`qibolab.pulses.P
amplitude=0.5, # this amplitude is relative to the range of the instrument
frequency=1e8, # frequency are in Hz
relative_phase=0, # phases are in radians
shape=Rectangular(),
envelope=Rectangular(),
channel="channel",
qubit=0,
)
Expand All @@ -356,7 +356,7 @@ To organize pulses into sequences, Qibolab provides the :class:`qibolab.pulses.P
.. testoutput:: python
:hide:

Total duration: 160
Total duration: 160.0
We have 0 pulses on channel 1.


Expand All @@ -383,7 +383,7 @@ Typical experiments may include both pre-defined pulses and new ones:
amplitude=0.5,
frequency=2500000000,
relative_phase=0,
shape=Rectangular(),
envelope=Rectangular(),
channel="0",
)
)
Expand Down Expand Up @@ -499,7 +499,9 @@ For example:
sequence = PulseSequence()

sequence.append(platform.create_RX_pulse(0))
sequence.append(Delay(sequence.duration, platform.qubits[0].readout.name))
sequence.append(
Delay(duration=sequence.duration, channel=platform.qubits[0].readout.name)
)
sequence.append(platform.create_MZ_pulse(0))

sweeper_freq = Sweeper(
Expand Down
10 changes: 6 additions & 4 deletions doc/source/tutorials/calibration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,18 @@ complex pulse sequence. Therefore with start with that:
AveragingMode,
AcquisitionType,
)
from qibolab.serialize_ import replace

# allocate platform
platform = create_platform("dummy")

# create pulse sequence and add pulses
sequence = PulseSequence()
drive_pulse = platform.create_RX_pulse(qubit=0)
drive_pulse.duration = 2000
drive_pulse.amplitude = 0.01
drive_pulse = replace(drive_pulse, duration=2000, amplitude=0.01)
readout_pulse = platform.create_MZ_pulse(qubit=0)
sequence.append(drive_pulse)
sequence.append(Delay(drive_pulse.duration, readout_pulse.channel))
sequence.append(Delay(duration=drive_pulse.duration, channel=readout_pulse.channel))
sequence.append(readout_pulse)

# allocate frequency sweeper
Expand Down Expand Up @@ -222,7 +222,9 @@ and its impact on qubit states in the IQ plane.
drive_pulse = platform.create_RX_pulse(qubit=0)
readout_pulse1 = platform.create_MZ_pulse(qubit=0)
one_sequence.append(drive_pulse)
one_sequence.append(Delay(drive_pulse.duration, readout_pulse1.channel))
one_sequence.append(
Delay(duration=drive_pulse.duration, channel=readout_pulse1.channel)
)
one_sequence.append(readout_pulse1)

# create pulse sequence 2 and add pulses
Expand Down
90 changes: 54 additions & 36 deletions doc/source/tutorials/lab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using different Qibolab primitives.

from qibolab import Platform
from qibolab.qubits import Qubit
from qibolab.pulses import Pulse, PulseType
from qibolab.pulses import Gaussian, Pulse, PulseType, Rectangular
from qibolab.channels import ChannelMap, Channel
from qibolab.native import SingleQubitNatives
from qibolab.instruments.dummy import DummyInstrument
Expand All @@ -48,18 +48,18 @@ using different Qibolab primitives.
RX=Pulse(
duration=40,
amplitude=0.05,
shape="Gaussian(5)",
envelope=Gaussian(rel_sigma=0.2),
type=PulseType.DRIVE,
qubit=qubit,
frequency=int(4.5e9),
qubit=qubit.name,
frequency=4.5e9,
),
MZ=Pulse(
duration=1000,
amplitude=0.005,
shape="Rectangular()",
envelope=Rectangular(),
type=PulseType.READOUT,
qubit=qubit,
frequency=int(7e9),
qubit=qubit.name,
frequency=7e9,
),
)

Expand Down Expand Up @@ -97,7 +97,7 @@ hold the parameters of the two-qubit gates.
.. testcode:: python

from qibolab.qubits import Qubit, QubitPair
from qibolab.pulses import PulseType, Pulse, PulseSequence
from qibolab.pulses import Gaussian, PulseType, Pulse, PulseSequence, Rectangular
from qibolab.native import (
SingleQubitNatives,
TwoQubitNatives,
Expand All @@ -112,36 +112,36 @@ hold the parameters of the two-qubit gates.
RX=Pulse(
duration=40,
amplitude=0.05,
shape="Gaussian(5)",
envelope=Gaussian(rel_sigma=0.2),
type=PulseType.DRIVE,
qubit=qubit0,
frequency=int(4.7e9),
qubit=qubit0.name,
frequency=4.7e9,
),
MZ=Pulse(
duration=1000,
amplitude=0.005,
shape="Rectangular()",
envelope=Rectangular(),
type=PulseType.READOUT,
qubit=qubit0,
frequency=int(7e9),
qubit=qubit0.name,
frequency=7e9,
),
)
qubit1.native_gates = SingleQubitNatives(
RX=Pulse(
duration=40,
amplitude=0.05,
shape="Gaussian(5)",
envelope=Gaussian(rel_sigma=0.2),
type=PulseType.DRIVE,
qubit=qubit1,
frequency=int(5.1e9),
qubit=qubit1.name,
frequency=5.1e9,
),
MZ=Pulse(
duration=1000,
amplitude=0.005,
shape="Rectangular()",
envelope=Rectangular(),
type=PulseType.READOUT,
qubit=qubit1,
frequency=int(7.5e9),
qubit=qubit1.name,
frequency=7.5e9,
),
)

Expand All @@ -153,9 +153,10 @@ hold the parameters of the two-qubit gates.
Pulse(
duration=30,
amplitude=0.005,
shape="Rectangular()",
envelope=Rectangular(),
type=PulseType.FLUX,
qubit=qubit1,
qubit=qubit1.name,
frequency=1e9,
)
],
)
Expand Down Expand Up @@ -194,9 +195,10 @@ coupler but qibolab will take them into account when calling :class:`qibolab.nat
Pulse(
duration=30,
amplitude=0.005,
shape="Rectangular()",
frequency=1e9,
envelope=Rectangular(),
type=PulseType.FLUX,
qubit=qubit1,
qubit=qubit1.name,
)
],
)
Expand Down Expand Up @@ -269,14 +271,18 @@ a two-qubit system:
"duration": 40,
"amplitude": 0.0484,
"frequency": 4855663000,
"shape": "Drag(5, -0.02)",
"envelope": {
"kind": "drag",
"rel_sigma": 0.2,
"beta": -0.02,
},
"type": "qd",
},
"MZ": {
"duration": 620,
"amplitude": 0.003575,
"frequency": 7453265000,
"shape": "Rectangular()",
"envelope": {"kind": "rectangular"},
"type": "ro",
}
},
Expand All @@ -285,14 +291,18 @@ a two-qubit system:
"duration": 40,
"amplitude": 0.05682,
"frequency": 5800563000,
"shape": "Drag(5, -0.04)",
"envelope": {
"kind": "drag",
"rel_sigma": 0.2,
"beta": -0.04,
},
"type": "qd",
},
"MZ": {
"duration": 960,
"amplitude": 0.00325,
"frequency": 7655107000,
"shape": "Rectangular()",
"envelope": {"kind": "rectangular"},
"type": "ro",
}
}
Expand All @@ -303,7 +313,7 @@ a two-qubit system:
{
"duration": 30,
"amplitude": 0.055,
"shape": "Rectangular()",
"envelope": {"kind": "rectangular"},
"qubit": 1,
"type": "qf"
},
Expand Down Expand Up @@ -371,7 +381,7 @@ we need the following changes to the previous runcard:
{
"duration": 30,
"amplitude": 0.6025,
"shape": "Rectangular()",
"envelope": {"kind": "rectangular"},
"qubit": 1,
"type": "qf"
},
Expand All @@ -389,7 +399,7 @@ we need the following changes to the previous runcard:
"type": "cf",
"duration": 40,
"amplitude": 0.1,
"shape": "Rectangular()",
"envelope": {"kind": "rectangular"},
"coupler": 0,
}
]
Expand Down Expand Up @@ -564,14 +574,18 @@ The runcard can contain an ``instruments`` section that provides these parameter
"duration": 40,
"amplitude": 0.0484,
"frequency": 4855663000,
"shape": "Drag(5, -0.02)",
"envelope": {
"kind": "drag",
"rel_sigma": 0.2,
"beta": -0.02,
},
"type": "qd",
},
"MZ": {
"duration": 620,
"amplitude": 0.003575,
"frequency": 7453265000,
"shape": "Rectangular()",
"envelope": {"kind": "rectangular"},
"type": "ro",
}
},
Expand All @@ -580,14 +594,18 @@ The runcard can contain an ``instruments`` section that provides these parameter
"duration": 40,
"amplitude": 0.05682,
"frequency": 5800563000,
"shape": "Drag(5, -0.04)",
"envelope": {
"kind": "drag",
"rel_sigma": 0.2,
"beta": -0.04,
},
"type": "qd",
},
"MZ": {
"duration": 960,
"amplitude": 0.00325,
"frequency": 7655107000,
"shape": "Rectangular()",
"envelope": {"kind": "rectangular"},
"type": "ro",
}
}
Expand All @@ -598,7 +616,7 @@ The runcard can contain an ``instruments`` section that provides these parameter
{
"duration": 30,
"amplitude": 0.055,
"shape": "Rectangular()",
"envelope": {"kind": "rectangular"},
"qubit": 1,
"type": "qf"
},
Expand Down
Loading

0 comments on commit f829e8f

Please sign in to comment.