diff --git a/qiskit/compiler/scheduler.py b/qiskit/compiler/scheduler.py index c4befa15c0a1..adbc41cfecab 100644 --- a/qiskit/compiler/scheduler.py +++ b/qiskit/compiler/scheduler.py @@ -78,23 +78,29 @@ def schedule( if inst_map: target.update_from_instruction_schedule_map(inst_map=inst_map) elif isinstance(backend, BackendV1): + defaults = backend.defaults() if hasattr(backend, "defaults") else None + if defaults is None: + raise QiskitError( + "The backend defaults are unavailable. The backend may not support pulse." + ) if backend.configuration() is not None: target = convert_to_target( configuration=backend.configuration(), properties=backend.properties(), - defaults=backend.defaults() if hasattr(backend, "defaults") else None, + defaults=defaults, ) if inst_map: target.update_from_instruction_schedule_map(inst_map=inst_map) else: raise QiskitError("Must specify backend that has a configuration.") else: - if inst_map: - target = Target(concurrent_measurements=meas_map) + if meas_map and inst_map: + target = Target(concurrent_measurements=meas_map, dt=dt) target.update_from_instruction_schedule_map(inst_map=inst_map) else: raise QiskitError( - "Must specify either target, backend, or inst_map for scheduling passes." + "Must specify either target, backend,\ + or both meas_map and inst_map for scheduling passes." ) circuits = circuits if isinstance(circuits, list) else [circuits] schedules = parallel_map(schedule_circuit, circuits, (None, target, method)) diff --git a/qiskit/compiler/sequencer.py b/qiskit/compiler/sequencer.py index 56cf509f8412..d2dbcc1bfbb7 100644 --- a/qiskit/compiler/sequencer.py +++ b/qiskit/compiler/sequencer.py @@ -73,8 +73,8 @@ def sequence( else: raise QiskitError("Must specify backend that has a configuration.") else: - if inst_map: - target = Target(concurrent_measurements=meas_map) + if meas_map and inst_map: + target = Target(concurrent_measurements=meas_map, dt=dt) target.update_from_instruction_schedule_map(inst_map=inst_map) else: raise QiskitError( diff --git a/test/python/compiler/test_scheduler.py b/test/python/compiler/test_scheduler.py index bb3379d490bc..aec167ccf352 100644 --- a/test/python/compiler/test_scheduler.py +++ b/test/python/compiler/test_scheduler.py @@ -45,7 +45,7 @@ def test_instruction_map_and_backend_not_supplied(self): """Test instruction map and backend not supplied.""" with self.assertRaisesRegex( QiskitError, - r"Must supply either a backend or InstructionScheduleMap for scheduling passes.", + r"Must specify either target, backend, or both meas_map and inst_map for scheduling passes.", ): schedule(self.circ) @@ -61,7 +61,7 @@ def test_measurement_map_and_backend_not_supplied(self): """Test measurement map and backend not supplied.""" with self.assertRaisesRegex( QiskitError, - r"Must supply either a backend or a meas_map for scheduling passes.", + r"Must specify either target, backend, or both meas_map and inst_map for scheduling passes.", ): schedule(self.circ, inst_map=InstructionScheduleMap()) diff --git a/test/python/pulse/test_builder.py b/test/python/pulse/test_builder.py index 55ff16e2f367..db00bdea9410 100644 --- a/test/python/pulse/test_builder.py +++ b/test/python/pulse/test_builder.py @@ -901,7 +901,7 @@ def test_complex_build(self): pulse.u2(0, pi / 2, 1) pulse.u2(0, pi / 2, 0) pulse.measure(0) - + print(schedule.instructions) # prepare and schedule circuits that will be used. single_u2_qc = circuit.QuantumCircuit(2) single_u2_qc.append(circuit.library.U2Gate(0, pi / 2), [1]) @@ -914,6 +914,7 @@ def test_complex_build(self): sequential_reference.insert(delay_dur, single_u2_sched, inplace=True) # align right + print(single_u2_sched.duration) align_right_reference = pulse.Schedule() align_right_reference += pulse.Play(library.Constant(long_dur, 0.1), d2) align_right_reference.insert( diff --git a/test/python/pulse/test_builder_v2.py b/test/python/pulse/test_builder_v2.py index fab3ce47d0c8..9ab2ca025e23 100644 --- a/test/python/pulse/test_builder_v2.py +++ b/test/python/pulse/test_builder_v2.py @@ -454,9 +454,9 @@ def test_complex_build(self): d0 = pulse.DriveChannel(0) d1 = pulse.DriveChannel(1) d2 = pulse.DriveChannel(2) - delay_dur = 30 - short_dur = 20 - long_dur = 49 + delay_dur = 300 + short_dur = 200 + long_dur = 810 with pulse.build(self.backend) as schedule: with pulse.align_sequential(): @@ -471,7 +471,6 @@ def test_complex_build(self): pulse.u2(0, np.pi / 2, 1) pulse.u2(0, np.pi / 2, 0) pulse.measure(0) - # prepare and schedule circuits that will be used. single_u2_qc = circuit.QuantumCircuit(2) single_u2_qc.append(circuit.library.U2Gate(0, np.pi / 2), [1]) @@ -505,7 +504,7 @@ def test_complex_build(self): # measurement measure_reference = macros.measure( - qubits=[0], inst_map=self.inst_map, meas_map=self.configuration.meas_map + qubits=[0], backend=self.backend, meas_map=self.backend.meas_map ) reference = pulse.Schedule() reference += sequential_reference