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

Decompose cx into cz and two hadamards #3067

Closed
wants to merge 6 commits into from

Conversation

Wikstahl
Copy link

@Wikstahl Wikstahl commented Sep 3, 2019

Summary

It is now possible to unroll a cx gate into a cz and two hadamards. This can for e.g. be used when transpiling a circuit containing 'cx' gates into 'cz' and 'h' gates.

Details and comments

To avoid circular import the CzGate is imported inside the _define function.

Added a test file that verify if the unrolling works

@CLAassistant
Copy link

CLAassistant commented Sep 3, 2019

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Member

@kdk kdk left a comment

Choose a reason for hiding this comment

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

Hi @Wikstahl , thanks for the contribution! This PR raises an interesting question about our Instruction.__eq__ ( https://github.com/Qiskit/qiskit-terra/blob/5aaf6e7/qiskit/circuit/instruction.py#L92 ).

Currently, we check if two Instructions are equal by checking if their definitions are equal. With this PR, cx would be defined in terms of cz, and cz would be defined in terms of cx, so this check will recur infinitely.

I think there are two possible paths forward:

  1. Stop comparing definitions. Consider Instructions equal if they match name, num_qubits and num_clbits.
  2. Make definition comparison smart enough to detect mutual definitions like this, and consider them equal.

I tested 1) briefly and all our tests passed, though we'd probably want to think more about if the definition check is required anywhere.

test/python/transpiler/test_unroll_cx.py Outdated Show resolved Hide resolved
@ajavadia
Copy link
Member

ajavadia commented Sep 9, 2019 via email

pep8 change

Co-Authored-By: Kevin Krsulich <kevin@krsulich.net>
@1ucian0 1ucian0 mentioned this pull request Sep 25, 2019
@1ucian0
Copy link
Member

1ucian0 commented Sep 25, 2019

I'm putting this one on hold until we decided something on #3146.

@1ucian0 1ucian0 added the on hold Can not fix yet label Sep 25, 2019
@kdk kdk self-assigned this Jan 8, 2020
@ajavadia
Copy link
Member

This is superseded by the RFC here: Qiskit/RFCs#6
And @kdk will PR an implementation.

@ajavadia ajavadia closed this Feb 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
on hold Can not fix yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants