-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Consective 1q param gates #8178
Conversation
moving rafal's changes to new branch
…iskit-terra into consective-1q-param-gates
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 2838137906
💛 - Coveralls |
That's a great extension! Does this also collect cases where other single qubit gates are in between Pauli rotations, like |
# Delete the other nodes in the run | ||
for current_node in run[idx:]: | ||
dag.remove_op_node(current_node) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice idea. If I understand correctly, currently the code completely replaces chains of parameterized "rz", "ry", "rx" gates by "optimized" chains. Would it be possible to avoid this replacement if no (or only few) optimizations take place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This worked in that way previously. But in the code, the optimization is done by converting the gates to the matrix and multiplying the unitary of the gates. And at the end, the decomposition is done. So before my changes the parameters gates were not optimized.
I am wondering if the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this. While this takes us a step further in optimizing parametric gates, it is still a bit limited. I opened an issue for a more general workflow: #8192
Another problem with this approach, as I commented below, is that it does not preserve basis gates.
passmanager.append(Optimize1qGatesDecomposition(basis)) | ||
result = passmanager.run(qc) | ||
expected = QuantumCircuit(1) | ||
expected.rz(2 * phi, 0) | ||
expected.ry(2 * phi, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the basis does not contain ry, then ry should not be emitted. This creates a bug as it does not conform to the spec of basis_gates
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ajavadia Do you suggest that it should do "merge" of gates only when there are in basis set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Giving a basis means I want my output to be in that basis. So ry should be written as rz + sx here. If basis=None then I think it's fine to emit any gate, including ry itself.
…iskit-terra into consective-1q-param-gates
…iskit-terra into consective-1q-param-gates
hi @rafal-pracht are you still working on this? |
Summary
Two or more Pauli rotation gates (Rx, Ry, Rz) that contain the parameters will be combined together.
Details and comments