A pass for choosing a Layout of a circuit onto a Coupling graph, as a a subgraph isomorphism problem, solved by VF2++.
If a solution is found that means there is a “perfect layout” and that no further swap mapping or routing is needed. If a solution is found the layout will be set in the property set as
property_set['layout']. However, if no solution is found, no
property_set['layout'] is set. The stopping reason is set in
property_set['VF2Layout_stop_reason'] in all the cases and will be one of the values enumerated in
VF2LayoutStopReason which has the following values:
"solution found": If a perfect layout was found.
"nonexistent solution": If no perfect layout was found.
">2q gates in basis": If VF2Layout can’t work with basis
By default this pass will construct a heuristic scoring map based on the the error rates in the provided
target is not provided). However, analysis passes can be run prior to this pass and set
vf2_avg_error_map in the property set with a
ErrorMap instance. If a value is
NaN that is treated as an ideal edge For example if an error map is created as:
from qiskit.transpiler.passes.layout.vf2_utils import ErrorMap error_map = ErrorMap(3) error_map.add_error((0, 0), 0.0024) error_map.add_error((0, 1), 0.01) error_map.add_error((1, 1), 0.0032)
that represents the error map for a 2 qubit target, where the avg 1q error rate is
0.0024 on qubit 0 and
0.0032 on qubit 1. Then the avg 2q error rate for gates that operate on (0, 1) is 0.01 and (1, 0) is not supported by the target. This will be used for scoring if it’s set as the
vf2_avg_error_map key in the property set when
VF2Layout is run.
VF2Layout pass instance
- coupling_map (CouplingMap) – Directed graph representing a coupling map.
- strict_direction (bool (opens in a new tab)) – If True, considers the direction of the coupling map. Default is False.
- seed (int (opens in a new tab)) – Sets the seed of the PRNG. -1 Means no node shuffling.
- call_limit (int (opens in a new tab)) – The number of state visits to attempt in each execution of VF2.
- time_limit (float (opens in a new tab)) – The total time limit in seconds to run
- properties (BackendProperties) – The backend properties for the backend. If
readout_error()is available it is used to score the layout.
- max_trials (int (opens in a new tab)) – The maximum number of trials to run VF2 to find a layout. If this is not specified the number of trials will be limited based on the number of edges in the interaction graph or the coupling graph (whichever is larger) if no other limits are set. If set to a value <= 0 no limit on the number of trials will be set.
- target (Target) – A target representing the backend device to run
VF2Layouton. If specified it will supersede a set value for
TypeError (opens in a new tab) – At runtime, if neither
target are provided.
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.
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).
execute(passmanager_ir, state, callback=None)
Execute optimization task for input Qiskit IR.
- passmanager_ir (Any (opens in a new tab)) – Qiskit IR to optimize.
- state (PassManagerState) – State associated with workflow execution by the pass manager itself.
- callback (Callable (opens in a new tab) | None) – A callback function which is caller per execution of optimization task.
Optimized Qiskit IR and state of the workflow.
Name of the pass.
run the layout method
Update workflow status.
- state (PassManagerState) – Pass manager state to update.
- run_state (RunState) – Completion status of current task.
Updated pass manager state.