---
title: SabrePreLayout (latest version)
description: API reference for qiskit.transpiler.passes.SabrePreLayout in the latest version of qiskit
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/qiskit.transpiler.passes.SabrePreLayout
---

# SabrePreLayout

*class* `qiskit.transpiler.passes.SabrePreLayout(*args, **kwargs)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/transpiler/passes/layout/sabre_pre_layout.py#L27-L168)

Bases: [`AnalysisPass`](/docs/api/qiskit/qiskit.transpiler.AnalysisPass "qiskit.transpiler.basepasses.AnalysisPass")

Choose a starting layout to use for additional Sabre layout trials.

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. The original edges are noise-free while the additional edges have noise that scales exponentially with the distance. The value of `d` is increased until an isomorphism is found.

Intuitively, a better VF2 layout involves fewer and of shorter-distance extra edges.

## Property Set Values Written

**`sabre_starting_layouts` (`list[Layout]`)**

An optional list of [`Layout`](/docs/api/qiskit/qiskit.transpiler.Layout "qiskit.transpiler.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](https://doi.org/10.48550/arXiv.2409.08368)

**param coupling\_map**

Directed graph representing the original coupling map or a target modelling the backend (including its connectivity).

**param max\_distance**

The maximum distance for running VF2 with the augmented coupling map. In particular, this also specifies the maximum distance between the original nodes that become connected in the augmented coupling map.

**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.

**param max\_trials\_vf2**

Specifies the maximum number of VF2 trials. This option remains primarily for legacy reasons since the introduction of on-the-fly scoring in VF2, which was introduced in Qiskit 2.3. To bound the time for the pass, set parameters `max_distance` and `call_limit_vf2` instead.

**param call\_limit\_vf2**

The maximum number of times that the inner VF2 isomorphism search will attempt to extend the mapping. If `None`, then no limit. If a 2-tuple, then the limit starts as the first item, and swaps to the second after the first match is found, without resetting the number of steps taken. This can be used to allow a long search for any mapping, but still terminate quickly with a small extension budget if one is found.

**param improve\_layout**

Unused (the option became obsolete with the introduction of on-the-fly scoring in VF2).

**param min\_distance**

The distance for the first VF2 run with the augmented coupling map. Setting `min_distance > 1` skips all smaller-distance checks, and in particular skips the distance-1 check which corresponds to running the `VF2Layout` pass.

**raises TranspilerError**

At runtime, if the argument `coupling_map` is not 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)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/passmanager/base_tasks.py#L76-L122)

Execute optimization task for input Qiskit IR.

**Parameters**

- **passmanager\_ir** (*IR*) – Qiskit IR to optimize.
- **state** ([*PassManagerState*](/docs/api/qiskit/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)*\[\[*[*Task*](/docs/api/qiskit/qiskit.passmanager.Task "qiskit.passmanager.base_tasks.Task")*, IR\_OUT,* [*PropertySet*](/docs/api/qiskit/qiskit.passmanager.PropertySet "qiskit.passmanager.compilation_status.PropertySet")*,* [*float*](https://docs.python.org/3/library/functions.html#float)*,* [*int*](https://docs.python.org/3/library/functions.html#int)*], None] | None*) – A callback function which is called 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)\[*IR\_OUT*, [*PassManagerState*](/docs/api/qiskit/qiskit.passmanager.PassManagerState "qiskit.passmanager.compilation_status.PassManagerState")]

### name

`name()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/passmanager/base_tasks.py#L72-L74)

Name of the pass.

**Return type**

[str](https://docs.python.org/3/library/stdtypes.html#str)

### run

`run(dag)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/transpiler/passes/layout/sabre_pre_layout.py#L107-L147)

Run the SabrePreLayout pass on dag.

The discovered starting layout is written to the property set value `sabre_starting_layouts`.

**Parameters**

**dag** ([*DAGCircuit*](/docs/api/qiskit/qiskit.dagcircuit.DAGCircuit "qiskit.dagcircuit.DAGCircuit")) – DAG to create starting layout for.

### update\_status

`update_status(state, run_state)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/2.5/qiskit/passmanager/base_tasks.py#L124-L142)

Update workflow status.

**Parameters**

- **state** ([*PassManagerState*](/docs/api/qiskit/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*](/docs/api/qiskit/qiskit.passmanager.PassManagerState "qiskit.passmanager.compilation_status.PassManagerState")
