Skip to content

Commit

Permalink
Set_detuning added, frame rotation correction, tuned up b.run() funct…
Browse files Browse the repository at this point in the history
…ion (#11)

* Added readme and set grounds for update frequency and general amplitude

* Refining update frequency (WIP) + Ramsey baking experiment

* Updated RamseyGauss example + refined code for update frequency

* Update of bakery run function

To do : describe in readme the set detuning, and the new run function parameters

* Corrected bug on pulse_length for added baked op + modification of RB

One can now choose which Cliffords should be added as baking objects for playing inverse op

* Deleted test file

* Reformat

* Corrected reset frame to have consistent behavior

* Reformat2

* Cleaning up files

* Corrections of readme

* Reformat

* Changed input amplitude to tuple instead of list

* Additional modifications to readme + reformat

* small fixes

Co-authored-by: Yoav Romach <[email protected]>
  • Loading branch information
arthurostrauss and yomach authored Jul 19, 2021
1 parent 6f05569 commit eb193a5
Show file tree
Hide file tree
Showing 6 changed files with 600 additions and 161 deletions.
7 changes: 3 additions & 4 deletions examples/bakery_examples/RB_1_qubit/RB_1qubit.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@
assign(state, I > th)
with if_(state):
play("X", "qe1")

play(
RB_baked_sequences[k].operations["qe1"], "qe1", truncate=truncate
) # Truncate for RB seq of smaller lengths
RB_baked_sequences[k].run(trunc_array=[("qe1", truncate)])
RB_sequences[k].play_revert_op2(inverse_op)

align("qe1", "rr")
Expand Down Expand Up @@ -78,6 +75,8 @@

print("Inversion operations:", inv)
print("Truncations indices:", truncate)
print(played_Cliffords)
print(played_inverse_Ops)

# Plotting first baked RB sequence
baked_pulse_I = config["waveforms"]["qe1_baked_wf_I_0"]["samples"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def IQ_imbalance_corr(g, phi):
Drive_freq = 5e9
Tpihalf = 32

Resonator_IF = 50e6
Resonator_IF = 50e6 * 0
Resonator_LO = Resonator_freq - Resonator_IF

Drive_IF = 31.25e6
Drive_IF = 31.25e6 * 0
Drive_LO = Drive_freq - Drive_IF

Readout_Amp = 0.1 # meas pulse amplitude
Expand Down Expand Up @@ -52,6 +52,16 @@ def IQ_imbalance_corr(g, phi):
Input1_offset = 0.0
Input2_offset = 0.0


dephasing0 = 0 # phase at the origin of the 2nd Tpihalf gauss pulse
Tpihalf = 32
wait_time_cc = 100

amplitude_pihalf = 1
drive_cc = int(Tpihalf / 4) + 4 # 12cc = 48ns for Tpihalf=32
if_freq = 31.25e6
Fastload_length = 320

config = {
"version": 1,
"controllers": {
Expand All @@ -62,9 +72,7 @@ def IQ_imbalance_corr(g, phi):
2: {"offset": Resonator_Q0}, # Resonator Q
3: {"offset": Drive_I0}, # Drive I
4: {"offset": Drive_Q0}, # Drive Q
5: {
"offset": 0
}, # Drive LO amplitude modulation ---------------> SHOULD BE A DIGITAL OUTPUT
5: {"offset": 0},
},
"digital_outputs": {
1: {}, # Resonator digital marker
Expand Down Expand Up @@ -107,8 +115,8 @@ def IQ_imbalance_corr(g, phi):
},
"Drive": { # Drive element
"mixInputs": {
"I": ("con1", 4),
"Q": ("con1", 3),
"I": ("con1", 3),
"Q": ("con1", 4),
"lo_frequency": Drive_LO,
"mixer": "Drive_mixer",
},
Expand Down
104 changes: 93 additions & 11 deletions examples/bakery_examples/Ramsey_fringes/Ramsey_Gauss_baking.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,115 @@
from qualang_tools.bakery import baking

from qm.qua import *
from qm.QuantumMachinesManager import QuantumMachinesManager
from RamseyGauss_configuration import *


from qm import SimulationConfig, LoopbackInterface
from matplotlib import pyplot as plt

dephasingStep = 0
number_of_pulses = 32
npts = 48
dmax = int(npts / 4)

baking_list = [] # Stores the baking objects
for i in range(number_of_pulses): # Create 16 different baked sequences
for i in range(number_of_pulses): # Create 32 different baked sequences
with baking(config, padding_method="left") as b:
init_delay = number_of_pulses # Put initial delay to ensure that all of the pulses will have the same length

b.frame_rotation(dephasingStep, "Drive")
b.wait(
init_delay, "Drive"
) # This is to compensate for the extra delay the Resonator is experiencing.

# Play uploads the sample in the original config file (here we use an existing pulse in the config)
b.play("gauss_drive", "Drive", amp=1) # duration Tpihalf+16
b.play_at("gauss_drive", "Drive", init_delay - i) # duration Tpihalf
b.play_at("gauss_drive", "Drive", t=init_delay - i) # duration Tpihalf

# Append the baking object in the list to call it from the QUA program
baking_list.append(b)


# You can retrieve and see the pulse you built for each baking object by modifying
# index of the waveform
plt.figure()
for i in range(number_of_pulses):
baked_pulse = config["waveforms"][f"Drive_baked_wf_I_{i}"]["samples"]
t = np.arange(0, len(baked_pulse), 1)
plt.plot(t, baked_pulse)
plt.plot(baked_pulse, label=f"pulse{i}")
plt.title("Baked Ramsey sequences")
plt.legend()


def play_ramsey():
with switch_(j):
for k in range(len(baking_list)):
with case_(k):
baking_list[k].run()


with program() as RamseyGauss: # to measure Rabi flops every 1ns starting from 0ns
I = declare(fixed, value=0.0)
Q = declare(fixed)
I1 = declare(fixed)
Q1 = declare(fixed)
I2 = declare(fixed)
Q2 = declare(fixed)

d = declare(int)
j = declare(int)
i_avg = declare(int)

I_stream = declare_stream()
Q_stream = declare_stream()

with for_(i_avg, 0, i_avg < 1000, i_avg + 1):
with for_(d, 0, d < dmax, d + 4):
with for_(j, 0, j < number_of_pulses, j + 1):
align(
"Drive", "Resonator"
) # This align makes sure that the reset phase happens here.
wait(
4 + 4 + d, "Drive"
) # 11 - resonator reset phase, 4 - wait inside the switch-case, 4 - switch-case delay
play_ramsey()
wait(drive_cc + d + 0, "Resonator")
play("chargecav", "Resonator") # to charge the cavity

measure(
"readout",
"Resonator",
None,
demod.full("integW_cos", I1, "out1"),
demod.full("integW_sin", Q1, "out1"),
demod.full("integW_cos", I2, "out2"),
demod.full("integW_sin", Q2, "out2"),
)
assign(
I, I1 + Q2
) # summing over all the items in the vectors before assigning to the final I and Q variables
assign(Q, I2 - Q1)
save(I, I_stream)
save(Q, Q_stream)

with stream_processing():
I_stream.buffer(1000, npts).save("Iall")
Q_stream.buffer(1000, npts).save("Qall")
I_stream.buffer(1000, npts).save("IallNav")
Q_stream.buffer(1000, npts).save("QallNav")

qmm = QuantumMachinesManager()
job = qmm.simulate(
config,
RamseyGauss,
SimulationConfig(
16 * (wait_time_cc + Readout_pulse_length + Fastload_length + drive_cc)
),
)
samps = job.get_simulated_samples()
plt.figure()
an1 = samps.con1.analog["1"].tolist()
an3 = samps.con1.analog["3"].tolist()
dig1 = samps.con1.digital["1"]
dig3 = samps.con1.digital["3"]

plt.plot(an1)
plt.plot(an3)

print("End prog")
plt.show()
print(job.result_handles.param2.fetch_all())
print(job.result_handles.param3.fetch_all())
Loading

0 comments on commit eb193a5

Please sign in to comment.