Skip to content

Allow decomposition of controlled 1x1 MatrixGate #7248

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

Open
daxfohl opened this issue Apr 8, 2025 · 1 comment · May be fixed by #7283
Open

Allow decomposition of controlled 1x1 MatrixGate #7248

daxfohl opened this issue Apr 8, 2025 · 1 comment · May be fixed by #7283
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

Comments

@daxfohl
Copy link
Collaborator

daxfohl commented Apr 8, 2025

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

@daxfohl daxfohl added kind/feature-request Describes new functionality 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" area/decomposition labels Apr 8, 2025
@pavoljuhas
Copy link
Collaborator

csynque meeting - let us accept for the sake of completeness

@pavoljuhas pavoljuhas added the triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on label Apr 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
2 participants