qiboteam / qibolab

Quantum hardware module and drivers for Qibo.
https://qibo.science
Apache License 2.0
42 stars 14 forks source link

Drop `.get` query on Qblox instruments #726

Closed PiergiorgioButtarini closed 10 months ago

PiergiorgioButtarini commented 10 months ago

This comment actually refers to a couple of lines below, but I cannot comment there because it is not part of this PR. It is also relevant for all other properties, not only lo_frequency.

Here, if you are connected (if self.module.device is not None) you query the device (device.get) for the corresponding value. In principle you can just return self._settings.lo_frequency directly even when you are connected since, if things are done properly, this value should always agree with the one uploaded in the instrument. If there is a situation where these two values are different then the user probably misused the driver (ie. accessed the qcodes interface directly, bypassing qibolab) or there is a bug.

This is the approach we follow in the local oscillators. It could also be slightly faster to return a value stored in the host memory than querying the instrument.

_Originally posted by @stavros11 in https://github.com/qiboteam/qibolab/pull/713#discussion_r1432811841_

See:

@property
  def lo_frequency(self):
      """Local oscillator frequency for the given port."""
      if self.module.device:
          if self.module.device.is_qrm_type:
              self._settings.lo_frequency = self.module.device.get(
                  f"out{self.port_number}_in{self.port_number}_lo_freq"
              )
          elif self.module.device.is_qcm_type:
              self._settings.lo_frequency = self.module.device.get(
                  f"out{self.port_number}_lo_freq"
              )
      return self._settings.lo_frequency