Swap Networks for Limited Connectivity
Overview
Swap Networks for Limited Connectivity
Real quantum hardware rarely lets every qubit interact directly with every other; qubits are laid out with limited connectivity, so two-qubit gates between distant qubits must be routed by physically swapping qubit states until the operands are adjacent. This Cirq tutorial demonstrates swap networks, a structured and highly efficient way to perform such routing, using the acquaintance submodule. As a concrete application it implements a single round of QAOA for Maximum Cut on a linearly connected device, even when the underlying problem graph is arbitrary and dense. The key idea is that a carefully designed sequence of swaps brings every pair of qubits into adjacency exactly once, so all the required two-qubit interaction terms of the cost Hamiltonian can be applied along the way without any wasted movement. The example shows how to express the desired circuit (alternating mixing and phase-separation layers) abstractly in terms of logical qubits, then compile it onto a line of physical qubits using acquaintance strategies that interleave the interaction gates with the swaps. It is a practical, advanced look at the routing and compilation problem that every near-term algorithm must solve to run on connectivity-limited hardware.
Run it
pip install -r requirements.txt
python swap_networks.py
Source and license
Imported from examples/swap_networks.py in quantumlib/Cirq at v1.6.1, under the Apache License 2.0. Original authors: The Cirq Developers. The upstream LICENSE is included alongside this example.
This entry was created automatically from publicly available records. QCR links to public sources and only stores repository content where the license permits redistribution.
Versions
Cite all versions? Use the base QCR ID to always reference the latest version of this entry.
Join the Discussion
Comments (0)
No comments yet. Be the first to share your thoughts!