{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "c960f206", "metadata": { "execution": { "iopub.execute_input": "2025-04-17T20:53:54.528207Z", "iopub.status.busy": "2025-04-17T20:53:54.527906Z", "iopub.status.idle": "2025-04-17T20:53:54.533039Z", "shell.execute_reply": "2025-04-17T20:53:54.532377Z" }, "nbsphinx": "hidden" }, "outputs": [], "source": [ "# Copyright 2025 Keysight Technologies Inc." ] }, { "cell_type": "raw", "id": "be55d8ff", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Loading Simulated Experiment data\n", "=================================\n", "\n", "\n", "This section explains how to load simulated experiment data using the `mock_data`\n", "parameter. The `mock_data` parameter allows you to test and analyze experiments\n", "without requiring actual hardware execution.\n", "\n", "The `mock_data` parameter should be structured as follows:\n", "\n", "- **Keys**: Instances of `Channels` representing the channels used in the experiment.\n", "- **Values**: Iterables containing the simulated data for each channel.\n", "\n", "Example usage:\n", "\n", ".. code-block:: python\n", "\n", " mock_data = {\n", " channel_1: [trace_data_1, trace_data_2, ...],\n", " channel_2: [trace_data_1, trace_data_2, ...],\n", " qubit_1: [trace_data_1, trace_data_2, ...],\n", " ...\n", " }\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "5da79903", "metadata": { "execution": { "iopub.execute_input": "2025-04-17T20:53:54.536032Z", "iopub.status.busy": "2025-04-17T20:53:54.535755Z", "iopub.status.idle": "2025-04-17T20:53:57.779658Z", "shell.execute_reply": "2025-04-17T20:53:57.778878Z" } }, "outputs": [], "source": [ "import keysight.qcs as qcs\n", "from keysight.qcs.experiments import Experiment, make_calibration_set\n", "import numpy as np" ] }, { "cell_type": "raw", "id": "d16ee3ac", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Before creating the :py:class:`~qcs.experiments.Experiment` with mock_data, we need a\n", ":py:class:`~qcs.ChannelMapper` and :py:class:`~qcs.Program` object to tell the\n", ":py:class:`~qcs.experiments.Experiment` class for what data structure to expect for\n", "mock_data.\n", "\n", "Creating a dummy :py:class:`~qcs.ChannelMapper`\n", "-----------------------------------------------\n", ":py:class:`~qcs.ChannelMapper` is required to configure the number of channels\n", "available for acquisition, and how many number of channel-data to expect in mock_data.\n", "The dimension of the accepted program is `[n_shots, sweep_a, sweep_b, ..., n_points]`\n", "\n", "- **n_shots**: Number of program repetitions\n", "- **sweep_a**, **sweep_b**, ...: Sweep variables\n", "- **n_points**: number of accepted points by the :py:class:`~qcs.IntegrationFilter` to\n", " covert trace data into IQ data." ] }, { "cell_type": "code", "execution_count": 3, "id": "c1088dfc", "metadata": { "execution": { "iopub.execute_input": "2025-04-17T20:53:57.783914Z", "iopub.status.busy": "2025-04-17T20:53:57.783473Z", "iopub.status.idle": "2025-04-17T20:53:57.858512Z", "shell.execute_reply": "2025-04-17T20:53:57.857692Z" } }, "outputs": [], "source": [ "n_channels = 2\n", "n_qubits = 2\n", "n_points = 240 # points accepted by the integration filter\n", "\n", "qubits = qcs.Qudits(range(n_qubits))\n", "channels = qcs.Channels(range(n_channels), \"xy_channels\", absolute_phase=False)\n", "\n", "mapper = qcs.ChannelMapper(\"dummy\")\n", "\n", "# assigning dummy physical addresses to the channels\n", "for i in range(n_channels):\n", " mapper.add_channel_mapping(\n", " channels=channels[i],\n", " addresses=qcs.Address(1, 1, i + 1),\n", " instrument_types=qcs.InstrumentEnum.M5300AWG,\n", " )" ] }, { "cell_type": "raw", "id": "04f11954", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Loading a simple Sweep Program and Data\n", "---------------------------------------\n", "\n", "The :py:class:`~qcs.Program` class gives information what dimension of data to expect\n", "from mock_data. The program can be a simple non-iterating program, a normal sweep,\n", "a nested sweep, or a zipped sweep. The data shape is determined by the structure of\n", "**program.repetitions.items**.\n", "\n", "Here, we will load data for a simple amplitude sweep program." ] }, { "cell_type": "code", "execution_count": 4, "id": "803283b5", "metadata": { "execution": { "iopub.execute_input": "2025-04-17T20:53:57.862057Z", "iopub.status.busy": "2025-04-17T20:53:57.861739Z", "iopub.status.idle": "2025-04-17T20:53:57.913435Z", "shell.execute_reply": "2025-04-17T20:53:57.912443Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Repeat(7)\n", "Sweep(amplitude=Array(name=amps, shape=(13,), dtype=float, unit=none))\n" ] } ], "source": [ "n_shots = 7\n", "num_amps = 13 # number of amplitude points to sweep on\n", "\n", "program = qcs.Program()\n", "amplitude = qcs.Scalar(\"amplitude\", dtype=float)\n", "phase = qcs.Scalar(\"phase\", dtype=float)\n", "amps = qcs.Array(\"amps\", value=np.linspace(0, 0.8, num_amps), dtype=float)\n", "waveform = qcs.RFWaveform(\n", " duration=20e-9,\n", " envelope=qcs.GaussianEnvelope(),\n", " amplitude=amplitude,\n", " rf_frequency=5.1e9,\n", ")\n", "program.add_waveform(waveform, channels)\n", "int_filter = qcs.RFWaveform(10e-8, qcs.ConstantEnvelope(), 1, 5.15e9)\n", "program.add_acquisition(int_filter, channels)\n", "program.sweep(amps, amplitude).n_shots(n_shots)\n", "\n", "# The shape of the accepted data must account for these dimensions\n", "for i in program.repetitions.items:\n", " print(i)" ] }, { "cell_type": "raw", "id": "70a41d6d", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Defining mock data and loading into the Experiment:\n" ] }, { "cell_type": "code", "execution_count": 5, "id": "76673de9", "metadata": { "execution": { "iopub.execute_input": "2025-04-17T20:53:57.917132Z", "iopub.status.busy": "2025-04-17T20:53:57.916821Z", "iopub.status.idle": "2025-04-17T20:53:58.692286Z", "shell.execute_reply": "2025-04-17T20:53:58.691476Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
(((Channels(labels=[0], name=xy_channels, absolute_phase=False))))...(((Channels(labels=[1], name=xy_channels, absolute_phase=False))))
0...6
(amplitude, 0)(amplitude, 0.0667)(amplitude, 0.1333)(amplitude, 0.2)(amplitude, 0.2667)(amplitude, 0.3333)(amplitude, 0.4)(amplitude, 0.4667)(amplitude, 0.5333)(amplitude, 0.6)...(amplitude, 0.2)(amplitude, 0.2667)(amplitude, 0.3333)(amplitude, 0.4)(amplitude, 0.4667)(amplitude, 0.5333)(amplitude, 0.6)(amplitude, 0.6667)(amplitude, 0.7333)(amplitude, 0.8)
00.031249-0.026000j-0.031621-0.012998j-0.011636-0.015886j0.004438-0.019826j0.023532+0.034597j-0.019214+0.049735j-0.006032-0.034850j0.026803+0.008326j0.002084+0.007049j0.000282-0.017490j...0.004098+0.004213j-0.006963-0.041617j-0.017787+0.002688j0.025167+0.012283j0.029283+0.059102j-0.039216+0.030935j-0.024009-0.028680j0.018269+0.040368j-0.020776+0.012157j-0.007685-0.010754j
\n", "

1 rows × 182 columns

\n", "
" ], "text/plain": [ " (((Channels(labels=[0], name=xy_channels, absolute_phase=False)))) \\\n", " 0 \n", " (amplitude, 0) \n", "0 0.031249-0.026000j \n", "\n", " \\\n", " \n", " (amplitude, 0.0667) (amplitude, 0.1333) (amplitude, 0.2) \n", "0 -0.031621-0.012998j -0.011636-0.015886j 0.004438-0.019826j \n", "\n", " \\\n", " \n", " (amplitude, 0.2667) (amplitude, 0.3333) (amplitude, 0.4) \n", "0 0.023532+0.034597j -0.019214+0.049735j -0.006032-0.034850j \n", "\n", " ... \\\n", " ... \n", " (amplitude, 0.4667) (amplitude, 0.5333) (amplitude, 0.6) ... \n", "0 0.026803+0.008326j 0.002084+0.007049j 0.000282-0.017490j ... \n", "\n", " (((Channels(labels=[1], name=xy_channels, absolute_phase=False)))) \\\n", " 6 \n", " (amplitude, 0.2) \n", "0 0.004098+0.004213j \n", "\n", " \\\n", " \n", " (amplitude, 0.2667) (amplitude, 0.3333) (amplitude, 0.4) \n", "0 -0.006963-0.041617j -0.017787+0.002688j 0.025167+0.012283j \n", "\n", " \\\n", " \n", " (amplitude, 0.4667) (amplitude, 0.5333) (amplitude, 0.6) \n", "0 0.029283+0.059102j -0.039216+0.030935j -0.024009-0.028680j \n", "\n", " \n", " \n", " (amplitude, 0.6667) (amplitude, 0.7333) (amplitude, 0.8) \n", "0 0.018269+0.040368j -0.020776+0.012157j -0.007685-0.010754j \n", "\n", "[1 rows x 182 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hw_demod = False\n", "\n", "# acceptable data shape\n", "shape = [n_shots, num_amps, n_points]\n", "\n", "# generate mock trace data\n", "mock_data = dict()\n", "for chan in channels:\n", " mock_data[chan] = np.random.random(shape)\n", "\n", "# load the mock_data using the mock_data parameter in the Experiment class\n", "backend = qcs.HclBackend(mapper, hw_demod=hw_demod)\n", "exp = Experiment(backend, make_calibration_set(2), qubits, program, mock_data=mock_data)\n", "\n", "exp.get_iq() # or exp.get_trace()" ] }, { "cell_type": "raw", "id": "8aaaf9fd", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Nested Sweeps with mock_data\n", "----------------------------\n", "\n", "Moving on to more complicated sweeps, we just have to that the shape of\n", "**program.repetitions.items** and our data matches." ] }, { "cell_type": "code", "execution_count": 6, "id": "b043aaf8", "metadata": { "execution": { "iopub.execute_input": "2025-04-17T20:53:58.697051Z", "iopub.status.busy": "2025-04-17T20:53:58.696010Z", "iopub.status.idle": "2025-04-17T20:53:58.709954Z", "shell.execute_reply": "2025-04-17T20:53:58.709258Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Repeat(7)\n", "Sweep(phase=Array(name=phases, shape=(17,), dtype=float, unit=none))\n", "Sweep(amplitude=Array(name=amps, shape=(13,), dtype=float, unit=none))\n" ] } ], "source": [ "n_shots = 7\n", "num_a = 13 # number of points to sweep on\n", "num_b = 17 # number of points to sweep on\n", "\n", "qubits = qcs.Qudits(range(n_qubits))\n", "channels = qcs.Channels(range(n_channels), \"xy_channels\", absolute_phase=False)\n", "\n", "program = qcs.Program()\n", "amplitude = qcs.Scalar(\"amplitude\", dtype=float)\n", "phase = qcs.Scalar(\"phase\", dtype=float)\n", "amps = qcs.Array(\"amps\", value=np.linspace(0, 0.8, num_a), dtype=float)\n", "phases = qcs.Array(\"phases\", value=np.linspace(0, np.pi, num_b), dtype=float)\n", "\n", "waveform = qcs.RFWaveform(\n", " duration=20e-9,\n", " envelope=qcs.GaussianEnvelope(),\n", " amplitude=amplitude,\n", " rf_frequency=5.1e9,\n", " instantaneous_phase=phase,\n", ")\n", "program.add_waveform(waveform, channels)\n", "int_filter = qcs.RFWaveform(10e-8, qcs.ConstantEnvelope(), 1, 5.15e9)\n", "program.add_acquisition(int_filter, channels)\n", "program.sweep(amps, amplitude).sweep(phases, phase).n_shots(n_shots)\n", "for i in program.repetitions.items:\n", " print(i)" ] }, { "cell_type": "raw", "id": "4c3084d1", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Defining and loading mock_data\n" ] }, { "cell_type": "code", "execution_count": 7, "id": "8258ab32", "metadata": { "execution": { "iopub.execute_input": "2025-04-17T20:53:58.713353Z", "iopub.status.busy": "2025-04-17T20:53:58.712836Z", "iopub.status.idle": "2025-04-17T20:54:00.018759Z", "shell.execute_reply": "2025-04-17T20:54:00.017964Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
(((Channels(labels=[0], name=xy_channels, absolute_phase=False))))...(((Channels(labels=[1], name=xy_channels, absolute_phase=False))))
0...6
(phase, 0 rad)...(phase, 3.1415926536 rad)
(amplitude, 0)(amplitude, 0.0667)(amplitude, 0.1333)(amplitude, 0.2)(amplitude, 0.2667)(amplitude, 0.3333)(amplitude, 0.4)(amplitude, 0.4667)(amplitude, 0.5333)(amplitude, 0.6)...(amplitude, 0.2)(amplitude, 0.2667)(amplitude, 0.3333)(amplitude, 0.4)(amplitude, 0.4667)(amplitude, 0.5333)(amplitude, 0.6)(amplitude, 0.6667)(amplitude, 0.7333)(amplitude, 0.8)
0-0.019448+0.013503j-0.002012-0.028937j-0.021066+0.015633j0.007827+0.058362j0.090904+0.036831j-0.004793-0.021340j0.037485+0.056948j0.014964+0.028572j-0.023797+0.026929j-0.044831+0.006169j...0.012186+0.042002j0.011547-0.022397j0.025953+0.012802j-0.045448-0.013421j-0.052819-0.031184j-0.005990+0.024468j0.037878-0.016779j0.017988-0.010031j-0.089399-0.027104j-0.025709-0.016623j
\n", "

1 rows × 3094 columns

\n", "
" ], "text/plain": [ " (((Channels(labels=[0], name=xy_channels, absolute_phase=False)))) \\\n", " 0 \n", " (phase, 0 rad) \n", " (amplitude, 0) \n", "0 -0.019448+0.013503j \n", "\n", " \\\n", " \n", " \n", " (amplitude, 0.0667) (amplitude, 0.1333) (amplitude, 0.2) \n", "0 -0.002012-0.028937j -0.021066+0.015633j 0.007827+0.058362j \n", "\n", " \\\n", " \n", " \n", " (amplitude, 0.2667) (amplitude, 0.3333) (amplitude, 0.4) \n", "0 0.090904+0.036831j -0.004793-0.021340j 0.037485+0.056948j \n", "\n", " ... \\\n", " ... \n", " ... \n", " (amplitude, 0.4667) (amplitude, 0.5333) (amplitude, 0.6) ... \n", "0 0.014964+0.028572j -0.023797+0.026929j -0.044831+0.006169j ... \n", "\n", " (((Channels(labels=[1], name=xy_channels, absolute_phase=False)))) \\\n", " 6 \n", " (phase, 3.1415926536 rad) \n", " (amplitude, 0.2) \n", "0 0.012186+0.042002j \n", "\n", " \\\n", " \n", " \n", " (amplitude, 0.2667) (amplitude, 0.3333) (amplitude, 0.4) \n", "0 0.011547-0.022397j 0.025953+0.012802j -0.045448-0.013421j \n", "\n", " \\\n", " \n", " \n", " (amplitude, 0.4667) (amplitude, 0.5333) (amplitude, 0.6) \n", "0 -0.052819-0.031184j -0.005990+0.024468j 0.037878-0.016779j \n", "\n", " \n", " \n", " \n", " (amplitude, 0.6667) (amplitude, 0.7333) (amplitude, 0.8) \n", "0 0.017988-0.010031j -0.089399-0.027104j -0.025709-0.016623j \n", "\n", "[1 rows x 3094 columns]" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hw_demod = False\n", "shape = [n_shots, num_a, num_b, n_points]\n", "\n", "mock_data = dict()\n", "for chan in channels:\n", " mock_data[chan] = np.random.random(shape)\n", "\n", "backend = qcs.HclBackend(mapper, hw_demod=hw_demod)\n", "exp = Experiment(backend, make_calibration_set(2), qubits, program, mock_data=mock_data)\n", "\n", "exp.get_iq() # OR exp.get_trace()" ] }, { "cell_type": "raw", "id": "5e1ef039", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Zipped Sweeps with mock_data\n", "----------------------------\n", "\n", "Zipped sweeps have special structure in **program.repetitions.items**" ] }, { "cell_type": "code", "execution_count": 8, "id": "75216d4d", "metadata": { "execution": { "iopub.execute_input": "2025-04-17T20:54:00.021949Z", "iopub.status.busy": "2025-04-17T20:54:00.021655Z", "iopub.status.idle": "2025-04-17T20:54:00.032911Z", "shell.execute_reply": "2025-04-17T20:54:00.032158Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Repeat(7)\n", "Sweep(amplitude=Array(name=amps, shape=(13,), dtype=float, unit=none), phase=Array(name=phases, shape=(13,), dtype=float, unit=none))\n" ] } ], "source": [ "num_a = 13\n", "\n", "# program\n", "qubits = qcs.Qudits(range(n_channels))\n", "channels = qcs.Channels(range(n_channels), \"xy_channels\", absolute_phase=False)\n", "\n", "program = qcs.Program()\n", "amplitude = qcs.Scalar(\"amplitude\", dtype=float)\n", "phase = qcs.Scalar(\"phase\", dtype=float)\n", "amps = qcs.Array(\"amps\", value=np.linspace(0, 0.8, num_a), dtype=float)\n", "phases = qcs.Array(\"phases\", value=np.linspace(0, np.pi, num_a), dtype=float)\n", "\n", "waveform = qcs.RFWaveform(\n", " duration=20e-9,\n", " envelope=qcs.GaussianEnvelope(),\n", " amplitude=amplitude,\n", " rf_frequency=5.1e9,\n", " instantaneous_phase=phase,\n", ")\n", "program.add_waveform(waveform, channels)\n", "int_filter = qcs.RFWaveform(10e-8, qcs.ConstantEnvelope(), 1, 5.15e9)\n", "program.add_acquisition(int_filter, channels)\n", "program.sweep((amps, phases), (amplitude, phase)).n_shots(n_shots)\n", "\n", "for i in program.repetitions.items:\n", " print(i)" ] }, { "cell_type": "raw", "id": "da653d96", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Defining and loading mock_data\n" ] }, { "cell_type": "code", "execution_count": 9, "id": "9ea34ae2", "metadata": { "execution": { "iopub.execute_input": "2025-04-17T20:54:00.035883Z", "iopub.status.busy": "2025-04-17T20:54:00.035608Z", "iopub.status.idle": "2025-04-17T20:54:00.252903Z", "shell.execute_reply": "2025-04-17T20:54:00.239170Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
(((Channels(labels=[0], name=xy_channels, absolute_phase=False))))...(((Channels(labels=[1], name=xy_channels, absolute_phase=False))))
0...6
(amplitude, 0), (phase, 0 rad)(amplitude, 0.0667), (phase, 261.8 mrad)(amplitude, 0.1333), (phase, 523.6 mrad)(amplitude, 0.2), (phase, 785.4 mrad)(amplitude, 0.2667), (phase, 1.0471975512 rad)(amplitude, 0.3333), (phase, 1.308996939 rad)(amplitude, 0.4), (phase, 1.5707963268 rad)(amplitude, 0.4667), (phase, 1.8325957146 rad)(amplitude, 0.5333), (phase, 2.0943951024 rad)(amplitude, 0.6), (phase, 2.3561944902 rad)...(amplitude, 0.2), (phase, 785.4 mrad)(amplitude, 0.2667), (phase, 1.0471975512 rad)(amplitude, 0.3333), (phase, 1.308996939 rad)(amplitude, 0.4), (phase, 1.5707963268 rad)(amplitude, 0.4667), (phase, 1.8325957146 rad)(amplitude, 0.5333), (phase, 2.0943951024 rad)(amplitude, 0.6), (phase, 2.3561944902 rad)(amplitude, 0.6667), (phase, 2.617993878 rad)(amplitude, 0.7333), (phase, 2.8797932658 rad)(amplitude, 0.8), (phase, 3.1415926536 rad)
0-0.010586-0.003072j0.002063-0.035717j-0.026939-0.029382j0.013823+0.022923j-0.026898-0.002183j0.018640-0.039584j-0.002380+0.035292j-0.010906+0.019501j0.021480+0.010561j0.016323-0.012088j...0.030539+0.008261j0.027897-0.048971j0.020939+0.028002j-0.004342+0.002680j-0.008071-0.035649j0.005053-0.000899j-0.038410-0.023571j0.006008+0.012163j0.035101-0.045239j-0.014720+0.011348j
\n", "

1 rows × 182 columns

\n", "
" ], "text/plain": [ " (((Channels(labels=[0], name=xy_channels, absolute_phase=False)))) \\\n", " 0 \n", " (amplitude, 0), (phase, 0 rad) \n", "0 -0.010586-0.003072j \n", "\n", " \\\n", " \n", " (amplitude, 0.0667), (phase, 261.8 mrad) \n", "0 0.002063-0.035717j \n", "\n", " \\\n", " \n", " (amplitude, 0.1333), (phase, 523.6 mrad) \n", "0 -0.026939-0.029382j \n", "\n", " \\\n", " \n", " (amplitude, 0.2), (phase, 785.4 mrad) \n", "0 0.013823+0.022923j \n", "\n", " \\\n", " \n", " (amplitude, 0.2667), (phase, 1.0471975512 rad) \n", "0 -0.026898-0.002183j \n", "\n", " \\\n", " \n", " (amplitude, 0.3333), (phase, 1.308996939 rad) \n", "0 0.018640-0.039584j \n", "\n", " \\\n", " \n", " (amplitude, 0.4), (phase, 1.5707963268 rad) \n", "0 -0.002380+0.035292j \n", "\n", " \\\n", " \n", " (amplitude, 0.4667), (phase, 1.8325957146 rad) \n", "0 -0.010906+0.019501j \n", "\n", " \\\n", " \n", " (amplitude, 0.5333), (phase, 2.0943951024 rad) \n", "0 0.021480+0.010561j \n", "\n", " ... \\\n", " ... \n", " (amplitude, 0.6), (phase, 2.3561944902 rad) ... \n", "0 0.016323-0.012088j ... \n", "\n", " (((Channels(labels=[1], name=xy_channels, absolute_phase=False)))) \\\n", " 6 \n", " (amplitude, 0.2), (phase, 785.4 mrad) \n", "0 0.030539+0.008261j \n", "\n", " \\\n", " \n", " (amplitude, 0.2667), (phase, 1.0471975512 rad) \n", "0 0.027897-0.048971j \n", "\n", " \\\n", " \n", " (amplitude, 0.3333), (phase, 1.308996939 rad) \n", "0 0.020939+0.028002j \n", "\n", " \\\n", " \n", " (amplitude, 0.4), (phase, 1.5707963268 rad) \n", "0 -0.004342+0.002680j \n", "\n", " \\\n", " \n", " (amplitude, 0.4667), (phase, 1.8325957146 rad) \n", "0 -0.008071-0.035649j \n", "\n", " \\\n", " \n", " (amplitude, 0.5333), (phase, 2.0943951024 rad) \n", "0 0.005053-0.000899j \n", "\n", " \\\n", " \n", " (amplitude, 0.6), (phase, 2.3561944902 rad) \n", "0 -0.038410-0.023571j \n", "\n", " \\\n", " \n", " (amplitude, 0.6667), (phase, 2.617993878 rad) \n", "0 0.006008+0.012163j \n", "\n", " \\\n", " \n", " (amplitude, 0.7333), (phase, 2.8797932658 rad) \n", "0 0.035101-0.045239j \n", "\n", " \n", " \n", " (amplitude, 0.8), (phase, 3.1415926536 rad) \n", "0 -0.014720+0.011348j \n", "\n", "[1 rows x 182 columns]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# mock_data\n", "shape = [n_shots, num_a, n_points]\n", "mock_data = dict()\n", "for chan in channels:\n", " mock_data[chan] = np.random.random(shape)\n", "\n", "# test for each mock_data\n", "backend = qcs.HclBackend(mapper, hw_demod=hw_demod)\n", "exp = Experiment(backend, make_calibration_set(2), qubits, program, mock_data=mock_data)\n", "\n", "exp.get_iq() # OR exp.get_trace()" ] }, { "cell_type": "raw", "id": "3eb8e071", "metadata": { "lines_to_next_cell": 0, "raw_mimetype": "text/restructuredtext" }, "source": [ "Example for a Qubit level program\n", "---------------------------------\n", "\n", "For qubit level program, the user need to additionally take care of the\n", "calibration set and the application of LinkerPass to the program, as shown below:\n" ] }, { "cell_type": "code", "execution_count": 10, "id": "f30f5026", "metadata": { "execution": { "iopub.execute_input": "2025-04-17T20:54:00.258185Z", "iopub.status.busy": "2025-04-17T20:54:00.257137Z", "iopub.status.idle": "2025-04-17T20:54:00.271168Z", "shell.execute_reply": "2025-04-17T20:54:00.270223Z" } }, "outputs": [], "source": [ "# channel mapper\n", "n_channels = 2\n", "n_qubits = 2\n", "n_points = 240 # points accepted by the integration filter\n", "\n", "mapper = qcs.ChannelMapper(\"dummy\")\n", "\n", "# channel_acq required for qubit-type mock_data\n", "# our default function qcs.experiments.make_calibration_set` creates channels with\n", "# name=\"readout_acquisition\", and supporting linkers for it.\n", "channels_acq = qcs.Channels(\n", " range(n_channels), \"readout_acquisition\", absolute_phase=True\n", ")\n", "# assigning dummy physical addresses to the channels\n", "for i in range(n_channels):\n", " mapper.add_channel_mapping(\n", " channels=channels_acq[i],\n", " addresses=qcs.Address(2, 1, i + 1),\n", " instrument_types=qcs.InstrumentEnum.M5300AWG,\n", " )" ] }, { "cell_type": "raw", "id": "9fc8c9b2", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Defining the program and other components:" ] }, { "cell_type": "code", "execution_count": 11, "id": "e34f9758", "metadata": { "execution": { "iopub.execute_input": "2025-04-17T20:54:00.286891Z", "iopub.status.busy": "2025-04-17T20:54:00.284311Z", "iopub.status.idle": "2025-04-17T20:54:00.485154Z", "shell.execute_reply": "2025-04-17T20:54:00.484402Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
(((Qudits(labels=[0], name=qudits, dim=2))))(((Qudits(labels=[1], name=qudits, dim=2))))
01234560123456
0-0.029511+0.003492j0.000815-0.028222j-0.015486-0.010311j-0.052808+0.017443j0.017927+0.033257j0.007270-0.001728j0.002164+0.004423j-0.030739-0.010229j0.028088+0.035851j0.021961-0.000595j0.032344-0.029078j-0.001332-0.001276j-0.002384+0.003196j-0.008209-0.009716j
\n", "
" ], "text/plain": [ " (((Qudits(labels=[0], name=qudits, dim=2)))) \\\n", " 0 1 \n", "0 -0.029511+0.003492j 0.000815-0.028222j \n", "\n", " \\\n", " 2 3 4 \n", "0 -0.015486-0.010311j -0.052808+0.017443j 0.017927+0.033257j \n", "\n", " \\\n", " 5 6 \n", "0 0.007270-0.001728j 0.002164+0.004423j \n", "\n", " (((Qudits(labels=[1], name=qudits, dim=2)))) \\\n", " 0 1 \n", "0 -0.030739-0.010229j 0.028088+0.035851j \n", "\n", " \\\n", " 2 3 4 \n", "0 0.021961-0.000595j 0.032344-0.029078j -0.001332-0.001276j \n", "\n", " \n", " 5 6 \n", "0 -0.002384+0.003196j -0.008209-0.009716j " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "n_shots = 7\n", "num_amps = 13 # number of amplitude points to sweep on\n", "hw_demod = False\n", "\n", "qubits = qcs.Qudits(range(n_channels))\n", "channels_acq = qcs.Channels(\n", " range(n_channels), \"readout_acquisition\", absolute_phase=True\n", ")\n", "\n", "program = qcs.Program()\n", "program.add_measurement(qubits)\n", "program.n_shots(n_shots)\n", "\n", "# Additional steps: Defining the calibration set and applying LinkerPass\n", "cal_set = make_calibration_set(n_channels)\n", "program = qcs.LinkerPass(*cal_set.linkers.values()).apply(program)\n", "\n", "# mock_data for qubits\n", "mock_data = dict()\n", "for qub in qubits:\n", " mock_data[qub] = np.random.random((n_shots, n_points))\n", "\n", "backend = qcs.HclBackend(mapper, hw_demod=hw_demod)\n", "\n", "exp = Experiment(backend, make_calibration_set(2), qubits, program, mock_data=mock_data)\n", "exp.get_iq()" ] } ], "metadata": { "jupytext": { "cell_metadata_filter": "nbsphinx,raw_mimetype,-all", "main_language": "python", "notebook_metadata_filter": "-all", "text_representation": { "extension": ".py", "format_name": "percent" } }, "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.10.15" } }, "nbformat": 4, "nbformat_minor": 5 }