SabreLayout
class SabreLayout(*args, **kwargs)
Bases: qiskit.transpiler.basepasses.AnalysisPass
Choose a Layout via iterative bidirectional routing of the input circuit.
Starting with a random initial Layout, the algorithm does a full routing of the circuit (via the routing_pass method) to end up with a final_layout. This final_layout is then used as the initial_layout for routing the reverse circuit. The algorithm iterates a number of times until it finds an initial_layout that reduces full routing cost.
This method exploits the reversibility of quantum circuits, and tries to include global circuit information in the choice of initial_layout.
References:
[1] Li, Gushu, Yufei Ding, and Yuan Xie. “Tackling the qubit mapping problem for NISQ-era quantum devices.” ASPLOS 2019. arXiv:1809.02573
SabreLayout initializer.
Parameters
- coupling_map (Coupling) – directed graph representing a coupling map.
- routing_pass (BasePass) – the routing pass to use while iterating. This is mutually exclusive with the
swap_trials
argument and if both are set an error will be raised. - seed (int) – seed for setting a random first trial layout.
- max_iterations (int) – number of forward-backward iterations.
- swap_trials (int) – The number of trials to run of
SabreSwap
for each iteration. This is equivalent to thetrials
argument onSabreSwap
. If this is not specified (androuting_pass
isn’t set) by default the number of physical CPUs on your local system will be used. For reproducibility between environments it is best to set this to an explicit number because the output will potentially depend on the number of trials run. This option is mutually exclusive with therouting_pass
argument and an error will be raised if both are used.
Raises
TranspilerError – If both routing_pass
and swap_trials
are specified
Methods
name
SabreLayout.name()
Return the name of the pass.
run
SabreLayout.run(dag)
Run the SabreLayout pass on dag.
Parameters
dag (DAGCircuit) – DAG to find layout for.
Raises
TranspilerError – if dag wider than self.coupling_map
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).