-
Notifications
You must be signed in to change notification settings - Fork 277
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
Suggestion: Meta gate for concatenation of gates #268
Comments
Thanks for the suggestion. A single qubit rotation around a general axis might indeed be useful. Can you think of more examples? A new gate would do the trick even better as the compiler could have a specialized rules for that one general rotation gate but of course if it happens frequently, then such a meta gate is worth thinking about. By the way, a similar feature of concatenating gates was discussed in #116 and I think some (but not all!) arguments apply here as well.
Would you suggest to limit A similar idea which was once floating around is an easier way to define new gates on the fly, which would also allow the use the |
Use cases will depend on the algorithms people write, but I like the idea of I would restrict
to get a gate on two qubits that would apply a CNOT followed by a x rotation on the first qubit (position 0 of 2) and and y rotation on the second qubit (position 1 of 2). The problem with this is again the incompatible syntax (also noted in #116) for how to specify the right hand side of |
I think adding a new gate for rotations around arbitrary axes would indeed be useful. It's not that tuples of qubits are different from quregs. The correct syntax of any gate is
so the argument is a tuple of quantum registers. We also allow incorrect syntax as long as we can infer what the correct syntax would be. E.g., ProjectQ automatically turns a tuple of qubits into a tuple of quantum registers of length 1... just to make things a bit easier for users and the code nicer to look at. |
That would be nice! Going a bit beyond the original scope of this issue (maybe the title should be changed if we go further in this direction): An arbitrary single qubit unitary and/or Hermitian gate would also be nice. Or would it be too complicated to define gate decompositions for these? |
So far arbitrary single qubit gates (must of course be unitary) can be defined by matrices (and the compiler decomposes them into our standard gates):
Do you have something else in mind? Hermitian gates are impossible, but one can represent hermitian operators using |
Nice! I wasn't aware of that! Is that somewhere explained in the documentation? I thought the BasicGate was really just a parent class for the other gates, and nothing I should be using as a user. I really need to give the decomposer/compiler code a closer look, to understand what it can do automatically and what needs special decomposition rules. There remains the suggestion to have an arbitrary single qubit rotation gate. Everything else looks perfect. |
It was rather silently introduced in the last release as we used it previously from time to time for testing It is suggested to use the native gates as they have specialized decompositions, whereas for a gate defined by a matrix the decomposition might not be close to optimal. For single qubit gates, there is a fall back implemented if we don't have a special decomposition but the gate has a matrix in https://github.com/ProjectQ-Framework/ProjectQ/blob/develop/projectq/setups/decompositions/arb1qubit2rzandry.py There is another user currently implementing a fallback for larger gate matrices. |
It could be nice to have a meta gate (similar to how
Tensor
andControledGate
work) that represents a concatenation of two or more gates. As a concrete use case, consider that a user might want to define a gate that does a three axis rotation. It would be nice if one could do something likeand then
would do the same as
The text was updated successfully, but these errors were encountered: