Quantum compiler module
Quantum compiler
silospin.quantum_compiler.quantum_compiler.GateSetTomographyQuantumCompiler(gst_file_path, awg, gate_parameters, n_inner=1, n_outer=1, trigger_channel=0, added_padding=0, config_awg=True)Class representing an instance of compiler gate set tomography experiment (uses entirely rectangular waves).
_awg(HdawgDriver) — Instance of HdawgDriver object, native to silospin._awg_cores(list) — List of indcices corresponding to the qubits (AWG cores) used in the program._channel_idxs(dict) — Grouping of channel indices for each core._channel_osc_idxs(dict) — Grouping of oscillator indices for each core._command_tables(dict) — Command table uplaoded to HDAWG containing phase change instructions for each gate._ct_idxs(dict) — Dictionary of command table entries executed in HDAWG FPGA sequencer. Outer dictonary keys correspond to GST line number. Inner keys correspond to qubit (AWG core) indices and values are lists of gate strings._gate_sequences(dict) — Dictionary of quantum gate sequences for each AWG core read in from GST file. Outer dictonary keys correspond to GST line number. Inner keys correspond to qubit (AWG core) indices and values are lists of gate strings._gst_path(str) — File path for gate set tomography program being read and compiled._qubit_parameters(dict) — Dictionary of standard parameters for each qubit. Dicionary keys correspond to qubit (AWG core) indices and value is dictonary of qubit parameters (["i_amp_pi", "q_amp_pi", "i_amp_pi_2", "q_amp_pi_2", "tau_pi", "tau_pi_2", "delta_iq", "mod_freq"])._sample_rate(float) — Sampling rate used by AWG. Set to 2.4 GSa/s_sequencer_code(dict) — Dictionary of sequencer code uploaded to each HDAWG coer._waveforms(dict) — Dictionary of rectangular 'pi' and 'pi/2' waveforms to be uploaded to each core of HDAWG. Dict keys correspond to qubit (AWG core) indices. Values are 2 element lists containing waveforms in the form of numpy arrays (['pi/2', 'pi']).
run_program(awg_idxs)(None.) — Runs uploaded quantum algorithm on the specified AWG cores.
run_program(awg_idxs=None)Runs uploaded quantum algorithm on the specified AWG cores.
Waits for external hardware trigger event to execute program.
Quantum compiler helper functions
silospin.quantum_compiler.quantum_compiler_helpers.channel_mapper(rf_cores=[1, 2, 3], plunger_channels={'p12': 7, 'p21': 8})Outputs the mapping between AWG cores/channels and gate labels.
Outer keys of dictionary correspond to core number running from 1-4 (e.g. chanel_mapping = {1 : {}, ... , 4: {}). These keys have values in the form of dictonaries with the following keys and values.
-
"ch", dictionary of the core's output channels, output gate labels, and gate indices in the GST convention (dict)
-
"rf", 1 if core is for RF pulses and 0 if for DC pulses (int)
The dictionaries corresponding to the key "ch" have the following keys and values, - "index", list of 2 channels corresponding the specified core (grouping given by- 1: [1,2], 2: [3,4], 3: [5,6], 4: [7,8]).
-
"label", list of 2 labels corresponding to each channel (e.g. ["i1", "q1"] as IQ pair for RF or ["p12", "p21"] as 2 plunger channels for DC).
-
"gateindex", list of 2 gate indices corresponding to GST indices. (e.g. gate (1)x(1) maps to gateindex [1,1] for core 1 or (7)p(7)(8)p(8) maps to indices [7,8] of core 4.)
Note: currently configured for 1 HDAWG unit with 4 AWG cores.
rf_cores(list) — list of core indices dedicated to RF control (default set to [1,2,3]).plunger_channels(dict) — dictionary of RF core (default set to {"p12": 7, "p21": 8})).
Dictionary representing channel mapping.
silospin.quantum_compiler.quantum_compiler_helpers.make_gate_parameters(tau_pi, tau_pi_2, i_amp, q_amp, mod_freq, plunger_length, plunger_amp)Outputs a dictionary representing the gate parameters of the set of qubits. Note that this dictionary should be stored as a pickle file and updated at each calibration step.
tau_pi(dict) — dictionary of pi-pulse durations for each qubit, in seconds.tau_pi_2(dict) — dictionary of pi/2-pulse durations for each qubit, in seconds.i_amp(dict) — dictionary of I-amplitudes for each qubit, in volts.q_amp(dict) — dictionary of Q-amplitudes for each qubit, in volts.mod_freq(dict) — dictionary of modulation frequencies for each qubit, in Hz.plunger_amp(dict) — dictionary of plunger gate amplitudes, in volts.plunger_lengths(dict) — dictionary of plunger gate lengths, in seconds.
gate parameters representing the currnet state of the set of qubits.
silospin.quantum_compiler.quantum_compiler_helpers.make_command_table_indices(gt_seqs, taus_std, taus_p, n_arbZ)Generates a dictionary with lists of command table executions for each core, provided the output of 'gst_file_parser'. This is the core of the quantum compiler, as it interprets longs RF and DC gate strings, converting them to FPGA instructions for amplitude and phase modulation.
Outer-most keys "plunger" and "rf", containing instructions to be addressed separatley on the dedicated RF and DC cores. Outputs a dictionary with outer keys "rf" and "plunger", corresponding to executions for dedicated RF and DC AWG cores. The values for the "rf" keys are dictionaries with outer keys corresponding to each core and "plunger" has values of dictionaries with keys corresponding to each DC channel. Each of these core and channel keys have values of lists of command table (CT) indices (integers) to be addressed on the AWG cores.
Each command table index maps to an entry of a CT, determining the waveform, amplitude, and phase to be played when the CT entry is executed. Phase changes for each gate are computed on-the-fly. Note that this function supports the following gates: 'x', 'xxx', 'xx', 'mxxm', 'y', 'yyy', 'y y', 'myym', 'arbZ', 'p', 't'. See 'Quantum Compiler' tab for a more elaborate description.
Note: this function is currently configured for 1 HDAWG unit with 4 AWG cores.
gt_seqs(dict) — dictionary output of 'gst_file_parser', representing sequence of RF and DC gate strings on each core.taus_std(list) — list of standard pi/2 and pi pulse lengths in ns ([tau_pi2, tau_pi]).taus_p(list) — list of tuples, each with elements (ch_idx, tau_p) representing the channel index and corresponding plunger pulse length.n_arbZ(int) — the accumulated number of previously seen arbitrary-Z rotations over all lines in GST file being read.
dictonary of command table indices to execute, list of tuples of (arbitrary Z comman table index, rotation angle).
silospin.quantum_compiler.quantum_compiler_helpers.make_rf_command_table(n_pi_2, n_pi, n_p=[], arbZ=[])Generates command tables for dedicated RF cores. Each command table index corresponds to a phase increment and waveform play. Command table entries correspond to the following indices:
-
0, initial xx gate in pi frame
-
1, initial yy gate in pi frame
-
2, initial mxxm gate in pi frame
-
3, initial myym gate in pi frame
-
4, initial x gate in pi frame
-
5, initial y gate in pi frame
-
6, initial xxx gate in pi frame
-
7, initial yyy gate in pi frame
-
8, initial x gate in pi/2 frame
-
9, initial y gate in pi/2 frame
-
10, initial xxx gate in pi/2 frame
-
11, initial yyy gate in pi/2 frame
-
12, increment by 0 degrees in for pi gate in a pi frame
-
13, increment by -90 degrees in for pi gate in a pi frame
-
14, increment by -180 degrees in for pi gate in a pi frame
-
15, increment by -270 degrees in for pi gate in a pi frame
-
16, increment by 90 degrees in for pi gate in a pi frame
-
17, increment by 180 degrees in for pi gate in a pi frame
-
18, increment by 270 degrees in for pi gate in a pi frame
-
19, increment by 0 degrees in for pi/2 gate in a pi frame
-
20, increment by -90 degrees in for pi/2 gate in a pi frame
-
21, increment by -180 degrees in for pi/2 gate in a pi frame
-
22, increment by -270 degrees in for pi/2 gate in a pi frame
-
23, increment by 90 degrees in for pi/2 gate in a pi frame
-
24, increment by 180 degrees in for pi/2 gate in a pi frame
-
25, increment by 270 degrees in for pi/2 gate in a pi frame
-
26, increment by 0 degrees in for pi/2 gate in a pi/2 frame
-
27, increment by -90 degrees in for pi/2 gate in a pi/2 frame
-
28, increment by -180 degrees in for pi/2 gate in a pi/2 frame
-
29, increment by -270 degrees in for pi/2 gate in a pi/2 frame
-
30, increment by 90 degrees in for pi/2 gate in a pi/2 frame
-
31, increment by 180 degrees in for pi/2 gate in a pi/2 frame
-
32, increment by 270 degrees in for pi/2 gate in a pi/2 frame
-
33, wait for pi/2 duration
-
34, wait for pi duration
-
35 - 35+n_p, wait for DC pulse durations
-
36+n_p, increment phase by 0 degrees (z0z gate)
-
36+n_p-36+n_p+n_z, perform arbitrary rotation by phi degrees (z phi z)
n_pi_2(int) — number of points for a stanard pi/2 pulse.n_pi(int) — number of points for a stanard pi pulse.n_p(list) — list of number of points for each plunger pulse length (default = []).arbZ(list) — list of tuples of (arbitrary Z command table index, rotation angle) (default = []).
Dictionary of the RF command table to be directly uploaded onto AWG core.
silospin.quantum_compiler.quantum_compiler_helpers.make_plunger_command_table(n_p, n_rf)Generates command table for a single DC AWG core. Each core has two channels. - 0, plunger 1 pulse in plunger 1 frame
-
1, plunger 2 pulse in plunger 2 frame
-
2, plunger 1 pulse in plunger 2 frame
-
3, plunger 2 pulse in plunger 1 frame
-
4, plunger 1 pulse in pi/2 frame
-
5, plunger 2 pulse in pi/2 frame
-
6, plunger 1 pulse in pi frame
-
7, plunger 2 pulse in pi frame
-
8, wait for pi/2 pulse duration
-
9, wait for pi pulse duration
-
10, wait for plunger 1 pulse duration
-
11, wait for plunger 2 pulse duration
-
12, impose 0 degree phase shift
n_p(list) — list of 2 tuples of the form (ch_idx, n_p) with ch_idx as plunger channel index and n_p as the number of points for the plunger pulse.n_rf(tuple) — tuple of the form (n_pi_2, n_pi), as the number of points for a pi/2 and pi pulse.
Dictionary of the plunger command table to be directly uploaded onto AWG core.
silospin.quantum_compiler.quantum_compiler_helpers.make_waveform_placeholders(n_array)Generates sequencer code for waveform placeholders on HDAWG FPGAs.
n_array(list) — list of the number of points used for each waveform. Note, that each element of n_array must be at least 48 and an integer multiple of 16.
sequencer code for waveform placeholders.
silospin.quantum_compiler.quantum_compiler_helpers.make_waveform_placeholders_plungers(n_array)Generates sequencer code for plunger gate waveform placeholders on HDAWG FPGAs.
n_array(list) — list of the number of points used for each waveform. Note, that each element of n_array must be at least 48 and an integer multiple of 16.
sequencer code for waveform placeholders.
silospin.quantum_compiler.quantum_compiler_helpers.make_gateset_sequencer_hard_trigger(n_seq, n_av, trig_channel=True)Generates sequencer code for waveform placeholders on HDAWG FPGAs.
n_av(int) — number of inner loops to iterate over during a GST run.trig_channel(bool) — True if this core receives a physical trigger input, False otherwise.n_array(list) — list of the command table indices being executed on the AWG core.
sequencer code for with command table executions for a given quantum algorithm.
silospin.quantum_compiler.quantum_compiler_helpers.make_gate_npoints(gate_parameters, sample_rate)Generates a dictionary with the number of poitns for each pulse type used in a quantum algorithm.
sample_rate(float) — sample rate of the HDAWG in samples per second.n_array(list) — list of the command table indices being executed on the AWG core.
sequencer code for with command table executions for a given quantum algorithm.
silospin.quantum_compiler.quantum_compiler_helpers.generate_waveforms(gate_npoints, channel_map, added_padding=0)Generates a dictionary with all waveforms to be uploaded on 4 AWG cores, provided the number of points for each gate, channel mapping, and additional uniform padding per gate. Waveforms generated in the form lists, accounting for all padding schemes. Additional padding adds delays uniformly to all gates in a sequenc. Padding on either side of gates not to exceed 5 ns.
Outer elements keys of waveform dictionary correspond to AWG core index (from 1-4). Dedicated RF cores have keys corresponding to each waveform: - "pi_pifr", pi pulse in a pi frame - "pi_2_pi_2fr", pi/2 pulse in a pi/2 frame - "pi_2_pifr", pi/2 pulse in a pi frame
Dedicated DC cores have keys corresponding to each waveform:
-
"p1_p1fr", plunger 1 pulse in plunger 1 frame
-
"p2_p2fr", plunger 2 pulse in plunger 2 frame
-
"p1_p2fr", plunger 1 pulse in plunger 2 frame
-
"p2_p1fr", plunger 2 pulse in plunger 1 frame
-
"p1_pi_2fr", plunger 1 pulse in pi/2 frame
-
"p2_pi_2fr", plunger 2 pulse in pi/2 frame
-
"p1_pifr", plunger 1 pulse in pi frame
-
"p2_pifr", plunger 2 pulse in pi frame
gate_npoints(dict) — dictionary of number of points per gatechannel_map(dict) — channel mapping dictionary.added_padding(float) — added padding to either side of a gate pulse, in ns.
dictionary of waveforms to be uploaded on each core.
silospin.quantum_compiler.quantum_compiler_helpers.config_hdawg(awg, gate_parameters)Configures HDAWG module to run a quantum algorithm. In particular, this function does the following: - enables oscillator control
-
sets oscillator frequencies
-
sets output amplitudes for each channel
-
turns on output channels
awg(silospin.drivers.zi_hdawg.HdawgDriver) — instance of HDAWG.gate_parameters(dict) — dictionary of gate paramters for each qubit.
None.
silospin.quantum_compiler.quantum_compiler_io.gst_file_parser(file_path, qubit_lengths, channel_mapping)Outputs a dictionary representation of a quantum algorithm saved in a CSV file. Quantum algorithm should follow standard GST convention.
file_path(str) — file path of the CSV quantum algorithm file.qubit_lengths(dict) — dictionary containing gate legnths for each qubit. output from 'make_gate_lengths' function.channel_mapping(dict) — channel mapping dictionary. output from 'channel_mapper' function.
sequence_table representing the interpreted gate sequences for each AWG core and channel.