{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f0a1b2c3",
   "metadata": {},
   "source": [
    "# The hierarchy of workflows in Boulder Opal\n",
    "\n",
    "**Understand how experiments, routines, and solutions compose into a three-tier calibration workflow**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f0a1body",
   "metadata": {},
   "source": [
    "Boulder Opal Scale Up organizes calibration work into three tiers: Experiments, Routines, and Solutions. Each tier is built from the one below it and adds a layer of automation, so you can enter at the level that fits your task and drop down to a lower tier when components need more direct tuning.\n",
    "\n",
    "This document describes each tier, how data flows between them, and how to recover when a routine fails."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d4e5f6a7",
   "metadata": {},
   "source": [
    "## 1. Introduction\n",
    "\n",
    "The three tiers form a hierarchy of increasing scope:\n",
    "\n",
    "- An experiment runs a single measurement program on the QPU and returns fitted parameters.\n",
    "- A routine runs a sequence of experiments against one component type and writes the updated parameters to the virtual device.\n",
    "- A solution runs a set of routines to calibrate the full QPU in one invocation.\n",
    "\n",
    "The tier you pick sets the scope of the run and the amount of control you keep. The table below summarizes the solutions, routines, and experiments currently available in Boulder Opal. Use it as a reference for the capabilities supported in the current release.\n",
    "\n",
    "<table>\n",
    "  <thead>\n",
    "    <tr><th>Solution</th><th>Routine</th><th>Experiment</th></tr>\n",
    "  </thead>\n",
    "  <tbody>\n",
    "    <tr><td rowspan=\"14\">Characterization</td><td rowspan=\"4\">Resonator Mapping</td><td>Feedline Discovery</td></tr>\n",
    "    <tr><td>Resonator Spectroscopy</td></tr>\n",
    "    <tr><td>Resonator Spectroscopy by Power</td></tr>\n",
    "    <tr><td>Resonator Spectroscopy by Bias</td></tr>\n",
    "    <tr><td rowspan=\"4\">Transmon Discovery</td><td>Transmon Spectroscopy</td></tr>\n",
    "    <tr><td>Transmon Anharmonicity</td></tr>\n",
    "    <tr><td>PowerRabi</td></tr>\n",
    "    <tr><td>Readout Classifier</td></tr>\n",
    "    <tr><td rowspan=\"3\">Transmon Coherence</td><td>T1</td></tr>\n",
    "    <tr><td>T2</td></tr>\n",
    "    <tr><td>T2 Echo</td></tr>\n",
    "    <tr><td rowspan=\"3\">Coupler Discovery</td><td>Chi01 Scan</td></tr>\n",
    "    <tr><td>CZ Spectroscopy by Bias</td></tr>\n",
    "    <tr><td>ZZ Ramsey</td></tr>\n",
    "    <tr><td rowspan=\"5\">Calibration</td><td rowspan=\"4\">1Q Calibration</td><td>Ramsey</td></tr>\n",
    "    <tr><td>Drag Leakage Calibration</td></tr>\n",
    "    <tr><td>Fine Amplitude Calibration</td></tr>\n",
    "    <tr><td>One Qubit RB</td></tr>\n",
    "    <tr><td>2Q Calibration</td><td>TBD</td></tr>\n",
    "  </tbody>\n",
    "</table>\n",
    "\n",
    "Note that solutions are not yet fully deployed within Boulder Opal, but are expected later in 2026.\n",
    "\n",
    " The rest of this document covers each tier in order, then shows how parameter data moves between them and how to recover from a routine failure."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b8c9d0e1",
   "metadata": {},
   "source": [
    "## 2. Experiments\n",
    "\n",
    "An experiment runs one control sequence on the QPU and returns fitted parameters for a single component.\n",
    "\n",
    "Each experiment class takes its required parameters like component identifiers (for a transmon or resonator), sweeps (frequency or power ranges), or shot count.\n",
    "Pass the defined experiment to `client.run`, which will return a job ID that you can use to retrieve the experiment data.\n",
    "See our [tutorial on running jobs](https://docs.q-ctrl.com/boulder-opal/autocalibration/discover/running-your-first-job-with-boulder-opal) for a more detailed guide."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e6d7a8b9",
   "metadata": {},
   "source": [
    "## 3. Routines\n",
    "\n",
    "A routine runs a sequence of experiments to characterize or calibrate one component type and writes the updated parameters to the virtual device. Before each experiment, the routine reads the current device state to set sweep ranges and initial guesses. As with experiments, its routine has its own set of parameters to control its logic, and can be executed via `client.run`.\n",
    "\n",
    "You can see some of the currently available routines in the table above. Each one covers a separate calibration task and runs its related experiments."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e8f9a0b1",
   "metadata": {},
   "source": [
    "## 4. Data integration and the virtual device\n",
    "\n",
    "Parameter data flows through the tiers as a closed loop:\n",
    "\n",
    "1. Experiments produce raw measurement data and fitted parameters.\n",
    "2. The parameters are written to the `SuperconductingProcessor` in the virtual device.\n",
    "3. Routines analyze the validated parameters, experiment results, and updated device state to define the next experiment.\n",
    "\n",
    "Each calibration step starts from the most recent values, and every successful measurement updates the device model.\n",
    "\n",
    "It is also possible to manually update device parameters, see the [relevant user guide](https://docs.q-ctrl.com/boulder-opal/autocalibration/apply/how-to-manually-update-device-parameters-with-boulder-opal)."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a6b7c8d9",
   "metadata": {},
   "source": [
    "## Next steps\n",
    "\n",
    "- [Running your first job](https://docs.q-ctrl.com/boulder-opal/autocalibration/discover/running-your-first-job-with-boulder-opal) for a more detailed guide.\n",
    "- [Reviewing job results and device history](https://docs.q-ctrl.com/boulder-opal/autocalibration/discover/reviewing-job-results-and-device-history-with-boulder-opal): navigate job history and inspect device state in depth.\n",
    "- [How to debug a failed routine](https://docs.q-ctrl.com/boulder-opal/autocalibration/apply/how-to-debug-a-failed-routine-with-boulder-opal) user guide."
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
