BIPMapping¶

class
BIPMapping
(*args, **kwargs)[source]¶ Bases:
qiskit.transpiler.basepasses.TransformationPass
Map a DAGCircuit onto a given
coupling_map
, allocating qubits and adding swap gates.The BIP mapper tries to find the best layout and routing at once by solving a BIP (binary integer programming) problem as described in [1].
The BIP problem represents the layerbylayer mapping of 2qubit gates, assuming all the gates in a layer can be run on the
coupling_map
. In the problem, the variables \(w\) represent the layout of qubits for each layer and the variables \(x\) represent which pair of qubits should be swapped in between layers. Based on the values in the solution of the BIP problem, the mapped circuit will be constructed.The BIP mapper depends on
docplex
to represent the BIP problem and CPLEX (cplex
) to solve it. Those packages can be installed withpip install qiskitterra[bipmapper]
. Since the free version of CPLEX can solve only small BIP problems, i.e. mapping of circuits with less than about 5 qubits, the paid version of CPLEX may be needed to map larger circuits.If you want to fix physical qubits to be used in the mapping (e.g. running Quantum Volume circuits), you need to supply
coupling_map
which contains only the qubits to be used. Please do not useinitial_layout
for that purpose because the BIP mapper gracefully ignoresinitial_layout
(and tries to determines its best layout).Warning
The BIP mapper does not scale very well with respect to the number of qubits or gates. For example, it would not work with
coupling_map
beyond 10 qubits because the BIP solver (CPLEX) could not find any solution within the default time limit.References:
[1] G. Nannicini et al. “Optimal qubit assignment and routing via integer programming.” arXiv:2106.06446
BIPMapping initializer.
 Parameters
coupling_map (CouplingMap) – Directed graph represented a coupling map.
objective (str) –
Type of objective function:
'error_rate'
: [NotImplemented] Predicted error rate of the circuit'depth'
: [Default] Depth (number of timesteps) of the circuit'balanced'
: [NotImplemented] Weighted sum of'error_rate'
and'depth'
backend_prop (BackendProperties) – Backend properties object
time_limit (float) – Time limit for solving BIP in seconds
threads (int) – Number of threads to be allowed for CPLEX to solve BIP
max_swaps_inbetween_layers (int) – Number of swaps allowed in between layers. If None, automatically set. Large value could decrease the probability to build infeasible BIP problem but also could reduce the chance of finding a feasible solution within the
time_limit
.
 Raises
MissingOptionalLibraryError – if cplex or docplex are not installed.
Methods
Return the name of the pass.
Run the BIPMapping pass on dag, assuming the number of virtual qubits (defined in dag) and the number of physical qubits (defined in coupling_map) are the same.
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).