-
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
Port TwoQubitControlledUDecomposer to rust #13139
Conversation
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 11812175968Warning: 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.
Overall the code looks good, I left a few inline comments on how to simplify or optimize things a bit. The biggest concern I have right now though is the backwards incompatibility of the API. This PR restricts the gate objects that TwoQubitControlledUDecomposer
class can work with to just standard gates defined in Qiskit. This wasn't a limitation before the rust rewrite and would be considered a breaking api change. However, I'm not sure the class is considered public, it's never been externally documented from what I can tell. I'm curious of your thoughts on this though because I'm not sure what you're thinking about making this class public or not.
#[pyclass(module = "qiskit._accelerate.two_qubit_decompose", subclass)] | ||
pub struct TwoQubitControlledUDecomposer { | ||
#[pyo3(get)] | ||
rxx_equivalent_gate: StandardGate, |
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.
Do you think we should treat this class as public at all? The python space definition wasn't limited to standard gates, it would support any python space Gate
object including a custom defined gate. This will error in the case of a custom PyGate
though.
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.
Currently, rxx_equivalent_gate
could be only a StandardGate
since in the code we need to invert it, and there is currently no inverse function for other types, see these lines:
let circ_c = self.to_rxx_gate(gamma)?;
...
for gate in circ_c.gates.into_iter().rev() {
let (inv_gate_name, inv_gate_params, inv_gate_qubits) = invert_2q_gate(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.
As for making this class public, I think that it may be useful. Should we do it now or only after it's added to the UnitarySynthesis
transpiler pass #13320?
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'd say lets do it later as the PR is large and intricate enough that we should review the change making it public on its own.
I would appreciate @levbishop opinion regarding this question as he wrote the original Python code. qiskit/test/python/synthesis/test_synthesis.py Line 1429 in fbfe738
So I wonder if this class was ever meant to be used with basic gates that are not standard gates. Anyway, since the Pulse library is being deprecated in #13164, the users will not be able to calibrate their own basic gates with Qiskit and hence this code will be useful only for standard gates. |
This commit adds back the missing support for custom gate classes so that a user defined gate class can be used with the decomposer.
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 LGTM now. I have one small suggestion on the test code but once that's fixed I think we're good to merge.
Summary
close #12907
Details and comments
depends on #13168
Performance improvement:
Synthesizing 100 random 4x4 unitary matrices into each of the basis gates
[RXX, RYY, RZZ, RZX, CRZ, CPhase]
takes:in Python: 20.57 sec
in Rust: 8.85