{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Readout IQ blob classification\n", "\n", "Feed a dense cloud of single-shot IQ values to the VLM. The model recognizes\n", "under-separated blobs, leakage to `|2⟩`, and skewed populations — all things\n", "that degrade readout fidelity. We also sketch a cheap linear threshold for\n", "reference." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "rng = np.random.default_rng(7)\n", "n = 4000\n", "ground = rng.normal(loc=(-0.9, 0.1), scale=(0.35, 0.35), size=(n//2, 2))\n", "excited = rng.normal(loc=(+0.8, 0.4), scale=(0.40, 0.40), size=(n//2, 2))\n", "iq = np.vstack([ground, excited])\n", "np.save('readout_iq.npy', iq)\n", "iq.shape" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from qcal.data import from_npy\n", "\n", "payload = from_npy('readout_iq.npy', experiment_type='readout_iq')\n", "payload.image" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from qcal.analyzer import analyze_payload\n", "\n", "result = analyze_payload(payload, backend='auto')\n", "result" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once the VLM returns a `recommended_parameters.readout_threshold`, wire it into\n", "your control stack's classifier. Below: a crude linear threshold along the I-axis\n", "for reference." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import matplotlib.pyplot as plt\n", "\n", "thresh = result.parsed.get('recommended_parameters', {}).get('readout_threshold', 0.0)\n", "fig, ax = plt.subplots(figsize=(5, 5))\n", "ax.scatter(iq[:, 0], iq[:, 1], s=3, alpha=0.4)\n", "ax.axvline(thresh, color='r', linewidth=1.0, label=f'threshold = {thresh}')\n", "ax.set_xlabel('I'); ax.set_ylabel('Q'); ax.legend(); ax.grid(alpha=0.3)" ] } ], "metadata": { "kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "language_info": {"name": "python", "version": "3.11"} }, "nbformat": 4, "nbformat_minor": 5 }