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

Add calibration result plotting functions #234

Merged
merged 45 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e0afe40
add calibration result plotting functions
paulQM Oct 22, 2024
31889c4
Update README.md
paulQM Oct 22, 2024
1aeec5d
Update qualang_tools/octave_tools/README.md
paulQM Oct 25, 2024
1281b56
Update qualang_tools/octave_tools/README.md
paulQM Oct 25, 2024
b023b3c
better plots
paulQM Oct 25, 2024
d593ae9
prettify plots
paulQM Oct 29, 2024
054f981
add figure titles
paulQM Oct 29, 2024
56e11d4
Update README.md
paulQM Oct 29, 2024
643ffe9
plots in dBm
paulQM Nov 20, 2024
c400484
add colorbar label
paulQM Nov 20, 2024
d3a5ab9
get lo and if supression formulas
paulQM Dec 9, 2024
72f0acc
factor 2 fix in dbm units
paulQM Dec 12, 2024
d18baea
allow plotting with nan value
paulQM Dec 17, 2024
dc35e10
fix get supression
paulQM Dec 17, 2024
88d5f26
add docstrings
paulQM Dec 17, 2024
4f949c1
Improve README.md
paulQM Dec 18, 2024
b630888
modularize code
paulQM Jan 20, 2025
b50841f
wip
paulQM Jan 23, 2025
2d360bb
wip
paulQM Jan 23, 2025
21fb39d
add integration_length from octave manager
paulQM Jan 31, 2025
85f08f7
make get_suppression functions public
paulQM Jan 31, 2025
c62f3c1
fix
paulQM Jan 31, 2025
988a247
fixes
paulQM Feb 3, 2025
68e301d
comments and renamings
paulQM Feb 3, 2025
e8ec458
add eliptical levels
paulQM Feb 6, 2025
73161fa
Update CHANGELOG.md
paulQM Feb 6, 2025
9c01a17
Update README.md
paulQM Feb 6, 2025
509796e
init test
TheoLaudatQM Feb 14, 2025
9f97be6
add tests
paulQM Feb 17, 2025
cb0cc98
fixes
paulQM Feb 17, 2025
df016d4
fix init
paulQM Feb 17, 2025
f1832d0
resolve comments
paulQM Feb 17, 2025
7a8638b
fix readme
paulQM Feb 17, 2025
941ab0c
remove unused import
TheoLaudatQM Feb 18, 2025
0685e68
remove unused parameters
TheoLaudatQM Feb 18, 2025
e4fad5c
remove print
TheoLaudatQM Feb 18, 2025
7da8734
fix typos
TheoLaudatQM Feb 18, 2025
d8a213e
fix linting
TheoLaudatQM Feb 18, 2025
ff51e97
fix small bug
TheoLaudatQM Feb 18, 2025
fb5f374
quick fix
paulQM Feb 18, 2025
14d63c7
remove DC_phase and DC_gain
paulQM Feb 18, 2025
cc95a9c
Merge branch 'main' into octave-tools-plotter
paulQM Feb 18, 2025
45c656e
Update README.md
paulQM Feb 18, 2025
a0751eb
Update README.md
paulQM Feb 18, 2025
5084c52
test with v4
TheoLaudatQM Feb 18, 2025
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 .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Setup pip Cache
id: cache-pip
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip
Expand All @@ -31,7 +31,7 @@ jobs:
- name: Setup venv Cache
id: cache-python
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: .venv
key: poetry-${{ hashFiles('poetry.lock') }}
Expand Down
23 changes: 12 additions & 11 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]
### Added
- Octave tools Calibration Result Plotter
- two-qubit rb - Added feature to plot the two qubit state distribution.

### Fixed
Expand All @@ -26,7 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- wirer - Fixed bug in the visualizer for LF-FEM and MW-FEM.
- macros/long_wait - Fix issue with `threshold_for_looping` not enforced to be an integer.
- simulator - Recast connection ports in `create_simulator_controller_connections` to be `int`, instead of `np.int64`.
- config/waveform_tools - Allow to set the detuning of a DRAG waveform even when the alpha parameter is 0.
- config/waveform_tools - Allow to set the detuning of a DRAG waveform even when the alpha parameter is 0.
- bakery - Fix error when waveform samples type was subclass of int/float (e.g. numpy.float64).

