Quickstart Guide

Get up and running with Stanza in 5 minutes.

Installation

$pip install cq-stanza

Or with Quantum Machines support:

$pip install "cq-stanza[qm]"

Step 1: Configure Your Device

Create device.yaml:

1name: "My Quantum Device"
2
3gates:
4 G1:
5 type: BARRIER
6 control_channel: 1
7 v_lower_bound: -3.0
8 v_upper_bound: 3.0
9
10contacts:
11 DRAIN:
12 type: DRAIN
13 control_channel: 4
14 measure_channel: 2
15 v_lower_bound: -3.0
16 v_upper_bound: 3.0
17
18routines:
19 - name: sweep_barrier
20 parameters:
21 gate: G1
22 v_start: -2.0
23 v_stop: 0.0
24 n_points: 100
25
26instruments:
27 - name: qdac2
28 type: GENERAL
29 driver: qdac2
30 ip_addr: 127.0.0.1
31 slew_rate: 1.0
32 measurement_duration: 1e-3
33 sample_time: 10e-6

Step 2: Write a Routine

Create routines.py:

1import numpy as np
2from stanza.routines import routine
3
4@routine
5def sweep_barrier(ctx, gate, v_start, v_stop, n_points):
6 """Sweep a gate and measure current."""
7 device = ctx.resources.device
8 voltages = np.linspace(v_start, v_stop, n_points)
9 v_data, i_data = device.sweep_1d(gate, voltages.tolist(), "DRAIN")
10 return {"voltages": v_data, "currents": i_data}

Step 3: Execute

Create run.py:

1from stanza.routines import RoutineRunner
2from stanza.utils import load_device_config
3
4# Load config and create runner
5config = load_device_config("device.yaml")
6runner = RoutineRunner(configs=[config])
7
8# Execute routine
9result = runner.run("sweep_barrier")
10print(f"Measured {len(result['currents'])} points")

Run it:

$python run.py

Add Logging (Optional)

Enable automatic data persistence:

1from stanza.logger import DataLogger
2from stanza.utils import load_device_config, device_from_config
3
4config = load_device_config("device.yaml")
5device = device_from_config(config)
6
7logger = DataLogger(
8 name="logger",
9 routine_name="sweep_barrier",
10 base_dir="./data",
11 formats=["hdf5"]
12)
13
14runner = RoutineRunner(resources=[device, logger])
15result = runner.run("sweep_barrier") # Data automatically saved

Next Steps