BlockBasePadder
class BlockBasePadder(schedule_idle_qubits=False, block_ordering_callable=None)
The base class of padding pass.
This pass requires one of scheduling passes to be executed before itself. Since there are multiple scheduling strategies, the selection of scheduling pass is left in the hands of the pass manager designer. Once a scheduling analysis pass is run, node_start_time
is generated in the property_set
. This information is represented by a python dictionary of the expected instruction execution times keyed on the node instances. The padding pass expects all DAGOpNode
in the circuit to be scheduled.
This base class doesn’t define any sequence to interleave, but it manages the location where the sequence is inserted, and provides a set of information necessary to construct the proper sequence. Thus, a subclass of this pass just needs to implement _pad()
method, in which the subclass constructs a circuit block to insert. This mechanism removes lots of boilerplate logic to manage whole DAG circuits.
Note that padding pass subclasses should define interleaving sequences satisfying:
- Interleaved sequence does not change start time of other nodes
- Interleaved sequence should have total duration of the provided
time_interval
.
Any manipulation violating these constraints may prevent this base pass from correctly tracking the start time of each instruction, which may result in violation of hardware alignment constraints.
Attributes
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.
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).
Methods
__call__
__call__(circuit, property_set=None)
Runs the pass on circuit.
Parameters
- circuit (QuantumCircuit) – The dag on which the pass is run.
- property_set (PropertySet | dict | None) – Input/output property set. An analysis pass might change the property set in-place.
Return type
QuantumCircuit
Returns
If on transformation pass, the resulting QuantumCircuit. If analysis pass, the input circuit.
execute
execute(passmanager_ir, state, callback=None)
Execute optimization task for input Qiskit IR.
Parameters
- passmanager_ir (
Any
) – Qiskit IR to optimize. - state (
PassManagerState
) – State associated with workflow execution by the pass manager itself. - callback (
Optional
[Callable
]) – A callback function which is caller per execution of optimization task.
Return type
tuple
[Any
, PassManagerState
]
Returns
Optimized Qiskit IR and state of the workflow.
name
name()
Name of the pass.
Return type
str
run
run(dag)
Run the padding pass on dag
.
Parameters
dag (DAGCircuit
) – DAG to be checked.
Returns
DAG with idle time filled with instructions.
Return type
DAGCircuit
Raises
TranspilerError – When a particular node is not scheduled, likely some transform pass is inserted before this node is called.
update_status
update_status(state, run_state)
Update workflow status.
Parameters
- state (
PassManagerState
) – Pass manager state to update. - run_state (
RunState
) – Completion status of current task.
Return type
Returns
Updated pass manager state.