Download

Download this file as Jupyter notebook: hello_hardware.ipynb.

Running a program on hardware#

This guide gives an overview of the initial steps to set up and run a “Hello Quantum World!” program on hardware using QCS. We will assume that the physical configuration of the hardware is already set up and that all required software has been installed via the Test Station Manager (TSM).

Setting up#

The first step is to define the software instances of the channels used to send and receive signals. In this example, we use two AWG channels and two digitizers.

[2]:
import keysight.qcs as qcs

# set the following to True when connected to hardware:
run_on_hw = False

# instantiate channels representing two AWGs and two digitizers
awgs = qcs.Channels(range(2), "readoutawg")
digs = qcs.Channels(range(2), "readoutreceiver")

The virtual channels above then have to be linked to the physical channels present in hardware. See Channel Mapper for details. For the purposes of this demonstration, we load a previously created ChannelMapper:

[3]:
mapper = qcs.load("../../assets/channel_mapper.qcs")

Defining a program#

In this section, we define a program to run on the hardware configuration specified above. For this example, we send a Gaussian waveform through the AWG channels and connect its output to our downconverter/digitizer channels to collect the results. The local oscillator (LO) frequency of our AWG and downconverter is set to 4 GHz.

[4]:
# instantiate an empty program
program = qcs.Program()

# add a 4.15 GHz RF waveform with a Gaussian envelope to the program
gauss = qcs.RFWaveform(80e-9, qcs.GaussianEnvelope(num_sigma=4), 1, 4.15e9)
program.add_waveform(gauss, awgs)

# add an acquisition to the program
program.add_acquisition(80e-9, digs)

# specify the number of shots
program.n_shots(10)

program.draw()
Program
Sweep Details:
Repetitions Repeat with 10 repetitions
(HW)Repeat(10)
keysight-logo-svg
Program Body
Program
Duration 80 ns
Layers 1
Targets 4
Layer #0
Layer #0
Duration 80 ns
readoutawg 0
RFWaveform on ('readoutawg', 0)

Parameters
Duration Scalar(name=_implicit, value=80 ns, dtype=float, unit=s)
Amplitude 1
Frequency 4.15 GHz
Envelope GaussianEnvelope(4.0)
Instantaneous Phase 0 rad
Post-phase 0 rad
1
RFWaveform on ('readoutawg', 1)

Parameters
Duration Scalar(name=_implicit, value=80 ns, dtype=float, unit=s)
Amplitude 1
Frequency 4.15 GHz
Envelope GaussianEnvelope(4.0)
Instantaneous Phase 0 rad
Post-phase 0 rad
readoutreceiver 0
Acquisition on ('readoutreceiver', 0)

Parameters
Duration Scalar(name=_implicit, value=80 ns, dtype=float, unit=s)
1
Acquisition on ('readoutreceiver', 1)

Parameters
Duration Scalar(name=_implicit, value=80 ns, dtype=float, unit=s)

Running on hardware#

To execute a program, we need to instantiate the HclBackend with the ChannelMapper specified above and add it to the Executor as a pass.

[5]:
if run_on_hw:
    # initialize the backend pass
    backend = qcs.HclBackend(channel_mapper=mapper)
    # the executor returns the program populated with results
    program = qcs.Executor(backend).execute(program)
    # (optional) export the data to an HDF5 file
    program.to_hdf5("program1.hdf5")

# we are loading a previously run program here for this example
program = qcs.load("program1.hdf5")

Note

When executing multiple programs with HCL, it is possible to execute them in sequence or in parallel. This is specified with the blocking property of HclBackend. When blocking = True, programs are run sequentially and Python blocks any further execution of the current script. When blocking = False, the execution exits immediately and the program continues to run in the background, enabling the execution of parallel programs on separate chassis.

If you are running the program for the first time, you may need to log in. You will be prompted to enter your username and password. See User Management. for a guide on the login process,

Retrieving data#

After a program is run, output data is stored in a database managed by QCS. Users can access the data through the program’s get_* methods, or export the data to an HDF5 file for later access using the to_hdf5() method on the program, as shown above. A saved program is then loaded using the load()method.

