-
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
Shorter and more structured gate definitions (part 1) #1741
Comments
the qelib1.inc file should not be modified (see #6125). However, can somebody check if the cases of shorter gates definitions apply when calling |
An example of the current (0.19) definition: from qiskit.circuit.library import CCXGate
CCXGate().definition.draw()
|
Note that there are several equivalent definitions for Note that currently the equivalence library has a shorter definition for a Perhaps we can add the suggested alternative of the |
I'm going to close this issue now; the definitions given in the OQ2 include file aren't something we're going to change (ideally, it's a standardised include file), and don't impact any parts of synthesis. Some of these definitions could potentially be added / changed in the standard equivalence libraries, but that's a general synthesis problem that's not really related to the initial concern of this issue. Feel free to re-open if there's more to discuss. |
What is the expected enhancement?
Regarding the
qelib1.inc
file.Lines 30-32: Phase gate is sufficiently often denoted as
p
. Physicists likes
, but in CS, it isp
. It is certainly worth havingp
, even if in addition tos
;Line 32: dagger may be coded as
d
sinced
is a clearly distinguishable suffix.d
is shorter thandg
and thus more compliant with the spirit of Shannon's optimal coding, as well as other notations, such ash
for Hadamard;Line 48: this is controlled-Z, not controlled-Phase;
Line 55: a shorter implementation of controlled-H is:
It requires only one CNOT, but not two. Maybe worth writing the single-qubit sequence PHT (and, symmetrically, its inverse) using U gates, maybe not.
Line62: It is worth introducing controlled-Phase=controlled-sqrt-Z,
cp
, and controlled-sqrt-NOT,cv
, as well as their complex conjugates,cpd
andcvd
. Controlled-sqrt-Y may also be there for symmetry, even though I have not seen it being used much. The ‘problem’ with controlled-sqrt-Y is it does not appear to have a standard notation. So maybe skip for now. Note that in the futurecv
will most likely be implemented directly as a single physical level two-qubit gate.Lines 63-72. CCX is best implemented as:
This exposes Toffoli gate’s structure:
CCX
isRCCX
phase corrected byCZ(a,c)
andCP(a,b)
. It is an important structure. It is also worth defining Toffoli astof
in addition toccx
.Line 89: can be worth parallelizing the singe-qubit gates. There are two ways to do it such that phase applies to primary qubits
a
andb
;Note that in the future
cv
may be implemented directly as a single physical level two-qubit gate. This means some of the circuits will admit shorter implementations. Specifically,ccx
(also helps to have it astof
) will require only 5 gates, and the cost ofcswap
will drop to 6 two-qubit gates.More to come.
The text was updated successfully, but these errors were encountered: