qcmet.benchmarks.T2#
- class qcmet.benchmarks.T2(qubit_index=0, method='hahn', num_idle_gates_per_circ=None, detuning_phase=None, delay=None, save_path=None)[source]#
Benchmark class for estimating the T2 coherence time of a qubit.
This benchmark supports two methods for measuring T2: - ‘ramsey’: Ramsey interference for measuring T2* (dephasing time) - ‘hahn’: Hahn echo (spin echo) for measuring T2 (coherence time)
The Ramsey method is sensitive to low-frequency noise and detuning, while the Hahn echo method refocuses static field inhomogeneities.
- config#
Configuration dictionary containing: - method (str): Either ‘ramsey’ or ‘hahn’ - num_idle_gates_per_circ (array-like): Number of idle gates per circuit - detuning_phase (float): Phase accumulation per idle gate for Ramsey
(defaults: np.pi/100 for idle_gates and np.pi/10 for delay gates)
delay (array-like): Length of delay per circuit
- Type:
- __init__(qubit_index=0, method='hahn', num_idle_gates_per_circ=None, detuning_phase=None, delay=None, save_path=None)[source]#
Initialize the T2 benchmark.
- Parameters:
qubit_index (int, optional) – The qubit index for routing. Defaults to 0.
method (str, optional) – Method to use for T2 measurement. Either ‘ramsey’ or ‘hahn’. Defaults to ‘hahn’.
num_idle_gates_per_circ (array-like, optional) – Sequence of idle gate counts to use. For Ramsey: defaults to np.arange(1, 1000, 50) For Hahn: defaults to np.arange(1, 2000, 100)
detuning_phase (float, optional) – Phase per idle/delay gate to simulate detuning in Ramsey.Defaults to np.pi/100 for idle gates approach and np.pi/10 for delay gates approach. These defaults had produced sensible fits for T2 and T2* with a noisy simulator.
delay (array-like, optional) – Sequence of delay gates to use in circuits. This is for alternate methodto the idle_gates approach. Do not set an argument for num_idle_gates_per_circ when defining delay. Units are in microseconds.
save_path (str | Path | FileManager | None, optional) – Directory path to save results. Defaults to None.
- Raises:
ValueError – If method is not ‘ramsey’ or ‘hahn’.
ValueError – If num_idle_gates_per_circ and delay are both specified.
Methods
__init__([qubit_index, method, ...])Initialize the T2 benchmark.
analyze()Analyze measurements to return benchmark results.
generate_circuits()Generate benchmark circuits, user facing.
hahn_fit_func(x, amp, dr, b)Exponential decay function for Hahn echo.
has_plotting()Check if _plot function is implemented in benchmark.
load_circuit_measurements(circuit_measurements)Load measurement counts into the experiment_data DataFrame.
measurements_to_probabilities()Convert raw measurement counts to normalized probabilities.
plot([axes])Plot benchmark result, user facing.
ramsey_fit_func(x, amp, dr, f, phi, b)Damped oscillation function for Ramsey interference.
run([device, num_shots, max_circs_per_job])Run benchmark.
save()Save benchmark current state.
set_save_path(save_path)Set benchmark save path if not set in class constructor.
Attributes
circuitsGets all benchmark circuits.
experiment_dataGetter for experiment_data dataframe.
num_qubitsNumber of qubits in this benchmark.
- static ramsey_fit_func(x, amp, dr, f, phi, b)[source]#
Damped oscillation function for Ramsey interference.
Models: amp * exp(-x/T2*) * cos(2πfx + φ) + b
- Parameters:
- Returns:
Computed damped oscillation values.
- Return type:
float or array-like