Eliminate multiple control layers on CX/CZ.controlled([0]) #7241
Labels
good first issue
This issue can be resolved by someone who is not familiar with the codebase. A good starting issue.
good for learning
For beginners in QC, this will help picking up some knowledge. Bit harder than "good first issues"
kind/design-issue
A conversation around design
triage/accepted
A consensus emerged that this bug report, feature request, or other action should be worked on
triage/needs-more-evidence
[Feature requests] Seems plausible, but maintainers are not convinced about the use cases yet
Describe your design idea/issue
All other cases of
.controlled()
in Cirq, as well as theControlledGate
constructor, do their best to flatten the layers of control where possible. The one exception isCX/CZ.controlled(...)
, where...
is a non-default set of control values.Output:
The
CX
andCZ
in the nontrivial control value cases end up with ControlledGates that wrapCX/CZ
, instead of having the ControlGate absorb the outer control layer like everywhere else. Beyond the inconsistency, multiple layers of control are futzy to work with, awkward to understand, and harder to decompose. (Hence theisinstance(subgate, CZ)
inControlledGate._decompose_
).Making this consistent seems worthwhile, and given the behavior of most cases, it seems like this was the original goal, but it just got lost in the special nontrivial control values cases.
I'm pretty sure this is just modifying the
CX/CZPowGate.controlled
methods and adding unit tests, so marking as good first issue.The text was updated successfully, but these errors were encountered: