1616import logging
1717from time import time
1818from typing import List , Union , Dict , Callable , Any , Optional , TypeVar
19- import warnings
2019
2120from qiskit import user_config
2221from qiskit .circuit .quantumcircuit import QuantumCircuit
2524from qiskit .transpiler import Layout , CouplingMap , PropertySet
2625from qiskit .transpiler .basepasses import BasePass
2726from qiskit .transpiler .exceptions import TranspilerError , CircuitTooWideForTarget
28- from qiskit .transpiler .instruction_durations import InstructionDurationsType
2927from qiskit .transpiler .passes .synthesis .high_level_synthesis import HLSConfig
3028from qiskit .transpiler .preset_passmanagers import generate_preset_pass_manager
3129from qiskit .transpiler .target import Target
32- from qiskit .utils import deprecate_arg
3330
3431logger = logging .getLogger (__name__ )
3532
3633_CircuitT = TypeVar ("_CircuitT" , bound = Union [QuantumCircuit , List [QuantumCircuit ]])
3734
3835
39- @deprecate_arg (
40- name = "instruction_durations" ,
41- since = "1.3" ,
42- package_name = "Qiskit" ,
43- removal_timeline = "in Qiskit 2.0" ,
44- additional_msg = "The `target` parameter should be used instead. You can build a `Target` instance "
45- "with defined instruction durations with "
46- "`Target.from_configuration(..., instruction_durations=...)`" ,
47- )
48- @deprecate_arg (
49- name = "timing_constraints" ,
50- since = "1.3" ,
51- package_name = "Qiskit" ,
52- removal_timeline = "in Qiskit 2.0" ,
53- additional_msg = "The `target` parameter should be used instead. You can build a `Target` instance "
54- "with defined timing constraints with "
55- "`Target.from_configuration(..., timing_constraints=...)`" ,
56- )
5736def transpile ( # pylint: disable=too-many-return-statements
5837 circuits : _CircuitT ,
5938 backend : Optional [Backend ] = None ,
@@ -64,10 +43,8 @@ def transpile( # pylint: disable=too-many-return-statements
6443 routing_method : Optional [str ] = None ,
6544 translation_method : Optional [str ] = None ,
6645 scheduling_method : Optional [str ] = None ,
67- instruction_durations : Optional [InstructionDurationsType ] = None ,
6846 dt : Optional [float ] = None ,
6947 approximation_degree : Optional [float ] = 1.0 ,
70- timing_constraints : Optional [Dict [str , int ]] = None ,
7148 seed_transpiler : Optional [int ] = None ,
7249 optimization_level : Optional [int ] = None ,
7350 callback : Optional [Callable [[BasePass , DAGCircuit , float , PropertySet , int ], Any ]] = None ,
@@ -90,8 +67,8 @@ def transpile( # pylint: disable=too-many-return-statements
9067
9168 The prioritization of transpilation target constraints works as follows: if a ``target``
9269 input is provided, it will take priority over any ``backend`` input or loose constraints
93- (``basis_gates``, ``coupling_map``, ``instruction_durations``,
94- ``dt`` or ``timing_constraints``). If a ``backend`` is provided together with any loose constraint
70+ (``basis_gates``, ``coupling_map``, or ``dt``). If a ``backend`` is provided
71+ together with any loose constraint
9572 from the list above, the loose constraint will take priority over the corresponding backend
9673 constraint. This behavior is summarized in the table below. The first column
9774 in the table summarizes the potential user-provided constraints, and each cell shows whether
@@ -103,9 +80,7 @@ def transpile( # pylint: disable=too-many-return-statements
10380 ============================ ========= ========================
10481 **basis_gates** target basis_gates
10582 **coupling_map** target coupling_map
106- **instruction_durations** target instruction_durations
10783 **dt** target dt
108- **timing_constraints** target timing_constraints
10984 ============================ ========= ========================
11085
11186 Args:
@@ -176,40 +151,10 @@ def transpile( # pylint: disable=too-many-return-statements
176151 to use for the ``scheduling`` stage. You can see a list of installed plugins by
177152 using :func:`~.list_stage_plugins` with ``"scheduling"`` for the ``stage_name``
178153 argument.
179- instruction_durations: Durations of instructions.
180- Applicable only if scheduling_method is specified.
181- The gate lengths defined in ``backend.properties`` are used as default.
182- They are overwritten if this ``instruction_durations`` is specified.
183- The format of ``instruction_durations`` must be as follows.
184- The `instruction_durations` must be given as a list of tuples
185- [(instruction_name, qubits, duration, unit), ...].
186- | [('cx', [0, 1], 12.3, 'ns'), ('u3', [0], 4.56, 'ns')]
187- | [('cx', [0, 1], 1000), ('u3', [0], 300)]
188- If unit is omitted, the default is 'dt', which is a sample time depending on backend.
189- If the time unit is 'dt', the duration must be an integer.
190154 dt: Backend sample time (resolution) in seconds.
191155 If ``None`` (default), ``backend.dt`` is used.
192156 approximation_degree (float): heuristic dial used for circuit approximation
193157 (1.0=no approximation, 0.0=maximal approximation)
194- timing_constraints: An optional control hardware restriction on instruction time resolution.
195- A quantum computer backend may report a set of restrictions, namely:
196-
197- - granularity: An integer value representing minimum pulse gate
198- resolution in units of ``dt``. A user-defined pulse gate should have
199- duration of a multiple of this granularity value.
200- - min_length: An integer value representing minimum pulse gate
201- length in units of ``dt``. A user-defined pulse gate should be longer
202- than this length.
203- - pulse_alignment: An integer value representing a time resolution of gate
204- instruction starting time. Gate instruction should start at time which
205- is a multiple of the alignment value.
206- - acquire_alignment: An integer value representing a time resolution of measure
207- instruction starting time. Measure instruction should start at time which
208- is a multiple of the alignment value.
209-
210- This information will be provided by the backend configuration.
211- If the backend doesn't have any restriction on the instruction time allocation,
212- then ``timing_constraints`` is None and no adjustment will be performed.
213158 seed_transpiler: Sets random seed for the stochastic parts of the transpiler
214159 optimization_level: How much optimization to perform on the circuits.
215160 Higher levels generate more optimized circuits,
@@ -308,18 +253,6 @@ def callback_func(**kwargs):
308253 config = user_config .get_config ()
309254 optimization_level = config .get ("transpile_optimization_level" , 2 )
310255
311- if (
312- scheduling_method is not None
313- and backend is None
314- and target is None
315- and not instruction_durations
316- ):
317- warnings .warn (
318- "When scheduling circuits without backend,"
319- " 'instruction_durations' should be usually provided." ,
320- UserWarning ,
321- )
322-
323256 if not ignore_backend_supplied_default_methods :
324257 if scheduling_method is None and hasattr (backend , "get_scheduling_stage_plugin" ):
325258 scheduling_method = backend .get_scheduling_stage_plugin ()
@@ -333,43 +266,27 @@ def callback_func(**kwargs):
333266 # Edge cases require using the old model (loose constraints) instead of building a target,
334267 # but we don't populate the passmanager config with loose constraints unless it's one of
335268 # the known edge cases to control the execution path.
336- # Filter instruction_durations and timing_constraints deprecation
337- with warnings .catch_warnings ():
338- warnings .filterwarnings (
339- "ignore" ,
340- category = DeprecationWarning ,
341- message = ".*``timing_constraints`` is deprecated as of Qiskit 1.3.*" ,
342- module = "qiskit" ,
343- )
344- warnings .filterwarnings (
345- "ignore" ,
346- category = DeprecationWarning ,
347- message = ".*``instruction_durations`` is deprecated as of Qiskit 1.3.*" ,
348- module = "qiskit" ,
349- )
350- pm = generate_preset_pass_manager (
351- optimization_level ,
352- target = target ,
353- backend = backend ,
354- basis_gates = basis_gates ,
355- coupling_map = coupling_map ,
356- instruction_durations = instruction_durations ,
357- timing_constraints = timing_constraints ,
358- initial_layout = initial_layout ,
359- layout_method = layout_method ,
360- routing_method = routing_method ,
361- translation_method = translation_method ,
362- scheduling_method = scheduling_method ,
363- approximation_degree = approximation_degree ,
364- seed_transpiler = seed_transpiler ,
365- unitary_synthesis_method = unitary_synthesis_method ,
366- unitary_synthesis_plugin_config = unitary_synthesis_plugin_config ,
367- hls_config = hls_config ,
368- init_method = init_method ,
369- optimization_method = optimization_method ,
370- dt = dt ,
371- qubits_initially_zero = qubits_initially_zero ,
372- )
269+ pm = generate_preset_pass_manager (
270+ optimization_level ,
271+ target = target ,
272+ backend = backend ,
273+ basis_gates = basis_gates ,
274+ coupling_map = coupling_map ,
275+ initial_layout = initial_layout ,
276+ layout_method = layout_method ,
277+ routing_method = routing_method ,
278+ translation_method = translation_method ,
279+ scheduling_method = scheduling_method ,
280+ approximation_degree = approximation_degree ,
281+ seed_transpiler = seed_transpiler ,
282+ unitary_synthesis_method = unitary_synthesis_method ,
283+ unitary_synthesis_plugin_config = unitary_synthesis_plugin_config ,
284+ hls_config = hls_config ,
285+ init_method = init_method ,
286+ optimization_method = optimization_method ,
287+ dt = dt ,
288+ qubits_initially_zero = qubits_initially_zero ,
289+ )
373290
374291 out_circuits = pm .run (circuits , callback = callback , num_processes = num_processes )
375292
0 commit comments