Running a measurement
To run a measurement, you need to define:
- which QPU you want to run a job on
- which measurement you want to carry out
- which qubits are involved in the measurement
In QruiseOS, just running a measurement with default parameters is as simple as:
from utils import get_measurement_backend, measurements
qpu = get_measurement_backend()
QUBIT_NAME = "Q4"
measurement = measurements.RabiAmplitude
data = measurement(qpu,QUBIT_NAME).measure()
Tip
The module measurements
is a catalogue of measurements you can pick from. To see which measurements are ready to be used, just use tab completion measurements.<TAB>
.
You can read about all our pre-defined measurements in the Experiment catalogue.
Note
The reason for not directly invoking data = measurement(qpu,"Q4").measure()
but rather defining a QUBIT_NAME
variable is to prepare for passing parameters, which will be needed to reuse this snippet within a Task. The point of QruiseOS is indeed not just to run jobs on QPUs but to orchestrate experiments and persist the data.
Specifying parameters of the measurement
To explicitly specify the configuration of a measurement, you can pass it as a dictionary. For example, if we start from the amplitude Rabi measurement above, we can specify the amplitude range and sampling and the number of shots for each amplitude by passing measurement_kwargs to the measure
method. The measure
method is defined in the code of the measurements.RabiAmplitude
class and can be used with an instance of this class like measurement(qpu,QUBIT_NAME)
.
from qruise.experiment.utils.sweep_util import SweepRange
measurement_kwargs = {amplitude = SweepRange(-20e6,20e6),
shots=1024
}
data = measurement(qpu,QUBIT_NAME).measure(**measurement_kwargs)
This approach allows for clear and structured definition of measurement parameters, ensuring that all necessary configurations are easily accessible and modifiable.
Custom measurement catalogue
Though Qruise has developed extensive measurement catalogues for different hardware setups, we expect QruiseOS users to also want to use their own in-house catalogue. With the QruiseOS architecture, doing so is only a matter of adding this line to utils.py
:
python
import yourlab.measurements as measurements
Of course, yourlab.measurements
has to be prepared so that it embraces the QruiseOS way to describe measurements. Qruise provides templates to streamline the whole process which basically consists in specifying qpu and data formatting code for each measurement as explained in the Integrating a measurement user guide.
The architecture choices explained: about the adapter file utils.py
The reason to define get_measurement_backend
and measurements
in a local utils.py
module is two-fold. First it provides normalisation hence low cognitive load in the way the user gets access to the qpu and measurement catalogue assets. Second it provides flexibility.
Imagine you want to leverage a different measurements
catalogue. It would typically require the user to change all the import statements across code snippets or code base. With QruiseOS architecture choice, this change is just becoming a matter of configuration by changing the definition of measurements
within utils
leaving all other code unchanged. This is well illustrated by the single line import yourlab.measurements as measurements
change in utils.py
that is suggested to leverage a new custom catalogue.