The program’s data can be accessed through the following methods:

All these methods take an optional argument avg which when set to True will average the data over shots.

Note

If the I/Q demodulation is performed on hardware, as can be specified by setting fpga_postprocessing=True in the HclBackend, no trace data will be stored.

These methods all return Pandas dataframes:

[6]:
program.get_trace_array()
[6]:
<xarray.DataArray (channel: 4, shot: 10, sample: 384)> Size: 123kB
array([[[-0.00615234, -0.00966797, -0.00791016, ..., -0.00065918,
         -0.00197754, -0.00175781],
        [-0.00593262, -0.00703125, -0.00900879, ..., -0.00087891,
         -0.00131836, -0.00021973],
        [-0.00571289, -0.0074707 , -0.00944824, ..., -0.00307617,
         -0.00241699, -0.00043945],
        ...,
        [-0.00571289, -0.00834961, -0.00856934, ..., -0.00175781,
         -0.00241699, -0.00263672],
        [-0.0065918 , -0.00593262, -0.00812988, ..., -0.00197754,
         -0.00263672, -0.00307617],
        [-0.00637207, -0.00834961, -0.00856934, ..., -0.00219727,
         -0.00263672, -0.00175781]],

       [[-0.00087891, -0.00681152, -0.0032959 , ...,  0.00527344,
          0.00175781,  0.00505371],
        [-0.00615234, -0.00461426, -0.00549316, ...,  0.0041748 ,
          0.00439453,  0.00373535],
        [-0.00175781, -0.00549316, -0.00900879, ...,  0.00109863,
          0.00439453, -0.00131836],
...
        [-0.00153809,  0.00043945, -0.00065918, ..., -0.00021973,
          0.00153809, -0.00109863],
        [ 0.00131836,  0.00043945,  0.00527344, ..., -0.00065918,
          0.00131836,  0.        ],
        [-0.00153809,  0.00087891, -0.00021973, ..., -0.00043945,
          0.0032959 , -0.00087891]],

       [[ 0.00439453,  0.00637207,  0.00966797, ...,  0.00439453,
          0.00615234,  0.0074707 ],
        [ 0.00637207,  0.00637207,  0.01010742, ...,  0.0065918 ,
          0.0065918 ,  0.00681152],
        [ 0.00615234,  0.00681152,  0.00944824, ...,  0.00769043,
          0.00681152,  0.00681152],
        ...,
        [ 0.00615234,  0.00812988,  0.01032715, ...,  0.0074707 ,
          0.00505371,  0.00703125],
        [ 0.00703125,  0.00922852,  0.00944824, ...,  0.00549316,
          0.0065918 ,  0.00681152],
        [ 0.0074707 ,  0.00769043,  0.0098877 , ...,  0.00483398,
          0.00769043,  0.0065918 ]]])
Coordinates:
  * channel  (channel) <U17 272B 'readoutreceiver_0' ... 'readoutreceiver_3'
  * shot     (shot) int64 80B 0 1 2 3 4 5 6 7 8 9
  * sample   (sample) int64 3kB 0 1 2 3 4 5 6 7 ... 377 378 379 380 381 382 383

This dataframe has the channels as its first column index, followed by the program’s repetitions (shots). Individual columns in the dataframe can be accessed by indexing the dataframe with first the channel and then the shot number. Note that other than the first column index (the channel), all other column indices are strings.

[7]:
df = program.get_trace_pandas()

# access trace data for channel 0, first shot
df[digs[0]]["0"]
[7]:
0     -0.006152
1     -0.009668
2     -0.007910
3     -0.007690
4     -0.010107
         ...
379   -0.002197
380   -0.001758
381   -0.000659
382   -0.001978
383   -0.001758
Name: 0, Length: 384, dtype: float64

We can extract a sample data using the following:

