162 lines
6.3 KiB
Plaintext
162 lines
6.3 KiB
Plaintext
---
|
||
title: SabrePreLayout (v1.2)
|
||
description: API reference for qiskit.transpiler.passes.SabrePreLayout in qiskit v1.2
|
||
in_page_toc_min_heading_level: 1
|
||
python_api_type: class
|
||
python_api_name: qiskit.transpiler.passes.SabrePreLayout
|
||
---
|
||
|
||
# SabrePreLayout
|
||
|
||
<Class id="qiskit.transpiler.passes.SabrePreLayout" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/passes/layout/sabre_pre_layout.py#L25-L220" signature="qiskit.transpiler.passes.SabrePreLayout(*args, **kwargs)" modifiers="class">
|
||
Bases: [`AnalysisPass`](qiskit.transpiler.AnalysisPass "qiskit.transpiler.basepasses.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`](qiskit.transpiler.Layout "qiskit.transpiler.Layout") objects to use for additional Sabre layout trials.
|
||
|
||
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
|
||
|
||
<Attribute id="qiskit.transpiler.passes.SabrePreLayout.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.SabrePreLayout.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.SabrePreLayout.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.SabrePreLayout.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.SabrePreLayout.run" github="https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/transpiler/passes/layout/sabre_pre_layout.py#L92-L135" signature="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*](qiskit.dagcircuit.DAGCircuit "qiskit.dagcircuit.DAGCircuit")) – DAG to create starting layout for.
|
||
</Function>
|
||
|
||
### update\_status
|
||
|
||
<Function id="qiskit.transpiler.passes.SabrePreLayout.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>
|
||
|