For efficiency, the mapping manager maps all logical and physical qubits to integers, and
maintains a mapping from logical qubit integers to physical qubit integers. This speedup is
important to avoid qubit hashing in hot-paths like querying distance of two logical qubits
on the device (via dist_on_device method).
All public methods of this class expect logical qubits (or corresponding integers that the
logical qubits are mapped to, via self.logical_qid_to_int map).
Args
device_graph
connectivity graph of qubits in the hardware device.
initial_mapping
the initial mapping of logical (keys) to physical qubits (values).
Attributes
induced_subgraph_int
Induced subgraph on physical qubit integers present in self.logical_to_physical.
int_to_logical_qid
Inverse mapping of unique integers to corresponding physical qubits.
self.logical_qid_to_int[self.int_to_logical_qid[i]] == i for each i.
int_to_physical_qid
Inverse mapping of unique integers to corresponding physical qubits.
self.physical_qid_to_int[self.int_to_physical_qid[i]] == i for each i.
logical_qid_to_int
Mapping of logical qubits, that were part of the initial mapping, to unique integers.
logical_to_physical
The mapping of logical qubit integers to physical qubit integers.
Let lq: cirq.Qid be a logical qubit. Then the corresponding physical qubit that it
maps to can be obtained by:
self.int_to_physical_qid[self.logical_to_physical[self.logical_qid_to_int[lq]]]
physical_qid_to_int
Mapping of physical qubits, that were part of the initial mapping, to unique integers.
physical_to_logical
The mapping of physical qubits integers to logical qubits integers.
Let pq: cirq.Qid be a physical qubit. Then the corresponding logical qubit that it
maps to can be obtained by:
self.int_to_logical_qid[self.physical_to_logical[self.physical_qid_to_int[pq]]]
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-11-25 UTC."],[],[]]