[8]:
xarray_data = program.get_trace_array()
xarray_data
[8]:
<xarray.DataArray (channel: 4, shot: 10, sample: 384)> Size: 123kB
array([[[-0.00615234, -0.00966797, -0.00791016, ..., -0.00065918,
         -0.00197754, -0.00175781],
        [-0.00593262, -0.00703125, -0.00900879, ..., -0.00087891,
         -0.00131836, -0.00021973],
        [-0.00571289, -0.0074707 , -0.00944824, ..., -0.00307617,
         -0.00241699, -0.00043945],
        ...,
        [-0.00571289, -0.00834961, -0.00856934, ..., -0.00175781,
         -0.00241699, -0.00263672],
        [-0.0065918 , -0.00593262, -0.00812988, ..., -0.00197754,
         -0.00263672, -0.00307617],
        [-0.00637207, -0.00834961, -0.00856934, ..., -0.00219727,
         -0.00263672, -0.00175781]],

       [[-0.00087891, -0.00681152, -0.0032959 , ...,  0.00527344,
          0.00175781,  0.00505371],
        [-0.00615234, -0.00461426, -0.00549316, ...,  0.0041748 ,
          0.00439453,  0.00373535],
        [-0.00175781, -0.00549316, -0.00900879, ...,  0.00109863,
          0.00439453, -0.00131836],
...
        [-0.00153809,  0.00043945, -0.00065918, ..., -0.00021973,
          0.00153809, -0.00109863],
        [ 0.00131836,  0.00043945,  0.00527344, ..., -0.00065918,
          0.00131836,  0.        ],
        [-0.00153809,  0.00087891, -0.00021973, ..., -0.00043945,
          0.0032959 , -0.00087891]],

       [[ 0.00439453,  0.00637207,  0.00966797, ...,  0.00439453,
          0.00615234,  0.0074707 ],
        [ 0.00637207,  0.00637207,  0.01010742, ...,  0.0065918 ,
          0.0065918 ,  0.00681152],
        [ 0.00615234,  0.00681152,  0.00944824, ...,  0.00769043,
          0.00681152,  0.00681152],
        ...,
        [ 0.00615234,  0.00812988,  0.01032715, ...,  0.0074707 ,
          0.00505371,  0.00703125],
        [ 0.00703125,  0.00922852,  0.00944824, ...,  0.00549316,
          0.0065918 ,  0.00681152],
        [ 0.0074707 ,  0.00769043,  0.0098877 , ...,  0.00483398,
          0.00769043,  0.0065918 ]]])
Coordinates:
  * channel  (channel) <U17 272B 'readoutreceiver_0' ... 'readoutreceiver_3'
  * shot     (shot) int64 80B 0 1 2 3 4 5 6 7 8 9
  * sample   (sample) int64 3kB 0 1 2 3 4 5 6 7 ... 377 378 379 380 381 382 383

get_trace_array() returns a xarray. From this xarray we can easily retrieve data of a specific channel and shot.

[9]:
print(xarray_data.sel(channel="readoutreceiver_0", shot=0))
<xarray.DataArray (sample: 384)> Size: 3kB
array([-6.15234347e-03, -9.66796838e-03, -7.91015569e-03, -7.69042969e-03,
       -1.01074213e-02, -1.23046869e-02, -1.12060541e-02, -1.12060541e-02,
       -9.22851544e-03, -8.78906250e-03, -7.03124981e-03, -6.59179688e-03,
       -3.73535138e-03, -2.63671856e-03,  1.53808587e-03,  6.81152334e-03,
        8.34960956e-03,  1.20849609e-02,  1.47216795e-02,  1.69189442e-02,
        2.08740234e-02,  2.26318352e-02,  2.15332024e-02,  2.19726562e-02,
        2.06542965e-02,  2.04345696e-02,  1.34033198e-02,  9.66796838e-03,
        1.97753892e-03, -4.17480478e-03, -1.16455071e-02, -1.97753906e-02,
       -2.52685547e-02, -3.42773423e-02, -4.17480469e-02, -4.68017571e-02,
       -4.87792939e-02, -5.36132790e-02, -5.44921868e-02, -5.25146462e-02,
       -4.94384766e-02, -4.19677719e-02, -3.44970711e-02, -2.48291008e-02,
       -1.05468743e-02,  1.75781245e-03,  1.51611324e-02,  3.07617188e-02,
        4.70214821e-02,  5.97656220e-02,  7.27294907e-02,  8.39355439e-02,
        9.16259736e-02,  9.73388627e-02,  9.79980454e-02,  9.47021469e-02,
        8.63525346e-02,  7.58056641e-02,  5.88867180e-02,  4.08691391e-02,
        1.86767578e-02, -8.12988263e-03, -3.60351540e-02, -6.08642548e-02,
       -8.89892578e-02, -1.12499997e-01, -1.33813471e-01, -1.50292963e-01,
       -1.65234372e-01, -1.72705069e-01, -1.72485352e-01, -1.64575189e-01,
       -1.50073245e-01, -1.32275388e-01, -1.04370117e-01, -7.11914077e-02,
       -3.60351540e-02,  4.39453125e-03,  4.65820283e-02,  8.59130844e-02,
...
        2.19726557e-04, -2.19726562e-03, -2.19726557e-04,  0.00000000e+00,
       -4.39453113e-04,  4.39453113e-04,  6.59179641e-04,  0.00000000e+00,
        0.00000000e+00, -2.85644527e-03, -2.41699209e-03, -6.59179641e-04,
       -1.97753892e-03, -1.31835928e-03, -1.97753892e-03, -1.09863281e-03,
       -2.19726557e-04, -8.78906227e-04, -1.97753892e-03, -2.41699209e-03,
       -1.53808587e-03, -2.41699209e-03, -8.78906227e-04, -2.19726557e-04,
       -1.09863281e-03, -4.39453113e-04, -2.19726557e-04, -1.53808587e-03,
       -1.31835928e-03, -3.07617174e-03, -2.63671856e-03, -6.59179641e-04,
        2.19726557e-04, -2.63671856e-03, -1.97753892e-03, -2.19726562e-03,
        0.00000000e+00, -1.09863281e-03, -1.31835928e-03, -2.63671856e-03,
       -1.75781245e-03, -1.31835928e-03, -2.41699209e-03, -1.53808587e-03,
       -1.97753892e-03, -1.97753892e-03, -2.41699209e-03, -2.19726562e-03,
       -1.53808587e-03, -2.41699209e-03, -1.09863281e-03, -1.31835928e-03,
        2.19726557e-04, -6.59179641e-04, -3.29589844e-03, -1.31835928e-03,
       -4.39453113e-04,  0.00000000e+00, -1.75781245e-03, -1.09863281e-03,
       -1.75781245e-03, -6.59179641e-04, -6.59179641e-04,  2.19726557e-04,
       -1.97753892e-03, -8.78906227e-04, -1.75781245e-03, -4.39453113e-04,
        8.78906227e-04, -8.78906227e-04, -1.31835928e-03, -1.97753892e-03,
        4.39453113e-04, -1.09863281e-03, -2.19726562e-03, -2.19726562e-03,
       -1.75781245e-03, -6.59179641e-04, -1.97753892e-03, -1.75781245e-03])
Coordinates:
    channel  <U17 68B 'readoutreceiver_0'
    shot     int64 8B 0
  * sample   (sample) int64 3kB 0 1 2 3 4 5 6 7 ... 377 378 379 380 381 382 383

xarray_data is a xarray which has the following

  • values: a numpy.ndarray or numpy-like array holding the array’s values

  • dims: dimension names for each axis (e.g. ‘channel’ or ‘qudit’, ‘shot’, ‘sample’)

  • coords: a dict-like container of arrays (coordinates) that label each point (e.g., 1-dimensional arrays of numbers, datetime objects or strings)

Also, the values can be accessed using the indices like

[10]:
xarray_data[0][0].values
[10]:
array([-6.15234347e-03, -9.66796838e-03, -7.91015569e-03, -7.69042969e-03,
       -1.01074213e-02, -1.23046869e-02, -1.12060541e-02, -1.12060541e-02,
       -9.22851544e-03, -8.78906250e-03, -7.03124981e-03, -6.59179688e-03,
       -3.73535138e-03, -2.63671856e-03,  1.53808587e-03,  6.81152334e-03,
        8.34960956e-03,  1.20849609e-02,  1.47216795e-02,  1.69189442e-02,
        2.08740234e-02,  2.26318352e-02,  2.15332024e-02,  2.19726562e-02,
        2.06542965e-02,  2.04345696e-02,  1.34033198e-02,  9.66796838e-03,
        1.97753892e-03, -4.17480478e-03, -1.16455071e-02, -1.97753906e-02,
       -2.52685547e-02, -3.42773423e-02, -4.17480469e-02, -4.68017571e-02,
       -4.87792939e-02, -5.36132790e-02, -5.44921868e-02, -5.25146462e-02,
       -4.94384766e-02, -4.19677719e-02, -3.44970711e-02, -2.48291008e-02,
       -1.05468743e-02,  1.75781245e-03,  1.51611324e-02,  3.07617188e-02,
        4.70214821e-02,  5.97656220e-02,  7.27294907e-02,  8.39355439e-02,
        9.16259736e-02,  9.73388627e-02,  9.79980454e-02,  9.47021469e-02,
        8.63525346e-02,  7.58056641e-02,  5.88867180e-02,  4.08691391e-02,
        1.86767578e-02, -8.12988263e-03, -3.60351540e-02, -6.08642548e-02,
       -8.89892578e-02, -1.12499997e-01, -1.33813471e-01, -1.50292963e-01,
       -1.65234372e-01, -1.72705069e-01, -1.72485352e-01, -1.64575189e-01,
       -1.50073245e-01, -1.32275388e-01, -1.04370117e-01, -7.11914077e-02,
       -3.60351540e-02,  4.39453125e-03,  4.65820283e-02,  8.59130844e-02,
        1.27001956e-01,  1.66992188e-01,  1.99072257e-01,  2.28295892e-01,
        2.45434567e-01,  2.55541980e-01,  2.52026349e-01,  2.41479486e-01,
        2.16650382e-01,  1.85229480e-01,  1.43261716e-01,  9.84374955e-02,
        4.06494141e-02, -1.20849609e-02, -6.67968765e-02, -1.23486325e-01,
       -1.76000968e-01, -2.23242179e-01, -2.70483404e-01, -3.03662091e-01,
       -3.29370111e-01, -3.42333972e-01, -3.36401373e-01, -3.21899414e-01,
       -2.84985334e-01, -2.45214835e-01, -1.91821277e-01, -1.32495120e-01,
       -7.07519501e-02, -2.85644527e-03,  6.81152344e-02,  1.34472653e-01,
        1.98852539e-01,  2.55981445e-01,  3.10253888e-01,  3.54858398e-01,
        3.86938453e-01,  3.99902344e-01,  3.87817383e-01,  3.68701160e-01,
        3.28271478e-01,  2.77514637e-01,  2.12915033e-01,  1.46777347e-01,
        6.89941421e-02, -3.73535138e-03, -7.82226548e-02, -1.50732413e-01,
       -2.20825195e-01, -2.81469733e-01, -3.39697242e-01, -3.87817383e-01,
       -4.19018537e-01, -4.35937494e-01, -4.28247064e-01, -4.04296875e-01,
       -3.59472632e-01, -3.03442389e-01, -2.38623038e-01, -1.67651370e-01,
       -8.85498002e-02, -1.42822266e-02,  6.61376938e-02,  1.39965817e-01,
        2.06323236e-01,  2.73779303e-01,  3.33764642e-01,  3.83862287e-01,
        4.19018537e-01,  4.34399396e-01,  4.26708966e-01,  3.95507812e-01,
        3.49145502e-01,  2.96411127e-01,  2.18847647e-01,  1.53369144e-01,
        7.53662065e-02, -2.85644527e-03, -8.19580033e-02, -1.50292963e-01,
       -2.20385730e-01, -2.84326166e-01, -3.33325177e-01, -3.77709955e-01,
       -4.08251941e-01, -4.18798804e-01, -4.06494141e-01, -3.76391590e-01,
       -3.29809576e-01, -2.77514637e-01, -2.09838867e-01, -1.43041983e-01,
       -6.94335923e-02,  0.00000000e+00,  6.83349594e-02,  1.33374020e-01,
        1.97973624e-01,  2.57299811e-01,  2.98608392e-01,  3.35742176e-01,
        3.53759766e-01,  3.56835932e-01,  3.45410138e-01,  3.17285150e-01,
        2.71142572e-01,  2.23901361e-01,  1.66992188e-01,  1.09423824e-01,
        4.43847626e-02, -1.29638668e-02, -7.18505830e-02, -1.27661124e-01,
       -1.73144519e-01, -2.13793933e-01, -2.50488281e-01, -2.71362305e-01,
       -2.80810535e-01, -2.79052734e-01, -2.65209943e-01, -2.40161121e-01,
       -2.05883786e-01, -1.70727536e-01, -1.28100589e-01, -8.15185532e-02,
       -3.75732407e-02,  8.34960956e-03,  4.96582016e-02,  8.70117173e-02,
        1.22387692e-01,  1.47875980e-01,  1.66772455e-01,  1.81933582e-01,
        1.85009763e-01,  1.83251947e-01,  1.72265619e-01,  1.57324210e-01,
        1.32934570e-01,  1.08105466e-01,  7.66845718e-02,  4.87792939e-02,
        2.02148426e-02, -9.88769531e-03, -3.42773423e-02, -5.69091775e-02,
       -7.66845718e-02, -9.20654237e-02, -1.03491209e-01, -1.10302731e-01,
       -1.12060547e-01, -1.09643549e-01, -1.03491209e-01, -9.18456987e-02,
       -7.91015625e-02, -6.37207031e-02, -4.89990227e-02, -3.36181633e-02,
       -1.38427727e-02,  1.97753892e-03,  1.69189442e-02,  2.98828110e-02,
        3.97705063e-02,  4.74609360e-02,  5.22949211e-02,  5.53710908e-02,
        5.66894524e-02,  5.44921868e-02,  4.98779267e-02,  4.30664048e-02,
        3.64746079e-02,  3.22998054e-02,  2.30712891e-02,  1.29638668e-02,
        5.49316406e-03, -2.19726562e-03, -1.01074213e-02, -1.51611324e-02,
       -2.17529293e-02, -2.46093739e-02, -2.65869126e-02, -2.94433590e-02,
       -2.83447262e-02, -2.70263664e-02, -2.41699219e-02, -2.13134754e-02,
       -1.91162098e-02, -1.56005854e-02, -1.18652340e-02, -8.78906250e-03,
       -6.37206994e-03, -1.53808587e-03,  2.85644527e-03,  3.95507785e-03,
        6.59179688e-03,  8.78906250e-03,  8.56933556e-03,  1.05468743e-02,
        9.66796838e-03,  9.44824237e-03,  7.47070275e-03,  6.81152334e-03,
        5.93261700e-03,  2.63671856e-03,  1.31835928e-03,  8.78906227e-04,
       -6.59179641e-04, -2.19726557e-04, -3.51562491e-03, -3.73535138e-03,
       -4.17480478e-03, -5.05371066e-03, -7.25097628e-03, -5.05371066e-03,
       -5.49316406e-03, -4.17480478e-03, -4.17480478e-03, -5.71289053e-03,
       -3.73535138e-03, -2.63671856e-03, -2.41699209e-03, -2.19726562e-03,
       -1.09863281e-03, -1.09863281e-03, -6.59179641e-04, -8.78906227e-04,
        2.19726557e-04, -2.19726562e-03, -2.19726557e-04,  0.00000000e+00,
       -4.39453113e-04,  4.39453113e-04,  6.59179641e-04,  0.00000000e+00,
        0.00000000e+00, -2.85644527e-03, -2.41699209e-03, -6.59179641e-04,
       -1.97753892e-03, -1.31835928e-03, -1.97753892e-03, -1.09863281e-03,
       -2.19726557e-04, -8.78906227e-04, -1.97753892e-03, -2.41699209e-03,
       -1.53808587e-03, -2.41699209e-03, -8.78906227e-04, -2.19726557e-04,
       -1.09863281e-03, -4.39453113e-04, -2.19726557e-04, -1.53808587e-03,
       -1.31835928e-03, -3.07617174e-03, -2.63671856e-03, -6.59179641e-04,
        2.19726557e-04, -2.63671856e-03, -1.97753892e-03, -2.19726562e-03,
        0.00000000e+00, -1.09863281e-03, -1.31835928e-03, -2.63671856e-03,
       -1.75781245e-03, -1.31835928e-03, -2.41699209e-03, -1.53808587e-03,
       -1.97753892e-03, -1.97753892e-03, -2.41699209e-03, -2.19726562e-03,
       -1.53808587e-03, -2.41699209e-03, -1.09863281e-03, -1.31835928e-03,
        2.19726557e-04, -6.59179641e-04, -3.29589844e-03, -1.31835928e-03,
       -4.39453113e-04,  0.00000000e+00, -1.75781245e-03, -1.09863281e-03,
       -1.75781245e-03, -6.59179641e-04, -6.59179641e-04,  2.19726557e-04,
       -1.97753892e-03, -8.78906227e-04, -1.75781245e-03, -4.39453113e-04,
        8.78906227e-04, -8.78906227e-04, -1.31835928e-03, -1.97753892e-03,
        4.39453113e-04, -1.09863281e-03, -2.19726562e-03, -2.19726562e-03,
       -1.75781245e-03, -6.59179641e-04, -1.97753892e-03, -1.75781245e-03])

