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
:
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 consists of specifying the QPU and how to handle the results of each measurement, as explained in our Integrating a new measurement user guide.
Architecture choices explained: the adapter file utils.py
get_measurement_backend
and measurements
are defined in a local utils.py
module for two main reasons:
- They standardise how users access the QPU and the measurement catalogue, reducing cognitive overhead.
- They offer flexibility, allowing you to easily accommodate different QPUs and measurement catalogues.
Imagine you want to leverage a different measurements
catalogue. This would typically require you to update the import statements everywhere in your codebase. With QruiseOS's architecture, you only need to change the measurements
entry in utils.py
and can leave all other code unchanged, i.e. you only need to update the line import yourlab.measurements as measurements
in utils.py
to leverage a new custom catalogue.