diff --git a/pulser-core/pulser/sequence/sequence.py b/pulser-core/pulser/sequence/sequence.py index 7ae1e01b..c504eb3c 100644 --- a/pulser-core/pulser/sequence/sequence.py +++ b/pulser-core/pulser/sequence/sequence.py @@ -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." @@ -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 diff --git a/tests/test_sequence.py b/tests/test_sequence.py index 4d6b9384..4b4115b4 100644 --- a/tests/test_sequence.py +++ b/tests/test_sequence.py @@ -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") @@ -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)