This data can also be plotted using:

[11]:
program.plot_trace(channel_subplots=False)

The trace above has the expected Gaussian envelope and oscillates with a frequency of 150 MHz, which is exactly the difference frequency between our LO frequency (4 GHz) and our pulse frequency (4.15 GHz).

The channel_subplots argument in qcs.programs.Program.plot_trace() determines whether the results from different channels are put on the same plot or whether subplots are created. By default, plotted data is averaged over shots. To disable this behavior, set avg=False:

[12]:
program.plot_trace(avg=False)

Trace data can also be plotted in terms of the power spectrum using the qcs.programs.Program.plot_spectrum() method:

[13]:
program.plot_spectrum(channel_subplots=False)

In most applications, we are more interested in I/Q-demodulated and classified data rather than the full trace data. Here the trace is integrated after being multiplied by an integration filter, which allows us to extract phase, frequency and amplitude information. Classification is performed by preparing each quantum state, measuring its distribution on the I/Q plane and using a classifier to distinguish them.

This demodulation can be performed either in software or hardware, and requires the use of an IntegrationFilter. For the program above, we can define an integration filter using the same RF waveform and use it to retrieve software-demodulated I/Q data:

[14]:
int_filter = qcs.IntegrationFilter(gauss)

program.get_iq_pandas(integration_filter=int_filter, stack_channels=True)
[14]:
0 1 2 3 4 5 6 7 8 9
(((readoutreceiver_0))) -0.096668+0.141480j -0.096803+0.141558j -0.097061+0.141420j -0.096894+0.141605j -0.096993+0.141334j -0.096475+0.141695j -0.096685+0.141704j -0.096973+0.141504j -0.097067+0.141404j -0.096606+0.141656j
(((readoutreceiver_1))) -0.154978-0.102885j -0.154762-0.102692j -0.155153-0.102373j -0.154574-0.102878j -0.155056-0.103058j -0.155483-0.102438j -0.155118-0.103004j -0.155390-0.102690j -0.154792-0.102564j -0.155009-0.103048j
(((readoutreceiver_2))) -0.034034-0.168999j -0.034074-0.169100j -0.034033-0.169087j -0.034205-0.168911j -0.034050-0.169022j -0.033996-0.169074j -0.034115-0.169119j -0.034122-0.169209j -0.034186-0.169128j -0.034049-0.168811j
(((readoutreceiver_3))) 0.002157-0.163991j 0.002045-0.164099j 0.002319-0.163882j 0.002204-0.164170j 0.002458-0.163904j 0.002226-0.164203j 0.002437-0.164006j 0.002381-0.164037j 0.002315-0.164348j 0.001842-0.164169j

Note that the get_iq_pandas() method can stack the channel index as rows in the dataframe, to allow users to spot correlations in the data more easily.

To enable I/Q demodulation in hardware, we need to pass the integration filter to the program’s acquisition, as shown in Sweeping program variables.


Download

Download this file as Jupyter notebook: hello_hardware.ipynb.