Implement the relative phase Toffoli gates#3761
Conversation
|
We can just call it the Margolus gate? See #1741 (item 8) and https://arxiv.org/abs/quant-ph/0312225. For now I think drawing it with a box and its name inside makes sense, unless we can come up with a modified notation for ccx that shows a relative phase difference. This is not a |
|
Agreed to not having it as controlled gate, that solves the issue. 👍 However I'm not sure about Margolus gate, since (1) we tried to get consistent "action-based" gate names, and (2) how would we call the method then? |
|
Ok I'm fine leaving rccx (that causes least disruption for now). I would at least put Margolus / Simplified Toffoli in the documentation because that seems a more common way of referring to this gate. There's some limit to "action-based" descriptions of gates, as gates have come to have common names in the literature and community. Like S gate and V gate, whose actions are basically rz90 and sqrt-x, but everyone just refers to them by the former names. |
|
Ok, I left the method name as |
…kit-terra into relative_phase_toffoli_gates
ajavadia
left a comment
There was a problem hiding this comment.
looks good mostly, some minor comments
Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
* implement relative phase toffoli gates as gates * fix CX, Cnot mixup * update init, remove unused import * add matrix repr, fix num_qubits * add test on relative phase toffolis * remove base_gate, X does not really apply * make Gate, not ControlledGate, update docstrings * rename to RCCX * add qasm definitions * update str length due to rcc(c)x definitions * fix deprecation warning and test * rename tgt/ctl to full names * Correct docstring Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> * Correct docstring Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com> Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Summary
Implement the relative phase Toffoli gates (CCX and CCCX), which only existed as functions and not
Gates. These gates are used in the definition of other multi-controlled gates and are blocking their implementation.Details and comments
These gates follow https://arxiv.org/pdf/1508.03273.pdf. The relative-phase CCX is shown in Fig. 3, dashed box and the relative-phase CCCX is shown in Fig. 4, the whole circuit.
Things left to decide:
rccx, which conflicts with the naming scheme we introduce in Consistent naming of controlled gates #3633 where we useRto denote a rotation.Edit: Named
rccx/RCCXGatesince the method is already calledrccx.Xas base gate suggests that they are the same as the Toffolis -- which they are not.Edit: Resolved by not being a controlled gate, thus the name is drawn in a box (composite gate style).
base_gate? The first idea might be to use theXGateas base gate, but this is not accurate, as the base gate implies that the controlled gate can be written ascontrolled_gate = |0><0| \times id + |1><1| \times X.Also this runs into problems with the default mechanisms of Qiskit to create a controlled gate.
If they don't have a
base_gatethis must be accordingly dealt with in the circuit drawer.Edit: Resolved by not being a
ControlledGatebutGatetype for now.