-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
MCMTGate
& plugins
#13150
MCMTGate
& plugins
#13150
Conversation
One or more of the following people are relevant to this code:
|
and fix tests
Pull Request Test Coverage Report for Build 11176416050Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
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 @Cryoris, this looks very nice. I have left a few minor comments and questions.
This default implementations requires no ancilla qubits, by broadcasting the target gate | ||
to the number of target qubits and using Qiskit's generic control routine to control the | ||
broadcasted target on the control qubits. If ancilla qubits are available, a more efficient | ||
variant using the so-called V-chain decomposition can be used. This is implemented in | ||
:class:`~qiskit.circuit.library.MCMTVChain`. |
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 part of the docstring probably needs to be updated.
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.
Good point 👍🏻 related question: do you know whether the synthesis methods like synth_mcx_...
are API-documented?
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.
I think so. The synthesis methods are described in https://docs.quantum.ibm.com/api/qiskit/synthesis. Also, the synthesis plugins are described in https://docs.quantum.ibm.com/api/qiskit/transpiler_synthesis_plugins.
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.
Great, I added the Sphinx doc in 646279a 👍🏻
if isinstance(gate, ControlledGate): | ||
base_gate = gate.base_gate | ||
elif isinstance(gate, Gate): | ||
base_gate = gate | ||
else: | ||
raise TypeError(f"Invalid gate type {type(gate)}.") |
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.
Would it make sense to consider a control-annotated operation as well?
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.
We could if we additionally ran HLS to apply the other modifiers that are not control
. A cleaner way might be to completely disallow 2q gates, from which we only extract the 1q base gate. That would require us to handle less cases and might be a leaner workflow.
Lol, the tests have failed due to |
Thank you very much! As per your question, could you please add a table for documenting MCMT synthesis plugins (in |
Added the :class:`.MCMTGate` to represent multi-control multi-target | ||
operations in a gate. This gate representation of the existing :class:`.MCMT` | ||
circuit allows the compiler to select the best available implementation | ||
according to the number of auxiliary qubits present in the circuit. |
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 super-minor, please feel free to ignore it:
Added the :class:`.MCMTGate` to represent multi-control multi-target | |
operations in a gate. This gate representation of the existing :class:`.MCMT` | |
circuit allows the compiler to select the best available implementation | |
according to the number of auxiliary qubits present in the circuit. | |
Added the :class:`.MCMTGate` to represent a multi-control multi-target | |
operation as a gate. This gate representation of the existing :class:`.MCMT` | |
circuit allows the compiler to select the best available implementation | |
according to the number and the state of auxiliary qubits present in the circuit. |
Do we want to list pending deprecations?
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.
I would just list the deprecations once they are not pending anymore 🙂 (I think that's what we typically have as well 🙂)
Co-authored-by: Alexander Ivrii <alexi@il.ibm.com>
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.
LGTM!
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.
Reapproving after the symengine fix.
This has a merge conflict now that 642debf has merged. The interface for |
Done in 60a82a3 👍🏻 |
@@ -501,6 +501,7 @@ | |||
Permutation, | |||
PermutationGate, | |||
GMS, | |||
MCMTGate, |
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.
You should also add it to line 188 in this file - it currently does not appear in the circuit library docs!
* MCMT in Rust & Plugin * test plugins * more docs * add support for ``ctrl_state`` and fix tests * Sasha's review comments * fix cyclic imports * add sphinx doc for mcmt_vchain * review comments & reno * Update releasenotes/notes/mcmt-gate-a201d516f05c7d56.yaml Co-authored-by: Alexander Ivrii <alexi@il.ibm.com> * Fix plugin name * Update from_packed_operations usage --------- Co-authored-by: Alexander Ivrii <alexi@il.ibm.com>
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.
Reapproving once more now that both Matthew's and Shelly's comments have been addressed! Thanks all!
* MCMT in Rust & Plugin * test plugins * more docs * add support for ``ctrl_state`` and fix tests * Sasha's review comments * fix cyclic imports * add sphinx doc for mcmt_vchain * review comments & reno * Update releasenotes/notes/mcmt-gate-a201d516f05c7d56.yaml Co-authored-by: Alexander Ivrii <alexi@il.ibm.com> * Fix plugin name * Update from_packed_operations usage * add missing MCMTGate to docs --------- Co-authored-by: Alexander Ivrii <alexi@il.ibm.com>
Summary
Make the MCMT circuits a gate with pluggable synthesis method, plus port the V-chain synthesis to Rust. This is part of #13046.
Details and comments
Even though the focus of this PR is the restructuring into a block that the compiler can reason about, there's also a nice speedup due to the port to Rust:
New runtime / Old runtime = 0.63 (geo mean)