Session 2 · Part 4 · 35 minutes

Experiment tracking case study in QML:

Quantum reservoir computing

Study on forecasting chaotic Mackey-Glass time series data with quantum reservoir computing

Valter Uotila · University of Helsinki
currently at TU Delft

QCE tutorial: From Circuits to Results
Part 4 · 02

What to expect from this part and lessons to learn

01

Brief background on quantum reservoir computing paradigm

02

The interactive use case pipeline

03

Experiment track a hiding failure and fix it

Reservoir computing -- high level idea and motivation

input signal
→
STATES EVOLVE NON-LINEARLY
→
readout is the only trained layer
track
dataset + τ, seeds
splits, scalers
track
n_qubits, γ, evolution time
observables, shots, backend
track
ridge α, n_features
R², NRMSE + model hash
why reservoir computing
why build the reservoir on a quantum device
Cheap to train
Only the readout is trained.
Reusable
The reservoir state remembers past inputs on its own.
Exponential state space
Every qubit doubles the state space which makes it rich.
No variational loop
Nothing inside the circuits is optimized which removes expensive variational loops.
Part 4 · 04 · BACKground

Some defining properties for reservoir computing

Echo state property

forget x₀
click for definition
echo state property
\bigl\| x_t(x_0^{A},u_n) - x_t(x_0^{B},u_n) \bigr\| \to 0, \quad n\to \infty

The distance between the states in which the system is driven after being fed by the same input sequence, but starting from different initial conditions, approaches 0 as the length of the input sequence grows.

[1] Echo State Property of Deep Reservoir Computing Networks. Claudio Gallicchio & Alessio Micheli. 2017.

Fading memory

now t − k
click for definition
fading memory
\sum_{k=0}^{\infty}\omega_k ||u_{t-k}^A - u_{t-k}^B|| < \delta \Rightarrow \|x^{A}_t - x^{B}_t\| < \varepsilon

The recent inputs are more represented in the outputs than older ones. Recent inputs dominate, and distant ones decay smoothly.

[2] Fading Memory and the Problem of Approximating Nonlinear Operators with Volterra Series. S. Boyd and L. O. Chua. 1985.

Memory capacity

m(k) k
click for definition
memory capacity
MC \leq N, \quad MC=\sum_{k\ge1} m(k),\quad m(k)=\frac{\mathrm{cov}^2(u_{t-k},\hat{y}_{k,t})}{\sigma^2_u\,\sigma^2_{\hat{y}_k}}

The linear Memory Capacity (MC) of a standard reservoir is limited by the number of internal nodes.

[3] Short term memory in echo state networks. Herbert Jaeger. 2002.

Separation

click for definition
separation property
||u^{A}_{\leq t} - u^{B}_{\leq t }|| \geq \delta \;\Longrightarrow\; ||x(u^{A}_{\leq t}) - x(u^{B}_{\leq t})|| \geq \varepsilon

Distinct input sequences are mapped to distinct states.

[4] Real-Time Computing Without Stable States: A New Framework for Neural Computation Based on Perturbations. Wolfgang Maass, Thomas Natschl¨ager, and Henry Markram. 2002.

Readout

W_out
click for definition
readout accessibility
\hat y_t = W_{\mathrm{out}}\,s_t,\quad s_t=\bigl(\langle O_i\rangle_{\rho_t}\bigr)_{i=1}^{M}

Targets are obtained by applying readout to M measured observables .

[5] Potential and limitations of quantum extreme learning machines. L. Innocenti, S. Lorenzo, I. Palmisano, A. Ferraro, M. Paternostro & G. M. Palma. 2023.

Universality

target reservoir
click for definition
universality
\forall\, F,\ \varepsilon>0\ \ \exists\, W_{\mathrm{out}}:\ \sup_{u}\|F(u)-\hat y(u)\|<\varepsilon

Classes of reservoir computing models are universal approximators.

[6] Reservoir Computing Universality With Stochastic Inputs. Lukas Gonon, Juan-Pablo Ortega. 2018.
[7] Dissipation as a resource for Quantum Reservoir Computing. Antonio Sannia, Rodrigo Martínez-Peña, Miguel C. Soriano, Gian Luca Giorgi, Roberta Zambrini. 2024
Part 4 · 06 · the pipeline

Define the learning task

\dot{x} = \dfrac{a\,x(t-\tau)}{1 + x(t-\tau)^{n}} - b\,x(t) — chaotic for \tau \gtrsim 17. Predict y[t+h].
The “echo state” approach to analysing and training recurrent neural networks. Herbert Jaeger. 2010.
y = mackey_glass(series_length, tau=17, seed=seed).flatten() mlflow.log_param("dataset", dataset) mlflow.log_param("tau", tau) mlflow.log_param("series_length", series_length) mlflow.log_param("seed", seed) u_hi = np.quantile(y[:val_start], 0.995) u_seq = np.clip(y / u_hi, 0.0, 1.0) * 0.5 mlflow.log_param("input_scaling/fit_range", "pre_validation") mlflow.log_param("input_scaling/u_hi", float(u_hi)) mlflow.log_param("washout", WASHOUT) mlflow.log_param("retrain_every", RETRAIN_EVERY)
Part 4 · 07 · BACKground on quantum reservoir computing

Dissipative quantum reservoir computing

