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

Handle inverse for Quil's SWAP gate #5341

Merged
merged 3 commits into from
May 10, 2022
Merged

Conversation

vtomole
Copy link
Collaborator

@vtomole vtomole commented May 10, 2022

SWAP is it's own self inverse. Fixes: #5310

@vtomole vtomole requested review from a team and cduck as code owners May 10, 2022 16:26
@vtomole vtomole requested a review from dabacon May 10, 2022 16:26
@CirqBot CirqBot added the Size: XS <10 lines changed label May 10, 2022
@@ -143,7 +143,7 @@ def _qasm_(self, args: 'cirq.QasmArgs', qubits: Tuple['cirq.Qid', ...]) -> Optio
def _quil_(
self, qubits: Tuple['cirq.Qid', ...], formatter: 'cirq.QuilFormatter'
) -> Optional[str]:
if self._exponent == 1:
if self._exponent == 1 or self._exponent == -1:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is _exponent restricted in any way? If not, I think this should be any odd power. i.e. if self._exponent % 2 == 1:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't know if it's restricted but your suggestion makes this more robust so i did it anyway.

@vtomole vtomole requested a review from dabacon May 10, 2022 18:36
Copy link
Collaborator

@dabacon dabacon left a comment

Choose a reason for hiding this comment

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

LGTM

Happy acquisition announcement day!

@dabacon dabacon added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label May 10, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label May 10, 2022
@CirqBot CirqBot merged commit 4ba730b into quantumlib:master May 10, 2022
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels May 10, 2022
@vtomole vtomole deleted the quil_inverse branch May 10, 2022 22:55
@vtomole
Copy link
Collaborator Author

vtomole commented May 11, 2022

@dabacon Thanks!!

rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Size: XS <10 lines changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected conversion to Quil of inverse SWAP gate
3 participants