SabrePreLayout
class qiskit.transpiler.passes.SabrePreLayout(*args, **kwargs)
Bases: AnalysisPass
Choose a starting layout to use for additional Sabre layout trials.
Property Set Values Written
sabre_starting_layouts
(list[Layout]
)
An optional list of Layout
objects to use for additional Sabre layout trials.
References:
[1] Henry Zou and Matthew Treinish and Kevin Hartman and Alexander Ivrii and Jake Lishman. “LightSABRE: A Lightweight and Enhanced SABRE Algorithm” arXiv:2409.08368
SabrePreLayout initializer.
The pass works by augmenting the coupling map with more and more “extra” edges until VF2 succeeds to find a perfect graph isomorphism. More precisely, the augmented coupling map contains edges between nodes that are within a given distance d
in the original coupling map, and the value of d
is increased until an isomorphism is found.
Intuitively, a better layout involves fewer extra edges. The pass also optionally minimizes the number of extra edges involved in the layout until a local minimum is found. This involves removing extra edges and running VF2 to see if an isomorphism still exists.
param coupling_map
directed graph representing the original coupling map or a target modelling the backend (including its connectivity).
type coupling_map
Union[CouplingMap, Target]
param max_distance
the maximum distance to consider for augmented coupling maps.
type max_distance
int
param error_rate
the error rate to assign to the “extra” edges. A non-zero error rate prioritizes VF2 to choose original edges over extra edges.
type error_rate
float
param max_trials_vf2
specifies the maximum number of VF2 trials. A larger number allows VF2 to explore more layouts, eventually choosing the one with the smallest error rate.
type max_trials_vf2
int
param call_limit_vf2
limits each call to VF2 by bounding the number of VF2 state visits.
type call_limit_vf2
int
param improve_layout
whether to improve the layout by minimizing the number of extra edges involved. This might be time-consuming as this requires additional VF2 calls.
type improve_layout
bool
raises TranspilerError
At runtime, if neither coupling_map
or target
are provided.
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
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 (Callable | None) – A callback function which is caller per execution of optimization task.
Returns
Optimized Qiskit IR and state of the workflow.
Return type
tuple[Any, qiskit.passmanager.compilation_status.PassManagerState]
name
run
run(dag)
Run the SabrePreLayout pass on dag.
The discovered starting layout is written to the property set value sabre_starting_layouts
.
Parameters
dag (DAGCircuit) – DAG to create starting layout for.
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.
Returns
Updated pass manager state.
Return type