qrunch.quantum.circuits.synthesis.layout

Module containing everything needed for layout synthesis.

Layout synthesis of the minimal example requiring at least one swap gate is setup up at performed as:

# Build circuit
circuit = Circuit(3)
circuit.append(CXGate(0, 1))
circuit.append(CXGate(1, 2))
circuit.append(CXGate(0, 2))

print("Original circuit:")
print(circuit)

# Make physical qubit connection graph.
connection_graph = QubitConnectionGraph(
    qubit_connections=[
        QubitConnection(PhysicalQubit(0), PhysicalQubit(1)),
        QubitConnection(PhysicalQubit(1), PhysicalQubit(2)),
    ],
    num_qubits=3,
)
# Initialize solver and layout synthesizer.
solver = PySATSolver()
layout_synthesizer = OneWayLayoutSynthesizer(connection_graph, solver)

# Run the layout synthesis.
result = layout_synthesizer.synthesize(circuit)

print("Synthesized circuit:")
print(result.circuit)

This prints the original and synthesized circuits as:

Original circuit:

q0: ────●─────────────●────
        │             │
      ┌─┴─┐           │
q1: ──┤ X ├────●──────┼────
      └───┘    │      │
             ┌─┴─┐  ┌─┴─┐
q2: ─────────┤ X ├──┤ X ├──
             └───┘  └───┘


Synthesized circuit:
      ┌───┐
q0: ──┤ X ├─────────●───────────
      └─┬─┘         │
        │         ┌─┴─┐  ┌───┐
q1: ────●─────╳───┤ X ├──┤ X ├──
              │   └───┘  └─┬─┘
              │            │
q2: ──────────╳────────────●────

Functions

layout_synthesizer_creator()

Begin creating a layout_synthesizer.

Classes

LayoutSynthesizerCreator

Class for creating layout synthesizers.

class LayoutSynthesizerCreator

Bases: object

Class for creating layout synthesizers.

static qubit_dependent() QubitDependentLayoutSynthesizerCreator

Create a qubit-dependent layout synthesizer that chooses between different layout synthesis strategies based on the number of qubits in the circuit.

This synthesizer uses the simple SAT-based layout synthesizer for circuits with a number of qubits less than or equal to a specified threshold. For circuits with a number of qubits exceeding this threshold, it employs the Sabre layout synthesizer. This approach allows for finding guaranteed optimal solutions for small circuits, while still being able to handle larger circuits efficiently when finding a guaranteed optimal solution becomes infeasible.

Return type:

QubitDependentLayoutSynthesizerCreator

static sabre() SabreLayoutSynthesizerCreator

Create a layout sabre layout synthesizer.

This synthesizer is based on Qiskit’s Sabre layout synthesizer. It is quite fast but unlike the simple layout synthesizer it does not guarantee to find the optimal solution.

Return type:

SabreLayoutSynthesizerCreator

static simple_sat() SimpleSatLayoutSynthesizerCreator

Create a simple boolean satisfiability (SAT) based layout synthesizer.

This synthesizer uses a one way encoding where the order of CNOT gates is encoded between the current and previous iteration. Additionally, the encoding is close to minimal and mostly only contains clauses necessary to find the correct solution.

This synthesizer guarantees to find the optimal solution with the given encoding, but can be quite slow for larger circuits.

Return type:

SimpleSatLayoutSynthesizerCreator

layout_synthesizer_creator() LayoutSynthesizerCreator

Begin creating a layout_synthesizer.

Layout synthesizers are used to transform a quantum circuit such that it conforms to the connectivity constraints of a given quantum hardware architecture. They are used by the different backends.

Return type:

LayoutSynthesizerCreator

Modules

hardware_mapping_utils

Module containing classes for describing qubit connections on quantum hardware.

layout_synthesis_protocols

Module containing protocols for layout synthesis.

qubit_dependent_synthesizer

A layout synthesizer that chooses between different layout synthesis strategies based on the number of qubits in the circuit.

sabre_layout_synthesizer

Module containing the class for performing layout synthesis using Qiskit's Sabre synthesizer.

simple_sat_layout_synthesizer

Module containing the class for performing layout synthesis using a simple encoding.