Skip to content

Commit 920bb1e

Browse files
Adds the main transformer to do routing in Cirq (#5838)
* added abstract initial mapper and identity initial mapper * added __str__ and __repr__ for MappingManager * minor bug * made MappingManager not serializable * removed unused import * pushed AbstractInitialMapping and IdentityInitialMapping name to 'cirq' namespace; made both classes not serializable * minor lint fix * addressed comments * addressed comments * fixed bug with edges not being sorted for graph equality testing * fixed bug with digraphs repr method in MappingManager and added test for it * addressed some comments * added grid testing device * added grid routing testing device * formatting * added line_initial_mapper and some tests; needs more testing * formatting * formatting * changed interface for LineInitialMapper and added better tests; test for directed graph value equality remaining * addressed comments and added ring device * added test for supportin directed graphs * changed interface for AbstractInitialMapper * formatting * changed RoutingTestingDevice interface; need to change is_isomorphic tests * added hard-coded isomorphism tests * fixed type issue * removed redundant imports * merged with routing testing device PR #5830 * simplified _value_equalit_values_ * addressed comments * removed unused import * pasted routing files * fixed nits * cleaned up circuit transformer class; needs tests * addressed comments * formatting * small fixes * removed unused import * modified test file * debugging * removed print statements * debugging statement * debugging statement * fix * fix * print statement * edges sorting * addressed comments; ready for review * fixed type bug * cleanup * wrote some tests * ready for review * type and lint fixes * working for basic tests * slightly modified _make_circuit_graph() * added some tests * added test for testing valid circuits and fixed bug in _make_circuit_graph() * debugging currently * made dict of dict storing pqubit distances into numpy integer numpy array * made dict of dict storing pqubit distances into numpy integer numpy array * used better cost function that sped up algorithm by a lot * cleaned up a little and added coverage tests * removed unitary testing code; will add it in next PR * fixed lint and type issues * small lint fix * added unitary testing for routed circuits * changed api to accept only a final mapping of a set of qubits to itself * fixed typos * fixed some docstrings, changed __call__ and route_circuit() order, and move a class function to free function * added tests * refactored _get_timesteps() as per suggestion * more fixes * changed construction of two and single qubit ops lists * fixed bug from _get_two_qubit_ops and added unitary testing * addressed comments and refactored _route() function * minor cleanup * addressed comments * made helper functions class variable and passed mapping manager as function argument everywhere * docstring and nomenclature changes Co-authored-by: Tanuj Khattar <[email protected]>
1 parent 8f9a0bc commit 920bb1e

File tree

6 files changed

+653
-2
lines changed

6 files changed

+653
-2
lines changed

cirq-core/cirq/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@
366366
parameterized_2q_op_to_sqrt_iswap_operations,
367367
prepare_two_qubit_state_using_cz,
368368
prepare_two_qubit_state_using_sqrt_iswap,
369+
RouteCQC,
369370
SqrtIswapTargetGateset,
370371
single_qubit_matrix_to_gates,
371372
single_qubit_matrix_to_pauli_rotations,

cirq-core/cirq/protocols/json_test_data/spec.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@
8585
'TransformerContext',
8686
# Routing utilities
8787
'HardCodedInitialMapper',
88-
'MappingManager',
8988
'LineInitialMapper',
89+
'MappingManager',
90+
'RouteCQC',
9091
# global objects
9192
'CONTROL_TAG',
9293
'PAULI_BASIS',

cirq-core/cirq/transformers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444
two_qubit_gate_product_tabulation,
4545
)
4646

47-
4847
from cirq.transformers.routing import (
4948
AbstractInitialMapper,
5049
HardCodedInitialMapper,
5150
LineInitialMapper,
5251
MappingManager,
52+
RouteCQC,
5353
)
5454

5555
from cirq.transformers.target_gatesets import (

cirq-core/cirq/transformers/routing/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@
1717
from cirq.transformers.routing.initial_mapper import AbstractInitialMapper, HardCodedInitialMapper
1818
from cirq.transformers.routing.mapping_manager import MappingManager
1919
from cirq.transformers.routing.line_initial_mapper import LineInitialMapper
20+
from cirq.transformers.routing.route_circuit_cqc import RouteCQC

0 commit comments

Comments
 (0)