{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "d9140e6f", "metadata": { "execution": { "iopub.execute_input": "2024-10-11T06:15:27.657937Z", "iopub.status.busy": "2024-10-11T06:15:27.657576Z", "iopub.status.idle": "2024-10-11T06:15:27.663420Z", "shell.execute_reply": "2024-10-11T06:15:27.662603Z" }, "nbsphinx": "hidden" }, "outputs": [], "source": [ "# Copyright 2024 Keysight Technologies Inc." ] }, { "cell_type": "raw", "id": "04f43758", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Channel mappers\n", "===============\n", "\n", ":py:class:`~keysight.qcs.channels.ChannelMapper`\\s can be used to map\n", ":py:class:`~keysight.qcs.channels.Channels` to\n", ":py:class:`~keysight.qcs.channels.PhysicalChannel`\\s, which represent the physical\n", "channels on hardware. In this tutorial, we show how to write a\n", ":py:class:`~keysight.qcs.channels.ChannelMapper`, including a multiplexing example.\n", "General purpose :py:class:`~keysight.qcs.channels.ChannelMapper`\\s can be defined for\n", "a given device, and are meant to be saved to file with\n", ":py:func:`~keysight.qcs.utils.save`\\, then loaded with\n", ":py:func:`~keysight.qcs.utils.load` and used to map program instructions to that\n", "device.\n", "\n", "In the examples below, we use a chassis with an AWG in slot 4, a digitizer in slot 3,\n", "and a downconverter in slot 2. The IF channels of the downconverter should be\n", "connected to corresponding channels of the digitizer for downconversion, while the RF\n", "channels should be connected to the qudit." ] }, { "cell_type": "code", "execution_count": 2, "id": "6a04a72f", "metadata": { "execution": { "iopub.execute_input": "2024-10-11T06:15:27.666700Z", "iopub.status.busy": "2024-10-11T06:15:27.666391Z", "iopub.status.idle": "2024-10-11T06:15:30.759727Z", "shell.execute_reply": "2024-10-11T06:15:30.758769Z" } }, "outputs": [], "source": [ "import keysight.qcs as qcs\n", "\n", "# define channels representing different AWGs and digitizers\n", "awgs = qcs.Channels(range(2), \"xy_pulse\")\n", "readout_awgs = qcs.Channels(range(1), \"readout_pulse\", absolute_phase=True)\n", "dig = qcs.Channels(range(1), \"readout_acquisition\", absolute_phase=True)\n", "\n", "# define the addresses of physical channels of 2 awgs, a digitizer, and a downconverter\n", "awg_1x4x1 = qcs.Address(chassis=1, slot=4, channel=1)\n", "awg_1x4x3 = qcs.Address(1, 4, 3)\n", "awg_1x4x4 = qcs.Address(1, 4, 4)\n", "dig_1x3x4 = qcs.Address(1, 3, 4)\n", "dc_1x2x4 = qcs.Address(1, 2, 4)" ] }, { "cell_type": "raw", "id": "fdf884f7", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "We can then initialize the channel mapper and define the correspondence between\n", "virtual and physical channels." ] }, { "cell_type": "code", "execution_count": 3, "id": "d996e8a1", "metadata": { "execution": { "iopub.execute_input": "2024-10-11T06:15:30.763810Z", "iopub.status.busy": "2024-10-11T06:15:30.763320Z", "iopub.status.idle": "2024-10-11T06:15:30.861877Z", "shell.execute_reply": "2024-10-11T06:15:30.860705Z" } }, "outputs": [], "source": [ "mapper = qcs.ChannelMapper()\n", "\n", "# specify the mapping between virtual and physical channels\n", "mapper.add_channel_mapping(awgs, [awg_1x4x1, awg_1x4x3], qcs.InstrumentEnum.M5300AWG)\n", "mapper.add_channel_mapping(readout_awgs, awg_1x4x4, qcs.InstrumentEnum.M5300AWG)\n", "mapper.add_channel_mapping(dig, dig_1x3x4, qcs.InstrumentEnum.M5200Digitizer)\n", "\n", "# specify the IF channel of the downconverter connected to `dig_1x3x4`\n", "mapper.add_downconverters(dig_1x3x4, dc_1x2x4)\n", "\n", "# set the LO frequency of the AWG and downconverter channels to be the same value by\n", "# passing in a range of possible RF frequencies\n", "mapper.constrain_lo_frequencies(\n", " [awg_1x4x1, awg_1x4x3, awg_1x4x4, dc_1x2x4], 5.5e9, 6.0e9\n", ")\n", "\n", "# save the mapper\n", "save_and_load = False\n", "if save_and_load:\n", " qcs.save(mapper, \"channel_mapper.qcs\")\n", "\n", "# then we can load the mapper from file to re-use later\n", "if save_and_load:\n", " mapper_loaded = qcs.load(\"channel_mapper.qcs\")\n", " assert mapper == mapper_loaded" ] }, { "cell_type": "raw", "id": "9170fc28", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "Multiplexing with channel mappers\n", "---------------------------------\n", "\n", ":py:class:`~keysight.qcs.channels.ChannelMapper`\\s support multiplexing, i.e.,\n", "mapping of different :py:class:`~keysight.qcs.channels.Channels` to the same\n", ":py:class:`~keysight.qcs.channels.PhysicalChannel`.\n", "The pulse sent or retrieved through the physical channel during execution is the sum\n", "of the pulses on the virtual channels." ] }, { "cell_type": "code", "execution_count": 4, "id": "c4958785", "metadata": { "execution": { "iopub.execute_input": "2024-10-11T06:15:30.865950Z", "iopub.status.busy": "2024-10-11T06:15:30.865570Z", "iopub.status.idle": "2024-10-11T06:15:30.872501Z", "shell.execute_reply": "2024-10-11T06:15:30.871679Z" } }, "outputs": [], "source": [ "# define channels object representing AWGs\n", "awgs = qcs.Channels(range(3), \"awgs\")\n", "\n", "# define the address of a physical channel\n", "awg_1x4x1 = qcs.Address(1, 4, 1)\n", "\n", "# initialize a mapper and specify the mapping\n", "mapper = qcs.ChannelMapper()\n", "mapper.add_channel_mapping(awgs, [awg_1x4x1] * 3, qcs.InstrumentEnum.M5300AWG)" ] }, { "cell_type": "raw", "id": "14149c23", "metadata": { "raw_mimetype": "text/restructuredtext" }, "source": [ "The :doc:`multiplexing` tutorial puts this to work and demonstrates multiplexed\n", "control and readout pulses." ] } ], "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.9.6" } }, "nbformat": 4, "nbformat_minor": 5 }