Skip to content

Commit

Permalink
Merge branch 'main' into fix_rounding_error
Browse files Browse the repository at this point in the history
  • Loading branch information
yomach authored May 19, 2024
2 parents 38c1d3d + c5517fd commit 1cf6254
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ 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]
- control_panel - Fix rounding error that caused voltage drifts.
### Fixed
- control_panel - Fix rounding error in `ManualOutputControl` that caused voltage drifts.
- 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).

## [0.17.4] - 2024-05-07
### Fixed
Expand Down
8 changes: 4 additions & 4 deletions qualang_tools/octave_tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions qualang_tools/octave_tools/octave_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand All @@ -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).
Expand All @@ -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.
Expand All @@ -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."
)
Expand Down
2 changes: 1 addition & 1 deletion qualang_tools/units/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1cf6254

Please sign in to comment.