Compiling a QGL2 RabiAmp and plotting the output


In [22]:
# Using phase=0, amp from 0 -> 1 stepping by 0.1

Imports


In [23]:
from pyqgl2.main import compile_function, qgl2_compile_to_hardware
from pyqgl2.test_cl import create_default_channelLibrary
from pyqgl2.qreg import QRegister
from QGL import plot_pulse_files, ChannelLibrary
import numpy as np

Create a test ChannelLibrary


In [24]:
create_default_channelLibrary(True, True)
# Alternatively could load an existing library, or create one here; see the 'AllXY' notebook

Create needed qubit(s)


In [25]:
# For QGL2, use a QRegister, not a QGL Qubit
q = QRegister(1)

Compile to QGL1


In [26]:
# Insert proper path to QGL2 source and name of qgl2main if not so marked
# Here we compile the named function in the named file from QGL2 to QGL1 and return the new functio

In [27]:
rAmpAmps = np.linspace(0, 1, 1)
qgl1MainFunc = compile_function("../src/python/qgl2/basic_sequences/Rabi.py", "RabiAmp", (q, rAmpAmps, 0), saveOutput=True)



COMPILING [../src/python/qgl2/basic_sequences/Rabi.py] main RabiAmp
2019-09-26 11:50:08.300694: CALLING IMPORTER
../src/python/qgl2/basic_sequences/Rabi.py:188:4: warning: conditional/runtime import [from pyqgl2.qreg import QRegister] ignored by pyqgl2
../src/python/qgl2/basic_sequences/Rabi.py:189:4: warning: conditional/runtime import [import pyqgl2.test_cl] ignored by pyqgl2
../src/python/qgl2/basic_sequences/Rabi.py:190:4: warning: conditional/runtime import [from pyqgl2.main import compile_function
from pyqgl2.main import qgl2_compile_to_hardware] ignored by pyqgl2
../src/python/qgl2/basic_sequences/Rabi.py:191:4: warning: conditional/runtime import [import numpy as np] ignored by pyqgl2
../src/python/qgl2/basic_sequences/Rabi.py:192:4: warning: conditional/runtime import [import QGL.PulseShapes] ignored by pyqgl2
../src/python/qgl2/basic_sequences/Rabi.py:290:12: warning: conditional/runtime import [from QGL.Scheduler import schedule] ignored by pyqgl2
../src/python/qgl2/basic_sequences/Rabi.py:293:12: warning: conditional/runtime import [from IPython.lib.pretty import pretty] ignored by pyqgl2
../src/python/qgl2/basic_sequences/Rabi.py:285:16: warning: conditional/runtime import [from QGL.PulseSequencePlotter import plot_pulse_files] ignored by pyqgl2
2019-09-26 11:50:08.365738: CALLING INLINER
2019-09-26 11:50:08.365983: ITERATION 0
2019-09-26 11:50:08.367424: ITERATION 1
2019-09-26 11:50:08.368372: CALLING EVALUATOR
2019-09-26 11:50:08.373181: CALLING FLATTENER
2019-09-26 11:50:08.373489: GENERATING QGL1 SEQUENCE FUNCTION
Saved compiled code to /home/ahelsing/machome/Projects/Quantum/pyqgl2/src/python/qgl2/basic_sequences/Rabiqgl1.py

Generate pulse sequences


In [28]:
# Now run the QGL1 function, producing a list of sequences
seqs = qgl1MainFunc()

Compile to machine instructions


In [29]:
from qgl2.basic_sequences.helpers import delay_descriptor, cal_descriptor
axis_desc = [{
            'name': 'amplitude',
            'unit': None,
            'points': list(rAmpAmps),
            'partition': 1
        }]
label = "Rabi"

metaFileName = qgl2_compile_to_hardware(seqs, filename=f"{label}/{label}", axis_descriptor=axis_desc)
print(f"Generated sequence details in '{metaFileName}'")


Compiled 1 sequences.
Generated sequence details in '/tmp/AWGpj4dtdnh/Rabi/Rabi-meta.json'

Plot the sequences


In [30]:
p = plot_pulse_files(metaFileName)
# Explicitly display the graph which fails to auto-draw in some cases
display(p)


Sampling rate from extract_waveforms 1200000000.0
Sampling rate from extract_waveforms 1200000000.0