{ "cells": [ { "cell_type": "markdown", "id": "042fff0c", "metadata": {}, "source": [ "# Simple binned acquisition" ] }, { "cell_type": "markdown", "id": "3c9d3eeb", "metadata": {}, "source": [ "## Setup configurations" ] }, { "cell_type": "code", "execution_count": null, "id": "3361b76b", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from quantify_core.measurement import MeasurementControl\n", "from quantify_scheduler import Schedule\n", "from quantify_scheduler.device_under_test.transmon_element import BasicTransmonElement\n", "from quantify_scheduler.gettables import ScheduleGettable\n", "from quantify_scheduler.device_under_test.quantum_device import QuantumDevice\n", "from quantify_scheduler.instrument_coordinator import InstrumentCoordinator\n", "from quantify_scheduler.instrument_coordinator.components.qblox import ClusterComponent, PulsarQRMComponent\n", "from quantify_scheduler.operations.gate_library import Measure, X\n", "from quantify_scheduler.resources import ClockResource\n", "from quantify_scheduler.operations.pulse_library import IdlePulse, SquarePulse\n", "from quantify_scheduler.operations.acquisition_library import SSBIntegrationComplex, Trace\n", "from quantify_scheduler.enums import BinMode\n", "from qcodes.instrument.parameter import ManualParameter\n", "from qblox_instruments import Cluster, ClusterType, Pulsar\n", "from quantify_core.data import handling as dh\n", "from quantify_scheduler import compilation\n", "from quantify_scheduler.backends import SerialCompiler\n", "import math" ] }, { "cell_type": "code", "execution_count": null, "id": "2c456282", "metadata": { "scrolled": true }, "outputs": [], "source": [ "dh.set_datadir(dh.default_datadir(verbose=False));" ] }, { "cell_type": "markdown", "id": "5e534641", "metadata": {}, "source": [ "## Setup cluster" ] }, { "cell_type": "code", "execution_count": null, "id": "4afcddc0", "metadata": {}, "outputs": [], "source": [ "cluster = Cluster(\"cluster0\",\n", " \"\",\n", " debug=1,\n", " dummy_cfg={15: ClusterType.CLUSTER_QRM},\n", " )\n", "\n", "ic_cluster0 = ClusterComponent(cluster)\n", "my_instr_coord = InstrumentCoordinator(\"my_instr_coord\")\n", "my_instr_coord.add_component(ic_cluster0)" ] }, { "cell_type": "code", "execution_count": null, "id": "c26df6a7", "metadata": {}, "outputs": [], "source": [ "ic_cluster0.name" ] }, { "cell_type": "code", "execution_count": null, "id": "d0b7f78d", "metadata": {}, "outputs": [], "source": [ "my_device = QuantumDevice(\"my_device\")" ] }, { "cell_type": "code", "execution_count": null, "id": "fbb46f17", "metadata": {}, "outputs": [], "source": [ "transmon0 = BasicTransmonElement(f\"q0\")\n", "transmon0.clock_freqs.readout(10e9)\n", "my_device.add_element(transmon0)\n", "transmon1 = BasicTransmonElement(f\"q1\")\n", "transmon1.clock_freqs.readout(10e9)\n", "my_device.add_element(transmon1)" ] }, { "cell_type": "code", "execution_count": null, "id": "20c75658", "metadata": {}, "outputs": [], "source": [ "my_device.instr_instrument_coordinator(\"my_instr_coord\")" ] }, { "cell_type": "code", "execution_count": null, "id": "16fb59d0", "metadata": {}, "outputs": [], "source": [ "hw_config = {\n", " \"backend\": \"quantify_scheduler.backends.qblox_backend.hardware_compile\",\n", " \"cluster0\": {\n", " \"ref\": \"internal\",\n", " \"instrument_type\": \"Cluster\",\n", " \"cluster0_module15\": {\n", " \"instrument_type\": \"QRM\",\n", " \"complex_output_0\": {\n", " \"portclock_configs\": [\n", " {\"port\": \"q0:res\", \"clock\": \"q0.ro\", \"interm_freq\": 0},\n", " {\"port\": \"q1:res\", \"clock\": \"q1.ro\", \"interm_freq\": 0},\n", " ]\n", " }\n", " }\n", " },\n", " }" ] }, { "cell_type": "code", "execution_count": null, "id": "2fcda1c3", "metadata": {}, "outputs": [], "source": [ "my_device.hardware_config(hw_config)\n", "my_device.cfg_sched_repetitions(1)" ] }, { "cell_type": "markdown", "id": "dbe2c90e", "metadata": {}, "source": [ "## Setup schedule, dummy data" ] }, { "cell_type": "code", "execution_count": null, "id": "cd055c49", "metadata": {}, "outputs": [], "source": [ "signal_delay = 148e-9\n", "num_acquisitions=1000" ] }, { "cell_type": "code", "execution_count": null, "id": "5e4ec5f9", "metadata": {}, "outputs": [], "source": [ "from qblox_instruments import DummyBinnedAcquisitionData, DummyScopeAcquisitionData" ] }, { "cell_type": "code", "execution_count": null, "id": "484d5236", "metadata": {}, "outputs": [], "source": [ "def set_dummy_data(repetitions=1):\n", " dummy_slot_idx = 15\n", " cluster.delete_dummy_binned_acquisition_data(slot_idx=dummy_slot_idx)\n", " dummy_data_0 = [\n", " DummyBinnedAcquisitionData(data=(4 * i, 0), thres=0, avg_cnt=0) for i in range(num_acquisitions)\n", " ] * repetitions\n", " cluster.set_dummy_binned_acquisition_data(slot_idx=dummy_slot_idx, sequencer=0, acq_index_name=\"0\", data=dummy_data_0)\n", " dummy_data_1 = [\n", " DummyBinnedAcquisitionData(data=(0, 8 * i), thres=0, avg_cnt=0) for i in range(num_acquisitions)\n", " ] * repetitions\n", " cluster.set_dummy_binned_acquisition_data(slot_idx=dummy_slot_idx, sequencer=1, acq_index_name=\"1\", data=dummy_data_1)" ] }, { "cell_type": "code", "execution_count": null, "id": "2bfdf412", "metadata": {}, "outputs": [], "source": [ "def add_increasing_pulse_level_acquisitions(\n", " schedule,\n", " max_pulse_level,\n", " port,\n", " clock,\n", " acq_channel,\n", " bin_mode,\n", " num_acquisitions,\n", "):\n", " pulse_duration = 120e-9\n", " pulse_levels = [max_pulse_level] if num_acquisitions == 1 else np.linspace(0, max_pulse_level, num_acquisitions)\n", " for acq_index, pulse_level in enumerate(pulse_levels):\n", " schedule.add(\n", " SquarePulse(\n", " duration=pulse_duration,\n", " amp=pulse_level,\n", " port=port,\n", " clock=clock,\n", " ),\n", " rel_time=1e-6,\n", " )\n", " schedule.add(\n", " SSBIntegrationComplex(\n", " t0=-pulse_duration + signal_delay,\n", " duration=pulse_duration,\n", " port=port,\n", " clock=clock,\n", " acq_channel=acq_channel,\n", " acq_index=acq_index,\n", " bin_mode=bin_mode,\n", " )\n", " )\n", "\n", "def create_schedule(\n", " repetitions: int,\n", " pulse_level_0: complex,\n", " pulse_level_1: complex,\n", " bin_mode=BinMode.AVERAGE,\n", " num_acquisitions=5,\n", ") -> Schedule:\n", "\n", " schedule = Schedule(\"Test schedule\", repetitions=repetitions)\n", "\n", " schedule.add(IdlePulse(duration=1e-6))\n", "\n", " add_increasing_pulse_level_acquisitions(\n", " schedule,\n", " pulse_level_0,\n", " \"q0:res\",\n", " \"q0.ro\",\n", " 0,\n", " bin_mode,\n", " num_acquisitions,\n", " )\n", "\n", " add_increasing_pulse_level_acquisitions(\n", " schedule,\n", " pulse_level_1,\n", " \"q1:res\",\n", " \"q1.ro\",\n", " 1,\n", " bin_mode,\n", " num_acquisitions,\n", " )\n", " \n", " return schedule" ] }, { "cell_type": "code", "execution_count": null, "id": "1ad56a5b", "metadata": {}, "outputs": [], "source": [ "set_dummy_data()" ] }, { "cell_type": "code", "execution_count": null, "id": "9706ee5b", "metadata": {}, "outputs": [], "source": [ "pulse_levels = []\n", "for i in [0, 1]:\n", " pulse_level = ManualParameter(\n", " name=f\"pulse_level_q{i}\",\n", " initial_value=0.0,\n", " unit=\"-\",\n", " label=\"pulse level\")\n", " pulse_level(0.125 * (i + 1))\n", " pulse_level.batched = False\n", " pulse_levels.append(pulse_level)" ] }, { "cell_type": "code", "execution_count": null, "id": "368f1115", "metadata": {}, "outputs": [], "source": [ "simple_binned_acquisition_kwargs = {\n", " \"pulse_level_0\": pulse_levels[0],\n", " \"pulse_level_1\": pulse_levels[1],\n", " \"num_acquisitions\": num_acquisitions,\n", "}" ] }, { "cell_type": "markdown", "id": "990d90ea", "metadata": {}, "source": [ "## Run schedule and profiling" ] }, { "cell_type": "code", "execution_count": null, "id": "cef8d15b", "metadata": {}, "outputs": [], "source": [ "def run_experiment():\n", " my_gettable = ScheduleGettable(\n", " my_device,\n", " create_schedule,\n", " simple_binned_acquisition_kwargs,\n", " batched=True,\n", " real_imag=False,\n", " data_labels=[f\"q0 abs\", f\"q0 phase\", f\"q1 abs\", f\"q1 phase\"],\n", " num_channels=2,\n", " )\n", " acq = my_gettable.get()\n", " return acq" ] } ], "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.9.17" } }, "nbformat": 4, "nbformat_minor": 5 }