### Deprecated
Expand Down Expand Up @@ -117,7 +118,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- simulator - ``create_simulator_controller_connections`` now creates the connections with a different algorithm that uses all available optical connections.
- simulator - ``create_simulator_controller_connections`` order of input parameters has changed.
- External_frameworks/qcodes - Fixed the unit of phase
- External_frameworks/qcodes - Added a flag to allow for the phase to remain wrapped
- External_frameworks/qcodes - Added a flag to allow for the phase to remain wrapped
- results - Add a warning when timeout is reached in ``wait_until_job_is_paused``.

### Deprecated
Expand All @@ -134,7 +135,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Added
- External_frameworks/qcodes - Added ``update_readout_length()`` to update locally the readout length of a given readout element and operation.
- External_frameworks/qcodes - Added ``update_qm()`` to update the quantum machine (close and re-open it) in case the config has been updated.
- External_frameworks/qcodes - Added ``update_qm()`` to update the quantum machine (close and re-open it) in case the config has been updated.
- External_frameworks/qcodes - Added ``live_plotting()`` to fetch and plot the OPX results while the program is running.
- Unit - Added `volts2dBm` and `dBm2volts`.

Expand Down Expand Up @@ -177,7 +178,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Config.helper_tools - Added the function `transform_negative_delays()` to adjust a config containing negative delays by offsetting all delays by the most negative one.

### Fixed
- Fixed the loops library to support `qm-qua` 1.1.0
- Fixed the loops library to support `qm-qua` 1.1.0

## [0.13.2] - 2023-02-23
### Added
Expand Down Expand Up @@ -210,9 +211,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [0.12.0] - 2022-08-29
### Changed
- **Breaking change!** - Waveform tools - Added a missing 2$\pi$ factor into `detuning` parameter in `drag_gaussian_pulse_waveforms` and `drag_cosine_pulse_waveforms`.
- **Breaking change!** - Waveform tools - Added a missing 2$\pi$ factor into `detuning` parameter in `drag_gaussian_pulse_waveforms` and `drag_cosine_pulse_waveforms`.
This will produce different results compared to previous versions, to get the same results, divide the `detuning` parameter by 2pi. Both `detuning`, `delta`, and `anharmonicity` are now expected in`Hz` rather than `rad`; a 2$\pi$ multiplication occurs in the built-in function.
- Waveform tools - Renamed argument `delta` to `anharmonicity` in `drag_gaussian_pulse_waveforms` and `drag_cosine_pulse_waveforms`.
- Waveform tools - Renamed argument `delta` to `anharmonicity` in `drag_gaussian_pulse_waveforms` and `drag_cosine_pulse_waveforms`.
`delta` is still accepted but will be deprecated in future versions.
- ConfigBuilder - renamed arguments (backward compatible) in Element and MeasureElement classes.
- ConfigBuilder - renamed AnalogOutputPort attribute channel_weights to crosstalk
Expand Down Expand Up @@ -286,7 +287,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Added
- Interactive plotlib - Support for 2d plot, better data manipulation and better fits
- Waveform tools - Added the waveform tool package, currently including scripts for creating Gaussian and Cosine DRAG waveforms
- Control Panel - VNA Mode - This module allows to configure the OPX as a VNA for a given element (readout resonator for instance) and
- Control Panel - VNA Mode - This module allows to configure the OPX as a VNA for a given element (readout resonator for instance) and
operation (readout pulse for instance) already defined in the configuration.

## [0.7.2] - 2022-03-15
Expand All @@ -296,12 +297,12 @@ operation (readout pulse for instance) already defined in the configuration.
## [0.7.1] - 2022-03-13
### Fixed
- Interactive Plotting Toolbox - Fixed several small issues when loading a figure
- Integration Weights Tool - When compressing and plotting integration weights, the correct label is shown.
- Integration Weights Tool - When compressing and plotting integration weights, the correct label is shown.
- Set minimum version of docutils dependency to 0.14
- Fix config builder GUI imports
### Added
- Interactive Plotting Toolbox - Added default markers when fitting
- Interactive Plotting Toolbox - Improved example and added a demo video
- Interactive Plotting Toolbox - Added default markers when fitting
- Interactive Plotting Toolbox - Improved example and added a demo video
- readme for config builder GUI

## [0.7.0] - 2022-02-10
Expand All @@ -317,7 +318,7 @@ operation (readout pulse for instance) already defined in the configuration.

