Allow decomposition of controlled 1x1 MatrixGate #7248
Labels
area/decomposition
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/feature-request
Describes new functionality
triage/accepted
A consensus emerged that this bug report, feature request, or other action should be worked on
Is your feature request related to a use case or problem? Please explain
A 1x1 MatrixGate, like
cirq.MatrixGate(np.array([[1j]]))
, is equivalent to a global phase gate. A controlled global phase gate decomposes toRz
plus a phase. A controlled 1x1 MatrixGate does not decompose. It seems that it should, and would be nice if it did.Describe the solution you would prefer
Currently
ControlledGate._decompose_
has a specific block forisinstance(subgate, GlobalPhaseGate)
. However, the logic there could apply to any gate that's equivalent to a global phase gate. i.e. any gate that has a 1x1 unitary. Thus instead of theisinstance
check, that condition could be changed to a check that there's a 1x1 unitary. The only subsequent change would be that you'd have to get the phase from that unitary (justu[0][0]
) instead of from thecoefficient
member that only exists on GlobalPhaseGate.This would allow controlled 1x1 MatrixGates to decompose, and get rid of an ugly
isinstance
check, so two improvements for the price of one.How urgent is this for you? Is it blocking important work?
P3 – I'm not really blocked by it; it's an idea I'm proposing based on principle
The text was updated successfully, but these errors were encountered: