Qubit mapping utilities for the optimization pipeline.
This namespace provides functions for creating, inverting, and composing qubit mappings throughout the optimization pipeline. These mappings are essential for tracing measurement results back to the original circuit.
Mapping Chain in Pipeline:
Reverse Mapping Chain (for results): hardware-physical → logical → compacted-logical → original-logical
Qubit mapping utilities for the optimization pipeline. This namespace provides functions for creating, inverting, and composing qubit mappings throughout the optimization pipeline. These mappings are essential for tracing measurement results back to the original circuit. Mapping Chain in Pipeline: 1. Qubit Optimization: original-logical → compacted-logical 2. Error Correction: compacted-logical → physical+ancillas 3. Topology Optimization: logical → hardware-physical Reverse Mapping Chain (for results): hardware-physical → logical → compacted-logical → original-logical
(compose-mappings mapping1 mapping2)
Compose two qubit mappings sequentially.
Given mapping1: A → B and mapping2: B → C, returns composed mapping: A → C
Parameters:
Returns: Composed mapping {A → C}
Example: (compose-mappings {0 10, 1 20} {10 100, 20 200}) ;=> {0 100, 1 200}
Compose two qubit mappings sequentially. Given mapping1: A → B and mapping2: B → C, returns composed mapping: A → C Parameters: - mapping1: First mapping {A → B} - mapping2: Second mapping {B → C} Returns: Composed mapping {A → C} Example: (compose-mappings {0 10, 1 20} {10 100, 20 200}) ;=> {0 100, 1 200}
(create-all-reverse-mappings ctx)
Create all reverse mappings in the context.
This is a convenience function that creates all reverse mappings from qubit optimization and error correction.
Parameters:
Returns: Context with all reverse mappings added
Create all reverse mappings in the context. This is a convenience function that creates all reverse mappings from qubit optimization and error correction. Parameters: - ctx: Context from optimization pipeline Returns: Context with all reverse mappings added
(create-reverse-ec-mappings ctx)
Create reverse mappings from error correction result.
This inverts the logical-to-physical and logical-to-ancillas mappings created by error correction, allowing tracing from physical qubits back to compacted logical qubits.
Parameters:
Returns: Context with added :physical-to-logical and :ancilla-to-logical
Create reverse mappings from error correction result. This inverts the logical-to-physical and logical-to-ancillas mappings created by error correction, allowing tracing from physical qubits back to compacted logical qubits. Parameters: - ctx: Context containing :logical-to-physical and :logical-to-ancillas Returns: Context with added :physical-to-logical and :ancilla-to-logical
(create-reverse-qubit-mapping ctx)
Create reverse mapping from qubit optimization result.
This inverts the qubit-mapping created by qubit optimization, allowing tracing from compacted logical qubits back to original logical qubits.
Parameters:
Returns: Context with added :inverse-qubit-mapping {compacted → original}
Create reverse mapping from qubit optimization result. This inverts the qubit-mapping created by qubit optimization, allowing tracing from compacted logical qubits back to original logical qubits. Parameters: - ctx: Context containing :qubit-mapping {original → compacted} Returns: Context with added :inverse-qubit-mapping {compacted → original}
(get-ancilla-qubits-for-logical logical-qubit ctx)
Get all ancilla qubit indices for an original logical qubit.
Parameters:
Returns: Vector of ancilla qubit indices, or empty vector if not found
Get all ancilla qubit indices for an original logical qubit. Parameters: - logical-qubit: Original logical qubit index - ctx: Context containing all forward mappings Returns: Vector of ancilla qubit indices, or empty vector if not found
(get-physical-qubits-for-logical logical-qubit ctx)
Get all physical qubit indices for an original logical qubit.
This composes forward mappings to find which physical qubits correspond to a logical qubit from the original circuit.
Parameters:
Returns: Vector of physical qubit indices, or empty vector if not found
Example: (get-physical-qubits-for-logical 4 ctx) ;=> [6 7 8] ; physical qubits for original logical qubit 4
Get all physical qubit indices for an original logical qubit. This composes forward mappings to find which physical qubits correspond to a logical qubit from the original circuit. Parameters: - logical-qubit: Original logical qubit index - ctx: Context containing all forward mappings Returns: Vector of physical qubit indices, or empty vector if not found Example: (get-physical-qubits-for-logical 4 ctx) ;=> [6 7 8] ; physical qubits for original logical qubit 4
(invert-simple-mapping mapping)
Invert a simple one-to-one qubit mapping.
Parameters:
Returns: Inverted mapping {target → source}
Example: (invert-simple-mapping {0 0, 2 1, 4 2}) ;=> {0 0, 1 2, 2 4}
Invert a simple one-to-one qubit mapping. Parameters: - mapping: Map from source qubits to target qubits {source → target} Returns: Inverted mapping {target → source} Example: (invert-simple-mapping {0 0, 2 1, 4 2}) ;=> {0 0, 1 2, 2 4}
(invert-vector-mapping vector-mapping)
Invert a one-to-many mapping (logical to physical/ancilla).
Parameters:
Returns: Inverted mapping {phys → log}
Example: (invert-vector-mapping {0 [0 1 2], 1 [3 4 5]}) ;=> {0 0, 1 0, 2 0, 3 1, 4 1, 5 1}
Invert a one-to-many mapping (logical to physical/ancilla). Parameters: - vector-mapping: Map from logical qubits to qubit vectors {log → [phys...]} Returns: Inverted mapping {phys → log} Example: (invert-vector-mapping {0 [0 1 2], 1 [3 4 5]}) ;=> {0 0, 1 0, 2 0, 3 1, 4 1, 5 1}
(map-measurements-to-original measurements ctx)
Map all measurement results back to original logical qubits.
Parameters:
Returns: Map of measurements mapped to original logical qubits
Example: (map-measurements-to-original {0 1, 1 0, 7 1} ctx) ;=> {0 1, 2 0, 4 1} ; mapped to original qubits
Map all measurement results back to original logical qubits. Parameters: - measurements: Map of qubit measurements {qubit-id → value} - ctx: Context containing all reverse mappings Returns: Map of measurements mapped to original logical qubits Example: (map-measurements-to-original {0 1, 1 0, 7 1} ctx) ;=> {0 1, 2 0, 4 1} ; mapped to original qubits
(map-qubit-to-original qubit-id ctx)
Map a final qubit index back to original logical qubit.
This composes the full reverse mapping chain: final-qubit → logical → compacted → original
Parameters:
Returns: Original logical qubit index, or nil if not mappable
Example: Given mappings: physical-to-logical {7 2}, inverse-qubit-mapping {2 4} (map-qubit-to-original 7 ctx) ;=> 4
Map a final qubit index back to original logical qubit. This composes the full reverse mapping chain: final-qubit → logical → compacted → original Parameters: - qubit-id: Final qubit index from optimized circuit - ctx: Context containing all reverse mappings Returns: Original logical qubit index, or nil if not mappable Example: Given mappings: physical-to-logical {7 2}, inverse-qubit-mapping {2 4} (map-qubit-to-original 7 ctx) ;=> 4
(summarize-mappings ctx)
Create a human-readable summary of all mappings in the context.
Parameters:
Returns: String with formatted mapping information
Create a human-readable summary of all mappings in the context. Parameters: - ctx: Context from optimization pipeline Returns: String with formatted mapping information
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 |