Skip to content

Commit

Permalink
Ignore the phase reference on the DMM channel's pulses (#700)
Browse files Browse the repository at this point in the history
  • Loading branch information
HGSilveri authored Jul 2, 2024
1 parent acd8911 commit e54c743
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
6 changes: 5 additions & 1 deletion pulser-core/pulser/sequence/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,9 @@ def _add(
ph_refs = {
self._basis_ref[basis][q].phase.last_phase for q in last.targets
}
if len(ph_refs) != 1:
if isinstance(channel_obj, DMM):
phase_ref = None
elif len(ph_refs) != 1:
raise ValueError(
"Cannot do a multiple-target pulse on qubits with different "
"phase references for the same basis."
Expand Down Expand Up @@ -2326,6 +2328,8 @@ def _validate_and_adjust_pulse(
detuning_map = cast(
_DMMSchedule, self._schedule[channel]
).detuning_map
# Ignore the phase reference for DMM
assert phase_ref is None
else:
# If channel name can't be found among _schedule keys, the
# Sequence is parametrized and channel is a dmm_name
Expand Down
31 changes: 30 additions & 1 deletion tests/test_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ def test_delay_min_duration(reg, device):
)


def test_phase(reg, device):
def test_phase(reg, device, det_map):
seq = Sequence(reg, device)
seq.declare_channel("ch0", "raman_local", initial_target="q0")
seq.phase_shift(-1, "q0", "q1")
Expand Down Expand Up @@ -1227,6 +1227,35 @@ def test_phase(reg, device):
assert seq.current_phase_ref("q1", "digital") == 0
assert seq.current_phase_ref("q10", "digital") == 1

# Check that the phase of DMM pulses is unaffected
seq.add(Pulse.ConstantPulse(100, 1, 0, 0), "ch1")
seq.config_detuning_map(det_map, "dmm_0")
det_wf = RampWaveform(100, -10, -1)
seq.add_dmm_detuning(det_wf, "dmm_0")
# We shift the phase of just one qubit, which blocks addition
# of new pulses on this basis
seq.phase_shift(1.0, "q0", basis="ground-rydberg")
with pytest.raises(
ValueError,
match="Cannot do a multiple-target pulse on qubits with different "
"phase references for the same basis.",
):
seq.add(Pulse.ConstantPulse(100, 1, 0, 0), "ch1")
# But it works on the DMM
seq.add_dmm_detuning(det_wf, "dmm_0")

seq_samples = sample(seq)
# The phase on the rydberg channel matches the phase ref
np.testing.assert_array_equal(
seq_samples.channel_samples["ch1"].phase,
seq.current_phase_ref("q1", basis="ground-rydberg"),
)

# but the phase in the DMMSamples stays at zero
np.testing.assert_array_equal(
sample(seq).channel_samples["dmm_0"].phase, 0.0
)


def test_align(reg, device):
seq = Sequence(reg, device)
Expand Down

0 comments on commit e54c743

Please sign in to comment.