Skip to content
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

Adds global phase to the PhaseShift decomposition #4657

Merged
merged 12 commits into from
Dec 13, 2023

Conversation

obliviateandsurrender
Copy link
Contributor

@obliviateandsurrender obliviateandsurrender commented Oct 6, 2023

Context: Adds GlobalPhase to PhaseShift decomposition, which is right now missing and simply expands to RZ.

Description of the Change: Changes the compute_decomposition for PhaseShift and a few tests using the previous decomposition

Benefits: We wouldn't miss out on the phase information when decomposing this gate.

Possible Drawbacks: N/A

Related GitHub Issues: N/A

Note for reviewers:
If a device does not support PhaseShift and also doesn't support GlobalPhase, this should not cause any trouble because GlobalPhase decomposes to nothing. It won't have the phase information, but it didn't in the past either (just the RZ, so it will remain correct up to a phase)

@github-actions
Copy link
Contributor

github-actions bot commented Oct 6, 2023

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (master@687ed22). Click here to learn what that means.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #4657   +/-   ##
=========================================
  Coverage          ?   99.65%           
=========================================
  Files             ?      388           
  Lines             ?    35158           
  Branches          ?        0           
=========================================
  Hits              ?    35038           
  Misses            ?      120           
  Partials          ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@timmysilv timmysilv self-requested a review October 10, 2023 16:11
@Jaybsoni
Copy link
Contributor

Just a few small comments, I think it would also be useful to look for decompositions of PhaseShift that don't use the GlobalPhase operator until we have a decomposition for it

@trbromley
Copy link
Contributor

Just a few small comments, I think it would also be useful to look for decompositions of PhaseShift that don't use the GlobalPhase operator until we have a decomposition for it

This is a good point, as I think we risk plugin devices failing with this change as they will not know how to handle GlobalPhase 🤔

@obliviateandsurrender - could we merge this PR after the 0.33 release to give us time to evaluate any issues?

Copy link
Contributor

@timmysilv timmysilv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the previous discussion kinda makes me worried. this is breaking for anything that didn't support PhaseShift but also doesn't support GlobalPhase (idk if any devices do other than default.qubit today). I'm not sure what would change after 0.33 is released, but we might need to work out a better plan for general GlobalPhase support before doing this.

@trbromley
Copy link
Contributor

I'm not sure what would change after 0.33 is released, but we might need to work out a better plan for general GlobalPhase support before doing this.

Agreed, I think we can just give a decomposition to the identity. This is wrong, but only as wrong as it was before.

@timmysilv
Copy link
Contributor

works for me... but what wire will we give to the decomposition 😅

@trbromley
Copy link
Contributor

works for me... but what wire will we give to the decomposition 😅

I want to say that it should be the wires of GlobalPhase, but I'm still confused by the docstrings about wires being an "unused argument".

@timmysilv
Copy link
Contributor

the op has no wires. the argument is only there to not break constructors - Lillian tried to remove it and it made a huge mess for some reason. If you give them and they match all device wires, nice! If they don't match, your circuit will fail. But if you don't give them at all, the op wires are an empty list. So, if you try to decompose to Identity in that case (a common one, who would give wires to a global phase??), we won't know what wires to use.

idea: remove the need for wires from Identity as well.

@trbromley trbromley deleted the phase_gate_decompose branch December 5, 2023 15:21
@timmysilv timmysilv restored the phase_gate_decompose branch December 12, 2023 22:18
@timmysilv timmysilv reopened this Dec 12, 2023
Copy link
Contributor

@timmysilv timmysilv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even better, GlobalPhase just decomposes to... nothing! (#4855)

add a changelog entry and this lgtm! [sc-51747]

Copy link
Contributor

@vincentmr vincentmr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks @obliviateandsurrender .

@obliviateandsurrender obliviateandsurrender enabled auto-merge (squash) December 13, 2023 20:27
@obliviateandsurrender obliviateandsurrender merged commit c486bff into master Dec 13, 2023
35 checks passed
@obliviateandsurrender obliviateandsurrender deleted the phase_gate_decompose branch December 13, 2023 21:01
mudit2812 pushed a commit that referenced this pull request Dec 15, 2023
**Context:** Adds `GlobalPhase` to `PhaseShift` decomposition, which is
right now missing and simply expands to `RZ`.

**Description of the Change:** Changes the `compute_decomposition` for
`PhaseShift` and a few tests using the previous decomposition

**Benefits:** We wouldn't miss out on the phase information when
decomposing this gate.

**Possible Drawbacks:** N/A

**Related GitHub Issues:** N/A

**Note for reviewers:**
If a device does not support `PhaseShift` and _also_ doesn't support
`GlobalPhase`, this should not cause any trouble because `GlobalPhase`
decomposes to nothing. It won't have the phase information, but it
didn't in the past either (just the `RZ`, so it will remain correct up
to a phase)
mudit2812 pushed a commit that referenced this pull request Jan 19, 2024
**Context:** Adds `GlobalPhase` to `PhaseShift` decomposition, which is
right now missing and simply expands to `RZ`.

**Description of the Change:** Changes the `compute_decomposition` for
`PhaseShift` and a few tests using the previous decomposition

**Benefits:** We wouldn't miss out on the phase information when
decomposing this gate.

**Possible Drawbacks:** N/A

**Related GitHub Issues:** N/A

**Note for reviewers:**
If a device does not support `PhaseShift` and _also_ doesn't support
`GlobalPhase`, this should not cause any trouble because `GlobalPhase`
decomposes to nothing. It won't have the phase information, but it
didn't in the past either (just the `RZ`, so it will remain correct up
to a phase)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants