From ddb2e6c2b5920b5f180b31be5c087a5be0605476 Mon Sep 17 00:00:00 2001 From: TheoLaudatQM <98808790+TheoLaudatQM@users.noreply.github.com> Date: Wed, 15 May 2024 09:12:08 +0200 Subject: [PATCH 1/2] bugfix - Octave tools (#213) * Fix case when qm & calibrate is None * Add AutoCalibrationParams * black * fix readme typo * fix typo in readme * Changelog --- CHANGELOG.md | 5 +++++ qualang_tools/octave_tools/README.md | 8 ++++---- qualang_tools/octave_tools/octave_tools.py | 9 +++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b41e5a2..c3f9aa16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] +### Fixed +- octave_tools - Fix bug when setting calibrate to False in ``get_correction_for_each_LO_and_IF()``. + +### Added +- octave_tools - Added the possibility to pass the AutoCalibrationParams to ``get_correction_for_each_LO_and_IF()`` to customize the calibration parameters (IF_amplitude for instance). ## [0.17.4] - 2024-05-07 ### Fixed diff --git a/qualang_tools/octave_tools/README.md b/qualang_tools/octave_tools/README.md index 055f987e..5a677736 100644 --- a/qualang_tools/octave_tools/README.md +++ b/qualang_tools/octave_tools/README.md @@ -166,8 +166,8 @@ with program() as LO_sweep_prog: ... with for_(i, 0, i < len(lo_frequencies) + 1, i + 1): pause() # This waits until it is resumed from python - set_dc_offset("qubit", "I", offset_I_qua) - set_dc_offset("qubit", "Q", offset_Q_qua) + set_dc_offset("qubit", "I", offset_I_qua[i]) + set_dc_offset("qubit", "Q", offset_Q_qua[i]) with for_(n, 0, n < n_avg, n + 1): with for_(*from_array(f, intermediate_frequencies)): # Update the frequency of the digital oscillator linked to the qubit element @@ -205,7 +205,7 @@ Each set of correction parameters will be saved in the calibration database. ### Usage example ```python -from qualang_tools.octave_tools import calibrate_several_frequencies +from qualang_tools.octave_tools import octave_calibration_tool # Open the QMM qmm = QuantumMachinesManager() @@ -224,7 +224,7 @@ df_external = f_max - f_min lo_frequencies = np.arange(f_min_external, f_max_external + df_external / 2, df_external) # Calibrate all the desired frequencies -calibrate_several_frequencies( +octave_calibration_tool( qm, element="qubit", lo_frequencies=lo_frequencies, diff --git a/qualang_tools/octave_tools/octave_tools.py b/qualang_tools/octave_tools/octave_tools.py index abd68b3a..9792139f 100644 --- a/qualang_tools/octave_tools/octave_tools.py +++ b/qualang_tools/octave_tools/octave_tools.py @@ -4,6 +4,7 @@ from qm.QmJob import QmJob from qm.jobs.running_qm_job import RunningQmJob from qm.QuantumMachine import QuantumMachine +from qm.octave.octave_mixer_calibration import AutoCalibrationParams def get_calibration_parameters_from_db( @@ -132,6 +133,7 @@ def get_correction_for_each_LO_and_IF( nb_of_updates: int, calibrate: bool = False, qm: QuantumMachine = None, + calibration_params: AutoCalibrationParams = None, ): """Look in the calibration database for the calibration parameters corresponding to the provided set of LO frequencies, intermediate frequencies and gain. @@ -145,6 +147,8 @@ def get_correction_for_each_LO_and_IF( 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 (all LO frequencies and only the ``nb_of_updates``` intermediate frequencies). + Custom calibration parameters can be passed using the `calibration_params` dataclass. For instance: + ```calibration_params = AutoCalibrationParams(); calibration_params.if_amplitude = 0.25``` The function will return the list on intermediate frequencies at which the correction matrix will be updated in the program, the 'I' and 'Q' offsets and the four coefficients of the correction matrix with one element for each pair (LO, IF). @@ -158,6 +162,7 @@ def get_correction_for_each_LO_and_IF( :param nb_of_updates: number of intermediate frequencies to calibrate and for which the program will update the correction pmatrix. :param calibrate: calibrate all the frequencies involved to the scan (LO and IF for the specified gain). Default is False. :param qm: the quantum machine object. Default is None. + :param calibration_params: class containing the calibration parameters (if_amplitude, offset_frequency...). Default is None. :return: the list on intermediate frequencies at which the correction matrix will be updated in the program (size nb_of_updates), the 'I' and 'Q' offsets and the four coefficients of the correction matrix with one element for each pair (LO, IF) (size nb_of_updates*len(LO_list)): IFs, c00, c01, c10, c11, offset_I, offset_Q. @@ -173,8 +178,8 @@ def get_correction_for_each_LO_and_IF( for lo in LO_list: if calibrate and qm is not None: - qm.calibrate_element(element, {lo: tuple(IFs)}) - elif qm is None: + qm.calibrate_element(element, {lo: tuple(IFs)}, params=calibration_params) + elif calibrate and qm is None: raise Exception( "The opened Quantum Machine object must be provided if the flag ```calibrate``` is set to True." ) From c5517fd6e3cc814da97897896e4204a69cb6b0b8 Mon Sep 17 00:00:00 2001 From: TheoLaudatQM <98808790+TheoLaudatQM@users.noreply.github.com> Date: Fri, 17 May 2024 08:42:05 +0200 Subject: [PATCH 2/2] unit.to_clock_cycles always returns an integer (#214) * force u.to_clock_cycles to return an integer * changelog --- CHANGELOG.md | 2 +- qualang_tools/units/units.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3f9aa16..2aad2bcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased] ### Fixed - octave_tools - Fix bug when setting calibrate to False in ``get_correction_for_each_LO_and_IF()``. - +- unit - ``to_clock_cycles()`` now always returns an integer. ### Added - octave_tools - Added the possibility to pass the AutoCalibrationParams to ``get_correction_for_each_LO_and_IF()`` to customize the calibration parameters (IF_amplitude for instance). diff --git a/qualang_tools/units/units.py b/qualang_tools/units/units.py index d579ecbc..649b96d7 100644 --- a/qualang_tools/units/units.py +++ b/qualang_tools/units/units.py @@ -182,7 +182,7 @@ def to_clock_cycles(self, t): f"Warning: the specified duration ({t}) to be converted to clock cycles in not an integer. It has been converted to int ({int(t)}) to avoid subsequent errors." ) t = int(t * self.ns) - return t // 4 + return int(t // 4) def demod2volts( self,