1. Construct input-dependent Hamiltonian
H(u_t) = \sum_i h_i X_i + \sum_i J_i Z_i Z_{i+1} + u_t \sum_i w_i Z_i
ut
input time series: sample t of the scaled sequence u
wi
how much of  ut reaches qubit i
hi, Ji
fixed linear and quadratic coefficients and independent of input u
2. unitary evolution
\tilde{\rho}_t = U(u_t)\,\rho_{t-1}\,U(u_t)^{\dagger}, \qquad U(u_t) = \exp\!\left(-i\,H(u_t)\,\tau\right)
3. Apply the dissipative step, where memory fades
\rho_t = (1-\gamma)\,\tilde{\rho}_t + \gamma\,|0\ldots 0\rangle\langle 0\ldots 0|
# 1. Hamiltonian: field + ZZ chain + the input drive def hamiltonian(u): field = [("X", [i], h[i]) for i in range(n)] chain = [("ZZ", [i, i+1], J[i]) for i in range(n-1)] drive = [("Z", [i], u * w[i]) for i in range(n)] return SparsePauliOp.from_sparse_list( field + chain + drive, num_qubits=n) # 3. dissipation = reset each qubit with probability gamma noise = NoiseModel() noise.add_all_qubit_quantum_error(reset_error(gamma), "id") sim = AerSimulator(method="density_matrix", noise_model=noise) qc = QuantumCircuit(n) for t, u in enumerate(inputs): evo = PauliEvolutionGate(hamiltonian(u), time=tau) qc.append(evo, range(n)) # 2. rho <- U rho U+ qc.id(range(n)) # 3. partial reset to |0..0> qc.save_density_matrix(label=f"t{t}")
Part 4 · 05 · the paradigm

Classical and quantum have similarities but also different state spaces

feature value vs. its own mean
below
above
each row scaled independently
Classical Echo State Network (ESN)
Dissipative Quantum Reservoir Computing (QRC)
Part 4 · 08 · the pipeline

Demonstrating echo state property

Part 4 · 10 · the pipeline

The readout phase: fitting regression model to the measured values

def fit_window(F, h, lo, hi, plo, phi, alpha): model = make_pipeline( StandardScaler(), Ridge(alpha=alpha)) model.fit(F[lo:hi], y[lo + h:hi + h]) return model.predict(F[plo:phi]) def rolling_test(F, h, alpha): for o in range(train_end, T - h, STEP): stop = min(o + STEP, T - h) args = (WASHOUT, o - h + 1, o, stop) pred = fit_window(F, h, *args, alpha) best_r2, best_g, best_a = max( (validation_r2(feats[g], h, a), g, a) for g in GAMMAS for a in ALPHAS) mlflow.log_param("readout/gamma", best_g) mlflow.log_param("readout/alpha", best_a) mlflow.log_metric("validation/r2", best_r2) mlflow.log_dict(grid, "readout/val_grid.json")
Part 4 · 09 · the pipeline

Examples of metrics and artifacts to track in the experiments

encoding
encoding method · scaling values
artifact
QASM3 per circuit · coupling map
transpilation
depth · cx/cz count · swaps
transpiler
opt level · layout & routing method · seeds · basis gates
backend
name · version · calibration ts · T1/T2 · gate & readout errors
noise
noise model · error mitigation · shots · seeds
features
per-timestep observable matrix
timing
compilation time · execution time · training time
versions
quantum SDK versions · classical SDK versions
pm = generate_preset_pass_manager( backend=backend, optimization_level=3, layout_method="sabre", routing_method="sabre", seed_transpiler=1234) tqc = pm.run(circuits) def info(qc): return {"qasm3": qasm3.dumps(qc), "layout": qc.layout.final_index_layout(), "depth": qc.depth(), "ops": dict(qc.count_ops())} meta = {f"t{i:03d}": info(qc) for i, qc in enumerate(tqc)} mlflow.log_dict(meta, "circuits/transpiled.json") mlflow.log_dict(noise.to_dict(), "backend/noise.json") mlflow.log_params({ "compilation/optimization_level": 3, "compilation/routing_method": "sabre", "compilation/seed_transpiler": 1234, "backend/name": backend.name, "execution/shots": shots, "backend/calibration_ts": props.last_update_date})
Part 4 · 11 · the pipeline

Run the whole pipeline

Part 4 · 13 · the tracking

On real hardware, noise and error mitigation are provenance too

Real devices drift

Recalibration changes the device and, hence, the reservoir. The same configuration will lead to different dynamics and a different model. These changes should be tracked.

calibration_timestamp
T1 / T2, gate & readout err
backend_version
Error mitigation requires data

Error mitigation is increasingly popular but always introduces an overhead and creates a demand for data. This data can be tracked.

mitigation_method / order
r2_raw vs r2_mitigated
Shot noise enters the features

Finite shots make every observable an estimate. Keeping this estimate statistically reliable, we should track the number of shots.

num_shots, seed
feature_std_mean
noise_model
Part 4 · 14 · the tracking · live

Example: detecting failure with MLflow

Part 4 · 18

Takeaways from the experiment tracking perspective

1

Quantum reservoir computing doubled the tracked elements

4

The bug in the failed experiment

2

Only a small amount of parameters had effect

5

We tracked the full grid and full feature set

3

Seeds are important to track, especially in quantum reservoir computing

6

Compared to classical hardware, quantum hardware drifts