Bugfix in Cirq Interop: Attempt 2 #1100
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Another attempt at #963. Opened a new PR instead of rebasing that one since a major reorganization has occurred since that attempt.
High level updates are:
decompose_from_registers
from theAdjoint
bloq and default to using the bloq-styledecompose_bloq
APIInteropQubitManager
had a bug where the managed qubits could be allocated twice (eg: by the underlying greedy qubit manager)The above two were the primary reason for #818, which is now fixed. As part of these upgrades, a few other minor improvements were done. For example:
SGate(is_adjoint=True).as_cirq_op()
was returningcirq.S
instead ofcirq.S**-1
. This is now fixed.Allocate
andFree
now have aas_cirq_op
defined and won't show up as explicit operations in the cirq circuit.ReflectionUsingPrepare
rely on not decomposingLessThanEqual
gate so the cirq simulator can make sure of the optimized implementation of apply_unitary forcirq.ArithmeticGate
's. This gets lost if we haveAdjoint(LessThanEqual)
instead ofLessThanEqual
in the circuit. Flattening out the entire cirq circuit forReflectionUsingPrepare -> StatePreparationViaAliasSampling -> LessThanEqual
is catastrophic for performance. cc @mpharrigan It'll be nice to see how the new tensor network simulation perform for this specific test. It'll be nice to get rid ofconstruct_gate_helper_and_qubit_order
and rewriteget_3q_uniform_dirac_notation
test with the same parameters but using tensor network simulations.Currently based on top of #1099
The only pending thing in this PR is that tests for
SelectSwapQROM
are still failing; and the failure is related to the one seen in #961. More investigations are needed here to figure out whats going wrong.