Skip to content

Commit

Permalink
chore: update T1, T2 signal and rabi length routines
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros11 committed Jul 15, 2024
1 parent e98ae67 commit 04ee2f6
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 56 deletions.
30 changes: 17 additions & 13 deletions src/qibocal/protocols/coherence/t1_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import plotly.graph_objects as go
from qibolab import AcquisitionType, AveragingMode, ExecutionParameters
from qibolab.platform import Platform
from qibolab.pulses import PulseSequence
from qibolab.pulses import Delay, PulseSequence
from qibolab.qubits import QubitId
from qibolab.sweeper import Parameter, Sweeper, SweeperType

Expand Down Expand Up @@ -81,15 +81,19 @@ def _acquisition(
# create a sequence of pulses for the experiment
# RX - wait t - MZ
qd_pulses = {}
delays = {}
ro_pulses = {}
sequence = PulseSequence()
for qubit in targets:
qd_pulses[qubit] = platform.create_RX_pulse(qubit, start=0)
ro_pulses[qubit] = platform.create_qubit_readout_pulse(
qubit, start=qd_pulses[qubit].duration
)
sequence.add(qd_pulses[qubit])
sequence.add(ro_pulses[qubit])
for q in targets:
qubit = platform.qubits[q]
qd_sequence = qubit.native_gates.RX.create_sequence(theta=np.pi, phi=0)
ro_sequence = qubit.native_gates.MZ.create_sequence()
qd_pulses[q] = qd_sequence[qubit.drive.name][0]
ro_pulses[q] = ro_sequence[qubit.measure.name][0]
delays[q] = Delay(duration=qd_pulses[q].duration)
sequence.extend(qd_sequence)
sequence[qubit.measure.name].append(delays[q])
sequence.extend(ro_sequence)

# define the parameter to sweep and its range:
# wait time before readout
Expand All @@ -100,9 +104,9 @@ def _acquisition(
)

sweeper = Sweeper(
Parameter.start,
Parameter.duration,
ro_wait_range,
[ro_pulses[qubit] for qubit in targets],
[delays[q] for q in targets],
type=SweeperType.ABSOLUTE,
)

Expand All @@ -122,15 +126,15 @@ def _acquisition(
)

data = T1SignalData()
for qubit in targets:
result = results[ro_pulses[qubit].serial]
for q in targets:
result = results[ro_pulses[q].id]
if params.single_shot:
_waits = np.array(len(result.magnitude) * [ro_wait_range])
else:
_waits = ro_wait_range
data.register_qubit(
utils.CoherenceType,
(qubit),
(q),
dict(wait=_waits, signal=result.magnitude, phase=result.phase),
)

Expand Down
42 changes: 22 additions & 20 deletions src/qibocal/protocols/coherence/t2_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import plotly.graph_objects as go
from qibolab import AcquisitionType, AveragingMode, ExecutionParameters
from qibolab.platform import Platform
from qibolab.pulses import PulseSequence
from qibolab.pulses import Delay, PulseSequence
from qibolab.qubits import QubitId
from qibolab.sweeper import Parameter, Sweeper, SweeperType

Expand Down Expand Up @@ -60,21 +60,23 @@ def _acquisition(
# create a sequence of pulses for the experiment
# RX90 - t - RX90 - MZ
ro_pulses = {}
RX90_pulses1 = {}
RX90_pulses2 = {}
qd_delays = {}
ro_delays = {}
sequence = PulseSequence()
for qubit in targets:
RX90_pulses1[qubit] = platform.create_RX90_pulse(qubit, start=0)
RX90_pulses2[qubit] = platform.create_RX90_pulse(
qubit,
start=RX90_pulses1[qubit].finish,
)
ro_pulses[qubit] = platform.create_qubit_readout_pulse(
qubit, start=RX90_pulses2[qubit].finish
)
sequence.add(RX90_pulses1[qubit])
sequence.add(RX90_pulses2[qubit])
sequence.add(ro_pulses[qubit])
for q in targets:
qubit = platform.qubits[q]
qd_sequence = qubit.native_gates.RX.create_sequence(theta=np.pi / 2, phi=0)
ro_sequence = qubit.native_gates.MZ.create_sequence()
qd_delays[q] = Delay(duration=16)
ro_delays[q] = Delay(duration=16)
qd_pulse = qd_sequence[qubit.drive.name][0]
ro_pulses[q] = ro_sequence[qubit.measure.name][0]
sequence.extend(qd_sequence)
sequence[qubit.drive.name].append(qd_delays[q])
sequence.extend(qd_sequence)
sequence[qubit.measure.name].append(Delay(duration=2 * qd_pulse.duration))
sequence[qubit.measure.name].append(ro_delays[q])
sequence.extend(ro_sequence)

# define the parameter to sweep and its range:
waits = np.arange(
Expand All @@ -85,9 +87,9 @@ def _acquisition(
)

sweeper = Sweeper(
Parameter.start,
Parameter.duration,
waits,
[RX90_pulses2[qubit] for qubit in targets],
[qd_delays[q] for q in targets] + [ro_delays[q] for q in targets],
type=SweeperType.ABSOLUTE,
)

Expand All @@ -106,15 +108,15 @@ def _acquisition(
)

data = T2SignalData()
for qubit in targets:
result = results[ro_pulses[qubit].serial]
for q in targets:
result = results[ro_pulses[q].id]
if params.single_shot:
_waits = np.array(len(result.magnitude) * [waits])
else:
_waits = waits
data.register_qubit(
utils.CoherenceType,
(qubit),
(q),
dict(wait=_waits, signal=result.magnitude, phase=result.phase),
)
return data
Expand Down
10 changes: 5 additions & 5 deletions src/qibocal/protocols/rabi/length.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _acquisition(
to find the drive pulse length that creates a rotation of a desired angle.
"""

sequence, qd_pulses, _, amplitudes = utils.sequence_length(
sequence, qd_pulses, delays, ro_pulses, amplitudes = utils.sequence_length(
targets, params, platform
)
# define the parameter to sweep and its range:
Expand All @@ -78,7 +78,7 @@ def _acquisition(
sweeper = Sweeper(
Parameter.duration,
qd_pulse_duration_range,
[qd_pulses[qubit] for qubit in targets],
[qd_pulses[q] for q in targets] + [delays[q] for q in targets],
type=SweeperType.ABSOLUTE,
)

Expand All @@ -96,11 +96,11 @@ def _acquisition(
sweeper,
)

for qubit in targets:
prob = results[qubit].probability(state=1)
for q in targets:
prob = results[ro_pulses[q].id].probability(state=1)
data.register_qubit(
RabiLenType,
(qubit),
(q),
dict(
length=qd_pulse_duration_range,
prob=prob,
Expand Down
10 changes: 5 additions & 5 deletions src/qibocal/protocols/rabi/length_signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _acquisition(
to find the drive pulse length that creates a rotation of a desired angle.
"""

sequence, qd_pulses, ro_pulses, amplitudes = utils.sequence_length(
sequence, qd_pulses, delays, ro_pulses, amplitudes = utils.sequence_length(
targets, params, platform
)

Expand All @@ -82,7 +82,7 @@ def _acquisition(
sweeper = Sweeper(
Parameter.duration,
qd_pulse_duration_range,
[qd_pulses[qubit] for qubit in targets],
[qd_pulses[q] for q in targets] + [delays[q] for q in targets],
type=SweeperType.ABSOLUTE,
)

Expand All @@ -100,11 +100,11 @@ def _acquisition(
sweeper,
)

for qubit in targets:
result = results[ro_pulses[qubit].serial]
for q in targets:
result = results[ro_pulses[q].id]
data.register_qubit(
RabiLenSignalType,
(qubit),
(q),
dict(
length=qd_pulse_duration_range,
signal=result.magnitude,
Expand Down
31 changes: 18 additions & 13 deletions src/qibocal/protocols/rabi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ def sequence_amplitude(
qd_pulses[q] = qd_sequence[qubit.drive.name][0]
if params.pulse_length is not None:
qd_pulses[q].duration = params.pulse_length

durations[q] = qd_pulses[q].duration

ro_pulses[q] = ro_sequence[qubit.measure.name][0]

sequence[qubit.drive.name].append(qd_pulses[q])
Expand All @@ -255,22 +255,27 @@ def sequence_length(
"""Return sequence for rabi length."""
sequence = PulseSequence()
qd_pulses = {}
delays = {}
ro_pulses = {}
amplitudes = {}
for qubit in targets:
qd_pulses[qubit] = platform.create_qubit_drive_pulse(
qubit, start=0, duration=params.pulse_duration_start
)
for q in targets:
qubit = platform.qubits[q]
qd_sequence = qubit.native_gates.RX.create_sequence(theta=np.pi, phi=0)
ro_sequence = qubit.native_gates.MZ.create_sequence()

qd_pulses[q] = qd_sequence[qubit.drive.name][0]
if params.pulse_amplitude is not None:
qd_pulses[qubit].amplitude = params.pulse_amplitude
amplitudes[qubit] = qd_pulses[qubit].amplitude
qd_pulses[q].amplitude = params.pulse_amplitude
amplitudes[q] = qd_pulses[q].amplitude

ro_pulses[qubit] = platform.create_qubit_readout_pulse(
qubit, start=qd_pulses[qubit].finish
)
sequence.add(qd_pulses[qubit])
sequence.add(ro_pulses[qubit])
return sequence, qd_pulses, ro_pulses, amplitudes
delays[q] = Delay(duration=16)
ro_pulses[q] = ro_sequence[qubit.measure.name][0]

sequence[qubit.drive.name].append(qd_pulses[q])
sequence[qubit.measure.name].append(delays[q])
sequence[qubit.measure.name].append(ro_pulses[q])

return sequence, qd_pulses, delays, ro_pulses, amplitudes


def fit_length_function(
Expand Down

0 comments on commit 04ee2f6

Please sign in to comment.