See also
A Jupyter notebook version of this tutorial can be downloaded here.

Ramsey#
In a Ramsey experiment, the qubit is placed in a superposition of |0⟩ and |1⟩ using an \(X_{\pi/2}\) pulse, while a frequency offset is given to its port clock, such that the qubit accumulates a phase over time as it moves along the Bloch sphere equator. After some time τ, a second \(X_{\pi/2}\) pulse is played such that the qubit is moved either towards the |0⟩ or the |1⟩ state depending on its phase. By sweeping τ, an oscillation will be observed corresponding to the qubit’s detuning from its “true” \(f_{01}\) frequency, with a decay corresponding to the qubit’s \(T_2^*\).
[1]:
from dependencies.analysis_utils import RamseyAnalysis
from xarray import open_dataset
from qblox_scheduler import HardwareAgent, Schedule
from qblox_scheduler.operations import X90, Measure, Reset, SetClockFrequency
from qblox_scheduler.operations.expressions import DType
from qblox_scheduler.operations.loop_domains import arange
Generating hash table for SingleQubitClifford.
Hash table generated.
Generating hash table for TwoQubitCliffordCZ.
Hash table generated.
Generating hash table for TwoQubitCliffordZX.
Hash table generated.
Testing decompositions.
Test passed.
Setup#
The hardware agent manages the connection to the instrument and ensures that pulses and acquisitions happen over the appropriate input and output channels of the Cluster. The cell below creates an instance of the HardwareAgent based on the hardware- and device-under-test configuration files in the ./dependencies/configs folder, allowing us to start doing measurements. We also define some convenient aliases to use throughout our measurements. For a more thorough discussion of the
hardware- and device-under-test configuration files, check out this tutorial.
[2]:
# Set up hardware agent, this automatically connects to the instrument
hw_agent = HardwareAgent(
hardware_configuration="./dependencies/configs/hw_config.json",
quantum_device_configuration="./dependencies/configs/dut_config.json",
)
# convenience aliases
q0 = hw_agent.quantum_device.get_element("q0")
q2 = hw_agent.quantum_device.get_element("q2")
cluster = hw_agent.get_clusters()["cluster"]
hw_options = hw_agent.hardware_configuration.hardware_options
qubit = q0
/builds/0/.venv/lib/python3.10/site-packages/qblox_scheduler/qblox/hardware_agent.py:460: UserWarning: cluster: Trying to instantiate cluster with ip 'None'.Creating a dummy cluster.
warnings.warn(
Experiment settings#
[3]:
# Detuning
frequency_detuning = 1e6 # Hz
# Tau settings in seconds
tau_start = 1e-6 # s
tau_stop = 25e-6 # s
tau_step = 0.5e-6 # s
repetitions = 1000
Experiment schedule#
Note: in order for the second \({\pi/2}\) pulse to have a phase difference \(\Delta \phi = \Delta f \tau\), relative to the first \(X_{\pi/2}\) pulse we offset the clock frequency by \(\Delta f\) for a time \(\tau\). Here, \(\Delta f\) is the frequency_detuning and \(\tau\) is tau.
[4]:
ramsey_sched = Schedule(name="ramsey_experiment")
with (
ramsey_sched.loop(arange(0, repetitions, 1, DType.NUMBER)),
ramsey_sched.loop(
arange(start=tau_start, stop=tau_stop, step=tau_step, dtype=DType.TIME)
) as tau,
):
ramsey_sched.add(Reset(qubit.name))
# Play X/2 pulse
ramsey_sched.add(X90(qubit=qubit.name))
# Implementing a phase kick:
# Detune the qubit's clock by the required frequency detuning
ramsey_sched.add(
SetClockFrequency(
clock=f"{qubit.name}.01",
clock_freq_new=qubit.clock_freqs.f01 + frequency_detuning,
)
)
# After a time tau, reset the qubit clock frequency to its original value
ramsey_sched.add(
SetClockFrequency(
clock=f"{qubit.name}.01",
clock_freq_new=qubit.clock_freqs.f01,
),
rel_time=tau,
)
# Play second X/2 pulse after time tau
ramsey_sched.add(X90(qubit=qubit.name))
ramsey_sched.add(Measure(qubit.name, coords={"tau": tau}, acq_channel="S_21"))
# Execute the experiment
ramsey_data = hw_agent.run(ramsey_sched)
if cluster.is_dummy:
example_data = open_dataset("./dependencies/datasets/ramsey.hdf5", engine="h5netcdf")
ramsey_data = ramsey_data.update({"S_21": example_data.S_21})
Analyze the experiment#
[5]:
ramsey_analysis = RamseyAnalysis(ramsey_data).run()
ramsey_analysis.display_figs_mpl()
Update the device configuration file#
After measurement, we may store the measured device properties inside a new file to use in future experiments. The time-unique identifier ensures that it is easy to find back previously found measurement results.
[6]:
hw_agent.quantum_device.to_json_file("./dependencies/configs", add_timestamp=True)
[6]:
'./dependencies/configs/two_flux_tunable_transmons_2025-10-30_00-37-33_UTC.json'