plasma_layout

Contents

plasma_layout#

Module: iqm.qrisp_iqm.passes.routing

iqm.qrisp_iqm.passes.routing.plasma_layout(connectivity: list[tuple[int, int]], effort: int = 30, sections: int = 0, depth_weight: float = 0.0, seed: int = 0) Callable[[QuantumCircuit], QuantumCircuit]#

Create a layout pass that finds an initial qubit mapping.

The returned pass remaps logical qubits to physical positions but does not insert SWAP gates. Chain it with plasma_route() for a full layout + routing pipeline:

pm = PassManager()
pm.add_pass(plasma_layout(connectivity, sections=0))
pm.add_pass(plasma_route(connectivity, sections=0))
transpiled = pm.run(qc)

When sectionalized routing is used (sections != 1), the layout search is section-aware: forward evaluation passes process the DAG in sections matching those that plasma_route() will use, so the proxy cost faithfully predicts the routing outcome. See the module docstring for details.

Parameters:
  • connectivity (list[tuple[int, int]]) – Hardware topology edges.

  • effort (int, optional) – Controls the number of initial layout candidates and refinement iterations. Passed to compute_parameters together with the circuit’s 2-qubit gate count to derive init_layout_attempts and layout_iterations. Default 30.

  • sections (int, optional) –

    Section count, forwarded to prepare_dag_and_sections().

    • 0 (default): Automatic — derive from 2-qubit critical path.

    • 1: No sectionalization — unsectioned layout evaluation.

    • N > 1: Exactly N sections.

    Must match the sections value passed to the downstream plasma_route() pass so the layout evaluation reflects the actual routing strategy. Default is 0.

  • depth_weight (float, optional) –

    Tradeoff between gate count and circuit depth (-1.0 to 1.0).

    • -1: Layout scored purely by swap count.

    • 0 (default): Balanced.

    • +1: Layout scored purely by circuit depth.

    Should match the depth_weight passed to plasma_route().

  • seed (int, optional) – Seed for the random number generator used to produce candidate initial layouts. Default is 0, making the layout search reproducible by default.

Returns:

A pass function that applies the optimised layout.

Return type:

Callable[[QuantumCircuit], QuantumCircuit]

Example

>>> from qrisp import QuantumCircuit, PassManager
>>> from iqm.qrisp_iqm import plasma_layout, plasma_route
>>> qc = QuantumCircuit(2); qc.cx(0, 1); qc.measure(qc.qubits)
>>> pm = PassManager()
>>> pm += plasma_layout(connectivity=[(0,1),(1,2),(2,3)])
>>> pm += plasma_route(connectivity=[(0,1),(1,2),(2,3)])
>>> transpiled_qc = pm.run(qc)