Skip to content

Commit bd2b953

Browse files
authored
Import transformers/analytical_decompositions/* methods in optimizers/* (quantumlib#4813)
After the recent migration of decompositions from `optimizers/*` to `transformers/analytical_decompositions/*`, the following user code breaks despite deprecating the moved submodules. ```python from cirq import optimizers from cirq.optimizers import two_qubit_decompositions _ = two_qubit_decompositions.two_qubit_matrix_to_operations(mat) # This is deprecated correctly and will emit a deprecation warning but work as expected. _ = optimizers.two_qubit_matrix_to_operations(mat) # This would currently break since the optimizers module is neither deprecated nor has these top-level objects available ``` This PR adds a fix to temporarily unbreak the above user code by importing top-level objects from `transformers/analytical_decompositions/*` to `optimizers/*`. Once all files from `optimizers/*` have been moved to `transformers/`, we will deprecate the `optimizers/` module, and then this hack can be reverted and the correct deprecation warnings will be emitted when using `optimizers.two_qubit_matrix_to_operations` (and other top-level objects). Part of quantumlib#4722
1 parent f40cb10 commit bd2b953

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

cirq/optimizers/__init__.py

+21
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,27 @@
6868
SynchronizeTerminalMeasurements,
6969
)
7070

71+
from cirq.transformers.analytical_decompositions import (
72+
compute_cphase_exponents_for_fsim_decomposition,
73+
decompose_cphase_into_two_fsim,
74+
decompose_clifford_tableau_to_operations,
75+
decompose_multi_controlled_x,
76+
decompose_multi_controlled_rotation,
77+
decompose_two_qubit_interaction_into_four_fsim_gates,
78+
is_negligible_turn,
79+
prepare_two_qubit_state_using_cz,
80+
prepare_two_qubit_state_using_sqrt_iswap,
81+
single_qubit_matrix_to_gates,
82+
single_qubit_matrix_to_pauli_rotations,
83+
single_qubit_matrix_to_phased_x_z,
84+
single_qubit_matrix_to_phxz,
85+
single_qubit_op_to_framed_phase_form,
86+
three_qubit_matrix_to_operations,
87+
two_qubit_matrix_to_diagonal_and_operations,
88+
two_qubit_matrix_to_operations,
89+
two_qubit_matrix_to_sqrt_iswap_operations,
90+
)
91+
7192
from cirq import _compat
7293

7394
_compat.deprecated_submodule(

0 commit comments

Comments
 (0)