Skip to content

Allow decomposition of controlled 1x1 MatrixGate #7248

Open
@daxfohl

Description

@daxfohl

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 to Rz 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 for isinstance(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 the isinstance 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 (just u[0][0]) instead of from the coefficient 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/decompositiongood first issueThis issue can be resolved by someone who is not familiar with the codebase. A good starting issue.good for learningFor beginners in QC, this will help picking up some knowledge. Bit harder than "good first issues"kind/feature-requestDescribes new functionalitytriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions