qiskit-documentation/docs/api/qiskit/1.2/qiskit.transpiler.passes.Co...

167 lines
8.1 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: ConstrainedReschedule (v1.2)
description: API reference for qiskit.transpiler.passes.ConstrainedReschedule in qiskit v1.2
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.transpiler.passes.ConstrainedReschedule
---
# ConstrainedReschedule
<Class id="qiskit.transpiler.passes.ConstrainedReschedule" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/passes/scheduling/alignments/reschedule.py#L27-L250" signature="qiskit.transpiler.passes.ConstrainedReschedule(*args, **kwargs)" modifiers="class">
Bases: [`AnalysisPass`](qiskit.transpiler.AnalysisPass "qiskit.transpiler.basepasses.AnalysisPass")
Rescheduler pass that updates node start times to conform to the hardware alignments.
This pass shifts DAG node start times previously scheduled with one of the scheduling passes, e.g. [`ASAPScheduleAnalysis`](qiskit.transpiler.passes.ASAPScheduleAnalysis "qiskit.transpiler.passes.ASAPScheduleAnalysis") or [`ALAPScheduleAnalysis`](qiskit.transpiler.passes.ALAPScheduleAnalysis "qiskit.transpiler.passes.ALAPScheduleAnalysis"), so that every instruction start time satisfies alignment constraints.
**Examples**
We assume executing the following circuit on a backend with 16 dt of acquire alignment.
```python
┌───┐┌────────────────┐┌─┐
q_0: ┤ X ├┤ Delay(100[dt]) ├┤M├
└───┘└────────────────┘└╥┘
c: 1/════════════════════════╩═
0
```
Note that delay of 100 dt induces a misalignment of 4 dt at the measurement. This pass appends an extra 12 dt time shift to the input circuit.
```python
┌───┐┌────────────────┐┌─┐
q_0: ┤ X ├┤ Delay(112[dt]) ├┤M├
└───┘└────────────────┘└╥┘
c: 1/════════════════════════╩═
0
```
**Notes**
Your backend may execute circuits violating these alignment constraints. However, you may obtain erroneous measurement result because of the untracked phase originating in the instruction misalignment.
Create new rescheduler pass.
The alignment values depend on the control electronics of your quantum processor.
**Parameters**
* **acquire\_alignment** Integer number representing the minimum time resolution to trigger acquisition instruction in units of `dt`.
* **pulse\_alignment** Integer number representing the minimum time resolution to trigger gate instruction in units of `dt`.
* **target** The [`Target`](qiskit.transpiler.Target "qiskit.transpiler.Target") representing the target backend, if `target` is specified then this argument will take precedence and `acquire_alignment` and `pulse_alignment` will be ignored.
## Attributes
### is\_analysis\_pass
<Attribute id="qiskit.transpiler.passes.ConstrainedReschedule.is_analysis_pass">
Check if the pass is an analysis pass.
If the pass is an AnalysisPass, that means that the pass can analyze the DAG and write the results of that analysis in the property set. Modifications on the DAG are not allowed by this kind of pass.
</Attribute>
### is\_transformation\_pass
<Attribute id="qiskit.transpiler.passes.ConstrainedReschedule.is_transformation_pass">
Check if the pass is a transformation pass.
If the pass is a TransformationPass, that means that the pass can manipulate the DAG, but cannot modify the property set (but it can be read).
</Attribute>
## Methods
### execute
<Function id="qiskit.transpiler.passes.ConstrainedReschedule.execute" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/passmanager/base_tasks.py#L72-L118" signature="execute(passmanager_ir, state, callback=None)">
Execute optimization task for input Qiskit IR.
**Parameters**
* **passmanager\_ir** ([*Any*](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.13)")) Qiskit IR to optimize.
* **state** ([*PassManagerState*](qiskit.passmanager.PassManagerState "qiskit.passmanager.compilation_status.PassManagerState")) State associated with workflow execution by the pass manager itself.
* **callback** ([*Callable*](https://docs.python.org/3/library/collections.abc.html#collections.abc.Callable "(in Python v3.13)") *| None*) A callback function which is caller per execution of optimization task.
**Returns**
Optimized Qiskit IR and state of the workflow.
**Return type**
[tuple](https://docs.python.org/3/library/stdtypes.html#tuple "(in Python v3.13)")\[[*Any*](https://docs.python.org/3/library/typing.html#typing.Any "(in Python v3.13)"), [qiskit.passmanager.compilation\_status.PassManagerState](qiskit.passmanager.PassManagerState "qiskit.passmanager.compilation_status.PassManagerState")]
</Function>
### name
<Function id="qiskit.transpiler.passes.ConstrainedReschedule.name" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/passmanager/base_tasks.py#L68-L70" signature="name()">
Name of the pass.
**Return type**
[str](https://docs.python.org/3/library/stdtypes.html#str "(in Python v3.13)")
</Function>
### run
<Function id="qiskit.transpiler.passes.ConstrainedReschedule.run" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/passes/scheduling/alignments/reschedule.py#L192-L250" signature="run(dag)">
Run rescheduler.
This pass should perform rescheduling to satisfy:
> * All DAGOpNode nodes (except for compiler directives) are placed at start time satisfying hardware alignment constraints.
> * The end time of a node does not overlap with the start time of successor nodes.
Assumptions:
> * Topological order and absolute time order of DAGOpNode are consistent.
> * All bits in either qargs or cargs associated with node synchronously start.
> * Start time of qargs and cargs may different due to I/O latency.
Based on the configurations above, the rescheduler pass takes the following strategy:
1. **The nodes are processed in the topological order, from the beginning of**
the circuit (i.e. from left to right). For every node (including compiler directives), the function `_push_node_back` performs steps 2 and 3.
2. **If the start time of the node violates the alignment constraint,**
the start time is increased to satisfy the constraint.
3. **Each immediate successor whose start\_time overlaps the nodes end\_time is**
pushed backwards (towards the end of the wire). Note that at this point the shifted successor does not need to satisfy the constraints, but this will be taken care of when that successor node itself is processed.
4. **After every node is processed, all misalignment constraints will be resolved,**
and there will be no overlap between the nodes.
**Parameters**
**dag** ([*DAGCircuit*](qiskit.dagcircuit.DAGCircuit "qiskit.dagcircuit.dagcircuit.DAGCircuit")) DAG circuit to be rescheduled with constraints.
**Raises**
[**TranspilerError**](transpiler#qiskit.transpiler.TranspilerError "qiskit.transpiler.TranspilerError") If circuit is not scheduled.
</Function>
### update\_status
<Function id="qiskit.transpiler.passes.ConstrainedReschedule.update_status" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/passmanager/base_tasks.py#L120-L138" signature="update_status(state, run_state)">
Update workflow status.
**Parameters**
* **state** ([*PassManagerState*](qiskit.passmanager.PassManagerState "qiskit.passmanager.compilation_status.PassManagerState")) Pass manager state to update.
* **run\_state** (*RunState*) Completion status of current task.
**Returns**
Updated pass manager state.
**Return type**
[*PassManagerState*](qiskit.passmanager.PassManagerState "qiskit.passmanager.compilation_status.PassManagerState")
</Function>
</Class>