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

Trim pulse's Shape to envelopes #818

Merged
merged 78 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
0287bf2
Remove leftover calls to pulse specific copy
alecandido Jan 18, 2024
a2fd175
Start rearranging pulses into a subpackage
alecandido Jan 18, 2024
b4dd723
test: fix tests
stavros11 Mar 20, 2024
cf72977
feat: Drop ShapeInitError in favor of pulse default value
alecandido Feb 23, 2024
67f8d54
feat: Sketch the new Shape template
alecandido Feb 23, 2024
2dc7460
feat: Trim the Rectangular pulse
alecandido Feb 23, 2024
c8d87de
feat: Add a Shapes enum, for sum-types deserialization
alecandido Feb 23, 2024
78b0ddd
feat: Rework the Exponential shape
alecandido Feb 23, 2024
cf3d4ce
feat!: Move Gaussian pulse to new shape
alecandido Feb 28, 2024
7695d51
feat: Add default implementation for shape components
alecandido Feb 28, 2024
133a60a
feat!: Move GaussianSquare to new shape
alecandido Feb 28, 2024
58ed4a3
feat!: Move DRAG to new shape
alecandido Feb 28, 2024
d728a62
feat!: Move IIR to new shape
alecandido Feb 28, 2024
dbeec43
feat!: Move SNZ to new shape
alecandido Feb 28, 2024
90f5d80
feat!: Move eCap to new shape
alecandido Feb 28, 2024
23a7f67
feat!: Move Custom to new shape
alecandido Feb 28, 2024
6891143
feat!: Export only shapes container
alecandido Feb 28, 2024
6eaf5b7
refactor: Split software modulation and related tests
alecandido Feb 28, 2024
b486387
feat: rename Shape to Envelope
alecandido Mar 5, 2024
d735a3a
docs: Describe the expected times, restricting the original purpose
alecandido Mar 5, 2024
16df509
feat: Move Gaussian pulses back to their original variables
alecandido Mar 5, 2024
eabc173
feat: Propagate window to drag and iir
alecandido Mar 5, 2024
5f53fc2
feat: Propagate envelopes to Pulse
alecandido Mar 5, 2024
0179c4d
feat: Keep the amplitude in the pulse, drop it in the shape
alecandido Mar 5, 2024
361b452
build: Exclude CC library in Nix shell for Linux
alecandido Mar 12, 2024
2525875
feat: Represent times as the parameters of linspace
alecandido Mar 12, 2024
581788a
test: Solve pytest collection errors for pulses tests
alecandido Mar 15, 2024
fee3919
test: Fix remaining pytests collection errors
alecandido Mar 15, 2024
90b5a60
fix: Drop shape initialization in pulse post init
alecandido Mar 15, 2024
575b1e1
fix: Fully drop post-init in pulse
alecandido Mar 15, 2024
7c94a73
fix: Propagate envelopes to modulation tests
alecandido Mar 15, 2024
49ce962
test: Simplify modualtion tests, decouple from pulses
alecandido Mar 15, 2024
0a2021e
test: Fix errors in pulse
alecandido Mar 15, 2024
3c1e599
build: Upgrade Nix shell to use Poetry 1.8
alecandido Mar 18, 2024
d846ced
build: Add linting deps to dev shell
alecandido Mar 18, 2024
f1ac8e8
feat!: Reintroduce sampling rate argument for pulse envelope retrieval
alecandido Mar 18, 2024
2704866
fix: Move default sampling rate to plots, drop from modulation
alecandido Mar 18, 2024
383dc6e
feat: Export explicitly all envelopes types
alecandido Mar 21, 2024
52ab2f4
fix: Update envelope names
alecandido Mar 21, 2024
ddadd33
fix: Propagate shape to envelope update in zhinst
alecandido Mar 21, 2024
67cdbf8
feat!: Start introducing pydantic
alecandido Mar 21, 2024
56d96bd
fix: Propagate Pydantic models to Pulse
alecandido Mar 21, 2024
0df11bd
fix: Propagate Pydantic models to Pulse-like classes
alecandido Mar 21, 2024
5088be8
fix: Fix Pylint errors
alecandido Mar 21, 2024
6378b91
feat: Add custom NumPy (de)serializer)
alecandido Mar 21, 2024
16d0564
fix: Adopt qibolab global model in pydantic-aware classes
alecandido Mar 21, 2024
44887a4
fix: Solve import-related issues in tests
alecandido Mar 21, 2024
738ac86
fix: Solve all Pytest collection errors
alecandido Mar 21, 2024
1422a3f
fix: Partial dummy runcard update
alecandido Mar 22, 2024
55c79b5
build: Upgrade devenv version
alecandido Mar 22, 2024
bf6b534
feat: Tag pulse envelopes for more reliable discrimination during des…
alecandido Mar 22, 2024
de63d47
fix: Add defaults to discriminator, include them in dummy
alecandido Mar 23, 2024
17c3219
feat!: Move duration from pulse to envelope
alecandido Mar 23, 2024
3c674b9
feat!: Move duration back to pulse
alecandido Mar 25, 2024
efa3067
feat: Add model equality account for numpy arrays
alecandido Mar 27, 2024
381f0f1
test: Explicit keyword arguments for envelope tests
alecandido Mar 27, 2024
5545a70
fix: Install custom equality for array dependent envelopes
alecandido Mar 27, 2024
eb3fc14
test: Fix drag tests
alecandido Mar 27, 2024
46e1ffb
test: Fix all envelope tests
alecandido Mar 27, 2024
3d19446
test: Fix plot tests
alecandido Mar 27, 2024
015e593
test: Fix most pulse tests
alecandido Mar 27, 2024
d7cb9b3
test: Fix pulse sequences tests
alecandido Mar 28, 2024
2258e4b
test: Use parent class BaseEnvelope for instance check, instead of th…
alecandido Mar 28, 2024
d41a1b3
feat: Make all pydantic models frozen
alecandido Mar 28, 2024
881827c
feat: Propagate pydantic models to execution parameters, fix backend …
alecandido Mar 28, 2024
0f32db7
test: Fix default compiler tests
alecandido Mar 28, 2024
ff326ed
test: Fix unrolling tests
alecandido Mar 28, 2024
1779e06
test: Fix sweepers tests
alecandido Mar 28, 2024
d98cada
fix: Replace some further occurrences of shape, related to platform
alecandido Mar 28, 2024
c2419f3
test: Fix dummy tests
alecandido Mar 29, 2024
9fd66c9
test: Drop pickle test, not used any longer
alecandido Mar 29, 2024
8052d8c
fix: Fix runcard dump
alecandido Mar 29, 2024
7dc7a47
test: Fix the doctests
alecandido Mar 29, 2024
28e3f0b
fix: Change exponential parameters units, from samples to duration
alecandido Mar 30, 2024
875a604
chore: Fix rebase leftover
alecandido Apr 15, 2024
d70a44d
chore: Poetry lock
alecandido Apr 15, 2024
b13e411
fix: Remove (again) duration from GaussianSquare envelope
alecandido Apr 15, 2024
6f4c84b
Improve envelopes' docstrings
alecandido Apr 16, 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
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
Loading