Hardware-specific optimization and topology management for quantum circuits.
This namespace provides functionality for optimizing quantum circuits for specific hardware topologies, including qubit routing, SWAP insertion, and topology-aware optimization strategies.
Hardware-specific optimization and topology management for quantum circuits. This namespace provides functionality for optimizing quantum circuits for specific hardware topologies, including qubit routing, SWAP insertion, and topology-aware optimization strategies.
(analyze-topology-connectivity topology)
Analyze the connectivity properties of a hardware topology.
Parameters:
Returns: Map containing topology analysis:
Analyze the connectivity properties of a hardware topology. Parameters: - topology: Hardware topology as vector of vectors Returns: Map containing topology 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 topology)
Calculate shortest path distances between all pairs of qubits in topology.
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 topology. Parameters: - topology: 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-topologies circuit topologies)
Compare multiple hardware topologies for a given circuit.
Parameters:
Returns: Vector of maps sorted by total cost, each containing:
Compare multiple hardware topologies for a given circuit. Parameters: - circuit: Quantum circuit to optimize - topologies: Map of topology-name to topology 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
(create-grid-topology rows cols)
Create a grid hardware topology with qubits arranged in a rectangular grid.
Parameters:
Returns: Vector of vectors representing adjacency list for grid topology
Create 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
(create-linear-topology num-qubits)
Create a linear hardware topology where qubits are connected in a line.
Parameters:
Returns: Vector of vectors representing adjacency list for linear topology
Create 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
(create-ring-topology num-qubits)
Create a ring hardware topology where qubits are connected in a circle.
Parameters:
Returns: Vector of vectors representing adjacency list for ring topology
Create 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
(create-star-topology num-qubits)
Create a star hardware topology with one central qubit connected to all others.
Parameters:
Returns: Vector of vectors representing adjacency list for star topology
Create 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
(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 arg1 arg2 arg3)
Find an optimal mapping from logical qubits to physical qubits using a greedy approach.
Parameters:
Returns: Map from logical qubit to physical qubit
Find an optimal mapping from logical qubits to physical qubits using a greedy approach. Parameters: - When called with 3 args [circuit topology distance-matrix]: - circuit: Quantum circuit to optimize - topology: Hardware topology - distance-matrix: Precomputed distance matrix - When called with 3 args [two-qubit-ops num-physical-qubits distance-matrix] (legacy): - two-qubit-ops: Vector of two-qubit operations - num-physical-qubits: Number of physical qubits available - distance-matrix: Precomputed distance matrix Returns: Map from logical qubit to physical qubit
(find-shortest-path topology start end)
Find shortest path between two qubits in the topology.
Parameters:
Returns: Vector of qubits representing the path from start to end
Find shortest path between two qubits in the topology. Parameters: - topology: Hardware topology - 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-topology-info topology)
(get-topology-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
(optimize circuit supported-operations & [topology options])
Optimization pipeline that handles gate decomposition properly.
The order is:
Parameters:
Returns: Complete optimization result with corrected pipeline
Optimization pipeline that handles gate decomposition properly. The order is: 1. Gate cancellation optimization (remove redundant gates) 2. Qubit optimization (minimize qubits before topology constraints) 3. Topology optimization (with decomposition-aware routing) 4. Final gate decomposition (handle any remaining virtual gates) 5. Validation and cleanup Parameters: - circuit: Quantum circuit to optimize - supported-operations: Set of natively supported operations - topology: Hardware topology (optional) - options: Optimization options Returns: Complete optimization result with corrected pipeline
(optimize-for-topology circuit topology)
(optimize-for-topology circuit topology 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) ;=> {:quantum-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 - topology: Hardware topology 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: - :quantum-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) ;=> {:quantum-circuit <optimized-circuit>, :logical-to-physical {0 1, 1 2, 2 3}, ...}
(topology-aware-transform circuit topology supported-operations options)
Transform circuit for topology while being aware of supported gates.
Transform circuit for topology while being aware of supported gates.
(validate-topology topology)
Validate that a hardware topology is well-formed.
Parameters:
Returns: Boolean indicating if topology is valid
Validate that a hardware topology is well-formed. Parameters: - topology: Vector of vectors representing qubit connectivity Returns: Boolean indicating if topology is valid
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close