## [0.6.4] - 2022-01-25
### Fixed
- Bakery - Using "delete_samples()" did not update the element internal time tracking.
- Bakery - Using "delete_samples()" did not update the element internal time tracking.

## [0.6.3] - 2022-01-24
### Added
Expand Down
113 changes: 100 additions & 13 deletions qualang_tools/octave_tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
This library includes tools to improve the users Octave experience.

## get_calibration_parameters_from_db
This function will look into the calibration database and return the correction parameters (offsets and correction
matrix) corresponding to a given set of intermediate frequency, Octave LO frequency and gain.
This function will look into the calibration database and return the correction parameters (offsets and correction
matrix) corresponding to a given set of intermediate frequency, Octave LO frequency and gain.

The correction parameters are returned in the format of a dictionary:
```
Expand All @@ -18,7 +18,7 @@ If no calibration parameters are found in the database, the function will either


### Usage example

```python
from qualang_tools.octave_tools import get_calibration_parameters_from_db

Expand All @@ -35,14 +35,14 @@ qm.octave.set_lo_frequency("qubit", 5e9)
qm.octave.set_rf_output_gain("qubit", -7)
# Get the correction parameters corresponding to the desired parameters:
param_qubit = get_calibration_parameters_from_db(
path_to_database="", config=config, element="qubit",
LO=5e9, IF=50e6, gain=-7,
path_to_database="", config=config, element="qubit",
LO=5e9, IF=50e6, gain=-7,
verbose_level=1)
```

## set_correction_parameters_to_opx
This function will look into the calibration database and update the correction parameters in Python, (offsets and
correction matrix) corresponding to a given set of intermediate frequency, Octave LO frequency and gain.
This function will look into the calibration database and update the correction parameters in Python, (offsets and
correction matrix) corresponding to a given set of intermediate frequency, Octave LO frequency and gain.

The goal to give the user the ability to easily update the correction parameters while sweeping the LO frequency
in Python for instance.
Expand Down Expand Up @@ -82,7 +82,7 @@ qm = qmm.open_qm(config)
# Set the Octave gain
qm.octave.set_rf_output_gain("qubit", 0)
# Loop over the LO frequencies
for i in range(len(lo_frequencies)):
for i in range(len(lo_frequencies)):
# Set the frequency and gain of the LO source
qm.octave.set_lo_frequency("qubit", lo_frequencies[i])
# Update the correction parameters
Expand Down Expand Up @@ -111,7 +111,7 @@ provided ```IF_list```. For instance, if a list of 100 intermediate frequencies
to 10, then only 10 correction parameters will be returned for the returned equally spaced intermediate frequencies.

The goal is to perform a wide frequency sweep (scan the LO frequency in Python and the IF in QUA) and update the
mixer correction parameters for each LO frequency and a few intermediate frequencies, given by ```nb_of_updates```,
mixer correction parameters for each LO frequency and a few intermediate frequencies, given by ```nb_of_updates```,
in QUA.

If the flag ```calibrate``` is set to True (the opened Quantum Machine needs to be provided), then the specified element will be calibrated at the given frequencies
Expand Down Expand Up @@ -141,7 +141,7 @@ f_max_external = 5.5e9 - f_max
df_external = f_max - f_min
lo_frequencies = np.arange(f_min_external, f_max_external + df_external / 2, df_external)

# Get the list of intermediate frequencies at which the correction matrix will
# Get the list of intermediate frequencies at which the correction matrix will
# be updated in QUA and the corresponding correction matrix elements
IFs, c00, c01, c10, c11, offset_I, offset_Q = get_correction_for_each_LO_and_IF(
path_to_database="",
Expand Down Expand Up @@ -185,9 +185,9 @@ with program() as LO_sweep_prog:
)
# Play the pulse
...

# Loop over the LO frequencies
for i in range(len(lo_frequencies)):
for i in range(len(lo_frequencies)):
# Set the frequency and gain of the LO source
qm.octave.set_lo_frequency("qubit", lo_frequencies[i])
# Resume the QUA program (escape the 'pause' statement)
Expand All @@ -199,7 +199,7 @@ for i in range(len(lo_frequencies)):
```

## calibrate_several_frequencies
Calibrate a given element for a set of LO and intermediate frequencies.
Calibrate a given element for a set of LO and intermediate frequencies.
Each set of correction parameters will be saved in the calibration database.

### Usage example
Expand Down Expand Up @@ -231,3 +231,90 @@ octave_calibration_tool(
intermediate_frequencies=intermediate_frequencies
)
```

# CalibrationResultPlotter

## show_lo_leakage_calibration_result()
paulQM marked this conversation as resolved.
Show resolved Hide resolved
Plot the calibration data for the LO leakage.
The resulting plot illustrates the LO leakage signal as a function of the `I_dc` and `Q_dc` DC offsets, including an initial coarse scan and a finer zoom-in scan on the minimum. Additionally, a third plot displays the fit error of the fine scan.

### Usage example:

```python
from qualang_tools.octave_tools.calibration_result_plotter import CalibrationResultPlotter

# Open the qmm and qm
qmm = QuantumMachinesManager()
qm = qmm.open_qm(config)

# Calibrate the desired set of LO frequency and IF
calibration_output = qm.calibrate_element("resonator", {6e9: (100e6,)})

plotter = CalibrationResultPlotter(calibration_output)

fig = plotter.show_lo_leakage_calibration_result()
```

### Outputs:

![image](https://github.com/user-attachments/assets/8b051dcd-9786-4637-8610-f10e9bc7b9d0)


**IMPORTANT NOTE**: The colorbar represents the power seen at the OPX inputs when routing the signal internally through the Octave down-conversion chain. The actual power out of the Octave RF output may vary up to 10 dBm, but the suppression in dB unit will be correct in any case.

## show_image_rejection_calibration_result()
Plot the calibration data for the image sideband.
The produced plot shows the image sideband signal as a function of the `dc_gain` and `dc_phase` parameters for an initial coarse scan and a finer zoom-in scan on the minimum. A third plot shows the fit error of the fine scan.

### Usage example:

```python
from qualang_tools.octave_tools.calibration_result_plotter import CalibrationResultPlotter

# Open the qmm and qm
qmm = QuantumMachinesManager()
qm = qmm.open_qm(config)

# Calibrate the desired set of LO frequency and IF
calibration_output = qm.calibrate_element("resonator", {6e9: (100e6,)})

plotter = CalibrationResultPlotter(calibration_output)

fig = plotter.show_image_rejection_calibration_result()
```

### Outputs:

![image](https://github.com/user-attachments/assets/d33c2e5f-bb12-4582-9559-a9cb774aa831)


**IMPORTANT NOTE**: The colorbar represents the power seen at the OPX inputs when routing the signal internally through the Octave down-conversion chain. The actual power out of the Octave RF output may vary up to 10 dBm, but the suppression in dB unit will be correct in any case.

## get_lo_leakage_rejection() and get_image_rejection()
Returns the LO leakage and image sideband suppression in dB after calibration compared to no calibration at all.

### Usage example:
paulQM marked this conversation as resolved.
Show resolved Hide resolved
```python
from qualang_tools.octave_tools.calibration_result_plotter import CalibrationResultPlotter

# Open the qmm and qm
qmm = QuantumMachinesManager()
qm = qmm.open_qm(config)

# Calibrate the desired set of LO frequency and IF
calibration_output = qm.calibrate_element("resonator", {6e9: (100e6,)})

plotter = CalibrationResultPlotter(calibration_output)

lo_rejection = plotter.get_lo_leakage_rejection()
image_rejection = plotter.get_image_rejection()

print(f'The calibration achieved an LO leakage suppression of {lo_rejection:.2f} dB and an image sideband suppression of {image_rejection:.2f} dB.')
```

### Outputs:


```
The calibration achieved an LO leakeage suppression of -27.23 dB and an image sideband suppression of -42.27 dB.
```
4 changes: 3 additions & 1 deletion qualang_tools/octave_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from qualang_tools.octave_tools.calibration_result_plotter import CalibrationResultPlotter
from qualang_tools.octave_tools.octave_tools import (
get_calibration_parameters_from_db,
set_correction_parameters_to_opx,
get_correction_for_each_LO_and_IF,
octave_calibration_tool,
set_correction_parameters_to_opx,
)

__all__ = [
"get_calibration_parameters_from_db",
"set_correction_parameters_to_opx",
"get_correction_for_each_LO_and_IF",
"octave_calibration_tool",
"CalibrationResultPlotter",
]
Loading
Loading