Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/transpiler/src/passes/constrained_reschedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ fn push_node_back(
| OperationRef::StandardInstruction(StandardInstruction::Measure) => Some(acquire_align),
OperationRef::StandardInstruction(StandardInstruction::Delay(_)) => None,
_ => {
if !op_view.directive() {
if op_view.directive() {
None
} else {
return Err(TranspilerError::new_err(format!(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fixed :class:`.ConstrainedReschedule` raising a :class:`.TranspilerError`
when rescheduling a circuit containing a :class:`.Barrier`.
21 changes: 21 additions & 0 deletions test/python/transpiler/test_scheduling_padding_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
from qiskit.transpiler.passes import (
ASAPScheduleAnalysis,
ALAPScheduleAnalysis,
ConstrainedReschedule,
PadDelay,
TimeUnitConversion,
)
from qiskit.transpiler.passmanager import PassManager
from qiskit.transpiler.exceptions import TranspilerError
Expand Down Expand Up @@ -311,6 +313,25 @@ def test_parallel_gate_different_length_with_barrier(self):

self.assertEqual(qc_asap, asap_expected)

def test_constrained_reschedule_accepts_barrier(self):
"""Test that ConstrainedReschedule allows compiler directives."""
qc = QuantumCircuit(2)
qc.cx(0, 1)
qc.barrier(0)

target = Target(num_qubits=2, dt=1, pulse_alignment=1, acquire_alignment=1)
target.add_instruction(CXGate(), {(0, 1): InstructionProperties(duration=100)})

pm = PassManager(
[
TimeUnitConversion(target.durations()),
ALAPScheduleAnalysis(target=target),
ConstrainedReschedule(target=target),
]
)

self.assertEqual(qc, pm.run(qc))

def test_padding_not_working_without_scheduling(self):
"""Test padding fails when un-scheduled DAG is input."""
qc = QuantumCircuit(1, 1)
Expand Down
Loading