Skip to content

Commit

Permalink
test: add chevron integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros11 committed Sep 17, 2024
1 parent b357789 commit c5929c1
Showing 1 changed file with 136 additions and 1 deletion.
137 changes: 136 additions & 1 deletion tests/integration/test_qm.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from qibolab import AcquisitionType, AveragingMode, ExecutionParameters, create_platform
from qibolab.instruments.qm.config import operation
from qibolab.pulses import Delay
from qibolab.pulses import Delay, Pulse, Rectangular
from qibolab.sweeper import Parameter, Sweeper

from ..instruments.test_qm import assert_qua_programs
Expand Down Expand Up @@ -307,3 +307,138 @@ def test_rabi_sweeps(dummy_qrc):
r2.buffer(5).buffer(5).average().save(f"{ro2}_3/acquisition_shots")

assert_qua_programs(experiment, target_experiment)


def test_chevron_sweeps(dummy_qrc):
platform = create_platform("qm")

natives = platform.natives.single_qubit
sequence = natives[1].RX(theta=np.pi / 2) + natives[2].RX(theta=np.pi / 2)
flux_pulse = Pulse(duration=20, amplitude=0.1, envelope=Rectangular())
ro_delay1 = Delay(duration=flux_pulse.duration)
ro_delay2 = Delay(duration=flux_pulse.duration)
sequence += [
("1/acquisition", Delay(duration=sequence.duration)),
("2/acquisition", Delay(duration=sequence.duration)),
("2/flux", Delay(duration=sequence.duration)),
("2/flux", flux_pulse),
("1/acquisition", ro_delay1),
("2/acquisition", ro_delay2),
]
sequence += natives[1].MZ() + natives[2].MZ()

sweeper_amp = Sweeper(
parameter=Parameter.amplitude,
range=(0.1, 1.0, 0.2),
pulses=[flux_pulse],
)
sweeper_dur = Sweeper(
parameter=Parameter.duration,
range=(10, 30, 5),
pulses=[flux_pulse, ro_delay1, ro_delay2],
)

options = ExecutionParameters(
nshots=1000,
relaxation_time=1000,
acquisition_type=AcquisitionType.DISCRIMINATION,
averaging_mode=AveragingMode.CYCLIC,
)
result = platform.execute([sequence], options, [[sweeper_dur], [sweeper_amp]])
experiment = result["program"]

# write target QUA program for the above experiment
qd1 = operation(sequence[0][1])
qd2 = operation(sequence[1][1])
ro1 = operation(sequence.acquisitions[0][1])
ro2 = operation(sequence.acquisitions[1][1])
with qua.program() as target_experiment:
v1 = declare(int)
v2 = declare(fixed)
v3 = declare(fixed)
v4 = declare(int)
v5 = declare(fixed)
v6 = declare(fixed)
v7 = declare(int)
v8 = declare(int)
v9 = declare(fixed)
wait(
(4 + (0 * ((Cast.to_int(v2) + Cast.to_int(v3)) + Cast.to_int(v4)))),
"1/acquisition",
)
wait(
(4 + (0 * ((Cast.to_int(v5) + Cast.to_int(v6)) + Cast.to_int(v7)))),
"2/acquisition",
)
with for_(v1, 0, (v1 < 1000), (v1 + 1)):
with for_(v8, 10, (v8 <= 25), (v8 + 5)):
with for_(
v9,
0.2211111111111111,
(v9 < 2.2111111111111112),
(v9 + 0.44222222222222224),
):
align()
play(qd1, "1/drive")
play(qd2, "2/drive")
wait(11, "1/acquisition")
wait(11, "2/acquisition")
wait(11, "2/flux")
with if_((v8 == 10), unsafe=True):
play("" * amp(v9), "2/flux")
with elif_(v8 == 15):
play("" * amp(v9), "2/flux")
with elif_(v8 == 20):
play("" * amp(v9), "2/flux")
with elif_(v8 == 25):
play("" * amp(v9), "2/flux")
with if_((v8 / 4) < 4):
wait(4, "1/acquisition")
with else_():
wait((v8 / 4), "1/acquisition")
with if_((v8 / 4) < 4):
wait(4, "2/acquisition")
with else_():
wait((v8 / 4), "2/acquisition")
measure(
ro1,
"1/acquisition",
None,
dual_demod.full("cos", "out1", "sin", "out2", v2),
dual_demod.full("minus_sin", "out1", "cos", "out2", v3),
)
threshold = platform.config("1/acquisition").threshold
angle = platform.config("1/acquisition").iq_angle
assign(
v4,
Cast.to_int(
v2 * np.cos(angle) - v3 * np.sin(angle) > threshold
),
)
r1 = declare_stream()
save(v4, r1)
measure(
ro2,
"2/acquisition",
None,
dual_demod.full("cos", "out1", "sin", "out2", v5),
dual_demod.full("minus_sin", "out1", "cos", "out2", v6),
)
threshold = platform.config("2/acquisition").threshold
angle = platform.config("2/acquisition").iq_angle
assign(
v7,
Cast.to_int(
v5 * np.cos(angle) - v6 * np.sin(angle) > threshold
),
)
r2 = declare_stream()
save(v7, r2)
wait(
250,
)
with stream_processing():
r1.buffer(5).buffer(4).average().save(f"{ro1}_1/acquisition_shots")
r2.buffer(5).buffer(4).average().save(f"{ro2}_2/acquisition_shots")

assert_qua_programs(experiment, target_experiment)

0 comments on commit c5929c1

Please sign in to comment.