{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Rabi calibration with QCal Copilot\n", "\n", "Load a raw `.npy` Rabi trace, auto-fit a damped sine, hand the plot + fit numbers to\n", "the Ising Calibration VLM, and emit a CUDA-Q script seeded with the recommended\n", "pulse amplitude.\n", "\n", "Inputs expected: a 1-D numpy array of readout populations vs drive amplitude (or time)\n", "and an optional matching `x` array. Works offline — the local VLM is optional." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "# Synthesize a Rabi sweep (replace with `np.load('your_trace.npy')`).\n", "t = np.linspace(0, 500e-9, 201) # seconds\n", "y = 0.5 * np.exp(-t/300e-9) * np.sin(2*np.pi*10e6*t) + 0.5\n", "np.save('rabi_trace.npy', y)\n", "np.save('rabi_time.npy', t)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from qcal.data import from_npy\n", "\n", "payload = from_npy(\n", " 'rabi_trace.npy',\n", " experiment_type='rabi',\n", " x_path='rabi_time.npy',\n", " x_unit='s',\n", ")\n", "payload.fit # FitResult — rich-displays in Jupyter as a table" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "payload.image # the rendered plot the VLM will see" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from qcal.analyzer import analyze_payload\n", "\n", "# backend='auto' uses NIM when NVIDIA_API_KEY is set, else the local HF weights.\n", "result = analyze_payload(payload, backend='auto')\n", "result # _repr_markdown_ — shows experiment, issues, recommended params" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from qcal.codegen import generate_script\n", "\n", "print(generate_script(result.parsed))" ] } ], "metadata": { "kernelspec": {"display_name": "Python 3", "language": "python", "name": "python3"}, "language_info": {"name": "python", "version": "3.11"} }, "nbformat": 4, "nbformat_minor": 5 }