Skip to content

Commit d3b08ad

Browse files
kevinsungmtreinish
andauthored
more transpiler docs improvements (#11300)
* more transpiler docs improvements * Update qiskit/transpiler/__init__.py Co-authored-by: Matthew Treinish <mtreinish@kortar.org> * use double ticks and remove extra line of code --------- Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
1 parent 89642bd commit d3b08ad

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

qiskit/transpiler/__init__.py

+24-19
Original file line numberDiff line numberDiff line change
@@ -105,40 +105,45 @@
105105
106106
.. code-block:: python
107107
108-
from qiskit.circuit.library import XGate, HGate, RXGate, PhaseGate, TGate, TdgGate
108+
import numpy as np
109+
from qiskit.circuit.library import HGate, PhaseGate, RXGate, TdgGate, TGate, XGate
109110
from qiskit.transpiler import PassManager
110-
from qiskit.transpiler.passes import ALAPScheduleAnalysis, PadDynamicalDecoupling
111-
from qiskit.transpiler.passes import CXCancellation, InverseCancellation
111+
from qiskit.transpiler.passes import (
112+
ALAPScheduleAnalysis,
113+
CXCancellation,
114+
InverseCancellation,
115+
PadDynamicalDecoupling,
116+
)
112117
113-
backend_durations = backend.target.durations()
114118
dd_sequence = [XGate(), XGate()]
115-
scheduling_pm = PassManager([
116-
ALAPScheduleAnalysis(backend_durations),
117-
PadDynamicalDecoupling(backend_durations, dd_sequence),
118-
])
119+
scheduling_pm = PassManager(
120+
[
121+
ALAPScheduleAnalysis(target=backend.target),
122+
PadDynamicalDecoupling(target=backend.target, dd_sequence=dd_sequence),
123+
]
124+
)
119125
inverse_gate_list = [
120126
HGate(),
121127
(RXGate(np.pi / 4), RXGate(-np.pi / 4)),
122128
(PhaseGate(np.pi / 4), PhaseGate(-np.pi / 4)),
123129
(TGate(), TdgGate()),
124-
125-
])
126-
logical_opt = PassManager([
127-
CXCancellation(),
128-
InverseCancellation([HGate(), (RXGate(np.pi / 4), RXGate(-np.pi / 4))
129-
])
130+
]
131+
logical_opt = PassManager(
132+
[
133+
CXCancellation(),
134+
InverseCancellation(inverse_gate_list),
135+
]
136+
)
130137
131138
132139
# Add pre-layout stage to run extra logical optimization
133140
pass_manager.pre_layout = logical_opt
134141
# Set scheduling stage to custom pass manager
135142
pass_manager.scheduling = scheduling_pm
136143
137-
138-
Then when :meth:`~.StagedPassManager.run` is called on ``pass_manager`` the
139-
``logical_opt`` :class:`~.PassManager` will be called prior to the ``layout`` stage
140-
and for the ``scheduling`` stage our custom :class:`~.PassManager`
141-
``scheduling_pm`` will be used.
144+
Now, when the staged pass manager is run via the :meth:`~.StagedPassManager.run` method,
145+
the ``logical_opt`` pass manager will be called before the ``layout`` stage, and the
146+
``scheduling_pm`` pass manager will be used for the ``scheduling`` stage instead of the default.
142147
143148
Custom Pass Managers
144149
====================

0 commit comments

Comments
 (0)