-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Organization (and deprecation) of cirq-core/optimizers in cirq-core/transformers #4722
Comments
I like the looks of this plan.
Where possible, I would be in favor of doing this one module at a time and not all at once so multiple people can work on this at once and also take the opportunity for the rewrite/cleanup of their module one module at a time. |
This is fine with me, but we should announce this broadly. We already mentioned at a cirq cync, but it might be worth an email to cirq-announce. We could maybe combine this with a forward-looking "What's changing in cirq 1.0" email to all of cirq-announce that explains all the changes we are planning to do. |
…rs/analytical_decompositions` (#4809) Moves the following files from `cirq/optimizers/` to `cirq/transformers/analytical_decompositions/` using `deprecated_submodule`: - two_qubit_decompositions.py --> two_qubit_to_cz.py - two_qubit_to_fsim.py - two_qubit_to_sqrt_iswap.py - three_qubit_decomposition.py Part of #4722
…ers/*` (#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 #4722
Picking up expand_composite.py. Please let me know if someone already works on it. |
…lytical_decompositions/two_qubit_state_preparation.py` (quantumlib#4762) Part of quantumlib#4722 This is safe to do without going through a deprecation cycle because `optimizers/two_qubit_state_preparation.py ` was recently introduced (quantumlib#4707) in the current dev version and hasn't been released yet.
…rq/transformers/analytical_decompositions/` (quantumlib#4785) Moves the following files from `cirq/optimizers/` to `cirq/transformers/analytical_decompositions/` using `deprecated_submodule`: - clifford_decomposition.py - controlled_gate_decomposition.py - cphase_to_fsim.py Part of quantumlib#4722
…positions/single_qubit_decompositions.py` (quantumlib#4799) Moves the following file from `cirq/optimizers/` to `cirq/transformers/analytical_decompositions/` using `deprecated_submodule`: - decompositions.py --> single_qubit_decompositions.py Part of quantumlib#4722
…rs/analytical_decompositions` (quantumlib#4809) Moves the following files from `cirq/optimizers/` to `cirq/transformers/analytical_decompositions/` using `deprecated_submodule`: - two_qubit_decompositions.py --> two_qubit_to_cz.py - two_qubit_to_fsim.py - two_qubit_to_sqrt_iswap.py - three_qubit_decomposition.py Part of quantumlib#4722
Hi all, I would like to help with this issue, Can anyone please tell me further details? |
The task which is still open is about adding a new transformer and not migrating any existing transformer, so I'm going to remove the task from the list and the issue will be tracked independently. This particular issue is about migration of all existing optimizers, which has been completed and I'll therefore go ahead and close the issue. |
…lytical_decompositions/two_qubit_state_preparation.py` (quantumlib#4762) Part of quantumlib#4722 This is safe to do without going through a deprecation cycle because `optimizers/two_qubit_state_preparation.py ` was recently introduced (quantumlib#4707) in the current dev version and hasn't been released yet.
…rq/transformers/analytical_decompositions/` (quantumlib#4785) Moves the following files from `cirq/optimizers/` to `cirq/transformers/analytical_decompositions/` using `deprecated_submodule`: - clifford_decomposition.py - controlled_gate_decomposition.py - cphase_to_fsim.py Part of quantumlib#4722
…positions/single_qubit_decompositions.py` (quantumlib#4799) Moves the following file from `cirq/optimizers/` to `cirq/transformers/analytical_decompositions/` using `deprecated_submodule`: - decompositions.py --> single_qubit_decompositions.py Part of quantumlib#4722
…rs/analytical_decompositions` (quantumlib#4809) Moves the following files from `cirq/optimizers/` to `cirq/transformers/analytical_decompositions/` using `deprecated_submodule`: - two_qubit_decompositions.py --> two_qubit_to_cz.py - two_qubit_to_fsim.py - two_qubit_to_sqrt_iswap.py - three_qubit_decomposition.py Part of quantumlib#4722
…ers/*` (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
…ronizeTerminalMeasurements` (quantumlib#4911) - Part of quantumlib#4722 - Follows the new Transformer API quantumlib#4483 - Supports no compile tags NoCompile Tag for optimizers quantumlib#4253 - Fixes quantumlib#4907
…lytical_decompositions/two_qubit_state_preparation.py` (quantumlib#4762) Part of quantumlib#4722 This is safe to do without going through a deprecation cycle because `optimizers/two_qubit_state_preparation.py ` was recently introduced (quantumlib#4707) in the current dev version and hasn't been released yet.
…rq/transformers/analytical_decompositions/` (quantumlib#4785) Moves the following files from `cirq/optimizers/` to `cirq/transformers/analytical_decompositions/` using `deprecated_submodule`: - clifford_decomposition.py - controlled_gate_decomposition.py - cphase_to_fsim.py Part of quantumlib#4722
…positions/single_qubit_decompositions.py` (quantumlib#4799) Moves the following file from `cirq/optimizers/` to `cirq/transformers/analytical_decompositions/` using `deprecated_submodule`: - decompositions.py --> single_qubit_decompositions.py Part of quantumlib#4722
…rs/analytical_decompositions` (quantumlib#4809) Moves the following files from `cirq/optimizers/` to `cirq/transformers/analytical_decompositions/` using `deprecated_submodule`: - two_qubit_decompositions.py --> two_qubit_to_cz.py - two_qubit_to_fsim.py - two_qubit_to_sqrt_iswap.py - three_qubit_decomposition.py Part of quantumlib#4722
…ers/*` (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
…ronizeTerminalMeasurements` (quantumlib#4911) - Part of quantumlib#4722 - Follows the new Transformer API quantumlib#4483 - Supports no compile tags NoCompile Tag for optimizers quantumlib#4253 - Fixes quantumlib#4907
Background
Currently, all optimizers in cirq are present in a single directory --
cirq-core/cirq/optimizers/*
. It contains not only transformers (which transform/optimize circuits) but also utility methods like analytical decompositions of matrices into target operations.Also, after #4708 and #4692; almost all existing optimizers would need to be re-implemented to
Proposal
The proposal is to
cirq/transformers/
cirq/optimizers
to sub directories undercirq/transformers/
cirq/optimizers
in favor of new implementations using the moment preserving primitives and following the new non-mutating API, which would be added at top-level incirq/transformers/
.cirq-core/cirq/transformers/heuristic_decompositions/*
Note: Heuristic compilation is an active area of research and is an important primitive for compensating for actual gate angles calibrated via techniques like Floquet / XEB calibration. We can expect more primitives to get added here in future.
cirq-core/cirq/transformers/analytical_decompositions/*
Newer versions of the following existing transformers in
cirq-core/cirq/optimizers/*
will get added incirq-core/cirq/transformers/*
Deprecation Plan
cirq/optimizers/*
tocirq/transformers/analytical_decompositions
. Existing methods will go through a deprecation cycle and the change should not impact usages of the formcirq.<method>
.cc @MichaelBroughton @dstrain115 @dabacon Thoughts?
Part of roadmap #3238
The text was updated successfully, but these errors were encountered: