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

Qhc 684 implement distortions in qprogram #779

Merged
merged 52 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
dc322a5
Changed handle waveform name into handle weight inside `_append_to_we…
jordivallsq Aug 16, 2024
9ab6d93
added distorsion application in platform for qblox
jordivallsq Aug 16, 2024
27a4c1a
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Aug 19, 2024
54ee04d
Added changelog
jordivallsq Aug 20, 2024
f53ae3e
solved quality errors and added tests
jordivallsq Aug 20, 2024
6f1a000
Fixed tests
jordivallsq Aug 20, 2024
22e3948
moved pylint exception
jordivallsq Aug 20, 2024
3081c9c
qpysequence
jordivallsq Aug 20, 2024
e343c7e
added missing data
jordivallsq Aug 20, 2024
7011aee
BLACK
jordivallsq Aug 21, 2024
17c2a0e
new qpysequence release
jordivallsq Aug 21, 2024
344d4a5
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Aug 21, 2024
968be40
added requested tests
jordivallsq Aug 21, 2024
a84d6d3
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Aug 21, 2024
ba8714f
Black
jordivallsq Aug 21, 2024
d925107
Merge branch 'qhc-684-implement-distortions-in-qprogram' of https://g…
jordivallsq Aug 21, 2024
e203217
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Aug 21, 2024
24379d5
fixed tests
jordivallsq Aug 21, 2024
10db912
removed array for list
jordivallsq Aug 21, 2024
4dd9712
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Aug 21, 2024
fdedc75
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Aug 22, 2024
f932f0d
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Sep 3, 2024
3a9201c
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Sep 3, 2024
c902512
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Sep 6, 2024
4064b94
Update requirements.txt
jordivallsq Sep 6, 2024
f0b39ab
tests
jordivallsq Sep 6, 2024
065a56c
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Sep 6, 2024
9bfb77e
added todict to the _waveforms
jordivallsq Sep 6, 2024
c5297cf
all waveformsto dict
jordivallsq Sep 6, 2024
b8ec232
Merge branch 'qhc-684-implement-distortions-in-qprogram' of https://g…
jordivallsq Sep 6, 2024
deb107e
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Sep 10, 2024
b2f8b86
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Sep 16, 2024
adf420b
Update requirements.txt
jordivallsq Sep 16, 2024
4a2aabb
Update requirements.txt
jordivallsq Sep 16, 2024
e9599b3
Update changelog-dev.md
jordivallsq Sep 16, 2024
f79e0a8
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Sep 17, 2024
624ede9
Update src/qililab/platform/platform.py
jordivallsq Sep 20, 2024
d9c9c22
Apply suggestions from code review
jordivallsq Sep 20, 2024
f11074d
TYPO
jordivallsq Sep 20, 2024
d871564
Merge branch 'main' into qhc-684-implement-distortions-in-qprogram
jordivallsq Sep 20, 2024
b8708bc
modified tests
jordivallsq Sep 20, 2024
5378868
Merge branch 'qhc-684-implement-distortions-in-qprogram' of https://g…
jordivallsq Sep 20, 2024
30c326a
tests
jordivallsq Sep 20, 2024
af10b8b
tests
jordivallsq Sep 20, 2024
df3874f
tests
jordivallsq Sep 20, 2024
30439c4
tests
jordivallsq Sep 20, 2024
93b7242
test
jordivallsq Sep 20, 2024
c131e25
tests
jordivallsq Sep 20, 2024
24710dc
tests
jordivallsq Sep 20, 2024
c46fce6
tests
jordivallsq Sep 20, 2024
bb52ffb
TESTS
jordivallsq Sep 20, 2024
5887616
fixed assertion
jordivallsq Sep 20, 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
29 changes: 29 additions & 0 deletions docs/releases/changelog-dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,35 @@

### Improvements

- Added pulse distorsions in `execute_qprogram` for QBlox in a similar methodology to the distorsions implemented in pulse circuits. The runcard needs to contain the same structure for distorsions as the runcards for circuits and the code will modify the waveforms after compilation (inside `platform.execute_qprogram`).

Example (for Qblox)

```
buses:
- alias: readout
...
distortions:
- name: exponential
tau_exponential: 1.
amp: 1.
sampling_rate: 1. # Optional. Defaults to 1
norm_factor: 1. # Optional. Defaults to 1
auto_norm: True # Optional. Defaults to True
- name: bias_tee
tau_bias_tee: 11000
sampling_rate: 1. # Optional. Defaults to 1
norm_factor: 1. # Optional. Defaults to 1
auto_norm: True # Optional. Defaults to True
- name: lfilter
a: []
b: []
norm_factor: 1. # Optional. Defaults to 1
auto_norm: True # Optional. Defaults to True
```

[#779](https://github.com/qilimanjaro-tech/qililab/pull/779)

### Breaking changes

### Deprecations / Removals
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ qcodes_contrib_drivers==0.18.0
PyVISA-py==0.7.1
tqdm==4.64.1
urllib3==1.26.12
qpysequence==0.10.1
qpysequence==0.10.4
h5py==3.11.0
papermill==2.4.0
qm-qua==1.2.0
Expand Down
8 changes: 7 additions & 1 deletion src/qililab/platform/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,13 @@ def _execute_qprogram_with_qblox( # pylint: disable=too-many-locals
markers=markers,
)
buses = {bus_alias: self._get_bus_by_alias(alias=bus_alias) for bus_alias in sequences}

for bus_alias, bus in buses.items():
if bus.distortions:
for distortion in bus.distortions:
for waveform in sequences[bus_alias]._waveforms._waveforms: # pylint: disable=protected-access
sequences[bus_alias]._waveforms.modify( # pylint: disable=protected-access
waveform.name, distortion.apply(waveform.data)
)
if debug:
with open("debug_qblox_execution.txt", "w", encoding="utf-8") as sourceFile:
for bus_alias in sequences:
Expand Down
6 changes: 3 additions & 3 deletions src/qililab/qprogram/qblox_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def handle_waveform(waveform: Waveform | None, default_length: int = 0):
return index_I, index_Q, length_I

def _append_to_weights_of_bus(self, bus: str, weights: IQPair):
def handle_waveform(waveform: Waveform):
def handle_weight(waveform: Waveform):
_hash = QbloxCompiler._hash_waveform(waveform)

if _hash in self._buses[bus].weight_to_index:
Expand All @@ -289,8 +289,8 @@ def handle_waveform(waveform: Waveform):
self._buses[bus].weight_to_index[_hash] = index
return index, length

index_I, length_I = handle_waveform(weights.I)
index_Q, _ = handle_waveform(weights.Q)
index_I, length_I = handle_weight(weights.I)
index_Q, _ = handle_weight(weights.Q)
return index_I, index_Q, length_I

def _handle_parallel(self, element: Parallel):
Expand Down
4 changes: 3 additions & 1 deletion tests/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,9 @@ class Galadriel:
RUNCARD.INSTRUMENTS: [InstrumentName.QBLOX_QCM.value, "rs_0"],
},
"port": "drive_q0",
RUNCARD.DISTORTIONS: [],
RUNCARD.DISTORTIONS: [
{"name": "lfilter", "a": [1.0, 0.0, 1.0], "auto_norm": True, "b": [0.5, 0.5], "norm_factor": 1.0}
],
RUNCARD.DELAY: 0,
},
{
Expand Down
22 changes: 21 additions & 1 deletion tests/platform/test_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from qibo import gates
from qibo.models import Circuit
from qm.exceptions import StreamProcessingDataLossError
from qpysequence import Sequence
from qpysequence import Sequence, Waveforms
from ruamel.yaml import YAML

from qililab import Arbitrary, save_platform
Expand Down Expand Up @@ -655,6 +655,26 @@ def test_execute_qprogram_with_qblox(self, platform: Platform):
# assure only one debug was called
assert patched_open.call_count == 1

def test_execute_qprogram_with_qblox_distortions(self, platform: Platform):
drive_wf = Square(amplitude=1.0, duration=4)
qprogram = QProgram()
qprogram.play(bus="drive_line_q0_bus", waveform=drive_wf)

test_waveforms_q0 = Waveforms()
test_waveforms_q0.add(array=[0.5, 1.0, 0.5, 0.0], index=0)
test_waveforms_q0.add(array=[0.0, 0.0, 0.0, 0.0], index=1)

with (
patch("builtins.open"),
patch.object(Bus, "upload_qpysequence") as upload,
patch.object(Bus, "run"),
patch.object(Bus, "acquire_qprogram_results"),
patch.object(QbloxModule, "sync_by_port"),
patch.object(QbloxModule, "desync_by_port"),
):
_ = platform.execute_qprogram(qprogram=qprogram)
assert test_waveforms_q0.to_dict() == upload.call_args_list[0].kwargs["qpysequence"]._waveforms.to_dict()

def test_execute_qprogram_with_quantum_machines(
self, platform_quantum_machines: Platform
): # pylint: disable=too-many-locals
Expand Down
Loading