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: ──────────╳────────────●────

Modules

creator

Main builder for layout synthesis.

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.