(all-to-all-coupling num-qubits)
Create the coupling for an all-to-all hardware topology where every qubit is connected to every other qubit.
Parameters:
Returns: Vector of vectors representing adjacency list for all-to-all topology
Create the coupling for an all-to-all hardware topology where every qubit is connected to every other qubit. Parameters: - num-qubits: Number of qubits in the topology Returns: Vector of vectors representing adjacency list for all-to-all topology
(analyze-coupling-connectivity coupling)
Analyze the connectivity properties of a hardware coupling.
Parameters:
Returns: Map containing coupling analysis:
Analyze the connectivity properties of a hardware coupling. Parameters: - coupling: Hardware coupling as vector of vectors Returns: Map containing coupling analysis: - :num-qubits - Total number of qubits - :total-edges - Total number of edges (connections) - :avg-degree - Average degree (connections per qubit) - :max-degree - Maximum degree - :min-degree - Minimum degree - :diameter - Maximum shortest path distance between any two qubits - :is-connected - Whether the topology is fully connected
(calculate-distance-matrix coupling)
Calculate shortest path distances between all pairs of qubits in coupling.
Parameters:
Returns: 2D vector where element [i][j] is the shortest distance from qubit i to qubit j
Calculate shortest path distances between all pairs of qubits in coupling. Parameters: - coupling: Vector of vectors representing qubit connectivity Returns: 2D vector where element [i][j] is the shortest distance from qubit i to qubit j
(calculate-mapping-cost two-qubit-ops mapping distance-matrix)
Calculate the cost of a logical-to-physical qubit mapping.
Parameters:
Returns: Total cost (sum of distances for all two-qubit operations)
Calculate the cost of a logical-to-physical qubit mapping. Parameters: - two-qubit-ops: Vector of two-qubit operations with :control and :target - mapping: Map from logical qubit to physical qubit - distance-matrix: 2D vector of distances between physical qubits Returns: Total cost (sum of distances for all two-qubit operations)
(compare-couplings circuit topologies)
Compare multiple hardware couplings for a given circuit.
Parameters:
Returns: Vector of maps sorted by total cost, each containing:
Compare multiple hardware couplings for a given circuit. Parameters: - circuit: Quantum circuit to optimize - topologies: Map of topology-name to coupling Returns: Vector of maps sorted by total cost, each containing: - :topology-name - Name of the topology - :total-cost - Total routing cost - :swap-count - Number of SWAP operations needed - :logical-to-physical - Optimal qubit mapping
(coupling-for-topology topology num-qubits)
Get the coupling for a given topology type and number of qubits.
Parameters:
Returns: Vector of vectors representing adjacency list for the specified topology
Get the coupling for a given topology type and number of qubits. Parameters: - topology: Keyword identifying the topology type :all-to-all, :linear, :ring, :star, :grid, :heavy-hex - num-qubits: Number of qubits in the topology (ignored for heavy-hex) Returns: Vector of vectors representing adjacency list for the specified topology
(ensure-symmetric-coupling coupling)
Ensure all connections in topology are symmetric.
Parameters:
Returns: Symmetric coupling where if qubit A connects to B, then B connects to A
Ensure all connections in topology are symmetric. Parameters: - coupling: Vector of vectors representing qubit connectivity Returns: Symmetric coupling where if qubit A connects to B, then B connects to A
(extract-two-qubit-operations circuit)
Extract all two-qubit operations from a circuit.
Parameters:
Returns: Vector of maps containing :control and :target qubit pairs
Extract all two-qubit operations from a circuit. Parameters: - circuit: Quantum circuit to analyze Returns: Vector of maps containing :control and :target qubit pairs
(find-optimal-mapping circuit coupling distance-matrix)
Find an optimal mapping from logical qubits to physical qubits for a circuit.
This function analyzes the circuit and finds the best mapping to minimize routing cost on the given hardware coupling.
Parameters:
Returns: Map from logical qubit to physical qubit
Example: (def circuit {:num-qubits 2 :operations [...]}) (def coupling (coupling-for-linear-topology 3)) (def dist-matrix (calculate-distance-matrix coupling)) (find-optimal-mapping circuit coupling dist-matrix) ;=> {0 1, 1 2}
Find an optimal mapping from logical qubits to physical qubits for a circuit. This function analyzes the circuit and finds the best mapping to minimize routing cost on the given hardware coupling. Parameters: - circuit: Quantum circuit to optimize - coupling: Hardware coupling as vector of vectors (adjacency list) - distance-matrix: Precomputed distance matrix for the coupling Returns: Map from logical qubit to physical qubit Example: (def circuit {:num-qubits 2 :operations [...]}) (def coupling (coupling-for-linear-topology 3)) (def dist-matrix (calculate-distance-matrix coupling)) (find-optimal-mapping circuit coupling dist-matrix) ;=> {0 1, 1 2}
(find-optimal-mapping-for-operations two-qubit-ops
num-logical-qubits
num-physical-qubits
distance-matrix)
Find an optimal mapping from logical qubits to physical qubits for a set of two-qubit operations.
This is the core mapping function that works with extracted operations.
Parameters:
Returns: Map from logical qubit to physical qubit
Throws:
Find an optimal mapping from logical qubits to physical qubits for a set of two-qubit operations. This is the core mapping function that works with extracted operations. Parameters: - two-qubit-ops: Sequence of two-qubit operations with :control and :target - num-logical-qubits: Number of logical qubits to map - num-physical-qubits: Number of physical qubits available - distance-matrix: 2D sequence of distances between physical qubits Returns: Map from logical qubit to physical qubit Throws: - ex-info if circuit requires more qubits than available
(find-shortest-path coupling start end)
Find shortest path between two qubits in the coupling.
Parameters:
Returns: Vector of qubits representing the path from start to end
Find shortest path between two qubits in the coupling. Parameters: - coupling: Hardware coupling - start: Starting qubit - end: Ending qubit Returns: Vector of qubits representing the path from start to end
(generate-swap-operations path target-qubit)
Generate SWAP operations to route a qubit from start to end position.
Parameters:
Returns: Vector of SWAP operation maps
Generate SWAP operations to route a qubit from start to end position. Parameters: - path: Vector of qubits representing routing path - target-qubit: The logical qubit that needs to be moved Returns: Vector of SWAP operation maps
(get-coupling-info topology)
(get-coupling-info topology name)
Get human-readable information about a topology.
Parameters:
Returns: String with topology information
Get human-readable information about a topology. Parameters: - topology: Hardware topology - name: Optional name for the topology Returns: String with topology information
(grid-coupling rows cols)
Create the coupling for a grid hardware topology with qubits arranged in a rectangular grid.
Parameters:
Returns: Vector of vectors representing adjacency list for grid topology
Create the coupling for a grid hardware topology with qubits arranged in a rectangular grid. Parameters: - rows: Number of rows in the grid - cols: Number of columns in the grid Returns: Vector of vectors representing adjacency list for grid topology
(heavy-hex-coupling num-qubits)
Create the coupling for a heavy-hex hardware topology as used by IBM quantum computers.
Heavy-hex topology consists of hexagonal units where each qubit has degree 2-3. This is IBM's actual production topology that reduces frequency collisions and spectator errors compared to square lattices.
Key properties of IBM heavy-hex topology:
Parameters:
Returns: Vector of vectors representing adjacency list for heavy-hex topology
Example: (heavy-hex-coupling 7)
Create the coupling for a heavy-hex hardware topology as used by IBM quantum computers. Heavy-hex topology consists of hexagonal units where each qubit has degree 2-3. This is IBM's actual production topology that reduces frequency collisions and spectator errors compared to square lattices. Key properties of IBM heavy-hex topology: - Each qubit has degree 1, 2 or 3 (never higher) - Forms hexagonal unit cells with edge qubits - Reduces spectator errors and frequency collisions - Used in all IBM quantum processors since 2021 Parameters: - num-qubits: Number of qubits in the topology (currently only 7 supported) Returns: Vector of vectors representing adjacency list for heavy-hex topology Example: (heavy-hex-coupling 7)
(linear-coupling num-qubits)
Create the coupling for a linear hardware topology where qubits are connected in a line.
Parameters:
Returns: Vector of vectors representing adjacency list for linear topology
Create the coupling for a linear hardware topology where qubits are connected in a line. Parameters: - num-qubits: Number of qubits in the topology Returns: Vector of vectors representing adjacency list for linear topology
(optimize-for-coupling circuit coupling)
(optimize-for-coupling circuit coupling options)
Optimize a quantum circuit for a specific hardware topology.
This function performs topology-aware optimization by:
Parameters:
Returns: Map containing:
Example: ;; Linear topology for 5 qubits: 0-1-2-3-4 (def linear-topology [[1] [0 2] [1 3] [2 4] [3]]) (optimize-for-topology my-circuit linear-topology) ;=> {:circuit <optimized-circuit>, :logical-to-physical {0 1, 1 2, 2 3}, ...}
Optimize a quantum circuit for a specific hardware topology. This function performs topology-aware optimization by: 1. Finding an optimal mapping from logical to physical qubits 2. Inserting SWAP operations when needed for routing 3. Minimizing the total cost of the circuit on the given topology Parameters: - circuit: Quantum circuit to optimize - coupling: Hardware coupling as vector of vectors (adjacency list) - options: Optional map with optimization options: :insert-swaps? - Whether to insert SWAP operations for routing (default: true) :optimize-mapping? - Whether to optimize qubit mapping (default: true) Returns: Map containing: - :circuit - The topology-optimized circuit - :logical-to-physical - Map from logical qubit to physical qubit - :physical-to-logical - Map from physical qubit to logical qubit - :swap-count - Number of SWAP operations inserted - :total-cost - Total routing cost of the optimized circuit - :topology-summary - Human-readable summary of topology optimization Example: ;; Linear topology for 5 qubits: 0-1-2-3-4 (def linear-topology [[1] [0 2] [1 3] [2 4] [3]]) (optimize-for-topology my-circuit linear-topology) ;=> {:circuit <optimized-circuit>, :logical-to-physical {0 1, 1 2, 2 3}, ...}
(ring-coupling num-qubits)
Create the coupling for a ring hardware topology where qubits are connected in a circle.
Parameters:
Returns: Vector of vectors representing adjacency list for ring topology
Create the coupling for a ring hardware topology where qubits are connected in a circle. Parameters: - num-qubits: Number of qubits in the topology Returns: Vector of vectors representing adjacency list for ring topology
(star-coupling num-qubits)
Create the coupling for a star hardware topology with one central qubit connected to all others.
Parameters:
Returns: Vector of vectors representing adjacency list for star topology
Create the coupling for a star hardware topology with one central qubit connected to all others. Parameters: - num-qubits: Number of qubits in the topology Returns: Vector of vectors representing adjacency list for star topology
(topology-aware-transform circuit coupling supported-operations options)
Transform circuit for topology while being aware of supported gates.
Transform circuit for topology while being aware of supported gates.
(validate-coupling coupling)
Validate that a hardware coupling is well-formed.
Parameters:
Returns: Boolean indicating if coupling is valid
Validate that a hardware coupling is well-formed. Parameters: - coupling: Vector of vectors representing qubit connectivity Returns: Boolean indicating if coupling is valid
cljdoc builds & hosts documentation for Clojure/Script libraries
Ctrl+k | Jump to recent docs |
← | Move to previous article |
→ | Move to next article |
Ctrl+/ | Jump to the search field |